Merge branch 'storageareas' into zma_to_thread

This commit is contained in:
Isaac Connor
2018-05-12 19:45:48 -04:00
11 changed files with 192 additions and 183 deletions

View File

@@ -94,9 +94,8 @@ const std::string stringtf( const std::string format, ... )
return( tempString );
}
bool startsWith( const std::string &haystack, const std::string &needle )
{
return( haystack.substr( 0, needle.length() ) == needle );
bool startsWith(const std::string &haystack, const std::string &needle) {
return( haystack.substr(0, needle.length()) == needle );
}
std::vector<std::string> split(const std::string &s, char delim) {
@@ -109,20 +108,18 @@ std::vector<std::string> split(const std::string &s, char delim) {
return elems;
}
StringVector split( const std::string &string, const std::string &chars, int limit ) {
StringVector split(const std::string &string, const std::string &chars, int limit) {
StringVector stringVector;
std::string tempString = string;
std::string::size_type startIndex = 0;
std::string::size_type endIndex = 0;
//Info( "Looking for '%s' in '%s', limit %d", chars.c_str(), string.c_str(), limit );
do
{
do {
// Find delimiters
endIndex = string.find_first_of( chars, startIndex );
//Info( "Got endIndex at %d", endIndex );
if ( endIndex > 0 )
{
if ( endIndex > 0 ) {
//Info( "Adding '%s'", string.substr( startIndex, endIndex-startIndex ).c_str() );
stringVector.push_back( string.substr( startIndex, endIndex-startIndex ) );
}
@@ -130,8 +127,7 @@ StringVector split( const std::string &string, const std::string &chars, int lim
break;
// Find non-delimiters
startIndex = tempString.find_first_not_of( chars, endIndex );
if ( limit && (stringVector.size() == (unsigned int)(limit-1)) )
{
if ( limit && (stringVector.size() == (unsigned int)(limit-1)) ) {
stringVector.push_back( string.substr( startIndex ) );
break;
}
@@ -139,22 +135,21 @@ StringVector split( const std::string &string, const std::string &chars, int lim
} while ( startIndex != std::string::npos );
//Info( "Finished with %d strings", stringVector.size() );
return( stringVector );
return stringVector;
}
const std::string join(const StringVector &v, const char * delim ) {
const std::string join(const StringVector &v, const char * delim=",") {
std::stringstream ss;
for(size_t i = 0; i < v.size(); ++i) {
if(i != 0)
ss << ",";
for (size_t i = 0; i < v.size(); ++i) {
if ( i != 0 )
ss << delim;
ss << v[i];
}
return ss.str();
}
const std::string base64Encode( const std::string &inString )
{
const std::string base64Encode(const std::string &inString) {
static char base64_table[64] = { '\0' };
if ( !base64_table[0] )