ROSE  0.11.98.0
Convert.h
1 #ifndef ROSE_StringUtility_Convert_H
2 #define ROSE_StringUtility_Convert_H
3 
4 #include <rosedll.h>
5 
6 #include <cstdint>
7 #include <string>
8 #include <vector>
9 
10 namespace Rose {
11 namespace StringUtility {
12 
14 // String conversion functions
16 
20 ROSE_UTIL_API std::string convertToLowerCase(const std::string &inputString);
21 
28 ROSE_UTIL_API std::string fixLineTermination(const std::string &input);
29 
37 ROSE_UTIL_API std::string prefixLines(const std::string &lines, const std::string &prefix,
38  bool prefixAtFront=true, bool prefixAtBack=false);
39 
44 ROSE_UTIL_API std::string leftJustify(const std::string &input, size_t width, char fill = ' ');
45 
50 ROSE_UTIL_API std::string rightJustify(const std::string &input, size_t width, char fill = ' ');
51 
56 ROSE_UTIL_API std::string centerJustify(const std::string &input, size_t width, char fill = ' ');
57 
67 ROSE_UTIL_API std::string makeOneLine(const std::string &s, std::string replacement=" ");
68 
72 ROSE_UTIL_API std::string trim(const std::string &str, const std::string &strip=" \t\r\n",
73  bool at_beginning=true, bool at_end=true);
74 
76 ROSE_UTIL_API std::string untab(const std::string &str, size_t tabstops=8, size_t firstcol=0);
77 
87 ROSE_UTIL_API std::string removeRedundantSubstrings(const std::string&);
88 
93 ROSE_UTIL_API std::string removeAnsiEscapes(const std::string&);
94 
101 ROSE_UTIL_API std::string encode_base64(const std::vector<uint8_t> &data, bool do_pad=true);
102 ROSE_UTIL_API std::string encode_base64(const uint8_t *data, size_t nbytes, bool do_padd=true);
106 ROSE_UTIL_API std::vector<uint8_t> decode_base64(const std::string &encoded);
107 
115 ROSE_UTIL_API unsigned long generate_checksum(std::string s);
116 
117 } // namespace
118 } // namespace
119 
120 #endif
ROSE_UTIL_API std::string removeRedundantSubstrings(const std::string &)
Remove redundant and blank lines.
ROSE_UTIL_API std::string encode_base64(const std::vector< uint8_t > &data, bool do_pad=true)
Convert binary data to base-64.
ROSE_UTIL_API std::string leftJustify(const std::string &input, size_t width, char fill= ' ')
Left justify a string to specified width.
Main namespace for the ROSE library.
ROSE_UTIL_API std::string prefixLines(const std::string &lines, const std::string &prefix, bool prefixAtFront=true, bool prefixAtBack=false)
Insert a prefix string before every line.
ROSE_UTIL_API std::vector< uint8_t > decode_base64(const std::string &encoded)
Convert base-64 to binary.
ROSE_UTIL_API std::string untab(const std::string &str, size_t tabstops=8, size_t firstcol=0)
Expand horizontal tab characters.
ROSE_UTIL_API std::string convertToLowerCase(const std::string &inputString)
Convert to lower case.
ROSE_UTIL_API std::string makeOneLine(const std::string &s, std::string replacement=" ")
Converts a multi-line string to a single line.
ROSE_UTIL_API std::string centerJustify(const std::string &input, size_t width, char fill= ' ')
Center a string in a field.
ROSE_UTIL_API std::string trim(const std::string &str, const std::string &strip=" \t\r\n", bool at_beginning=true, bool at_end=true)
Trims white space from the beginning and end of a string.
ROSE_UTIL_API unsigned long generate_checksum(std::string s)
Compute a checkshum.
ROSE_UTIL_API std::string fixLineTermination(const std::string &input)
Normalizes line termination.
ROSE_UTIL_API std::string removeAnsiEscapes(const std::string &)
Remove ANSI escape characters.
ROSE_UTIL_API std::string rightJustify(const std::string &input, size_t width, char fill= ' ')
Right justify a string to specified width.