src/c++/include/common/StringUtil.hh
/**
     * @brief Split a string along separators
     */
@brief Split a string along separators
@brief Split a string along separators
static inline void
    split(std::string str, std::vector<std::string>& result, const std::string& seps = " ,", bool return_empty = false)
    {
        bool has_last = false;
        while (str.size() > 0)
        {
            size_t pos = str.find_first_of(seps);
            if (pos != std::string::npos)
            {
                if (return_empty || pos > 0)
                {
                    result.push_back(str.substr(0, pos));
                }
                str = str.substr(pos + 1);
                has_last = true;
            }
            else
            {
                result.push_back(str);
                str = "";
                has_last = false;
            }
        }
        if (has_last && return_empty)
        {
            result.push_back("");
        }
    }
static inline void split ( std :: string str , std :: vector < std :: string > & result , const std :: string & seps = " " , bool return_empty = false ) { bool has_last = false ; while ( str . size ( ) > 0 ) { size_t pos = str . find_first_of ( seps ) ; if ( pos != std :: string :: npos ) { if ( return_empty || pos > 0 ) { result . push_back ( str . substr ( 0 , pos ) ) ; } str = str . substr ( pos + 1 ) ; has_last = true ; } else { result . push_back ( str ) ; str = " " ; has_last = false ; } } if ( has_last && return_empty ) { result . push_back ( " " ) ; } }
@brief Split a string along separators
@brief Split a string along separators