Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToTecplot360 / tecio / tecsrc / STRUTIL.h
blob00a4f89d15a28038c88a127db20a4b88ebc28a86
1 /*
2 * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM
4 * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide.
6 * Tecplot hereby grants OpenCFD limited authority to distribute without
7 * alteration the source code to the Tecplot Input/Output library, known
8 * as TecIO, as part of its distribution of OpenFOAM and the
9 * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby
10 * granted access to the TecIO source code, and may redistribute it for the
11 * purpose of maintaining the converter. However, no authority is granted
12 * to alter the TecIO source code in any form or manner.
14 * This limited grant of distribution does not supersede Tecplot, Inc.'s
15 * copyright in TecIO. Contact Tecplot, Inc. for further information.
17 * Tecplot, Inc.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
25 ******************************************************************
26 ******************************************************************
27 ******* ********
28 ****** (C) 1988-2008 Tecplot, Inc. *******
29 ******* ********
30 ******************************************************************
31 ******************************************************************
34 #if defined EXTERN
35 #undef EXTERN
36 #endif
37 #if defined STRUTILMODULE
38 #define EXTERN
39 #else
40 #define EXTERN extern
41 #endif
43 #include <string>
45 namespace tecplot
47 namespace strutil
49 class Scanner;
54 #if defined TECPLOTKERNEL
55 /* CORE SOURCE CODE REMOVED */
56 #endif
60 EXTERN void FormatStringBufferCleanup(void);
63 * This is a helper function for FormatString or any other functions that want
64 * to format a string based on a format string followed by a set of arguments.
65 * See FormatString or ErrMsg functions for example usage.
67 * @param Format
68 * C format string.
69 * @param Arguments
70 * Variable argument list already fetched using va_start().
72 * @return
73 * Allocated string with the formatted string or NULL if it failed.
75 EXTERN char *vFormatString(const char *Format,
76 va_list Arguments);
78 /**
79 * Formats a string using the specified C format string.
81 * @param Format
82 * C format string.
83 * @param ...
84 * Any arguments needed by the C format string.
86 * @return
87 * Allocated string with the formatted string or NULL if it failed. The
88 * client is responsible for deallocating the resource.
90 EXTERN char *FormatString(tecplot::strutil::TranslatedString Format,
91 ...); /* 0 or more variable arguments */
93 /**
94 * Formats a string using the specified C format string and places the result
95 * in the string buffer.
97 * @param Buffer
98 * String buffer to receive the formatted string.
99 * @param Format
100 * C format string.
101 * @param ...
102 * Any arguments needed by the C format string.
104 * @return
105 * Upon successful return, these functions return the number of characters
106 * printed, not including the trailing '\0' used to end output to strings. If
107 * unsuccessful -1 is returned.
109 EXTERN int FormatString(std::string& Buffer,
110 tecplot::strutil::TranslatedString Format
111 ...); /* 0 or more variable arguments */
112 EXTERN char *DupString(tecplot::strutil::TranslatedString String);
113 EXTERN void CopySubString(char *Target,
114 const char *Source,
115 int Index,
116 int Count);
118 #if !defined MSWIN
120 EXTERN void ReplaceCharInString(char *S,
121 short OldChar,
122 short NewChar);
123 #endif
125 EXTERN void MakeStringLowerCase(char *str);
126 EXTERN void MakeStringUpperCase(char *str);
127 EXTERN char *TrimLeadAndTrailSpaces(char *String);
128 EXTERN char *StringFlushLeft(char *String);
129 EXTERN char *StringTruncate(char *String,
130 LgIndex_t MaxLength);
131 EXTERN char *StringTrimAndTruncate(char *String,
132 LgIndex_t MaxLength);
134 #ifndef MSWIN
135 EXTERN StringList_pa LineBreakString(const char *String,
136 UInt32_t WrapMargin);
137 #endif
139 EXTERN Boolean_t MatchKey(char *StringToMatch,
140 char *Key);
141 EXTERN void RemoveSeparator(const char **CPtr);
142 EXTERN void SkipWhiteSpace(const char **CPtr);
143 EXTERN void SkipNonWhiteSpace(char **CPtr);
144 EXTERN const char *ustrstr(const char *s1,
145 const char *s2);
146 EXTERN int ustrncmp(const char *s1,
147 const char *s2,
148 size_t Len);
149 EXTERN int ustrcmp(const char *s1,
150 const char *s2);
151 /* public access */
152 /* InternalResetString should not be used directly (use ResetString macro) */
153 #if !defined NO_ASSERTS
154 EXTERN Boolean_t InternalResetString(char **SBase,
155 const char *NewString,
156 Boolean_t IssueErrMsg,
157 const char *FileName,
158 int LineNumber);
159 # define ResetString(SBase, NewString, IssueErrMsg) InternalResetString( \
160 SBase, \
161 NewString, \
162 IssueErrMsg, \
163 __FILE__, __LINE__)
164 #else
165 EXTERN Boolean_t InternalResetString(char **SBase,
166 const char *NewString,
167 Boolean_t IssueErrMsg);
168 # define ResetString(SBase, NewString, IssueErrMsg) InternalResetString( \
169 SBase, \
170 NewString, \
171 IssueErrMsg)
172 #endif
174 EXTERN Boolean_t ScanForString(tecplot::strutil::Scanner &scanner,
175 std::string &DestString,
176 Boolean_t GrabEntireStringIncludingDelimiters);
177 EXTERN Boolean_t TackOnString(char **SBase,
178 const char *StringToAdd,
179 Boolean_t DeleteStringToAdd,
180 Boolean_t ConvertNewlineToAscii);
181 EXTERN Boolean_t TackOnConstString(char **SBase,
182 const char *StringToAdd,
183 Boolean_t ConvertNewlineToAscii);
184 EXTERN Boolean_t TackOnChar(char **SBase,
185 char CharToAdd);
186 EXTERN Boolean_t ReplaceNewlineWithBackslashN(char **String);
187 EXTERN Boolean_t ReplaceBackslashNWithNewline(char **S);
189 EXTERN Boolean_t EscapeOutDelimitersInString(char **S,
190 char Delimiter);
191 EXTERN Boolean_t ScanForSymbol(tecplot::strutil::Scanner &scanner,
192 char Symbol,
193 Boolean_t OnlySkipWhiteSpace);
196 /* Newline Delimited Strings */
197 EXTERN char *ConvertStringToNewlineDelimitedString(const char *OriginalString);
198 EXTERN char *ConvertNewlineDelimitedStringToQuotedString(const char *NewlineDelimitedString,
199 Boolean_t SeparateInstructionsWithPlus);
203 EXTERN char *InsertNameAtPlaceHolder(char *BaseString,
204 char *NameToInsert);
205 #if defined TECPLOTKERNEL
206 /* CORE SOURCE CODE REMOVED */
207 #if !defined NO_ASSERTS
208 #endif /* !NO_ASSERTS */
209 #endif //TECPLOTKERNEL
211 inline char* EndOfString(char* str)
213 return str + strlen(str);
215 inline char const* EndOfString(char const* str)
217 return str + strlen(str);