feisty meow concerns codebase 2.140
list_parsing.h
Go to the documentation of this file.
1#ifndef LIST_PARSING_CLASS
2#define LIST_PARSING_CLASS
3
4/*****************************************************************************\
5* *
6* Name : list_parsing *
7* Author : Chris Koeritz *
8* Author : Gary Hardley *
9* *
10*******************************************************************************
11* Copyright (c) 2002-$now By Author. This program is free software; you can *
12* redistribute it and/or modify it under the terms of the GNU General Public *
13* License as published by the Free Software Foundation; either version 2 of *
14* the License or (at your option) any later version. This is online at: *
15* http://www.fsf.org/copyleft/gpl.html *
16* Please send any updates to: fred@gruntose.com *
17\*****************************************************************************/
18
19#include <basis/contracts.h>
20#include <structures/set.h>
23
24namespace textual {
25
27
29{
30public:
31 virtual ~list_parsing();
32 DEFINE_CLASS_NAME("list_parsing");
33
34 static bool get_ids_from_string(const basis::astring &string, structures::int_set &ids);
36
40 static bool get_ids_from_string(const basis::astring &string, basis::int_array &ids);
42
44 static basis::astring put_ids_in_string(const structures::int_set &ids, char separator = ',');
46
47 static basis::astring put_ids_in_string(const basis::int_array &ids, char separator = ',');
49
50 static basis::astring emit_quoted_chunk(const basis::astring &to_emit);
52
53 static bool parse_csv_line(const basis::astring &to_parse, structures::string_array &fields);
55
61 static void create_csv_line(const structures::string_array &to_csv, basis::astring &target);
62 static void create_csv_line(const structures::string_table &to_csv, basis::astring &target);
64
67};
68
69} //namespace.
70
71#endif
72
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
A simple object that wraps a templated array of ints.
Definition array.h:275
A simple object that wraps a templated set of ints.
Definition set.h:156
An array of strings with some additional helpful methods.
Provides a symbol_table that holds strings as the content.
A set of functions that help out with parsing lists of things.
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.
static basis::astring put_ids_in_string(const structures::int_set &ids, char separator=',')
returns a string containing a "separator" separated list of ids.
static basis::astring emit_quoted_chunk(const basis::astring &to_emit)
ensures that quotes inside the string "to_emit" are escaped.
static void create_csv_line(const structures::string_array &to_csv, basis::astring &target)
DEFINE_CLASS_NAME("list_parsing")
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".