wxPlatform.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00027 #ifndef HUGIN_WXPLATFORM_H
00028 #define HUGIN_WXPLATFORM_H
00029 
00030 #include "hugin_shared.h"
00031 #include <wx/string.h>
00032 
00033 namespace hugin_utils {
00034 
00035 template <class str>
00036 str wxQuoteStringInternal(const str & arg, const str & quotechar,
00037                         const str & replacements)
00038 {
00039     // loop over all chars..
00040     str ret(arg);
00041     size_t len = replacements.size();
00042     for (size_t i = 0; i < len; i++) {
00043         str source(replacements.substr(i,1));
00044         str dest(quotechar + source);
00045         size_t idx = 0;
00046         do {
00047             idx = ret.find(source,idx);
00048             if (idx != str::npos) {
00049                 ret.replace(idx, 1, dest);
00050                 // skip to next unknown char.
00051                 idx += 2;
00052             }
00053         } while (idx != str::npos);
00054     }
00055     return ret;
00056 }
00057 
00065 template <class str>
00066 str wxQuoteString(const str & arg)
00067 {
00068 #ifdef WIN32
00069     // escape all strange chars with ^
00070     // is this true for create process?
00071     return wxQuoteStringInternal(arg, str(wxT("^")), str(wxT("^ \"$|()")));
00072 #else
00073     return wxQuoteStringInternal(arg, str(wxT("\\")), str(wxT("\\ ~$\"|'`{}[]()")));
00074 #endif
00075 }
00076 
00081 template <class str>
00082 str wxQuoteFilename(const str & arg)
00083 {
00084 #ifdef WIN32
00085     str ret;
00086     // just a guess
00087     ret = wxQuoteStringInternal(arg, str(wxT("^")), str(wxT("\"")));
00088     return str(wxT("\"")) + ret + str(wxT("\""));
00089 #else
00090     str ret;
00091     ret = wxQuoteStringInternal(arg, str(wxT("\\")), str(wxT("\"")));
00092     return str(wxT("\"")) + ret + str(wxT("\""));
00093 #endif
00094     }
00095 
00096 WXIMPEX wxString doubleTowxString(double d, int digits=-1);
00097 WXIMPEX bool str2double(const wxString& s, double & d);
00098 
00099 } // namespace
00100 
00101 #endif // HUGIN_WXPLATFORM_H

Generated on 29 Jul 2015 for Hugintrunk by  doxygen 1.4.7