feisty meow concerns codebase
2.140
|
A set of functions that help out with parsing lists of things. More...
#include <list_parsing.h>
Public Member Functions | |
virtual | ~list_parsing () |
DEFINE_CLASS_NAME ("list_parsing") | |
Static Public Member Functions | |
static bool | get_ids_from_string (const basis::astring &string, structures::int_set &ids) |
returns true if a set of unique ids can be extracted from "string". More... | |
static bool | get_ids_from_string (const basis::astring &string, basis::int_array &ids) |
same as above except result is an array – to preserve order. More... | |
static basis::astring | put_ids_in_string (const structures::int_set &ids, char separator=',') |
returns a string containing a "separator" separated list of ids. More... | |
static basis::astring | put_ids_in_string (const basis::int_array &ids, char separator=',') |
operates on an array instead of a set. More... | |
static basis::astring | emit_quoted_chunk (const basis::astring &to_emit) |
ensures that quotes inside the string "to_emit" are escaped. More... | |
static bool | parse_csv_line (const basis::astring &to_parse, structures::string_array &fields) |
examines the string "to_parse" which should be in csv format. More... | |
static void | create_csv_line (const structures::string_array &to_csv, basis::astring &target) |
static void | create_csv_line (const structures::string_table &to_csv, basis::astring &target) |
writes a CSV line of text into the "target" from the items in "to_csv". More... | |
A set of functions that help out with parsing lists of things.
Definition at line 28 of file list_parsing.h.
|
virtual |
Definition at line 34 of file list_parsing.cpp.
|
static |
Definition at line 158 of file list_parsing.cpp.
References basis::astring::empty_string(), and basis::array< contents >::length().
|
static |
writes a CSV line of text into the "target" from the items in "to_csv".
the "target" is reset before the line is stored there; thus, this is not cumulative. further, the end of line character is not appended. this will escape quote and backslash characters with a prepended backslash.
Definition at line 148 of file list_parsing.cpp.
References basis::astring::empty_string(), structures::symbol_table< contents >::name(), and structures::symbol_table< contents >::symbols().
textual::list_parsing::DEFINE_CLASS_NAME | ( | "list_parsing" | ) |
|
static |
ensures that quotes inside the string "to_emit" are escaped.
Definition at line 135 of file list_parsing.cpp.
References basis::astring::length().
|
static |
same as above except result is an array – to preserve order.
this also retains duplicates.
Definition at line 48 of file list_parsing.cpp.
References basis::astring::length(), MAXINT32, and basis::array< contents >::reset().
|
static |
returns true if a set of unique ids can be extracted from "string".
valid separators are spaces, commas, hyphens. note that this returns an int_set although the integers will all be non-negative. e.g. "1-4,5 6 7,30-25" is a valid string.
Definition at line 37 of file list_parsing.cpp.
References structures::set< contents >::add(), structures::set< contents >::clear(), and basis::array< contents >::length().
|
static |
examines the string "to_parse" which should be in csv format.
the "fields" list is set to the entries found on the line. true is returned if the line parsed without any errors. this method will accept a backslash as an escape character if it is immediately followed by a quote character or another backslash character. no other escapes are currently supported; backslashes will be taken literally otherwise.
Definition at line 196 of file list_parsing.cpp.
|
static |
operates on an array instead of a set.
Definition at line 121 of file list_parsing.cpp.
References basis::array< contents >::length().
|
static |
returns a string containing a "separator" separated list of ids.
spaces are also used between entries for readability.
Definition at line 107 of file list_parsing.cpp.
References basis::array< contents >::length().