#include <StringManipulator.h>
Definition at line 15 of file StringManipulator.h.
StringManipulator::StringManipulator |
( |
const std::string & |
sin | ) |
|
|
inlineexplicit |
StringManipulator::StringManipulator |
( |
const char * |
chin | ) |
|
|
inlineexplicit |
const char* StringManipulator::c_str |
( |
| ) |
const |
|
inline |
Definition at line 110 of file StringManipulator.cxx.
112 ssout.setf(std::ios::fixed);
113 ssout.precision(prec);
115 string sout = ssout.str();
116 if ( trunc && sout.size() ) {
117 string::size_type ipos = sout.size() - 1;
119 if ( sout[ipos] ==
'.' ) {
122 }
else if ( sout[ipos] ==
'0' ) --ipos;
125 sout = sout.substr(0, ipos + 1);
126 if ( sdot.size() && sdot !=
"." ) {
127 for ( ipos=0; ipos<sout.size(); ++ipos ) {
128 if ( sout[ipos] ==
'.' ) {
129 sout.replace(ipos, 1, sdot);
130 ipos += sdot.size() - 1;
134 if ( smin.size() && smin !=
"." ) {
135 for ( ipos=0; ipos<sout.size(); ++ipos ) {
136 if ( sout[ipos] ==
'-' ) {
137 sout.replace(ipos, 1, smin);
138 ipos += smin.size() - 1;
template<typename T >
static char StringManipulator::getFill |
( |
typename std::enable_if< std::is_integral< T >::value, const T & >::type |
val | ) |
|
|
inlinestatic |
template<typename T >
static char StringManipulator::getFill |
( |
typename std::enable_if<!std::is_integral< T >::value, const T & >::type |
val | ) |
|
|
inlinestatic |
bool StringManipulator::isDigits |
( |
| ) |
const |
Definition at line 148 of file StringManipulator.cxx.
150 for (
char c :
str() )
if ( ! std::isdigit(
c) )
return false;
const std::string & str() const
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
bool StringManipulator::isFloat |
( |
| ) |
const |
Definition at line 174 of file StringManipulator.cxx.
175 if (
str().
size() == 0 )
return false;
177 strtof(
c_str(), &pch);
178 return pch[0] ==
'\0';
const std::string & str() const
std::string::size_type size() const
const char * c_str() const
bool StringManipulator::isInt |
( |
| ) |
const |
Definition at line 156 of file StringManipulator.cxx.
159 string schk = (c ==
'+' || c ==
'-') ?
str().substr(1) :
str();
const std::string & str() const
StringManipulator(std::string &strin, bool copy)
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
bool StringManipulator::isUnsignedInt |
( |
| ) |
const |
Definition at line 165 of file StringManipulator.cxx.
168 string schk = c ==
'+' ?
str().substr(1) :
str();
const std::string & str() const
StringManipulator(std::string &strin, bool copy)
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Index StringManipulator::logLevel |
( |
| ) |
const |
|
inline |
Definition at line 51 of file StringManipulator.cxx.
52 const string myname =
"StringManipulator::patternSplit: ";
56 if ( spat.size() < 2 )
return m_splits;
57 char chStart = spat[0];
58 char chEnd = spat[spat.size() - 1 ];
59 string seps = spat.substr(1, spat.size() - 2 );
63 for (
char ch :
m_str ) {
66 if ( ch == chStart ) {
77 wordvv.push_back(sman.split(seps));
85 if ( word.size() ) wordvv.push_back(
StringVector(1, word));
87 cout << myname <<
"Word sequence count: " << wordvv.size() <<
endl;
94 for (
string str1 : strs1 ) {
95 for (
string word : wordvec ) {
96 strs2.push_back(str1 + word);
102 cout << myname <<
"Split count: " <<
m_splits.size() <<
endl;
std::vector< string > StringVector
std::vector< StringVector > StringVV
std::vector< std::string > StringVector
union ptb::content::word::word word
QTextStream & endl(QTextStream &s)
template<typename T >
int StringManipulator::replace |
( |
std::string |
substr, |
|
|
const T & |
xsub |
|
) |
| |
Definition at line 136 of file StringManipulator.h.
138 bool havesub =
false;
139 std::string::size_type ipos =
m_str.find(ssubout);
141 while ( ipos != std::string::npos ) {
143 std::ostringstream sssubin;
145 ssubin = sssubin.str();
147 std::string::size_type lout = ssubout.size();
148 m_str.replace(ipos, lout, ssubin);
149 ipos =
m_str.find(ssubout, ipos+lout);
template<typename T >
int StringManipulator::replaceFixedWidth |
( |
std::string |
substr, |
|
|
const T & |
xsub, |
|
|
Index |
width |
|
) |
| |
Definition at line 159 of file StringManipulator.h.
161 char cfill = getFill<T>(xsubin);
162 bool havesub =
false;
163 std::string::size_type ipos =
m_str.find(ssubout);
165 while ( ipos != std::string::npos ) {
167 std::ostringstream sssubin;
169 sssubin.width(width);
171 ssubin = sssubin.str();
173 std::string::size_type lout = ssubout.size();
174 m_str.replace(ipos, lout, ssubin);
175 ipos =
m_str.find(ssubout, ipos+lout);
void StringManipulator::setLogLevel |
( |
Index |
logLevel | ) |
|
|
inline |
std::string::size_type StringManipulator::size |
( |
| ) |
const |
|
inline |
Definition at line 19 of file StringManipulator.cxx.
21 if ( seps.size() == 0 ) {
28 for (
char ch : seps.substr(1) ) {
29 for (
char& rch : str )
if ( rch == ch ) rch = csep;
34 for (
char ch :
m_str ) {
37 if ( fullSplit || word.size() ) {
45 if ( word.size() || (fullSplit && isSep) )
m_splits.push_back(word);
const std::string & str() const
union ptb::content::word::word word
float StringManipulator::toFloat |
( |
float |
valbad = 0 | ) |
const |
Definition at line 197 of file StringManipulator.cxx.
198 if (
str().
size() == 0 )
return badval;
201 return pch[0] ==
'\0' ? val : badval;
const std::string & str() const
std::string::size_type size() const
const char * c_str() const
int StringManipulator::toInt |
( |
int |
valbad = 0 | ) |
const |
unsigned int StringManipulator::toUnsignedInt |
( |
unsigned int |
valbad = 0 | ) |
const |
Definition at line 190 of file StringManipulator.cxx.
192 return std::strtoul(
c_str(),
nullptr, 10);
const char * c_str() const
bool isUnsignedInt() const
int StringManipulator::m_LogLevel = 0 |
|
private |
The documentation for this class was generated from the following files: