31#ifndef CFGFILE__STRING_FORMAT_HPP__INCLUDED
32#define CFGFILE__STRING_FORMAT_HPP__INCLUDED
47template<
typename Trait >
48static inline typename Trait::string_t to_cfgfile_format(
49 const typename Trait::string_t & what )
52 return Trait::from_ascii(
"\"\"" );
68 typename Trait::string_t result;
72 for(
const typename Trait::char_t & ch : what )
75 result.append( Trait::from_ascii(
"\\\"" ) );
77 result.append( Trait::from_ascii(
"\\n" ) );
79 result.append( Trait::from_ascii(
"\\r" ) );
81 result.append( Trait::from_ascii(
"\\t" ) );
83 result.append( Trait::from_ascii(
"\\\\" ) );
85 result.push_back( ch );
100template<
typename Trait =
string_trait_t >
101static inline typename Trait::string_t from_cfgfile_format(
102 const typename Trait::string_t & what )
107 typename Trait::string_t tmp = what.substr( 1, what.length() - 2 );
109 typename Trait::string_t result;
111 for(
typename Trait::string_t::size_type i = 0; i < tmp.length(); ++i )
115 if( i + 1 < tmp.length() )
128 throw exception_t< Trait > ( Trait::from_ascii(
129 "Unrecognized backslash sequence \"\\" ) +
130 typename Trait::string_t( 1, tmp.at( i + 1 ) ) +
131 Trait::from_ascii(
"\"." ) );
136 throw exception_t< Trait > ( Trait::from_ascii(
137 "Unfinished backslash sequence \"\\\"." ) );
140 result.push_back( tmp.at( i ) );
static const Trait::char_t c_line_feed
Definition const.hpp:56
static const Trait::char_t c_back_slash
Definition const.hpp:52
static const Trait::char_t c_r
Definition const.hpp:51
static const Trait::char_t c_tab
Definition const.hpp:54
static const Trait::char_t c_n
Definition const.hpp:49
static const Trait::string_t c_finish_multi_line_comment
Definition const.hpp:62
static const Trait::string_t c_one_line_comment
Definition const.hpp:60
static const Trait::char_t c_quotes
Definition const.hpp:48
static const Trait::char_t c_t
Definition const.hpp:50
static const Trait::char_t c_begin_tag
Definition const.hpp:46
static const Trait::char_t c_carriage_return
Definition const.hpp:55
static const Trait::string_t c_start_multi_line_comment
Definition const.hpp:61
static const Trait::char_t c_space
Definition const.hpp:53
static const Trait::char_t c_end_tag
Definition const.hpp:47