Example #1
0
TEST_F(SyslogTests, test_csv_separator) {
  ASSERT_EQ(std::vector<std::string>({"", "", "", "", ""}), splitCsv(",,,,"));
  ASSERT_EQ(std::vector<std::string>({" ", " ", " ", " ", " "}),
            splitCsv(" , , , , "));
  ASSERT_EQ(std::vector<std::string>({"foo", "bar", "baz"}),
            splitCsv("foo,bar,baz"));
  ASSERT_EQ(std::vector<std::string>({"foo", "bar", "baz"}),
Example #2
0
/**   
* split and trim comma-separated list of values (other delimiters can be used too, ie: semicolon).
*
* RFC 4180 difference: 
* skip space-only lines, trim values unless it is " quoted ",
* line can end with CRLF or LF, multi-line strings not supported.
*
* @param[in] i_values       source string of comma separated values.
* @param[in] i_delimiters   list of delimiters, default: comma.
* @param[in] i_isUnquote    if true then do "unquote ""csv"" ", default: false.
* @param[in] i_quote        quote character, default: sql single ' quote.
*/
list<string> openm::splitCsv(const string & i_values, const char * i_delimiters, bool i_isUnquote, char i_quote)
{
    list<string> resultLst;
    splitCsv(i_values, resultLst, i_delimiters, i_isUnquote, i_quote);
    return resultLst;
}