StringAdapter.h

Go to the documentation of this file.
00001 /*
00002 This file is part of hugin.
00003 
00004 hugin is free software: you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation, either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 hugin is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with hugin.  If not, see <http://www.gnu.org/licenses/>.
00016 */
00017 
00025 #ifndef STRINGADAPTER_H_
00026 #define STRINGADAPTER_H_
00027 
00028 #include <string>
00029 #include <sstream>
00030 
00031 
00032 namespace makefile
00033 {
00040 class MAKEIMPEX StringAdapter : public std::string
00041 {
00042         void use_narrow(const wchar_t* ws)
00043         {
00044                 std::ostringstream ostr;
00045                 for(const wchar_t* i = ws; *i; i++)
00046                 {
00047                         ostr.put(ostr.narrow(*i, '?'));
00048                 }
00049                 assign(ostr.str());
00050         }
00051 public:
00052         StringAdapter(std::wstring& ws)
00053         {
00054                 use_narrow(ws.c_str());
00055         }
00056         StringAdapter(const std::string& s)
00057         : std::string(s)
00058         {}
00059         StringAdapter(const wchar_t* ws)
00060         {
00061                 use_narrow(ws);
00062         }
00063         StringAdapter(const char* s)
00064         : std::string(s)
00065         {}
00066         virtual ~StringAdapter()
00067         {
00068         }
00069 };
00070 
00071 }
00072 
00073 #endif /* STRINGADAPTER_H_ */

Generated on 21 Nov 2014 for Hugintrunk by  doxygen 1.4.7