RSC  0.17.1
ContainerIO.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the RSC project
4  *
5  * Copyright (C) 2010, 2011, 2014 Jan Moringen
6  *
7  * This file may be licensed under the terms of the
8  * GNU Lesser General Public License Version 3 (the ``LGPL''),
9  * or (at your option) any later version.
10  *
11  * Software distributed under the License is distributed
12  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
13  * express or implied. See the LGPL for the specific language
14  * governing rights and limitations.
15  *
16  * You should have received a copy of the LGPL along with this
17  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
18  * or write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * The development of this software was supported by:
22  * CoR-Lab, Research Institute for Cognition and Robotics
23  * Bielefeld University
24  *
25  * ============================================================ */
26 
27 #include "ContainerIO.h"
28 
29 namespace std {
30 namespace detail {
31 
32 // Pair style
33 
34 void pair_style_delete(ios_base::event event_, ios_base& stream, int /*index*/) {
35  if (event_ == ios_base::erase_event && stream.pword(
37  delete reinterpret_cast<pair_style*> (stream.pword(
39  }
40 }
41 
42 pair_style::pair_style(const string& open_brace, const string& separator,
43  const string& close_brace) :
44  open_brace(open_brace), separator(separator), close_brace(close_brace) {
45 }
46 
47 const int pair_style::stream_storage = ios_base::xalloc();
48 
49 // Element sequence style
50 
51 void element_sequence_style_delete(ios_base::event event_, ios_base& stream, int /*index*/) {
52  if (event_ == ios_base::erase_event && stream.pword(
54  delete reinterpret_cast<element_sequence_style*> (stream.pword(
56  }
57 }
58 
60  const string& first_separator, const string& last_separator) :
61  separator(separator), first_separator(first_separator), last_separator(
62  last_separator) {
63 }
64 
65 const int element_sequence_style::stream_storage = ios_base::xalloc();
66 
67 // Container style
68 
69 void container_style_delete(ios_base::event event_, ios_base& stream, int /*index*/) {
70  if (event_ == ios_base::erase_event && stream.pword(
72  delete reinterpret_cast<container_style*> (stream.pword(
74  }
75 }
76 
77 container_style::container_style(const string& open, const string& close) :
78  open(open), close(close) {
79 }
80 
81 const int container_style::stream_storage = ios_base::xalloc();
82 
83 }
84 
85 // Default pair styles
86 
89 };
90 
92  detail::pair_style("", " ", "")
93 };
94 
95 // Default element sequence styles
96 
98 element_sequence(const string& separator,
99  const string& first_separator,
100  const string& last_separator) {
102  (detail::element_sequence_style(separator, first_separator, last_separator));
103 }
104 
108 
112 
113 // Default container styles
114 
117 };
118 
120  detail::container_style("(", ")")
121 };
122 
124  detail::container_style("#(", ")")
125 };
126 
128  detail::container_style("d(", ")")
129 };
130 
132  detail::container_style("[", "]")
133 };
134 
136  detail::container_style("{", "}")
137 };
138 
139 }
const detail::set_container_style< detail::container_style > container_hash
const detail::set_container_style< detail::container_style > container_braces
detail::set_element_sequence_style< detail::element_sequence_style > element_sequence(const string &separator, const string &first_separator, const string &last_separator)
Definition: ContainerIO.cpp:98
pair_style(const string &open_brace="(", const string &separator=", ", const string &close_brace=")")
Definition: ContainerIO.cpp:42
const detail::set_container_style< detail::container_style > container_d
const detail::set_container_style< detail::container_style > container_brackets
const detail::set_element_sequence_style< detail::element_sequence_style > element_sequence_multiline
STL namespace.
container_style(const string &open, const string &close)
Definition: ContainerIO.cpp:77
void container_style_delete(ios_base::event event_, ios_base &stream, int)
Definition: ContainerIO.cpp:69
void pair_style_delete(ios_base::event event_, ios_base &stream, int)
Definition: ContainerIO.cpp:34
const detail::set_element_sequence_style< detail::element_sequence_style > element_sequence_singleline
const detail::set_pair_style< detail::pair_style > pair_default
Definition: ContainerIO.cpp:87
static const int stream_storage
Definition: ContainerIO.h:59
const detail::set_pair_style< detail::pair_style > pair_whitespace
Definition: ContainerIO.cpp:91
const detail::set_container_style< detail::container_style > container_none
static const int stream_storage
Definition: ContainerIO.h:105
element_sequence_style(const string &separator=", ", const string &first_separator="", const string &last_separator="")
Definition: ContainerIO.cpp:59
const detail::set_container_style< detail::container_style > container_parentheses
void element_sequence_style_delete(ios_base::event event_, ios_base &stream, int)
Definition: ContainerIO.cpp:51