CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
string.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_UTIL_STRING_H_
6 #define CVMFS_UTIL_STRING_H_
7 
8 #include <stdint.h>
9 #include <sys/time.h>
10 
11 #include <cstdio>
12 #include <map>
13 #include <string>
14 #include <vector>
15 
16 #ifdef CVMFS_NAMESPACE_GUARD
17 namespace CVMFS_NAMESPACE_GUARD {
18 #endif
19 
20 std::string StringifyBool(const bool value);
21 std::string StringifyInt(const int64_t value);
22 std::string StringifyUint(const uint64_t value);
23 std::string StringifyByteAsHex(const unsigned char value);
24 std::string StringifyDouble(const double value);
25 std::string StringifyTime(const time_t seconds, const bool utc);
26 std::string StringifyTimeval(const timeval value);
27 std::string RfcTimestamp();
28 std::string IsoTimestamp();
29 std::string WhitelistTimestamp(time_t when);
30 time_t IsoTimestamp2UtcTime(const std::string &iso8601);
31 int64_t String2Int64(const std::string &value);
32 uint64_t String2Uint64(const std::string &value);
33 bool String2Uint64Parse(const std::string &value, uint64_t *result);
34 
35 void String2Uint64Pair(const std::string &value, uint64_t *a, uint64_t *b);
36 bool HasPrefix(const std::string &str, const std::string &prefix,
37  const bool ignore_case);
38 bool HasSuffix(const std::string &str, const std::string &suffix,
39  const bool ignore_case);
40 
41 std::vector<std::string> SplitString(const std::string &str, const char delim,
42  const unsigned max_chunks = 0);
43 std::string JoinStrings(const std::vector<std::string> &strings,
44  const std::string &joint);
45 void ParseKeyvalMem(const unsigned char *buffer, const unsigned buffer_size,
46  std::map<char, std::string> *content);
47 bool ParseKeyvalPath(const std::string &filename,
48  std::map<char, std::string> *content);
49 
50 std::string GetLineMem(const char *text, const int text_size);
51 bool GetLineFile(FILE *f, std::string *line);
52 bool GetLineFd(const int fd, std::string *line);
53 std::string Trim(const std::string &raw, bool trim_newline = false);
54 std::string ToUpper(const std::string &mixed_case);
55 std::string ReplaceAll(const std::string &haystack, const std::string &needle,
56  const std::string &replace_by);
57 std::string Tail(const std::string &source, unsigned num_lines);
58 
59 std::string Base64(const std::string &data);
60 std::string Base64Url(const std::string &data);
61 bool Debase64(const std::string &data, std::string *decoded);
62 std::string GetGMTimestamp(std::string format = "%Y-%m-%d %H:%M:%S");
63 
64 
65 #ifdef CVMFS_NAMESPACE_GUARD
66 } // namespace CVMFS_NAMESPACE_GUARD
67 #endif
68 
69 #endif // CVMFS_UTIL_STRING_H_
string GetLineMem(const char *text, const int text_size)
Definition: string.cc:372
vector< string > SplitString(const string &str, const char delim, const unsigned max_chunks)
Definition: string.cc:287
std::string IsoTimestamp()
Definition: string.cc:148
string Trim(const string &raw, bool trim_newline)
Definition: string.cc:420
string ReplaceAll(const string &haystack, const string &needle, const string &replace_by)
Definition: string.cc:453
string JoinStrings(const vector< string > &strings, const string &joint)
Definition: string.cc:317
string Tail(const string &source, unsigned num_lines)
Definition: string.cc:560
string StringifyTime(const time_t seconds, const bool utc)
Definition: string.cc:104
string StringifyDouble(const double value)
Definition: string.cc:95
std::string StringifyUint(const uint64_t value)
Definition: string.cc:83
bool Debase64(const string &data, string *decoded)
Definition: string.cc:532
string StringifyByteAsHex(const unsigned char value)
Definition: string.cc:89
string StringifyBool(const bool value)
Definition: string.cc:75
bool String2Uint64Parse(const std::string &value, uint64_t *result)
Definition: string.cc:242
string Base64Url(const string &data)
Definition: string.cc:504
std::string RfcTimestamp()
Definition: string.cc:126
int64_t String2Int64(const string &value)
Definition: string.cc:221
bool GetLineFile(FILE *f, std::string *line)
Definition: string.cc:378
string ToUpper(const string &mixed_case)
Definition: string.cc:445
bool HasSuffix(const std::string &str, const std::string &suffix, const bool ignore_case)
Definition: string.cc:278
std::string WhitelistTimestamp(time_t when)
Definition: string.cc:168
string StringifyInt(const int64_t value)
Definition: string.cc:77
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
Definition: string.cc:264
time_t IsoTimestamp2UtcTime(const std::string &iso8601)
Definition: string.cc:197
bool GetLineFd(const int fd, std::string *line)
Definition: string.cc:396
string Base64(const string &data)
Definition: string.cc:473
uint64_t String2Uint64(const string &value)
Definition: string.cc:227
bool ParseKeyvalPath(const string &filename, map< char, string > *content)
Definition: string.cc:358
string StringifyTimeval(const timeval value)
Definition: string.cc:184
void ParseKeyvalMem(const unsigned char *buffer, const unsigned buffer_size, map< char, string > *content)
Definition: string.cc:329
std::string GetGMTimestamp(std::string format)
Definition: string.cc:583
void String2Uint64Pair(const string &value, uint64_t *a, uint64_t *b)
Definition: string.cc:260