Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

lStr.h

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /* POLiTe - Persistent Object Library Test                                    */
00004 /*                                        Ph.D. Thesis by Mgr. Michal Kopecky */
00005 /*                                                                            */
00006 /* Charles University Prague                                                  */
00007 /*                                                                            */
00008 /******************************************************************************/
00009 /*                                                                            */
00010 /* File name: ...                                                             */
00011 /* Module: ......                                                             */
00012 /*                                                                            */
00013 /******************************************************************************/
00014 
00015 #ifndef __L_STR_H__
00016 #define __L_STR_H__
00017 
00018 // Standard Header(s)
00019 #include <iostream.h>
00020 #include <string.h>
00021 
00022 // Common POLiTe Header(s)
00023 #include <lDefs.h>
00024 #include <lTypes.h>
00025 
00026 DLL_External int StrLen(const char * const src);
00027 //counts number of chars in src, returns 0 if src == NULL
00028 
00029 DLL_External char *StrCpy(char * (&dst), const char * const src);
00030 //copies the source "src" into destination dst
00031 //frees previously allocated memory for dst
00032 //aloocates memory for dst
00033 
00034 DLL_External char *StrCpy(const char * const src);
00035 //copies the source "src" and returns the copy
00036 //aloocates memory for it
00037 
00038 DLL_External char *StrExp(char * dst, const char * src, int len);
00039 //copies the source "src" into destination dst, maximum of copied character
00040 //is "len". copy is terminated by \0 char, so the buffer must be at least
00041 //"len+1" characters long
00042 //buffer must exists before calling this method!!!
00043 
00044 DLL_External int StrCmp(const char * const dst, const char * const src);
00045 //compares the source "src" with the destination dst
00046 
00047 DLL_External int StrCmpUp(const char * const dst, const char * const src);
00048 //compares the source "src" with the destination "dst" in upper case
00049 
00050 DLL_External char *StrFree(char * (&dst));
00051 //frees dynamically allocated string
00052 
00053 DLL_External char *StrCat(char * (&dst), const char * const src);
00054 //concatenates dst and src in given order
00055 //free previously allocated memory for dst
00056 //allocates memory for the result
00057 
00058 DLL_External char *StrCat(char * (&dst), const int n, const char * const src, ...);
00059 //concatenates dst_1, ... , dst_n to src in given order
00060 //free previously allocated memory for dst
00061 //allocates memory for the result
00062 
00063 DLL_External char *StrAnd(char * (&dst), const char * const src);
00064 //returns "(dst) AND (src)"
00065 //free previously allocated memory for dst
00066 //allocates memory for the result
00067 
00068 DLL_External char *StrOr(char * (&dst), const char * const src);
00069 //returns "(dst) OR (src)"
00070 //free previously allocated memory for dst
00071 //allocates memory for the result
00072 
00073 DLL_External char *StrNot(char * (&dst));
00074 //returns "NOT(dst)"
00075 //free previously allocated memory for dst
00076 //allocates memory for the result
00077 
00078 DLL_External char *StrClause(char * (&dst), const char * const prf);
00079 //returns "<prf> <dst> " if dst is not empty
00080 //if dst is the empty string, returns NULL
00081 //examples:
00082 //              StrClause("ID = 100", "WHERE") == "WHERE ID = 100 "
00083 //              StrClause(NULL,"WHERE") == NULL
00084 //free previously allocated memory for dst
00085 //allocates memory for the result
00086 
00087 DLL_External void StrSwap(const char * (&s1), const char * (&s2));
00088 //Swaps two strings
00089 
00090 
00091 DLL_External char *StrSplit(char * (&src), const char delim, char * (&dst));
00092 //splits src in form "<dst> <delim> <rest_of_string>"
00093 //returns dst = <dst>, src = <rest_of_string>
00094 //free previously allocated memory for dst and src
00095 //allocates memory for the results
00096 
00097 DLL_External char *StrPrefix(char * (&src), const char delim, char * (&dst));
00098 //like StrSplit() function
00099 //if no delimiter is found in the string, return <dst> == NULL,
00100 //meanwhile StrSplit() returns <src> == NULL
00101 
00102 DLL_External char *StrPrefixCut(char * (&src), const char delim);
00103 //like StrPrefix() function
00104 //Prefix - if exists is cut off
00105 
00106 DLL_External char *LongToStr(const long n);
00107 //returns long number n as a char*, allocates space for the result.
00108 
00109 DLL_External char *ULongToStr(const unsigned long n);
00110 //returns unsigned long number n as a char*, allocates space for the result.
00111 
00112 DLL_External char *FloatToStr(const double x);
00113 //returns float number x as a char*, allocates space for the result.
00114 
00115 DLL_External long StrToLong(const char *s);
00116 //returns a char* converted to long.
00117 
00118 DLL_External char *StrMergeLists(
00119         char * (&dst),
00120         char * (&list1),
00121         char * (&list2),
00122         const char l_delim,
00123         const char *const sep_begin,
00124         const char *const sep_values,
00125         const char *const sep_middle,
00126         const char *const sep_end
00127         );
00128 
00129 DLL_External char *StrMergeLists(
00130         char * (&dst),
00131         char * (&list1),
00132         char * (&list2),
00133         const char l_delim,
00134         const char p_delim,
00135         const char *const sep_begin,
00136         const char *const sep_values,
00137         const char *const sep_middle,
00138         const char *const sep_end
00139         );
00140 
00141 DLL_External char *AliasR(int i);
00142 //Returns alias of i-th relation- "r_i", allocates space for the result.
00143 
00144 DLL_External char *AliasT(int i, int j);
00145 //Returns alias of j-th table of i-th DatabaseObject - "t_i_j",
00146 //allocates space for the result.
00147 
00148 DLL_External char *AliasQ(int i);
00149 //Returns alias prefix of table aliases of tables for i-th inner query - "t_i_",
00150 //allocates space for the result.
00151 
00152 DLL_External char *StrAddPrefix(char * &dst, const char * const src, const char * const delim);
00153 //Adds prefix src to dst-returns src delim dst
00154 
00155 DLL_External char * RealiasR(char * &fragment, int begin, int end, int incr);
00156 // Increases the numbers of relation aliases beginning i and ending number j
00157 // of incr
00158 
00159 DLL_External char * RealiasQ(char * &fragment, int begin, int end, int incr);
00160 // Increases the numbers of queries aliases beginning i and ending number j
00161 // of incr
00162 
00163 DLL_External bool StrReplace(
00164         char * &dst,
00165         const char * const oldstr,
00166         const char * const newstr,
00167         bool lwb = false, //left-side word boundary required
00168         bool rwb = false //right-side word boundary required
00169         );
00170 //Replaces firts occurence of oldstr in dst with newstr
00171 //Returns true if succeed
00172 
00173 DLL_External char * StrReplaceAll(
00174         char * &dst,
00175         const char * const oldstr,
00176         const char * const newstr,
00177         bool lwb = false, //left-side word boundary required
00178         bool rwb = false //right-side word boundary required
00179         );
00180 //Replaces all occurences of oldstr in dst with newstr
00181 //Returns dst
00182 
00183 DLL_External char *StrAndOnly(char * (&dst), const char * const src);
00184 //returns "dst AND src"
00185 //free previously allocated memory for dst
00186 //allocates memory for the result
00187 
00188 DLL_External char *StrEncode(char * (&dst), const char * const src);
00189 DLL_External char *StrEncode(char * (&src));
00190 // encodes string by doubling all backslashes and apostrophes
00191 // encloses result in apostrophes
00192 // allocates new space for the result
00193 // needed to find it in the comma-separated lists
00194 
00195 DLL_External char *StrDecode(char * (&dst), const char * const src);
00196 DLL_External char *StrDecode(char * (&src));
00197 // takes encoded string and return original one
00198 
00199 #endif //__L_STR_H__
00200 

Generated on Sun Jul 14 20:51:15 2002 for POLiTe by doxygen1.2.16