LiteSQL
string.hpp
Go to the documentation of this file.
1 /* LiteSQL
2  *
3  * The list of contributors at http://litesql.sf.net/
4  *
5  * See LICENSE for copyright information. */
6 
9 #ifndef litesql_string_hpp
10 #define litesql_string_hpp
11 
12 #include <string>
13 #include <sstream>
14 #include <vector>
15 
16 namespace litesql {
19  template <class T>
20  std::string toString(T a) {
21  std::ostringstream ost;
22  ost << a;
23  return ost.str();
24  }
25 
27  bool startsWith(const std::string& what, const std::string& with);
29  bool endsWith(const std::string& what, const std::string& with);
31  std::string toLower(const std::string& s);
33  std::string toUpper(const std::string& s);
34 
35  std::string capitalize(const std::string& s);
36  std::string decapitalize(const std::string& s);
37 
38 
40  std::string rstrip(std::string s);
42  std::string lstrip(std::string s);
44  std::string replace(const std::string& s, const std::string& what, const std::string& with);
46  int hexToInt(const std::string& s);
48  int atoi(const std::string &s);
50  std::string operator*(int amount, const std::string &s);
52  std::string operator*(const std::string &s, int amount);
55  std::string escapeSQL(const std::string &str);
56 
58  std::vector<std::string> split(const std::string& s, const std::string& delim=" ");
59 
61  std::string join(const std::vector<std::string>& strings,const std::string& delim=" ");
62 
68  std::vector<std::string> slice(const std::vector<std::string>& strings,int start, int end);
69 
70 }
71 
72 #endif
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
std::string lstrip(std::string s)
returns a string with no empty characters at the beginning of the string
std::string rstrip(std::string s)
returns a string with no empty characters at the end of the string
std::string replace(const std::string &s, const std::string &what, const std::string &with)
returns a copy string 's' where 'what' is replaced with 'with'
std::string toString(T a)
returns string representation of passed parameter if it can be written to ostringstream
Definition: string.hpp:20
int hexToInt(const std::string &s)
converts string representation of a hex number to integer
std::string toLower(const std::string &s)
returns lower-case version of the string
int atoi(const std::string &s)
string version of atoi
bool endsWith(const std::string &what, const std::string &with)
returns true if 'what' end with 'with'
std::string operator*(int amount, const std::string &s)
returns a string which is duplicated 'amount' times
Definition: string.cpp:93
std::string escapeSQL(const std::string &str)
escapes ' characters so that they do not break SQL statements.
std::vector< std::string > split(const std::string &s, const std::string &delim=" ")
from string.
std::string toUpper(const std::string &s)
returns upper-case version of the string
bool startsWith(const std::string &what, const std::string &with)
returns true if 'what' starts with 'with'
std::string join(const std::vector< std::string > &strings, const std::string &delim=" ")
returns strings joined with delimiter
std::vector< std::string > slice(const std::vector< std::string > &strings, int start, int end)
returns a part of strings
Definition: string.cpp:144

SourceForge.net Logo