Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wxPlatform.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
27 #ifndef HUGIN_WXPLATFORM_H
28 #define HUGIN_WXPLATFORM_H
29 
30 #include "hugin_shared.h"
31 #include <wx/string.h>
32 
33 namespace hugin_utils {
34 
35 template <class str>
36 str wxQuoteStringInternal(const str & arg, const str & quotechar,
37  const str & replacements)
38 {
39  // loop over all chars..
40  str ret(arg);
41  size_t len = replacements.size();
42  for (size_t i = 0; i < len; i++) {
43  str source(replacements.substr(i,1));
44  str dest(quotechar + source);
45  size_t idx = 0;
46  do {
47  idx = ret.find(source,idx);
48  if (idx != str::npos) {
49  ret.replace(idx, 1, dest);
50  // skip to next unknown char.
51  idx += 2;
52  }
53  } while (idx != str::npos);
54  }
55  return ret;
56 }
57 
65 template <class str>
66 str wxQuoteString(const str & arg)
67 {
68 #ifdef _WIN32
69  // escape all strange chars with ^
70  // is this true for create process?
71  return wxQuoteStringInternal(arg, str(wxT("^")), str(wxT("^ \"$|()")));
72 #else
73  return wxQuoteStringInternal(arg, str(wxT("\\")), str(wxT("\\ ~$\"|'`{}[]()")));
74 #endif
75 }
76 
81 template <class str>
82 str wxQuoteFilename(const str & arg)
83 {
84 #ifdef _WIN32
85  str ret;
86  // just a guess
87  ret = wxQuoteStringInternal(arg, str(wxT("^")), str(wxT("\"")));
88  return str(wxT("\"")) + ret + str(wxT("\""));
89 #else
90  str ret;
91  ret = wxQuoteStringInternal(arg, str(wxT("\\")), str(wxT("\"")));
92  return str(wxT("\"")) + ret + str(wxT("\""));
93 #endif
94  }
95 
96 WXIMPEX wxString doubleTowxString(double d, int digits=-1);
97 WXIMPEX bool str2double(const wxString& s, double & d);
98 
99 } // namespace
100 
101 #ifndef __WXMSW__
102 
103 WXIMPEX void FixHelpSettings();
104 #endif
105 
106 #if defined __WXGTK__
107 
108 WXIMPEX void CheckConfigFilename();
109 #endif
110 
111 #endif // HUGIN_WXPLATFORM_H
str wxQuoteStringInternal(const str &arg, const str &quotechar, const str &replacements)
Definition: wxPlatform.h:36
bool str2double(const wxString &s, double &d)
Definition: wxPlatform.cpp:37
str wxQuoteString(const str &arg)
Try to escape special chars on windows and linux.
Definition: wxPlatform.h:66
wxString doubleTowxString(double d, int digits)
Definition: wxPlatform.cpp:31
WXIMPEX void FixHelpSettings()
helper function to check window position settings of help window
Definition: wxPlatform.cpp:53
#define WXIMPEX
Definition: hugin_shared.h:40
str wxQuoteFilename(const str &arg)
Quote a filename, so that it is surrounded by &quot;&quot;.
Definition: wxPlatform.h:82