This commit is contained in:
Jean-Francois Dockes 2021-11-11 18:43:47 +01:00
parent 728129e5ce
commit a1e98c1bdc
3 changed files with 6 additions and 4 deletions

View File

@ -720,7 +720,9 @@ bool ConfSimple::commentsAsXML(ostream& out)
{
string::size_type pos = line.m_data.find_first_not_of("# ");
if (pos != string::npos) {
out << line.m_data.substr(pos) << endl;
out << line.m_data.substr(pos) << "\n";
} else {
out << "\n";
}
break;
}

View File

@ -347,7 +347,7 @@ template void stringsToCSV<vector<string> >(const vector<string>&, string&,
#endif
void stringToTokens(const string& str, vector<string>& tokens,
const string& delims, bool skipinit)
const string& delims, bool skipinit, bool allowempty)
{
string::size_type startPos = 0, pos;
@ -367,7 +367,7 @@ void stringToTokens(const string& str, vector<string>& tokens,
}
if (pos == startPos) {
// Dont' push empty tokens after first
if (tokens.empty()) {
if (allowempty || tokens.empty()) {
tokens.emplace_back();
}
startPos = ++pos;

View File

@ -142,7 +142,7 @@ template <class T> void stringsToCSV(const T& tokens, std::string& s,
extern void stringToTokens(const std::string& s,
std::vector<std::string>& tokens,
const std::string& delims = " \t",
bool skipinit = true);
bool skipinit = true, bool allowempty = false);
/** Like toTokens but with multichar separator */
extern void stringSplitString(const std::string& str,