2
This file is part of hugin.
4
hugin 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 2 of the License, or
7
(at your option) any later version.
9
hugin 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.
14
You should have received a copy of the GNU General Public License
15
along with hugin. If not, see <http://www.gnu.org/licenses/>.
19
* @file StringAdapter.h
21
* Created on: Jul 23, 2010
22
* @author Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
25
#ifndef STRINGADAPTER_H_
26
#define STRINGADAPTER_H_
35
* Adapts a string of wide or narrow characters to a narrow character std::string.
36
* It uses the narrow method of standard iostreams, it doesn't do any code conversion.
37
* It's purpose is to allow exception texts to contain wide strings, regardless of
40
class MAKEIMPEX StringAdapter : public std::string
42
void use_narrow(const wchar_t* ws)
44
std::ostringstream ostr;
45
for(const wchar_t* i = ws; *i; i++)
47
ostr.put(ostr.narrow(*i, '?'));
52
StringAdapter(std::wstring& ws)
54
use_narrow(ws.c_str());
56
StringAdapter(const std::string& s)
59
StringAdapter(const wchar_t* ws)
63
StringAdapter(const char* s)
66
virtual ~StringAdapter()
73
#endif /* STRINGADAPTER_H_ */