28 #ifndef __TERRALIB_COMMON_INTERNAL_STRINGUTILS_H    29 #define __TERRALIB_COMMON_INTERNAL_STRINGUTILS_H    44 #include <boost/cstdint.hpp>    58       char name[std::numeric_limits<boost::int16_t>::digits10 + 2];
    59       sprintf(name, 
"%hd", value);
    70       char name[std::numeric_limits<boost::uint16_t>::digits10 + 2];
    71       sprintf(name, 
"%hu", value);
    82       char name[std::numeric_limits<boost::int32_t>::digits10 + 2];
    83       sprintf(name, 
"%d", value);
    94       char name[std::numeric_limits<boost::uint32_t>::digits10 + 2];
    95       sprintf(name, 
"%u", value);
   106       char name[std::numeric_limits<boost::int64_t>::digits10 + 2];
   107       sprintf(name, 
"%" PRId64 
"", value);
   118       char name[std::numeric_limits<boost::uint64_t>::digits10 + 2];
   119       sprintf(name, 
"%" PRIu64 
"", value);
   130       char name[std::numeric_limits<float>::digits10 + std::numeric_limits<float>::digits + 4];
   131       sprintf(name, 
"%f", value);
   142       char name[std::numeric_limits<double>::digits10 + std::numeric_limits<double>::digits + 4];
   143       sprintf(name, 
"%e", value);
   157       sprintf(name, 
"%.*f", precision, value );
   170       size_t size = value.size();
   172       std::string aux(size, 
' ');
   174       for(
size_t i = 0; i < size; ++i)
   175         aux[i] = ((value[i] >= 97) && (value[i] <= 122)) ? (value[i] - 32) : value[i];
   189       size_t size = value.size();
   191       for(
size_t i = 0; i < size; ++i)
   192         value[i] = ((value[i] >= 97) && (value[i] <= 122)) ? (value[i] - 32) : value[i];
   204       size_t size = value.size();
   206       std::string aux(size, 
' ');
   208       for(
size_t i = 0; i < size; ++i)
   209         aux[i] = ((value[i] >= 65) && (value[i] <= 90)) ? (value[i] + 32) : value[i];
   222                          std::vector<std::string>& tokens,
   223                          const std::string& delimiters = 
" ")
   226       size_t lastPos = str.find_first_not_of(delimiters, 0);
   229       size_t pos = str.find_first_of(delimiters, lastPos);
   231       while((std::string::npos != pos) ||
   232             (std::string::npos != lastPos))
   235         tokens.push_back(str.substr(lastPos, pos - lastPos));
   238         lastPos = str.find_first_not_of(delimiters, pos);
   241         pos = str.find_first_of(delimiters, lastPos);
   257                            std::map<std::string, std::string>& kvp,
   258                            const std::string& kvpDelimiter = 
"&",
   259                            const std::string& kvDelimiter = 
"=",
   260                            bool toUpper = 
false)
   266       std::vector<std::string> tokens;
   268       Tokenize(kvpStr, tokens, kvpDelimiter);
   271       size_t size = tokens.size();
   273       for(
size_t i = 0; i < size; ++i)
   275         std::vector<std::string> kv;
   277         Tokenize(tokens[i], kv, kvDelimiter);
   295           for(
size_t k = 1; k < kv.size(); ++k)
   298           size_t pos = aux.size() - 1;
   300           kvp[kv[0]] = aux.erase(pos, 1);
   314       char* cs = 
new char[s.length() + 1];
   315       strncpy(cs, s.c_str(), s.length() + 1);
   328       std::size_t ns = vs.size() ;
   330       char** as = 
new char*[ns + 1];
   334       for(std::size_t i = 0; i< ns; ++i)
   336         as[i] = 
new char[vs[i]->length() + 1];
   338         strncpy(as[i], vs[i]->c_str(), vs[i]->length() + 1);
   353       std::size_t ns = vs.size() ;
   355       char** as = 
new char*[ns + 1];
   359       for(std::size_t i = 0; i< ns; ++i)
   361         as[i] = 
new char[vs[i].length() + 1];
   363         strncpy(as[i], vs[i].c_str(), vs[i].length() + 1);
   380       for (std::size_t i = 0; i < str.size(); ++i)
   382         unsigned char c = (
unsigned char)str.at(i);
   387             (c >= 48 && c <= 57) ||
   388             (c >= 65 && c <= 90) ||
   389             (c >= 97 && c <= 122))
   395             unsigned char add = 95;
   401           unsigned char cAux = (
unsigned char)str.at(i + 1);
   407             if (cAux >= 128 && cAux <= 133)
   409             else if (cAux >= 136 && cAux <= 139)
   411             else if (cAux >= 140 && cAux <= 143)
   413             else if (cAux >= 146 && cAux <= 150)
   415             else if (cAux >= 153 && cAux <= 156)
   417             else if (cAux >= 160 && cAux <= 165)
   419             else if (cAux >= 168 && cAux <= 171)
   421             else if (cAux >= 172 && cAux <= 175)
   423             else if (cAux >= 178 && cAux <= 182)
   425             else if (cAux >= 185 && cAux <= 188)
   430               unsigned char add = value;
   454 #endif  // __TERRALIB_COMMON_INTERNAL_STRINGUTILS_H std::string Convert2LCase(const std::string &value)
It converts a string to lower case. 
 
Configuration flags for the TerraLib Common Runtime module. 
 
void ExtractKVP(const std::string &kvpStr, std::map< std::string, std::string > &kvp, const std::string &kvpDelimiter="&", const std::string &kvDelimiter="=", bool toUpper=false)
It extracts a key-value map from a string. 
 
std::string Convert2UCase(const std::string &value)
It converts a string to upper case. 
 
std::string ReplaceSpecialChars(const std::string &str, bool &changed)
It replace special characters of a string. 
 
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice. 
 
void Convert2UCaseInPlace(std::string &value)
It converts a string to upper case in place (it doesn't allocate an auxiliar buffer). 
 
#define TECOMMONEXPORT
You can use this macro in order to export/import classes and functions from this module. 
 
TECOMMONEXPORT std::vector< std::string > SplitString(const std::string &str, const char &delimiter)
 
char * CreateCString(const std::string &s)
It converts the C++ string to a C-string. 
 
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string. 
 
char ** CreateCStringArray(const std::vector< std::string * > &vs)
It converts the C++ vector of string pointers to a C array os strings.