gconvert.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // gconvert.cpp
19 //
20 
21 #include "gdef.h"
22 #include "gconvert.h"
23 
25 {
26  out_ = s ;
27 }
28 
29 void G::Convert::convert( std::string & out_ , const std::string & s )
30 {
31  out_ = s ;
32 }
33 
34 void G::Convert::convert( std::string & out_ , const std::string & s , const ThrowOnError & )
35 {
36  out_ = s ;
37 }
38 
39 void G::Convert::convert( std::wstring & out_ , const std::wstring & s )
40 {
41  out_ = s ;
42 }
43 
44 void G::Convert::convert( G::Convert::utf8 & out_ , const std::string & s )
45 {
46  out_ = utf8(narrow(widen(s,false),true)) ;
47 }
48 
49 void G::Convert::convert( G::Convert::utf8 & out_ , const std::wstring & s )
50 {
51  out_ = utf8(narrow(s,true)) ;
52 }
53 
54 void G::Convert::convert( std::string & out_ , const G::Convert::utf8 & s , const ThrowOnError & e )
55 {
56  out_ = narrow(widen(s.s,true),false,e.context) ;
57 }
58 
59 void G::Convert::convert( std::string & out_ , const std::wstring & s , const ThrowOnError & e )
60 {
61  out_ = narrow(s,false,e.context) ;
62 }
63 
64 void G::Convert::convert( std::wstring & out_ , const std::string & s )
65 {
66  out_ = widen(s,false) ;
67 }
68 
69 void G::Convert::convert( std::wstring & out_ , const G::Convert::utf8 & s )
70 {
71  out_ = widen(s.s,true) ;
72 }
73 
static void convert(utf8 &utf_out, const std::string &in_)
Converts between string types/encodings.
Definition: gconvert.cpp:44
Holds error context information for when convert() may fail.
Definition: gconvert.h:52
std::string context
Definition: gconvert.h:56
A string wrapper that indicates UTF-8 encoding.
Definition: gconvert.h:44
std::string s
Definition: gconvert.h:48