All Classes Namespaces Functions Variables Enumerations Enumerator Pages
utils.h
1 /*
2  Copyright (c) 2014 by Elvis Angelaccio
3 
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  THE SOFTWARE.
21 */
22 
23 #ifndef UTILS_H
24 #define UTILS_H
25 
26 #include <string>
27 
29 namespace utils
30 {
31  const int ERROR_BUFF_SIZE = 2048;
32  const size_t KILOBYTE = 1000;
33  const size_t MEGABYTE = 1000000;
39  bool isBlankLine(const std::string& s);
40 
45  bool isIntegerString(const std::string& s);
46 
51  bool isFloatString(const std::string& s);
52 
57  bool isQuoted(const std::string& s);
58 
63  bool isQuotedSentence(const std::string& s);
64 
70  std::string removeSubstring(const std::string& str, const std::string substr);
71 
76  std::string removeEndSlash(const std::string& str);
77 
84  std::string parseUntilQuote(std::istringstream& parser, const std::string& begin);
85 
90  template<typename T> std::string toString(T type);
91 
98  std::string syscallError(const std::string& syscall, int errorCode);
99 
103  std::string getCurrentTime();
104 
109  std::string formatSize(size_t size);
110 
115  std::string getMacroName(int errorCode);
116 
117 }
118 
119 #endif
std::string removeSubstring(const std::string &str, const std::string substr)
bool isFloatString(const std::string &s)
bool isQuotedSentence(const std::string &s)
std::string getCurrentTime()
Definition: utils.cpp:177
std::string formatSize(size_t size)
Definition: utils.cpp:206
const size_t KILOBYTE
Definition: utils.h:32
bool isQuoted(const std::string &s)
std::string getMacroName(int errorCode)
Definition: utils.cpp:229
std::string toString(T type)
std::string removeEndSlash(const std::string &str)
bool isBlankLine(const std::string &s)
const size_t MEGABYTE
Definition: utils.h:33
bool isIntegerString(const std::string &s)
std::string parseUntilQuote(std::istringstream &parser, const std::string &begin)
std::string syscallError(const std::string &syscall, int errorCode)
Definition: utils.cpp:153