Status: | Rejected |
---|---|
Rejected by: | Jay Taoko |
Proposed branch: | lp:~unity-team/nux/nstring |
Merge into: | lp:nux |
Diff against target: |
7706 lines (+1089/-2651) 102 files modified
Nux/AbstractComboBox.cpp (+1/-1) Nux/ActionItem.cpp (+1/-1) Nux/ActionItem.h (+1/-1) Nux/BaseWindow.h (+2/-2) Nux/ColorPreview.cpp (+9/-2) Nux/Coverflow.cpp (+2/-2) Nux/DoubleValidator.cpp (+7/-3) Nux/DoubleValidator.h (+1/-1) Nux/EditTextBox.cpp (+62/-46) Nux/EditTextBox.h (+12/-22) Nux/FileSelector.cpp (+2/-2) Nux/FloatingWindow.cpp (+5/-5) Nux/FloatingWindow.h (+2/-2) Nux/HLayout.cpp (+1/-1) Nux/HLayout.h (+1/-1) Nux/HexRegExpValidator.cpp (+2/-3) Nux/HexRegExpValidator.h (+1/-1) Nux/IntegerValidator.cpp (+2/-3) Nux/IntegerValidator.h (+1/-1) Nux/KeyboardHandler.cpp (+58/-63) Nux/KeyboardHandler.h (+7/-8) Nux/KineticScrolling/KineticAxisScroller.h (+1/-1) Nux/KineticScrolling/KineticScrollingTickSource.h (+1/-0) Nux/Layout.h (+1/-1) Nux/MainLoopGLib.cpp (+4/-0) Nux/MenuPage.cpp (+1/-1) Nux/MenuPage.h (+1/-1) Nux/NumericValuator.cpp (+8/-6) Nux/PangoText.cpp (+4/-4) Nux/PangoText.h (+2/-2) Nux/RGBValuator.cpp (+61/-37) Nux/RGBValuator.h (+1/-1) Nux/RangeValue.cpp (+13/-6) Nux/RangeValue.h (+1/-1) Nux/RangeValueInteger.cpp (+6/-6) Nux/RangeValueInteger.h (+1/-1) Nux/SpinBox.cpp (+7/-7) Nux/SpinBoxDouble.cpp (+7/-7) Nux/SpinBox_Logic.cpp (+3/-3) Nux/StaticTextBox.cpp (+9/-21) Nux/StaticTextBox.h (+3/-5) Nux/SystemThread.h (+1/-1) Nux/TabView.cpp (+3/-3) Nux/TabView.h (+3/-3) Nux/VLayout.cpp (+1/-1) Nux/VLayout.h (+1/-1) Nux/Validator.cpp (+3/-3) Nux/Validator.h (+1/-1) Nux/WindowCompositor.cpp (+8/-8) Nux/WindowCompositor.h (+1/-1) NuxCore/FileIO.cpp (+1/-1) NuxCore/FileIO.h (+3/-1) NuxCore/FileManager/NFileManagerGNU.h (+5/-5) NuxCore/FileManager/NFileManagerGeneric.cpp (+15/-15) NuxCore/FileManager/NFileManagerGeneric.h (+7/-8) NuxCore/FileManager/NFileManagerWindows.cpp (+10/-10) NuxCore/FileManager/NFileManagerWindows.h (+3/-3) NuxCore/FileManager/NSerializer.cpp (+1/-1) NuxCore/FileName.cpp (+96/-98) NuxCore/FileName.h (+12/-15) NuxCore/FilePath.cpp (+36/-34) NuxCore/FilePath.h (+5/-5) NuxCore/NumberConversion.cpp (+13/-10) NuxCore/NumberConversion.h (+4/-6) NuxCore/NuxCore.cpp (+10/-1) NuxCore/OutputDevice.cpp (+43/-21) NuxCore/OutputDevice.h (+1/-1) NuxCore/Parsing.cpp (+8/-8) NuxCore/Parsing.h (+8/-8) NuxCore/Platform.cpp (+21/-21) NuxCore/Platform.h (+10/-10) NuxCore/Plugin/NPluginManager.cpp (+2/-2) NuxCore/Process.cpp (+2/-3) NuxCore/Process.h (+2/-2) NuxCore/TextString.cpp (+0/-1265) NuxCore/TextString.h (+0/-236) NuxCore/ThreadWin.cpp (+1/-1) NuxCore/ThreadWin.h (+2/-2) NuxCore/TimeFunctions.cpp (+3/-3) NuxCore/TimeFunctions.h (+1/-1) NuxCore/Win32Dialogs/NWin32Clipboard.cpp (+2/-2) NuxCore/Win32Dialogs/NWin32Clipboard.h (+1/-1) NuxCore/Win32Dialogs/NWin32CustomDialog.cpp (+7/-7) NuxCore/Win32Dialogs/NWin32CustomDialog.h (+6/-6) NuxGraphics/FontTexture.cpp (+14/-18) NuxGraphics/FontTexture.h (+4/-4) NuxGraphics/GLSh_ColorPicker.cpp (+21/-21) NuxGraphics/GLSh_DrawFunction.cpp (+8/-8) NuxGraphics/GpuDevice.cpp (+70/-46) NuxGraphics/GpuDevice.h (+0/-1) NuxGraphics/GraphicsDisplayWin.cpp (+1/-1) NuxGraphics/GraphicsDisplayX11.cpp (+12/-12) NuxGraphics/GraphicsDisplayX11.h (+10/-10) NuxGraphics/GraphicsEngine.cpp (+7/-7) NuxGraphics/IOpenGLGLSLShader.cpp (+7/-7) NuxGraphics/NuxGraphics.h (+2/-2) NuxGraphics/NuxGraphicsResources.cpp (+24/-101) NuxGraphics/NuxGraphicsResources.h (+7/-7) NuxGraphics/RenderingPipeAsm.cpp (+88/-110) NuxGraphics/RenderingPipeGLSL.cpp (+117/-153) NuxGraphics/RenderingPipeTextureBlend.cpp (+15/-24) configure.ac (+4/-2) |
To merge this branch: | bzr merge lp:~unity-team/nux/nstring |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jay Taoko (community) | Abstain | ||
Review via email:
|
Commit message
Description of the change
* Removal of nux::NString in favor of std::string.
* The branch has a lot of changes due to the enablement of -Werror. All the warnings have been fixed.
* -Werror is disabled when building with --enable-debug.
[Test] The changes are covered by existing tests.
To post a comment you must log in.
lp:~unity-team/nux/nstring
updated
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Nux/AbstractComboBox.cpp' |
2 | --- Nux/AbstractComboBox.cpp 2012-10-02 07:32:55 +0000 |
3 | +++ Nux/AbstractComboBox.cpp 2012-10-11 16:27:25 +0000 |
4 | @@ -73,7 +73,7 @@ |
5 | GetPainter().PaintShape(graphics_engine, base, m_sCOMBO_COLOR, eSHAPE_CORNER_ROUND4); |
6 | |
7 | { |
8 | - //GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), _combo_box_area->GetGeometry(), _combo_box_area->GetBaseString().GetTCharPtr(), GetTextColor(), eAlignTextLeft); |
9 | + //GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), _combo_box_area->GetGeometry(), _combo_box_area->GetBaseString().c_str(), GetTextColor(), eAlignTextLeft); |
10 | _pango_static_text->SetGeometry(_combo_box_area->GetGeometry()); |
11 | _pango_static_text->ProcessDraw(graphics_engine, true); |
12 | } |
13 | |
14 | === modified file 'Nux/ActionItem.cpp' |
15 | --- Nux/ActionItem.cpp 2012-09-26 06:44:12 +0000 |
16 | +++ Nux/ActionItem.cpp 2012-10-11 16:27:25 +0000 |
17 | @@ -133,7 +133,7 @@ |
18 | |
19 | const char *ActionItem::GetLabel() const |
20 | { |
21 | - return m_Label.GetTCharPtr(); |
22 | + return m_Label.c_str(); |
23 | } |
24 | |
25 | void ActionItem::SetIcon(const BaseTexture* icon) |
26 | |
27 | === modified file 'Nux/ActionItem.h' |
28 | --- Nux/ActionItem.h 2011-04-06 21:54:09 +0000 |
29 | +++ Nux/ActionItem.h 2012-10-11 16:27:25 +0000 |
30 | @@ -67,7 +67,7 @@ |
31 | //! A value defined by the user at construction time. |
32 | int m_UserValue; |
33 | BaseTexture* m_Icon; |
34 | - NString m_Label; |
35 | + std::string m_Label; |
36 | bool m_IsActivated; |
37 | MenuPage *m_Menu; |
38 | bool m_Enable; |
39 | |
40 | === modified file 'Nux/BaseWindow.h' |
41 | --- Nux/BaseWindow.h 2012-10-02 07:32:55 +0000 |
42 | +++ Nux/BaseWindow.h 2012-10-11 16:27:25 +0000 |
43 | @@ -185,7 +185,7 @@ |
44 | //! Emit a signal when the BaseWindow becomes hidden. |
45 | sigc::signal<void, BaseWindow*> sigHidden; |
46 | |
47 | - NString GetWindowName() |
48 | + std::string GetWindowName() |
49 | { |
50 | return _name; |
51 | } |
52 | @@ -251,7 +251,7 @@ |
53 | //! Contains the background of the texture. Can be used to blur. It is set by the window compositor. |
54 | ObjectPtr<BaseTexture> _background_texture; |
55 | |
56 | - NString _name; |
57 | + std::string _name; |
58 | bool _size_match_layout; |
59 | bool _is_visible; |
60 | bool _is_modal; |
61 | |
62 | === modified file 'Nux/ColorPreview.cpp' |
63 | --- Nux/ColorPreview.cpp 2012-10-02 07:32:55 +0000 |
64 | +++ Nux/ColorPreview.cpp 2012-10-11 16:27:25 +0000 |
65 | @@ -27,6 +27,9 @@ |
66 | #include "TimerProc.h" |
67 | #include "StaticTextBox.h" |
68 | |
69 | +#include <sstream> |
70 | +#include <iomanip> |
71 | + |
72 | namespace nux |
73 | { |
74 | |
75 | @@ -50,8 +53,12 @@ |
76 | m_ColorValue->SetFont(GetSysBoldFont()); |
77 | m_ColorValue->SetMinimumWidth(128); |
78 | |
79 | - NString text = NString::Printf("[ R:%d, G:%d, B:%d ]", (int) (m_Color.red * 255), (int) (m_Color.green * 255), (int) (m_Color.blue * 255)); |
80 | - m_ColorValue->SetText(text); |
81 | + std::stringstream s; |
82 | + s << "[ R:" << (int)(m_Color.red * 255) |
83 | + << ", G:" << (int)(m_Color.green * 255) |
84 | + << ", B:" << (int)(m_Color.blue * 255) |
85 | + << " ]"; |
86 | + m_ColorValue->SetText(s.str()); |
87 | |
88 | m_ColorArea->mouse_click.connect(sigc::mem_fun(this, &ColorPreview::RecvClick)); |
89 | |
90 | |
91 | === modified file 'Nux/Coverflow.cpp' |
92 | --- Nux/Coverflow.cpp 2012-09-26 06:44:12 +0000 |
93 | +++ Nux/Coverflow.cpp 2012-10-11 16:27:25 +0000 |
94 | @@ -286,8 +286,8 @@ |
95 | |
96 | text_loader_.font_size = 10; |
97 | |
98 | - NString resource_path = NUX_FIND_RESOURCE_LOCATION_NOFAIL("UITextures/coverflow.oval-shadow.png"); |
99 | - BaseTexture* texture = LoadTextureFromFile(resource_path.GetTCharPtr()); |
100 | + std::string resource_path = NUX_FIND_RESOURCE_LOCATION_NOFAIL("UITextures/coverflow.oval-shadow.png"); |
101 | + BaseTexture* texture = LoadTextureFromFile(resource_path.c_str()); |
102 | drop_shadow_texture_ = texture->GetDeviceTexture(); |
103 | texture->UnReference(); |
104 | |
105 | |
106 | === modified file 'Nux/DoubleValidator.cpp' |
107 | --- Nux/DoubleValidator.cpp 2012-09-19 04:53:45 +0000 |
108 | +++ Nux/DoubleValidator.cpp 2012-10-11 16:27:25 +0000 |
109 | @@ -23,6 +23,9 @@ |
110 | #include "Nux.h" |
111 | #include "DoubleValidator.h" |
112 | |
113 | +#include <sstream> |
114 | +#include <iomanip> |
115 | + |
116 | namespace nux |
117 | { |
118 | |
119 | @@ -127,10 +130,11 @@ |
120 | m_Decimals = Clamp<int> (dec, 0, 13); |
121 | } |
122 | |
123 | - NString DoubleValidator::ToString(double d) |
124 | + std::string DoubleValidator::ToString(double d) |
125 | { |
126 | - NString Prec = NString("%.") + NString::Printf("%d", m_Decimals) + NString("f"); |
127 | - return NString::Printf(Prec.GetTCharPtr(), d); |
128 | + std::stringstream s; |
129 | + s << std::setprecision(m_Decimals) << d; |
130 | + return s.str(); |
131 | } |
132 | |
133 | double DoubleValidator::ToDouble(const char *str) |
134 | |
135 | === modified file 'Nux/DoubleValidator.h' |
136 | --- Nux/DoubleValidator.h 2011-10-17 21:23:50 +0000 |
137 | +++ Nux/DoubleValidator.h 2012-10-11 16:27:25 +0000 |
138 | @@ -52,7 +52,7 @@ |
139 | void SetMaximum(double value); |
140 | double GetMaximum() const; |
141 | |
142 | - NString ToString(double d); |
143 | + std::string ToString(double d); |
144 | double ToDouble(const char *str); |
145 | |
146 | private: |
147 | |
148 | === modified file 'Nux/EditTextBox.cpp' |
149 | --- Nux/EditTextBox.cpp 2012-10-02 07:32:55 +0000 |
150 | +++ Nux/EditTextBox.cpp 2012-10-11 16:27:25 +0000 |
151 | @@ -160,7 +160,7 @@ |
152 | { |
153 | |
154 | GetPainter().PaintColorTextLineEdit(graphics_engine, GetGeometry(), |
155 | - m_KeyboardHandler.GetTextLine().m_string, |
156 | + m_KeyboardHandler.GetTextLine(), |
157 | GetTextColor(), |
158 | m_WriteAlpha, |
159 | m_SelectedTextColor, |
160 | @@ -177,7 +177,7 @@ |
161 | else |
162 | { |
163 | GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), GetGeometry(), |
164 | - m_KeyboardHandler.GetTextLine().m_string, |
165 | + m_KeyboardHandler.GetTextLine(), |
166 | GetTextColor()); |
167 | } |
168 | } |
169 | @@ -189,34 +189,30 @@ |
170 | |
171 | } |
172 | |
173 | - void EditTextBox::SetText(const char &Caption) |
174 | - { |
175 | - NString s(Caption); |
176 | - SetText(s); |
177 | - } |
178 | - |
179 | void EditTextBox::SetText(const char *Caption) |
180 | { |
181 | - NString s(Caption); |
182 | - SetText(s); |
183 | - } |
184 | - |
185 | - void EditTextBox::SetText(const tstring &Caption) |
186 | - { |
187 | - NString s(Caption); |
188 | - SetText(s); |
189 | - } |
190 | - |
191 | - void EditTextBox::SetText(const NString &Caption) |
192 | - { |
193 | - NString s(Caption); |
194 | - s.RemovePrefix(m_Prefix); |
195 | - s.RemoveSuffix(m_Suffix); |
196 | - |
197 | - if (ValidateKeyboardEntry(s.GetTCharPtr())) |
198 | + std::string s(Caption); |
199 | + SetText(s); |
200 | + } |
201 | + |
202 | + void EditTextBox::SetText(const std::string &Caption) |
203 | + { |
204 | + std::string s(Caption); |
205 | + size_t pos = s.find(m_Prefix, 0); |
206 | + if (pos == 0) |
207 | + { |
208 | + s.erase(0, m_Prefix.size()); |
209 | + } |
210 | + pos = s.rfind(m_Suffix); |
211 | + if (pos != std::string::npos && pos == s.size() - m_Suffix.size()) |
212 | + { |
213 | + s.erase(pos); |
214 | + } |
215 | + |
216 | + if (ValidateKeyboardEntry(s.c_str())) |
217 | { |
218 | m_Text = (m_Prefix + s) + m_Suffix; |
219 | - m_KeyboardHandler.SetText(m_Text.GetTStringRef()); |
220 | + m_KeyboardHandler.SetText(m_Text); |
221 | m_temporary_caption = m_Text; |
222 | sigSetText.emit(this); |
223 | } |
224 | @@ -227,16 +223,24 @@ |
225 | |
226 | const char *EditTextBox::GetText() const |
227 | { |
228 | - return m_Text.GetTCharPtr(); |
229 | + return m_Text.c_str(); |
230 | } |
231 | |
232 | //! Return a caption string striping out the prefix and the suffix |
233 | - NString EditTextBox::GetCleanText() const |
234 | + std::string EditTextBox::GetCleanText() const |
235 | { |
236 | - NString CleanText(m_Text); |
237 | - CleanText.RemovePrefix(m_Prefix); |
238 | - CleanText.RemoveSuffix(m_Suffix); |
239 | - return CleanText.m_string; |
240 | + std::string CleanText(m_Text); |
241 | + size_t pos = CleanText.find(m_Prefix, 0); |
242 | + if (pos == 0) |
243 | + { |
244 | + CleanText.erase(0, m_Prefix.size()); |
245 | + } |
246 | + pos = CleanText.rfind(m_Suffix); |
247 | + if (pos != std::string::npos && pos == CleanText.size() - m_Suffix.size()) |
248 | + { |
249 | + CleanText.erase(pos); |
250 | + } |
251 | + return CleanText; |
252 | } |
253 | |
254 | void EditTextBox::RecvMouseDoubleClick(int /* x */, int /* y */, unsigned long /* button_flags */, unsigned long /* key_flags */) |
255 | @@ -337,10 +341,14 @@ |
256 | |
257 | if (keysym == NUX_VK_ENTER || keysym == NUX_KP_ENTER) |
258 | { |
259 | - NString str(m_KeyboardHandler.GetTextLine()); |
260 | - str.RemoveSuffix(m_Suffix); |
261 | + std::string str(m_KeyboardHandler.GetTextLine()); |
262 | + size_t pos = str.rfind(m_Suffix); |
263 | + if (pos != std::string::npos && pos == str.size() - m_Suffix.size()) |
264 | + { |
265 | + str.erase(pos); |
266 | + } |
267 | |
268 | - if (ValidateKeyboardEntry(str.m_string.c_str())) |
269 | + if (ValidateKeyboardEntry(str.c_str())) |
270 | { |
271 | m_Text = m_KeyboardHandler.GetTextLine(); |
272 | m_temporary_caption = m_Text; |
273 | @@ -392,7 +400,7 @@ |
274 | |
275 | void EditTextBox::EnteringKeyboardFocus() |
276 | { |
277 | - m_KeyboardHandler.SetText(m_Text.GetTStringRef()); |
278 | + m_KeyboardHandler.SetText(m_Text); |
279 | m_KeyboardHandler.SelectAllText(); |
280 | // Preserve the current caption text. If ESC is pressed while we have keyboard focus then |
281 | // the previous caption text is restored |
282 | @@ -403,25 +411,33 @@ |
283 | |
284 | void EditTextBox::QuitingKeyboardFocus() |
285 | { |
286 | - NString CleanText(m_KeyboardHandler.GetTextLine()); |
287 | - CleanText.RemovePrefix(m_Prefix); |
288 | - CleanText.RemoveSuffix(m_Suffix); |
289 | + std::string CleanText(m_KeyboardHandler.GetTextLine()); |
290 | + size_t pos = CleanText.find(m_Prefix, 0); |
291 | + if (pos == 0) |
292 | + { |
293 | + CleanText.erase(0, m_Prefix.size()); |
294 | + } |
295 | + pos = CleanText.rfind(m_Suffix); |
296 | + if (pos != std::string::npos && pos == CleanText.size() - m_Suffix.size()) |
297 | + { |
298 | + CleanText.erase(pos); |
299 | + } |
300 | |
301 | - if (ValidateKeyboardEntry(CleanText.GetTCharPtr())) |
302 | + if (ValidateKeyboardEntry(CleanText.c_str())) |
303 | { |
304 | CleanText = m_Prefix + CleanText; |
305 | CleanText = CleanText + m_Suffix; |
306 | |
307 | - m_Text = CleanText.m_string; //m_KeyboardHandler.GetTextLine(); |
308 | - m_KeyboardHandler.SetText(CleanText.m_string); |
309 | + m_Text = CleanText; //m_KeyboardHandler.GetTextLine(); |
310 | + m_KeyboardHandler.SetText(CleanText); |
311 | m_temporary_caption = m_Text; |
312 | - sigValidateKeyboardEntry.emit(this, m_Text.GetTStringRef()); |
313 | + sigValidateKeyboardEntry.emit(this, m_Text); |
314 | sigValidateEntry.emit(this); |
315 | } |
316 | else |
317 | { |
318 | m_Text = m_temporary_caption; |
319 | - m_KeyboardHandler.SetText(m_Text.GetTStringRef()); |
320 | + m_KeyboardHandler.SetText(m_Text); |
321 | m_KeyboardHandler.SelectAllText(); |
322 | } |
323 | |
324 | @@ -450,12 +466,12 @@ |
325 | |
326 | void EditTextBox::SetDoubleValue(double d) |
327 | { |
328 | - SetText(NString::Printf("%f", d)); |
329 | + SetText(std::to_string((long double)d)); |
330 | } |
331 | |
332 | void EditTextBox::SetIntegerValue(int i) |
333 | { |
334 | - SetText(NString::Printf("%d", i)); |
335 | + SetText(std::to_string((long long)i)); |
336 | } |
337 | |
338 | void EditTextBox::SetTextBackgroundColor(const Color &color) |
339 | |
340 | === modified file 'Nux/EditTextBox.h' |
341 | --- Nux/EditTextBox.h 2012-10-02 07:32:55 +0000 |
342 | +++ Nux/EditTextBox.h 2012-10-11 16:27:25 +0000 |
343 | @@ -49,21 +49,19 @@ |
344 | unsigned int keysym, |
345 | const char* character); |
346 | |
347 | - void SetText(const char &Caption); |
348 | void SetText(const char *Caption); |
349 | - void SetText(const tstring &Caption); |
350 | - void SetText(const NString &Caption); |
351 | + void SetText(const std::string &Caption); |
352 | const char *GetText() const; |
353 | unsigned int GetTextSize() const |
354 | { |
355 | - return (unsigned int) m_Text.Length(); |
356 | + return (unsigned int) m_Text.length(); |
357 | } |
358 | |
359 | void SetDoubleValue(double d); |
360 | void SetIntegerValue(int i); |
361 | |
362 | //! Return a caption string striping out the prefix and the suffix |
363 | - virtual NString GetCleanText() const; |
364 | + virtual std::string GetCleanText() const; |
365 | |
366 | void SetTextBackgroundColor(const Color &color); |
367 | Color GetTextBackgroundColor() const; |
368 | @@ -127,10 +125,6 @@ |
369 | void RecvEndKeyFocus(); |
370 | |
371 | |
372 | - void SetPrefix(const tstring &p) |
373 | - { |
374 | - m_Prefix = p; |
375 | - }; |
376 | void SetPrefix(const char *p) |
377 | { |
378 | m_Prefix = p; |
379 | @@ -139,19 +133,15 @@ |
380 | { |
381 | m_Prefix = p; |
382 | }; |
383 | - void SetPrefix(const NString &p) |
384 | + void SetPrefix(const std::string &p) |
385 | { |
386 | m_Prefix = p; |
387 | }; |
388 | - NString GetPrefix() const |
389 | + std::string GetPrefix() const |
390 | { |
391 | return m_Prefix; |
392 | }; |
393 | |
394 | - void SetSuffix(const tstring &s) |
395 | - { |
396 | - m_Suffix = s; |
397 | - }; |
398 | void SetSuffix(const char *s) |
399 | { |
400 | m_Suffix = s; |
401 | @@ -160,11 +150,11 @@ |
402 | { |
403 | m_Suffix = s; |
404 | }; |
405 | - void SetSuffix(const NString &s) |
406 | + void SetSuffix(const std::string &s) |
407 | { |
408 | m_Suffix = s; |
409 | }; |
410 | - NString Getsuffix() const |
411 | + std::string Getsuffix() const |
412 | { |
413 | return m_Suffix; |
414 | }; |
415 | @@ -174,7 +164,7 @@ |
416 | sigc::signal< void, EditTextBox *, unsigned int > sigCharacter; // Emitted every time a character typed |
417 | sigc::signal< void, EditTextBox * > sigEditChange; // Emitted every time a character typed |
418 | |
419 | - sigc::signal< void, EditTextBox *, const NString &> sigValidateKeyboardEntry; |
420 | + sigc::signal< void, EditTextBox *, const std::string &> sigValidateKeyboardEntry; |
421 | sigc::signal< void, EditTextBox * > sigValidateEntry; // Emitted when the text is validated |
422 | sigc::signal< void, EditTextBox * > sigSetText; // Emitted when text is set with setCaption |
423 | sigc::signal< void, EditTextBox * > sigEscapeKeyboardFocus; |
424 | @@ -195,7 +185,7 @@ |
425 | |
426 | virtual long PostLayoutManagement(long LayoutResult); |
427 | |
428 | - NString m_Text; |
429 | + std::string m_Text; |
430 | HLayout *hlayout; |
431 | |
432 | Color m_BackgroundColor; |
433 | @@ -205,12 +195,12 @@ |
434 | Color m_CursorColor; |
435 | |
436 | BaseKeyboardHandler m_KeyboardHandler; |
437 | - NString m_temporary_caption; |
438 | + std::string m_temporary_caption; |
439 | BaseKeyboardHandler::eKeyEntryType m_keytype; |
440 | |
441 | Validator *m_Validator; |
442 | - NString m_Suffix; |
443 | - NString m_Prefix; |
444 | + std::string m_Suffix; |
445 | + std::string m_Prefix; |
446 | |
447 | bool BlinkCursor; |
448 | void BlinkCursorTimerInterrupt(void *v); |
449 | |
450 | === modified file 'Nux/FileSelector.cpp' |
451 | --- Nux/FileSelector.cpp 2012-10-02 07:32:55 +0000 |
452 | +++ Nux/FileSelector.cpp 2012-10-11 16:27:25 +0000 |
453 | @@ -53,9 +53,9 @@ |
454 | SetMinimumSize(DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT); |
455 | SetLayout(m_hlayout); |
456 | |
457 | - NString Path = NUX_FINDRESOURCELOCATION("Icons/Folder-16x16.png"); |
458 | + std::string Path = NUX_FINDRESOURCELOCATION("Icons/Folder-16x16.png"); |
459 | m_Texture = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture(); |
460 | - m_Texture->Update(Path.GetTCharPtr()); |
461 | + m_Texture->Update(Path.c_str()); |
462 | } |
463 | |
464 | FileSelector::~FileSelector() |
465 | |
466 | === modified file 'Nux/FloatingWindow.cpp' |
467 | --- Nux/FloatingWindow.cpp 2012-10-02 07:32:55 +0000 |
468 | +++ Nux/FloatingWindow.cpp 2012-10-11 16:27:25 +0000 |
469 | @@ -98,12 +98,12 @@ |
470 | SetMinimumSize(32, 32); |
471 | SetGeometry(Geometry(100, 100, 320, 200)); |
472 | |
473 | - NString Path = NUX_FINDRESOURCELOCATION("UITextures/AddButton.png"); |
474 | + std::string Path = NUX_FINDRESOURCELOCATION("UITextures/AddButton.png"); |
475 | MinimizeIcon = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture(); |
476 | - MinimizeIcon->Update(Path.GetTCharPtr()); |
477 | + MinimizeIcon->Update(Path.c_str()); |
478 | Path = NUX_FINDRESOURCELOCATION("UITextures/CancelButton.png"); |
479 | CloseIcon = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture(); |
480 | - CloseIcon->Update(Path.GetTCharPtr()); |
481 | + CloseIcon->Update(Path.c_str()); |
482 | |
483 | SetWindowTitle(WindowName); |
484 | } |
485 | @@ -178,7 +178,7 @@ |
486 | _title_bar->GetBaseWidth(), _title_bar->GetBaseHeight()), Color(0xFF2f2f2f), |
487 | eSHAPE_CORNER_ROUND10, eCornerTopLeft | eCornerTopRight); |
488 | |
489 | - GetPainter().PaintTextLineStatic(graphics_engine, GetSysBoldFont(), _window_title_bar->GetGeometry(), _window_title.m_string, Color(0xFFFFFFFF), true, eAlignTextCenter); |
490 | + GetPainter().PaintTextLineStatic(graphics_engine, GetSysBoldFont(), _window_title_bar->GetGeometry(), _window_title, Color(0xFFFFFFFF), true, eAlignTextCenter); |
491 | GetPainter().Draw2DTextureAligned(graphics_engine, CloseIcon, _close_button->GetGeometry(), TextureAlignmentStyle(eTACenter, eTACenter)); |
492 | } |
493 | |
494 | @@ -457,7 +457,7 @@ |
495 | _window_title = title; |
496 | } |
497 | |
498 | - NString FloatingWindow::GetWindowTitle() |
499 | + std::string FloatingWindow::GetWindowTitle() |
500 | { |
501 | return _window_title; |
502 | } |
503 | |
504 | === modified file 'Nux/FloatingWindow.h' |
505 | --- Nux/FloatingWindow.h 2012-10-02 07:32:55 +0000 |
506 | +++ Nux/FloatingWindow.h 2012-10-11 16:27:25 +0000 |
507 | @@ -71,7 +71,7 @@ |
508 | void RecvTitleBarMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
509 | |
510 | void SetWindowTitle(const char *title); |
511 | - NString GetWindowTitle(); |
512 | + std::string GetWindowTitle(); |
513 | |
514 | //! Return true if this object can break the layout. |
515 | /* |
516 | @@ -133,7 +133,7 @@ |
517 | std::list<View *> m_InterfaceObject; |
518 | HLayout *_title_bar_layout; |
519 | |
520 | - NString _window_title; |
521 | + std::string _window_title; |
522 | |
523 | friend class PopUpWindow; |
524 | friend class ComboBox_Logic_WindowView; |
525 | |
526 | === modified file 'Nux/HLayout.cpp' |
527 | --- Nux/HLayout.cpp 2012-09-26 06:44:12 +0000 |
528 | +++ Nux/HLayout.cpp 2012-10-11 16:27:25 +0000 |
529 | @@ -48,7 +48,7 @@ |
530 | m_ContentStacking = eStackLeft; |
531 | } |
532 | |
533 | - HLayout::HLayout(NString name, NUX_FILE_LINE_DECL) |
534 | + HLayout::HLayout(std::string name, NUX_FILE_LINE_DECL) |
535 | : LinearLayout(NUX_FILE_LINE_PARAM) |
536 | { |
537 | m_name = name; |
538 | |
539 | === modified file 'Nux/HLayout.h' |
540 | --- Nux/HLayout.h 2011-10-21 22:06:35 +0000 |
541 | +++ Nux/HLayout.h 2012-10-11 16:27:25 +0000 |
542 | @@ -33,7 +33,7 @@ |
543 | NUX_DECLARE_OBJECT_TYPE(HLayout, LinearLayout); |
544 | public: |
545 | HLayout(NUX_FILE_LINE_PROTO); |
546 | - HLayout(NString name, NUX_FILE_LINE_PROTO); |
547 | + HLayout(std::string name, NUX_FILE_LINE_PROTO); |
548 | ~HLayout(); |
549 | |
550 | virtual long ComputeContentSize(); |
551 | |
552 | === modified file 'Nux/HexRegExpValidator.cpp' |
553 | --- Nux/HexRegExpValidator.cpp 2012-09-19 04:53:45 +0000 |
554 | +++ Nux/HexRegExpValidator.cpp 2012-10-11 16:27:25 +0000 |
555 | @@ -121,10 +121,9 @@ |
556 | { |
557 | } |
558 | |
559 | - NString HexRegExpValidator::ToString(int i) |
560 | + std::string HexRegExpValidator::ToString(int i) |
561 | { |
562 | - NString Prec("%d"); |
563 | - return NString::Printf(Prec.GetTCharPtr(), i); |
564 | + return std::to_string((long long)i); |
565 | } |
566 | |
567 | int HexRegExpValidator::ToInteger(const char *str) |
568 | |
569 | === modified file 'Nux/HexRegExpValidator.h' |
570 | --- Nux/HexRegExpValidator.h 2011-10-17 21:23:50 +0000 |
571 | +++ Nux/HexRegExpValidator.h 2012-10-11 16:27:25 +0000 |
572 | @@ -50,7 +50,7 @@ |
573 | void SetMaximum(int value); |
574 | int GetMaximum() const; |
575 | |
576 | - NString ToString(int i); |
577 | + std::string ToString(int i); |
578 | int ToInteger(const char *str); |
579 | |
580 | private: |
581 | |
582 | === modified file 'Nux/IntegerValidator.cpp' |
583 | --- Nux/IntegerValidator.cpp 2012-09-19 04:53:45 +0000 |
584 | +++ Nux/IntegerValidator.cpp 2012-10-11 16:27:25 +0000 |
585 | @@ -122,10 +122,9 @@ |
586 | { |
587 | } |
588 | |
589 | - NString IntegerValidator::ToString(int i) |
590 | + std::string IntegerValidator::ToString(int i) |
591 | { |
592 | - NString Prec("%d"); |
593 | - return NString::Printf(Prec.GetTCharPtr(), i); |
594 | + return std::to_string((long long)i); |
595 | } |
596 | |
597 | int IntegerValidator::ToInteger(const char *str) |
598 | |
599 | === modified file 'Nux/IntegerValidator.h' |
600 | --- Nux/IntegerValidator.h 2011-10-17 21:23:50 +0000 |
601 | +++ Nux/IntegerValidator.h 2012-10-11 16:27:25 +0000 |
602 | @@ -49,7 +49,7 @@ |
603 | void SetMaximum(int value); |
604 | int GetMaximum() const; |
605 | |
606 | - NString ToString(int i); |
607 | + std::string ToString(int i); |
608 | int ToInteger(const char *str); |
609 | |
610 | private: |
611 | |
612 | === modified file 'Nux/KeyboardHandler.cpp' |
613 | --- Nux/KeyboardHandler.cpp 2012-09-26 06:44:12 +0000 |
614 | +++ Nux/KeyboardHandler.cpp 2012-10-11 16:27:25 +0000 |
615 | @@ -63,7 +63,7 @@ |
616 | |
617 | // Remove the characters |
618 | for (int i = nFirst; i < nLast; ++i) |
619 | - m_textline.Erase(nFirst, 1); |
620 | + m_textline.erase(nFirst, 1); |
621 | } |
622 | |
623 | void BaseKeyboardHandler::InsertChar(unsigned int /* character */) |
624 | @@ -78,19 +78,19 @@ |
625 | m_caret = 0; |
626 | |
627 | m_previous_cursor_position = 0; |
628 | - m_textline.Clear(); |
629 | + m_textline.clear(); |
630 | } |
631 | |
632 | void BaseKeyboardHandler::PlaceCaret(unsigned int nCP) |
633 | { |
634 | - nuxAssert(nCP <= (unsigned int) m_textline.Length()); |
635 | + nuxAssert(((int)nCP >= 0) && (nCP <= (unsigned int) m_textline.length())); |
636 | m_previous_cursor_position = m_caret; |
637 | m_caret = nCP; |
638 | } |
639 | |
640 | unsigned int BaseKeyboardHandler::NextWordPosition(unsigned int cp) |
641 | { |
642 | - unsigned int num_char = (unsigned int) m_textline.Length(); |
643 | + unsigned int num_char = (unsigned int) m_textline.length(); |
644 | |
645 | if (cp == num_char) |
646 | return cp; |
647 | @@ -159,10 +159,10 @@ |
648 | if (m_entering_focus) |
649 | return; |
650 | |
651 | - if (m_textline.Length() == 0) |
652 | + if (m_textline.length() == 0) |
653 | return; |
654 | |
655 | - unsigned int StrLength = (unsigned int) m_textline.Length(); |
656 | + unsigned int StrLength = (unsigned int) m_textline.length(); |
657 | int total = m_text_positionx; |
658 | unsigned int nCP = StrLength; |
659 | |
660 | @@ -210,17 +210,17 @@ |
661 | if (m_entering_focus) |
662 | return; |
663 | |
664 | - if (m_textline.Length() == 0) |
665 | + if (m_textline.length() == 0) |
666 | return; |
667 | |
668 | - int StrLength = (int) m_textline.Length(); |
669 | + int StrLength = (int) m_textline.length(); |
670 | |
671 | //nuxDebugMsg("[BaseKeyboardHandler::ResolveCaretPosition]"); |
672 | if (x < geo.x) |
673 | { |
674 | if (m_mouse_inside_text_area) |
675 | { |
676 | - while (m_caret && (GetFont()->GetCharStringWidth(m_textline.GetTCharPtr(), m_caret) + m_text_positionx > 0)) |
677 | + while (m_caret && (GetFont()->GetCharStringWidth(m_textline.c_str(), m_caret) + m_text_positionx > 0)) |
678 | { |
679 | --m_caret; |
680 | //nuxDebugMsg("Group Add: %c", m_textline[m_caret]); |
681 | @@ -242,7 +242,7 @@ |
682 | { |
683 | if (m_mouse_inside_text_area) |
684 | { |
685 | - while ((m_caret != StrLength) && (GetFont()->GetCharStringWidth(m_textline.GetTCharPtr(), m_caret) + m_text_positionx < geo.GetWidth())) |
686 | + while ((m_caret != StrLength) && (GetFont()->GetCharStringWidth(m_textline.c_str(), m_caret) + m_text_positionx < geo.GetWidth())) |
687 | { |
688 | ++m_caret; |
689 | //nuxDebugMsg("Group Add: %c", m_textline[m_caret-1]); |
690 | @@ -311,7 +311,7 @@ |
691 | // If we are in overwrite mode and there is already |
692 | // a char at the caret's position, simply replace it. |
693 | // Otherwise, we insert the char as normal. |
694 | - if ( !m_insert_mode && m_caret < (int) m_textline.Length()) |
695 | + if ( !m_insert_mode && m_caret < (int) m_textline.length()) |
696 | { |
697 | m_textline[m_caret] = key; |
698 | PlaceCaret(m_caret + 1 ); |
699 | @@ -320,9 +320,9 @@ |
700 | else |
701 | { |
702 | // Insert the char |
703 | - if ( m_caret <= (int) m_textline.Length()) |
704 | + if ( m_caret <= (int) m_textline.length()) |
705 | { |
706 | - m_textline.Insert(m_caret, 1, key); |
707 | + m_textline.insert(m_caret, 1, key); |
708 | PlaceCaret(m_caret + 1 ); |
709 | m_selection_start = m_caret; |
710 | } |
711 | @@ -334,7 +334,7 @@ |
712 | // If we are in overwrite mode and there is already |
713 | // a char at the caret's position, simply replace it. |
714 | // Otherwise, we insert the char as normal. |
715 | - if ( !m_insert_mode && m_caret < (int) m_textline.Length()) |
716 | + if ( !m_insert_mode && m_caret < (int) m_textline.length()) |
717 | { |
718 | m_textline[m_caret] = key; |
719 | PlaceCaret(m_caret + 1 ); |
720 | @@ -343,9 +343,9 @@ |
721 | else |
722 | { |
723 | // Insert the char |
724 | - if ( m_caret <= (int) m_textline.Length()) |
725 | + if ( m_caret <= (int) m_textline.length()) |
726 | { |
727 | - m_textline.Insert(m_caret, 1, key); |
728 | + m_textline.insert(m_caret, 1, key); |
729 | PlaceCaret(m_caret + 1 ); |
730 | m_selection_start = m_caret; |
731 | } |
732 | @@ -371,7 +371,7 @@ |
733 | // If we are in overwrite mode and there is already |
734 | // a char at the caret's position, simply replace it. |
735 | // Otherwise, we insert the char as normal. |
736 | - if (!m_insert_mode && (m_caret < (int) m_textline.Length())) |
737 | + if (!m_insert_mode && (m_caret < (int) m_textline.length())) |
738 | { |
739 | m_textline[m_caret] = key; |
740 | PlaceCaret(m_caret + 1 ); |
741 | @@ -380,9 +380,9 @@ |
742 | else |
743 | { |
744 | // Insert the char |
745 | - if ( m_caret <= (int) m_textline.Length()) |
746 | + if ( m_caret <= (int) m_textline.length()) |
747 | { |
748 | - m_textline.Insert(m_caret, 1, key); |
749 | + m_textline.insert(m_caret, 1, key); |
750 | PlaceCaret(m_caret + 1 ); |
751 | m_selection_start = m_caret; |
752 | } |
753 | @@ -393,7 +393,7 @@ |
754 | // If we are in overwrite mode and there is already |
755 | // a char at the caret's position, simply replace it. |
756 | // Otherwise, we insert the char as normal. |
757 | - if (!m_insert_mode && (m_caret < (int) m_textline.Length())) |
758 | + if (!m_insert_mode && (m_caret < (int) m_textline.length())) |
759 | { |
760 | m_textline[m_caret] = key; |
761 | PlaceCaret(m_caret + 1 ); |
762 | @@ -402,9 +402,9 @@ |
763 | else |
764 | { |
765 | // Insert the char |
766 | - if (m_caret <= (int) m_textline.Length()) |
767 | + if (m_caret <= (int) m_textline.length()) |
768 | { |
769 | - m_textline.Insert(m_caret, 1, key); |
770 | + m_textline.insert(m_caret, 1, key); |
771 | PlaceCaret(m_caret + 1 ); |
772 | m_selection_start = m_caret; |
773 | } |
774 | @@ -428,7 +428,7 @@ |
775 | // If we are in overwrite mode and there is already |
776 | // a char at the caret's position, simply replace it. |
777 | // Otherwise, we insert the char as normal. |
778 | - if (!m_insert_mode && (m_caret < (int) m_textline.Length())) |
779 | + if (!m_insert_mode && (m_caret < (int) m_textline.length())) |
780 | { |
781 | m_textline[m_caret] = key; |
782 | PlaceCaret(m_caret + 1 ); |
783 | @@ -437,9 +437,9 @@ |
784 | else |
785 | { |
786 | // Insert the char |
787 | - if (m_caret <= (int) m_textline.Length()) |
788 | + if (m_caret <= (int) m_textline.length()) |
789 | { |
790 | - m_textline.Insert(m_caret, 1, key); |
791 | + m_textline.insert(m_caret, 1, key); |
792 | PlaceCaret(m_caret + 1 ); |
793 | m_selection_start = m_caret; |
794 | } |
795 | @@ -463,7 +463,7 @@ |
796 | // If we are in overwrite mode and there is already |
797 | // a char at the caret's position, simply replace it. |
798 | // Otherwise, we insert the char as normal. |
799 | - if (!m_insert_mode && (m_caret < (int) m_textline.Length())) |
800 | + if (!m_insert_mode && (m_caret < (int) m_textline.length())) |
801 | { |
802 | m_textline[m_caret] = key; |
803 | PlaceCaret(m_caret + 1 ); |
804 | @@ -472,9 +472,9 @@ |
805 | else |
806 | { |
807 | // Insert the char |
808 | - if (m_caret <= (int) m_textline.Length()) |
809 | + if (m_caret <= (int) m_textline.length()) |
810 | { |
811 | - m_textline.Insert(m_caret, 1, key); |
812 | + m_textline.insert(m_caret, 1, key); |
813 | PlaceCaret(m_caret + 1 ); |
814 | m_selection_start = m_caret; |
815 | } |
816 | @@ -497,7 +497,7 @@ |
817 | // If we are in overwrite mode and there is already |
818 | // a char at the caret's position, simply replace it. |
819 | // Otherwise, we insert the char as normal. |
820 | - if (!m_insert_mode && (m_caret < (int) m_textline.Length())) |
821 | + if (!m_insert_mode && (m_caret < (int) m_textline.length())) |
822 | { |
823 | m_textline[m_caret] = key; |
824 | PlaceCaret(m_caret + 1 ); |
825 | @@ -506,9 +506,9 @@ |
826 | else |
827 | { |
828 | // Insert the char |
829 | - if (m_caret <= (int) m_textline.Length()) |
830 | + if (m_caret <= (int) m_textline.length()) |
831 | { |
832 | - m_textline.Insert(m_caret, 1, key); |
833 | + m_textline.insert(m_caret, 1, key); |
834 | PlaceCaret(m_caret + 1 ); |
835 | m_selection_start = m_caret; |
836 | } |
837 | @@ -524,9 +524,9 @@ |
838 | // CTRL+C |
839 | if ((virtual_code == NUX_VK_C) && (state & NUX_STATE_CTRL)) |
840 | { |
841 | - NString s = GetSelectedText(); |
842 | + std::string s = GetSelectedText(); |
843 | #if defined(NUX_OS_WINDOWS) |
844 | - inlCopyTextToClipboard(s.GetTCharPtr()); |
845 | + inlCopyTextToClipboard(s.c_str()); |
846 | #endif |
847 | } |
848 | |
849 | @@ -534,15 +534,15 @@ |
850 | if ((virtual_code == NUX_VK_V) && (state & NUX_STATE_CTRL)) |
851 | { |
852 | #if defined(NUX_OS_WINDOWS) |
853 | - NString s = inlReadTextToClipboard(); |
854 | + std::string s = inlReadTextToClipboard(); |
855 | #elif defined(NUX_OS_LINUX) |
856 | - NString s = "Paste not implemented yet"; |
857 | + std::string s = "Paste not implemented yet"; |
858 | #endif |
859 | unsigned int start = GetTextSelectionStart(); |
860 | unsigned int end = GetTextSelectionEnd(); |
861 | - m_textline.Replace(start, end - start, s.m_string); |
862 | + m_textline.replace(start, end - start, s); |
863 | |
864 | - m_caret = start + (unsigned int) s.Length(); |
865 | + m_caret = start + (unsigned int) s.length(); |
866 | UnselectAllText(); |
867 | } |
868 | |
869 | @@ -568,7 +568,7 @@ |
870 | // Deleting one character |
871 | if ( m_caret > 0 ) |
872 | { |
873 | - m_textline.Erase(m_caret - 1, 1); |
874 | + m_textline.erase(m_caret - 1, 1); |
875 | PlaceCaret(m_caret - 1 ); |
876 | |
877 | m_selection_start = m_caret; |
878 | @@ -585,9 +585,9 @@ |
879 | else |
880 | { |
881 | // Deleting one character |
882 | - if (m_caret < (int) m_textline.Length()) |
883 | + if (m_caret < (int) m_textline.length()) |
884 | { |
885 | - m_textline.Erase(m_caret, 1); |
886 | + m_textline.erase(m_caret, 1); |
887 | } |
888 | } |
889 | } |
890 | @@ -637,7 +637,7 @@ |
891 | m_caret = NextWordPosition( m_caret); |
892 | PlaceCaret(m_caret ); |
893 | } |
894 | - else if (m_caret < (int) m_textline.Length()) |
895 | + else if (m_caret < (int) m_textline.length()) |
896 | PlaceCaret(m_caret + 1 ); |
897 | |
898 | if ((state & NUX_STATE_SHIFT) == 0) |
899 | @@ -666,14 +666,14 @@ |
900 | { |
901 | if ((state & NUX_STATE_SHIFT) == 0) |
902 | { |
903 | - PlaceCaret((unsigned int) m_textline.Length()); |
904 | + PlaceCaret((unsigned int) m_textline.length()); |
905 | // Shift is not down. Update selection |
906 | // start along with the caret. |
907 | m_selection_start = m_caret; |
908 | } |
909 | else |
910 | { |
911 | - PlaceCaret((unsigned int) m_textline.Length()); |
912 | + PlaceCaret((unsigned int) m_textline.length()); |
913 | } |
914 | } |
915 | else if (virtual_code == NUX_VK_ESCAPE) |
916 | @@ -695,19 +695,19 @@ |
917 | } |
918 | else if (virtual_code == NUX_VK_END) |
919 | { |
920 | - unsigned int str_width = GetFont()->GetStringWidth(m_textline.GetTCharPtr()); |
921 | + unsigned int str_width = GetFont()->GetStringWidth(m_textline.c_str()); |
922 | |
923 | if (str_width + s_cursor_width > (unsigned int) m_clip_region.GetWidth()) |
924 | m_text_positionx = m_clip_region.GetWidth() - (str_width + s_cursor_width); |
925 | else |
926 | m_text_positionx = 0; |
927 | } |
928 | - else if (m_textline.Length() != 0) |
929 | + else if (m_textline.length() != 0) |
930 | { |
931 | AdjustCursorAndTextPosition(); |
932 | m_need_redraw = true; |
933 | } |
934 | - else if (m_textline.Length() == 0) |
935 | + else if (m_textline.length() == 0) |
936 | { |
937 | ClearText(); |
938 | m_need_redraw = true; |
939 | @@ -719,11 +719,11 @@ |
940 | |
941 | void BaseKeyboardHandler::AdjustCursorAndTextPosition() |
942 | { |
943 | - int str_width = GetFont()->GetStringWidth(m_textline.GetTCharPtr()); |
944 | - NString temp0; |
945 | + int str_width = GetFont()->GetStringWidth(m_textline.c_str()); |
946 | + std::string temp0; |
947 | |
948 | if (m_caret > 0) |
949 | - temp0 = m_textline.GetSubString(0, m_caret - 1).GetTStringRef(); |
950 | + temp0 = m_textline.substr(0, m_caret - 1); |
951 | else |
952 | temp0 = ""; |
953 | |
954 | @@ -736,8 +736,8 @@ |
955 | // temp1 = "abcdefgh" |
956 | // temp2 = "abcdefghi" |
957 | |
958 | - NString temp1 = m_textline.GetSubString(0, m_caret).GetTStringRef(); |
959 | - NString temp2 = m_textline.GetSubString(0, m_caret + 1).GetTStringRef(); |
960 | + std::string temp1 = m_textline.substr(0, m_caret); |
961 | + std::string temp2 = m_textline.substr(0, m_caret + 1); |
962 | int str_width0 = GetFont()->GetStringWidth(temp0); |
963 | int str_width1 = GetFont()->GetStringWidth(temp1); |
964 | int str_width2 = GetFont()->GetStringWidth(temp2); |
965 | @@ -746,7 +746,7 @@ |
966 | if ((m_text_positionx + str_width1 + s_cursor_width) > m_clip_region.GetWidth()) |
967 | { |
968 | // Hitting the end of the text box |
969 | - if (m_caret == (int) m_textline.Length()) |
970 | + if (m_caret == (int) m_textline.length()) |
971 | { |
972 | m_text_positionx = - (str_width + (int) s_cursor_width - m_clip_region.GetWidth()); |
973 | } |
974 | @@ -814,7 +814,7 @@ |
975 | } |
976 | void BaseKeyboardHandler::MoveCursorAtEnd() |
977 | { |
978 | - unsigned int StrLength = ( unsigned int) m_textline.Length(); |
979 | + unsigned int StrLength = ( unsigned int) m_textline.length(); |
980 | m_previous_cursor_position = m_caret; |
981 | m_caret = StrLength; |
982 | } |
983 | @@ -846,16 +846,11 @@ |
984 | m_text_positionx = 0; |
985 | } |
986 | |
987 | - void BaseKeyboardHandler::SetText(const tstring &s) |
988 | + void BaseKeyboardHandler::SetText(const std::string &s) |
989 | { |
990 | SetText(s.c_str()); |
991 | } |
992 | |
993 | - void BaseKeyboardHandler::SetText(const NString &s) |
994 | - { |
995 | - SetText(s.GetTCharPtr()); |
996 | - } |
997 | - |
998 | void BaseKeyboardHandler::SetClipRegion(const Geometry &g) |
999 | { |
1000 | m_clip_region = g; |
1001 | @@ -880,7 +875,7 @@ |
1002 | void BaseKeyboardHandler::SelectAllText() |
1003 | { |
1004 | m_selection_start = 0; |
1005 | - m_caret = (unsigned int) m_textline.Length(); |
1006 | + m_caret = (unsigned int) m_textline.length(); |
1007 | AdjustCursorAndTextPosition(); |
1008 | } |
1009 | |
1010 | @@ -889,15 +884,15 @@ |
1011 | m_selection_start = m_caret; |
1012 | } |
1013 | |
1014 | - NString BaseKeyboardHandler::GetSelectedText() const |
1015 | + std::string BaseKeyboardHandler::GetSelectedText() const |
1016 | { |
1017 | if (m_selection_start == m_caret) |
1018 | { |
1019 | - return NString(""); |
1020 | + return std::string(""); |
1021 | } |
1022 | else |
1023 | { |
1024 | - NString s = m_textline.GetSubString(GetTextSelectionStart(), GetTextSelectionEnd() - GetTextSelectionStart()).GetTStringRef(); |
1025 | + std::string s = m_textline.substr(GetTextSelectionStart(), GetTextSelectionEnd() - GetTextSelectionStart()); |
1026 | return s; |
1027 | } |
1028 | } |
1029 | |
1030 | === modified file 'Nux/KeyboardHandler.h' |
1031 | --- Nux/KeyboardHandler.h 2011-10-21 22:06:35 +0000 |
1032 | +++ Nux/KeyboardHandler.h 2012-10-11 16:27:25 +0000 |
1033 | @@ -61,13 +61,13 @@ |
1034 | char character /*character*/, |
1035 | const Geometry &g); |
1036 | |
1037 | - NString GetTextLine() const |
1038 | + std::string GetTextLine() const |
1039 | { |
1040 | return m_textline; |
1041 | } |
1042 | unsigned int GetLength() const |
1043 | { |
1044 | - return (unsigned int) m_textline.Length(); |
1045 | + return (unsigned int) m_textline.length(); |
1046 | } |
1047 | |
1048 | unsigned int GetCursorPosition() const |
1049 | @@ -88,8 +88,7 @@ |
1050 | } |
1051 | |
1052 | void SetText(const char *str); |
1053 | - void SetText(const tstring &s); |
1054 | - void SetText(const NString &s); |
1055 | + void SetText(const std::string &s); |
1056 | |
1057 | void ClearText(); |
1058 | void PlaceCaret(unsigned int cp); |
1059 | @@ -104,13 +103,13 @@ |
1060 | void GetTextSelection(int *start, int *end) const; |
1061 | int GetTextSelectionStart() const; |
1062 | int GetTextSelectionEnd() const; |
1063 | - NString GetSelectedText() const; |
1064 | + std::string GetSelectedText() const; |
1065 | void SelectAllText(); |
1066 | void UnselectAllText(); |
1067 | bool IsTextSelected(); |
1068 | |
1069 | - void SetPrefix(NString); // 0x865, 25 rad, 25 degree... |
1070 | - void SetPostfix(NString); |
1071 | + void SetPrefix(std::string); // 0x865, 25 rad, 25 degree... |
1072 | + void SetPostfix(std::string); |
1073 | |
1074 | void EnterFocus(); |
1075 | |
1076 | @@ -128,7 +127,7 @@ |
1077 | |
1078 | protected: |
1079 | ObjectPtr<FontTexture> m_Font; |
1080 | - NString m_textline; |
1081 | + std::string m_textline; |
1082 | int m_previous_cursor_position; |
1083 | bool m_need_redraw; |
1084 | int m_text_positionx; |
1085 | |
1086 | === modified file 'Nux/KineticScrolling/KineticAxisScroller.h' |
1087 | --- Nux/KineticScrolling/KineticAxisScroller.h 2012-10-02 14:57:05 +0000 |
1088 | +++ Nux/KineticScrolling/KineticAxisScroller.h 2012-10-11 16:27:25 +0000 |
1089 | @@ -56,7 +56,7 @@ |
1090 | /*! |
1091 | Enumeration that describes the possible states of the kinetic scroller |
1092 | */ |
1093 | - enum class State |
1094 | + enum States |
1095 | { |
1096 | Idle, /*!< It's not pressed and not moving. This is the initial state */ |
1097 | Pressed, /*!< It's pressed but not yet moving. */ |
1098 | |
1099 | === modified file 'Nux/KineticScrolling/KineticScrollingTickSource.h' |
1100 | --- Nux/KineticScrolling/KineticScrollingTickSource.h 2012-10-02 14:57:05 +0000 |
1101 | +++ Nux/KineticScrolling/KineticScrollingTickSource.h 2012-10-11 16:27:25 +0000 |
1102 | @@ -21,6 +21,7 @@ |
1103 | #ifndef NUX_KS_TICK_SOURCE_H |
1104 | #define NUX_KS_TICK_SOURCE_H |
1105 | |
1106 | +#include <stdint.h> |
1107 | #include <Nux/TimerProc.h> |
1108 | |
1109 | /***** |
1110 | |
1111 | === modified file 'Nux/Layout.h' |
1112 | --- Nux/Layout.h 2012-09-26 06:44:12 +0000 |
1113 | +++ Nux/Layout.h 2012-10-11 16:27:25 +0000 |
1114 | @@ -294,7 +294,7 @@ |
1115 | |
1116 | std::list<Area *> _layout_element_list; |
1117 | |
1118 | - NString m_name; |
1119 | + std::string m_name; |
1120 | |
1121 | LayoutContentDistribution m_ContentStacking; |
1122 | }; |
1123 | |
1124 | === modified file 'Nux/MainLoopGLib.cpp' |
1125 | --- Nux/MainLoopGLib.cpp 2012-10-02 00:31:15 +0000 |
1126 | +++ Nux/MainLoopGLib.cpp 2012-10-11 16:27:25 +0000 |
1127 | @@ -332,7 +332,11 @@ |
1128 | } |
1129 | } |
1130 | |
1131 | +#if defined(NUX_OS_WINDOWS) |
1132 | + bool WindowThread::AddChildWindowGlibLoop(WindowThread* wnd_thread) |
1133 | +#else |
1134 | bool WindowThread::AddChildWindowGlibLoop(WindowThread* /* wnd_thread */) |
1135 | +#endif |
1136 | { |
1137 | #if defined(NUX_OS_WINDOWS) |
1138 | if (wnd_thread == NULL) |
1139 | |
1140 | === modified file 'Nux/MenuPage.cpp' |
1141 | --- Nux/MenuPage.cpp 2012-10-02 07:32:55 +0000 |
1142 | +++ Nux/MenuPage.cpp 2012-10-11 16:27:25 +0000 |
1143 | @@ -277,7 +277,7 @@ |
1144 | // |
1145 | const char *MenuPage::GetName() const |
1146 | { |
1147 | - return m_Name.GetTCharPtr(); |
1148 | + return m_Name.c_str(); |
1149 | } |
1150 | |
1151 | bool MenuPage::CanClose() const |
1152 | |
1153 | === modified file 'Nux/MenuPage.h' |
1154 | --- Nux/MenuPage.h 2012-10-02 07:32:55 +0000 |
1155 | +++ Nux/MenuPage.h 2012-10-11 16:27:25 +0000 |
1156 | @@ -272,7 +272,7 @@ |
1157 | VLayout* _vlayout; |
1158 | bool m_NextMouseUpMeanStop; |
1159 | MenuItem *m_SubMenuAction; |
1160 | - NString m_Name; |
1161 | + std::string m_Name; |
1162 | |
1163 | bool m_Action_Triggered; |
1164 | MenuPage *m_Parent; |
1165 | |
1166 | === modified file 'Nux/NumericValuator.cpp' |
1167 | --- Nux/NumericValuator.cpp 2012-10-02 07:32:55 +0000 |
1168 | +++ Nux/NumericValuator.cpp 2012-10-11 16:27:25 +0000 |
1169 | @@ -26,6 +26,8 @@ |
1170 | #include "DoubleValidator.h" |
1171 | #include "NumericValuator.h" |
1172 | |
1173 | +#include <string> |
1174 | + |
1175 | namespace nux |
1176 | { |
1177 | |
1178 | @@ -47,7 +49,7 @@ |
1179 | void NumericValuator::InitializeWidgets() |
1180 | { |
1181 | m_EditLine->SetValidator(&m_DoubleValidator); |
1182 | - m_EditLine->SetText(NString::Printf("%d", m_DoubleValidator.GetMinimum())); |
1183 | + m_EditLine->SetText(std::to_string((long double)m_DoubleValidator.GetMinimum())); |
1184 | |
1185 | m_EditLine->SetMinimumSize(2 * DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT); |
1186 | m_EditLine->SetGeometry(Geometry(0, 0, 2 * DEFAULT_WIDGET_WIDTH, PRACTICAL_WIDGET_HEIGHT)); |
1187 | @@ -99,7 +101,7 @@ |
1188 | if (m_fValue > m_DoubleValidator.GetMaximum()) |
1189 | m_fValue = m_DoubleValidator.GetMaximum(); |
1190 | |
1191 | - m_EditLine->SetText(NString::Printf("%f", m_fValue)); |
1192 | + m_EditLine->SetText(std::to_string((long double)m_fValue)); |
1193 | } |
1194 | |
1195 | float NumericValuator::GetValue() const |
1196 | @@ -147,25 +149,25 @@ |
1197 | void NumericValuator::ImplementValidateEntry() |
1198 | { |
1199 | double ret = 0; |
1200 | - ret = CharToDouble(m_EditLine->GetCleanText().GetTCharPtr()); |
1201 | + ret = CharToDouble(m_EditLine->GetCleanText().c_str()); |
1202 | { |
1203 | m_fValue = ret; |
1204 | |
1205 | if (m_fValue < m_DoubleValidator.GetMinimum()) |
1206 | { |
1207 | m_fValue = m_DoubleValidator.GetMinimum(); |
1208 | - m_EditLine->SetText(NString::Printf("%f", m_fValue)); |
1209 | + m_EditLine->SetText(std::to_string((long double)m_fValue)); |
1210 | } |
1211 | |
1212 | if (m_fValue > m_DoubleValidator.GetMaximum()) |
1213 | { |
1214 | m_fValue = m_DoubleValidator.GetMaximum(); |
1215 | - m_EditLine->SetText(NString::Printf("%f", m_fValue)); |
1216 | + m_EditLine->SetText(std::to_string((long double)m_fValue)); |
1217 | } |
1218 | } |
1219 | // else |
1220 | // { |
1221 | -// m_EditLine->SetText(NString::Printf("%f", m_fValue)); |
1222 | +// m_EditLine->SetText(std::string::Printf("%f", m_fValue)); |
1223 | // } |
1224 | } |
1225 | |
1226 | |
1227 | === modified file 'Nux/PangoText.cpp' |
1228 | --- Nux/PangoText.cpp 2012-10-02 07:32:55 +0000 |
1229 | +++ Nux/PangoText.cpp 2012-10-11 16:27:25 +0000 |
1230 | @@ -126,7 +126,7 @@ |
1231 | |
1232 | } |
1233 | |
1234 | - void PangoText::SetText(NString text) |
1235 | + void PangoText::SetText(std::string text) |
1236 | { |
1237 | if (_text != text) |
1238 | { |
1239 | @@ -183,7 +183,7 @@ |
1240 | pango_layout_set_font_description(layout, desc); |
1241 | pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); |
1242 | pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); |
1243 | - pango_layout_set_text(layout, _text.GetTCharPtr(), -1); |
1244 | + pango_layout_set_text(layout, _text.c_str(), -1); |
1245 | |
1246 | pangoCtx = pango_layout_get_context(layout); // is not ref'ed |
1247 | pango_cairo_context_set_font_options(pangoCtx, font_options); |
1248 | @@ -232,7 +232,7 @@ |
1249 | |
1250 | pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); |
1251 | pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); |
1252 | - pango_layout_set_text(layout, _text.GetTCharPtr(), -1); |
1253 | + pango_layout_set_text(layout, _text.c_str(), -1); |
1254 | |
1255 | pangoCtx = pango_layout_get_context(layout); |
1256 | pango_cairo_context_set_font_options(pangoCtx, font_options); |
1257 | @@ -256,7 +256,7 @@ |
1258 | |
1259 | void PangoText::UpdateTextLayout() |
1260 | { |
1261 | - pango_layout_set_text(_pango_layout, _text.GetTCharPtr(), -1); |
1262 | + pango_layout_set_text(_pango_layout, _text.c_str(), -1); |
1263 | |
1264 | // reset the glyph string |
1265 | if (_glyph_text) |
1266 | |
1267 | === modified file 'Nux/PangoText.h' |
1268 | --- Nux/PangoText.h 2012-10-02 07:32:55 +0000 |
1269 | +++ Nux/PangoText.h 2012-10-11 16:27:25 +0000 |
1270 | @@ -39,7 +39,7 @@ |
1271 | //! Return true if the widget with changes to match the text width. |
1272 | bool GetSizeMatchText() const; |
1273 | |
1274 | - void SetText(NString text); |
1275 | + void SetText(std::string text); |
1276 | void SetTextColor(Color textColor); |
1277 | |
1278 | sigc::signal<void, PangoText*> sigTextChanged; |
1279 | @@ -67,7 +67,7 @@ |
1280 | PangoFont* font; // font this glyph uses(for bidi text, you need several fonts) |
1281 | } pango_glyph; |
1282 | |
1283 | - NString _text; |
1284 | + std::string _text; |
1285 | Color _textColor; |
1286 | |
1287 | CairoGraphics *_cairoGraphics; |
1288 | |
1289 | === modified file 'Nux/RGBValuator.cpp' |
1290 | --- Nux/RGBValuator.cpp 2012-09-26 06:44:12 +0000 |
1291 | +++ Nux/RGBValuator.cpp 2012-10-11 16:27:25 +0000 |
1292 | @@ -31,6 +31,9 @@ |
1293 | #include "DoubleValidator.h" |
1294 | #include "RGBValuator.h" |
1295 | |
1296 | +#include <sstream> |
1297 | +#include <iomanip> |
1298 | + |
1299 | namespace nux |
1300 | { |
1301 | NUX_IMPLEMENT_OBJECT_TYPE(RGBValuator); |
1302 | @@ -648,6 +651,27 @@ |
1303 | SetRGB(color.red, color.green, color.blue); |
1304 | } |
1305 | |
1306 | + std::string as_hex(float f) |
1307 | + { |
1308 | + std::ostringstream s; |
1309 | + s << std::hex << (int)f; |
1310 | + return s.str(); |
1311 | + } |
1312 | + |
1313 | + std::string as_dec(float f) |
1314 | + { |
1315 | + std::ostringstream s; |
1316 | + s << (int)f; |
1317 | + return s.str(); |
1318 | + } |
1319 | + |
1320 | + std::string as_float(float f) |
1321 | + { |
1322 | + std::ostringstream s; |
1323 | + s << std::setprecision(3) << f; |
1324 | + return s.str(); |
1325 | + } |
1326 | + |
1327 | void RGBValuator::SetRGB(float r, float g, float b) |
1328 | { |
1329 | rgb_.red = Clamp(r, 0.0f, 1.0f); |
1330 | @@ -660,21 +684,21 @@ |
1331 | |
1332 | if (m_color_format == color::HEX) |
1333 | { |
1334 | - red_caption_->SetText(NString::Printf("%x", (int) (rgb_.red * 255))); |
1335 | - green_caption_->SetText(NString::Printf("%x", (int) (rgb_.green * 255))); |
1336 | - blue_caption_->SetText(NString::Printf("%x", (int) (rgb_.blue * 255))); |
1337 | + red_caption_->SetText(as_hex(rgb_.red * 255)); |
1338 | + green_caption_->SetText(as_hex(rgb_.green * 255)); |
1339 | + blue_caption_->SetText(as_hex(rgb_.blue * 255)); |
1340 | } |
1341 | else if (m_color_format == color::INT) |
1342 | { |
1343 | - red_caption_->SetText(NString::Printf("%d", (int) (rgb_.red * 255))); |
1344 | - green_caption_->SetText(NString::Printf("%d", (int) (rgb_.green * 255))); |
1345 | - blue_caption_->SetText(NString::Printf("%d", (int) (rgb_.blue * 255))); |
1346 | + red_caption_->SetText(as_dec(rgb_.red * 255)); |
1347 | + green_caption_->SetText(as_dec(rgb_.green * 255)); |
1348 | + blue_caption_->SetText(as_dec(rgb_.blue * 255)); |
1349 | } |
1350 | else |
1351 | { |
1352 | - red_caption_->SetText(NString::Printf("%.3f", rgb_.red)); |
1353 | - green_caption_->SetText(NString::Printf("%.3f", rgb_.green)); |
1354 | - blue_caption_->SetText(NString::Printf("%.3f", rgb_.blue)); |
1355 | + red_caption_->SetText(as_float(rgb_.red)); |
1356 | + green_caption_->SetText(as_float(rgb_.green)); |
1357 | + blue_caption_->SetText(as_float(rgb_.blue)); |
1358 | } |
1359 | |
1360 | // Restore text selection if necessary. |
1361 | @@ -701,21 +725,21 @@ |
1362 | |
1363 | if (m_color_format == color::HEX) |
1364 | { |
1365 | - red_caption_->SetText(NString::Printf("%x", (int) (hsv_.hue * 255))); |
1366 | - green_caption_->SetText(NString::Printf("%x", (int) (hsv_.saturation * 255))); |
1367 | - blue_caption_->SetText(NString::Printf("%x", (int) (hsv_.value * 255))); |
1368 | + red_caption_->SetText(as_hex(hsv_.hue * 255)); |
1369 | + green_caption_->SetText(as_hex(hsv_.saturation * 255)); |
1370 | + blue_caption_->SetText(as_hex(hsv_.value * 255)); |
1371 | } |
1372 | else if (m_color_format == color::INT) |
1373 | { |
1374 | - red_caption_->SetText(NString::Printf("%d", (int) (hsv_.hue * 255))); |
1375 | - green_caption_->SetText(NString::Printf("%d", (int) (hsv_.saturation * 255))); |
1376 | - blue_caption_->SetText(NString::Printf("%d", (int) (hsv_.value * 255))); |
1377 | + red_caption_->SetText(as_dec(hsv_.hue * 255)); |
1378 | + green_caption_->SetText(as_dec(hsv_.saturation * 255)); |
1379 | + blue_caption_->SetText(as_dec(hsv_.value * 255)); |
1380 | } |
1381 | else |
1382 | { |
1383 | - red_caption_->SetText(NString::Printf("%.3f", hsv_.hue)); |
1384 | - green_caption_->SetText(NString::Printf("%.3f", hsv_.saturation)); |
1385 | - blue_caption_->SetText(NString::Printf("%.3f", hsv_.value)); |
1386 | + red_caption_->SetText(as_float(hsv_.hue)); |
1387 | + green_caption_->SetText(as_float(hsv_.saturation)); |
1388 | + blue_caption_->SetText(as_float(hsv_.value)); |
1389 | } |
1390 | |
1391 | if (hsv_.hue >= 1.0f) |
1392 | @@ -746,21 +770,21 @@ |
1393 | |
1394 | if (m_color_format == color::HEX) |
1395 | { |
1396 | - red_caption_->SetText(NString::Printf("%x", (int) (hls_.hue * 255))); |
1397 | - green_caption_->SetText(NString::Printf("%x", (int) (hls_.lightness * 255))); |
1398 | - blue_caption_->SetText(NString::Printf("%x", (int) (hls_.saturation * 255))); |
1399 | + red_caption_->SetText(as_hex(hls_.hue * 255)); |
1400 | + green_caption_->SetText(as_hex(hls_.lightness * 255)); |
1401 | + blue_caption_->SetText(as_hex(hls_.saturation * 255)); |
1402 | } |
1403 | else if (m_color_format == color::INT) |
1404 | { |
1405 | - red_caption_->SetText(NString::Printf("%d", (int) (hls_.hue * 255))); |
1406 | - green_caption_->SetText(NString::Printf("%d", (int) (hls_.lightness * 255))); |
1407 | - blue_caption_->SetText(NString::Printf("%d", (int) (hls_.saturation * 255))); |
1408 | + red_caption_->SetText(as_dec(hls_.hue * 255)); |
1409 | + green_caption_->SetText(as_dec(hls_.lightness * 255)); |
1410 | + blue_caption_->SetText(as_dec(hls_.saturation * 255)); |
1411 | } |
1412 | else |
1413 | { |
1414 | - red_caption_->SetText(NString::Printf("%.3f", hls_.hue)); |
1415 | - green_caption_->SetText(NString::Printf("%.3f", hls_.lightness)); |
1416 | - blue_caption_->SetText(NString::Printf("%.3f", hls_.saturation)); |
1417 | + red_caption_->SetText(as_float(hls_.hue)); |
1418 | + green_caption_->SetText(as_float(hls_.lightness)); |
1419 | + blue_caption_->SetText(as_float(hls_.saturation)); |
1420 | } |
1421 | |
1422 | if (hls_.hue >= 1.0f) |
1423 | @@ -785,15 +809,15 @@ |
1424 | |
1425 | if (m_color_format == color::HEX) |
1426 | { |
1427 | - alpha_caption_->SetText(NString::Printf("%x", (int) (alpha_ * 255))); |
1428 | + alpha_caption_->SetText(as_hex(alpha_ * 255)); |
1429 | } |
1430 | else if (m_color_format == color::INT) |
1431 | { |
1432 | - alpha_caption_->SetText(NString::Printf("%d", (int) (alpha_ * 255))); |
1433 | + alpha_caption_->SetText(as_dec(alpha_ * 255)); |
1434 | } |
1435 | else |
1436 | { |
1437 | - alpha_caption_->SetText(NString::Printf("%.3f", alpha_)); |
1438 | + alpha_caption_->SetText(as_float(alpha_)); |
1439 | } |
1440 | |
1441 | sigColorChanged.emit(rgb_.red, rgb_.green, rgb_.blue, alpha_); |
1442 | @@ -1211,21 +1235,21 @@ |
1443 | |
1444 | } |
1445 | |
1446 | - void RGBValuator::OnComponentInput(EditTextBox * /* textbox */, const NString &s, int componentIndex) |
1447 | + void RGBValuator::OnComponentInput(EditTextBox* /* textbox */, const std::string &s, int componentIndex) |
1448 | { |
1449 | float f = 0; |
1450 | |
1451 | - if ((m_color_format == color::HEX) && (m_HexRegExp.Validate(s.GetTCharPtr()) == Validator::Acceptable)) |
1452 | + if ((m_color_format == color::HEX) && (m_HexRegExp.Validate(s.c_str()) == Validator::Acceptable)) |
1453 | { |
1454 | - f = (float) m_HexRegExp.ToInteger(s.GetTCharPtr()) / 255.0f; |
1455 | + f = (float) m_HexRegExp.ToInteger(s.c_str()) / 255.0f; |
1456 | } |
1457 | - else if ((m_color_format == color::INT) && (m_IntRegExp.Validate(s.GetTCharPtr()) == Validator::Acceptable)) |
1458 | + else if ((m_color_format == color::INT) && (m_IntRegExp.Validate(s.c_str()) == Validator::Acceptable)) |
1459 | { |
1460 | - f = (float) m_IntRegExp.ToInteger(s.GetTCharPtr()) / 255.0f; |
1461 | + f = (float) m_IntRegExp.ToInteger(s.c_str()) / 255.0f; |
1462 | } |
1463 | else |
1464 | { |
1465 | - f = (float) m_DoubleRegExp.ToDouble(s.GetTCharPtr()); |
1466 | + f = (float) m_DoubleRegExp.ToDouble(s.c_str()); |
1467 | } |
1468 | |
1469 | f = Clamp(f, 0.0f, 1.0f); |
1470 | @@ -1302,7 +1326,7 @@ |
1471 | if (componentIndex == 3) |
1472 | { |
1473 | float f = 0; |
1474 | - f = CharToDouble(s.GetTCharPtr()); |
1475 | + f = CharToDouble(s.c_str()); |
1476 | f = Clamp(f, 0.0f, 1.0f); |
1477 | //if(m_color_model == color::RGB) |
1478 | { |
1479 | |
1480 | === modified file 'Nux/RGBValuator.h' |
1481 | --- Nux/RGBValuator.h 2012-08-17 12:41:21 +0000 |
1482 | +++ Nux/RGBValuator.h 2012-10-11 16:27:25 +0000 |
1483 | @@ -87,7 +87,7 @@ |
1484 | void OnReceiveMouseUp_Green (int x, int y, unsigned long button_flags, unsigned long key_flags); |
1485 | void OnReceiveMouseUp_Blue (int x, int y, unsigned long button_flags, unsigned long key_flags); |
1486 | |
1487 | - void OnComponentInput (EditTextBox *textbox, const NString &s, int componentIndex); |
1488 | + void OnComponentInput (EditTextBox *textbox, const std::string &s, int componentIndex); |
1489 | void OnChannelKeyboardFocus(); |
1490 | void OnChannelLostKeyboardFocus(); |
1491 | void OnChannelValidateKeyboardEntry(); |
1492 | |
1493 | === modified file 'Nux/RangeValue.cpp' |
1494 | --- Nux/RangeValue.cpp 2012-10-02 07:32:55 +0000 |
1495 | +++ Nux/RangeValue.cpp 2012-10-11 16:27:25 +0000 |
1496 | @@ -25,6 +25,9 @@ |
1497 | #include "HLayout.h" |
1498 | #include "RangeValue.h" |
1499 | |
1500 | +#include <sstream> |
1501 | +#include <iomanip> |
1502 | + |
1503 | namespace nux |
1504 | { |
1505 | NUX_IMPLEMENT_OBJECT_TYPE(RangeValue); |
1506 | @@ -167,7 +170,7 @@ |
1507 | else |
1508 | m_Value = value; |
1509 | |
1510 | - m_ValueString->SetText(NString::Printf("%.3f", m_Value)); |
1511 | + m_ValueString->SetText(std::to_string((long double)m_Value)); |
1512 | QueueDraw(); |
1513 | } |
1514 | |
1515 | @@ -188,7 +191,7 @@ |
1516 | else |
1517 | m_Value = m_min + (m_max - m_min) * (float) x / (float) m_Percentage->GetBaseWidth(); |
1518 | |
1519 | - m_ValueString->SetText(NString::Printf("%.3f", m_Value)); |
1520 | + m_ValueString->SetText(std::to_string((long double)m_Value)); |
1521 | sigValueChanged.emit(this); |
1522 | sigFloatChanged.emit(m_Value); |
1523 | sigMouseDown.emit(m_Value); |
1524 | @@ -206,7 +209,9 @@ |
1525 | else |
1526 | m_Value = m_min + (m_max - m_min) * (float) x / (float) m_Percentage->GetBaseWidth(); |
1527 | |
1528 | - m_ValueString->SetText(NString::Printf("%.3f", m_Value)); |
1529 | + std::stringstream s; |
1530 | + s << std::setprecision(3) << m_Value; |
1531 | + m_ValueString->SetText(s.str()); |
1532 | sigValueChanged.emit(this); |
1533 | sigFloatChanged.emit(m_Value); |
1534 | sigMouseUp.emit(m_Value); |
1535 | @@ -223,7 +228,9 @@ |
1536 | else |
1537 | m_Value = m_min + (m_max - m_min) * (float) x / (float) m_Percentage->GetBaseWidth(); |
1538 | |
1539 | - m_ValueString->SetText(NString::Printf("%.3f", m_Value)); |
1540 | + std::stringstream s; |
1541 | + s << std::setprecision(3) << m_Value; |
1542 | + m_ValueString->SetText(s.str()); |
1543 | sigValueChanged.emit(this); |
1544 | sigFloatChanged.emit(m_Value); |
1545 | sigMouseDrag.emit(m_Value); |
1546 | @@ -241,10 +248,10 @@ |
1547 | |
1548 | } |
1549 | |
1550 | - void RangeValue::OnValidateKeyboardEntry(EditTextBox * /* textbox */, const NString &text) |
1551 | + void RangeValue::OnValidateKeyboardEntry(EditTextBox* /* textbox */, const std::string &text) |
1552 | { |
1553 | float f; |
1554 | - f = CharToDouble(text.GetTCharPtr()); |
1555 | + f = CharToDouble(text.c_str()); |
1556 | SetValue(f); |
1557 | sigValueChanged.emit(this); |
1558 | sigFloatChanged.emit(m_Value); |
1559 | |
1560 | === modified file 'Nux/RangeValue.h' |
1561 | --- Nux/RangeValue.h 2012-10-02 07:32:55 +0000 |
1562 | +++ Nux/RangeValue.h 2012-10-11 16:27:25 +0000 |
1563 | @@ -88,7 +88,7 @@ |
1564 | void OnReceiveMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
1565 | void OnKeyboardFocus(); |
1566 | void OnLostKeyboardFocus(); |
1567 | - void OnValidateKeyboardEntry(EditTextBox *textbox, const NString &text); |
1568 | + void OnValidateKeyboardEntry(EditTextBox *textbox, const std::string &text); |
1569 | |
1570 | bool IsCtrlKeyPressed() const |
1571 | { |
1572 | |
1573 | === modified file 'Nux/RangeValueInteger.cpp' |
1574 | --- Nux/RangeValueInteger.cpp 2012-10-02 07:32:55 +0000 |
1575 | +++ Nux/RangeValueInteger.cpp 2012-10-11 16:27:25 +0000 |
1576 | @@ -164,7 +164,7 @@ |
1577 | m_Value = value; |
1578 | |
1579 | m_MarkerPosition = m_Value; |
1580 | - m_ValueString->SetText(NString::Printf("%d", m_Value)); |
1581 | + m_ValueString->SetText(std::to_string((long long)m_Value)); |
1582 | QueueDraw(); |
1583 | } |
1584 | |
1585 | @@ -197,7 +197,7 @@ |
1586 | m_Value++; |
1587 | } |
1588 | |
1589 | - m_ValueString->SetText(NString::Printf("%d", m_Value)); |
1590 | + m_ValueString->SetText(std::to_string((long long)m_Value)); |
1591 | sigValueChanged.emit(this); |
1592 | sigMouseDown.emit(m_Value); |
1593 | sigValueChanged2.emit(m_Value); |
1594 | @@ -220,7 +220,7 @@ |
1595 | } |
1596 | |
1597 | m_MarkerPosition = m_Value; |
1598 | - m_ValueString->SetText(NString::Printf("%d", m_Value)); |
1599 | + m_ValueString->SetText(std::to_string((long long)m_Value)); |
1600 | sigValueChanged.emit(this); |
1601 | sigMouseUp.emit(m_Value); |
1602 | sigValueChanged2.emit(m_Value); |
1603 | @@ -249,7 +249,7 @@ |
1604 | m_Value++; |
1605 | } |
1606 | |
1607 | - m_ValueString->SetText(NString::Printf("%d", m_Value)); |
1608 | + m_ValueString->SetText(std::to_string((long long)m_Value)); |
1609 | sigValueChanged.emit(this); |
1610 | sigMouseDrag.emit(m_Value); |
1611 | sigValueChanged2.emit(m_Value); |
1612 | @@ -267,10 +267,10 @@ |
1613 | |
1614 | } |
1615 | |
1616 | - void RangeValueInteger::OnValidateKeyboardEntry(EditTextBox * /* textbox */, const NString &text) |
1617 | + void RangeValueInteger::OnValidateKeyboardEntry(EditTextBox* /* textbox */, const std::string &text) |
1618 | { |
1619 | int i; |
1620 | - i = CharToInteger(text.GetTCharPtr()); |
1621 | + i = CharToInteger(text.c_str()); |
1622 | SetValue(i); |
1623 | sigValueChanged.emit(this); |
1624 | sigSetTypedValue.emit(i); |
1625 | |
1626 | === modified file 'Nux/RangeValueInteger.h' |
1627 | --- Nux/RangeValueInteger.h 2012-10-02 07:32:55 +0000 |
1628 | +++ Nux/RangeValueInteger.h 2012-10-11 16:27:25 +0000 |
1629 | @@ -93,7 +93,7 @@ |
1630 | void OnReceiveMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
1631 | void OnKeyboardFocus(); |
1632 | void OnLostKeyboardFocus(); |
1633 | - void OnValidateKeyboardEntry(EditTextBox *textbox, const NString &text); |
1634 | + void OnValidateKeyboardEntry(EditTextBox *textbox, const std::string &text); |
1635 | |
1636 | bool IsCtrlKeyPressed() const |
1637 | { |
1638 | |
1639 | === modified file 'Nux/SpinBox.cpp' |
1640 | --- Nux/SpinBox.cpp 2012-10-02 07:32:55 +0000 |
1641 | +++ Nux/SpinBox.cpp 2012-10-11 16:27:25 +0000 |
1642 | @@ -43,7 +43,7 @@ |
1643 | m_EditLine->SetValidator(&m_IntValidator); |
1644 | m_EditLine->SetSuffix(""); |
1645 | m_EditLine->SetPrefix(""); |
1646 | - m_EditLine->SetText(NString::Printf("%d", m_IntValidator.GetMinimum())); |
1647 | + m_EditLine->SetText(std::to_string((long long)m_IntValidator.GetMinimum())); |
1648 | |
1649 | m_EditLine->SetMinimumSize(1.5 * DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT); |
1650 | m_EditLine->SetGeometry(Geometry(0, 0, DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT)); |
1651 | @@ -129,7 +129,7 @@ |
1652 | void SpinBox::SetValue(int value) |
1653 | { |
1654 | m_iValue = m_IntValidator.GetClampedValue(value); |
1655 | - m_EditLine->SetText(NString::Printf("%d", m_iValue)); |
1656 | + m_EditLine->SetText(std::to_string((long long)m_iValue)); |
1657 | sigValueChanged.emit(this); |
1658 | sigValue.emit(m_iValue); |
1659 | QueueDraw(); |
1660 | @@ -216,27 +216,27 @@ |
1661 | void SpinBox::ImplementValidateEntry() |
1662 | { |
1663 | double ret = 0; |
1664 | - ret = CharToDouble(m_EditLine->GetCleanText().GetTCharPtr()); |
1665 | + ret = CharToDouble(m_EditLine->GetCleanText().c_str()); |
1666 | { |
1667 | m_iValue = m_IntValidator.GetClampedValue(ret); |
1668 | - m_EditLine->SetText(NString::Printf("%d", m_iValue)); |
1669 | + m_EditLine->SetText(std::to_string((long long)m_iValue)); |
1670 | sigValueChanged.emit(this); |
1671 | sigValue.emit(m_iValue); |
1672 | // |
1673 | // if (m_iValue < m_IntValidator.GetMinimum()) |
1674 | // { |
1675 | // m_iValue = m_IntValidator.GetMinimum(); |
1676 | -// m_EditLine->SetText(NString::Printf("%d", m_iValue)); |
1677 | +// m_EditLine->SetText(std::string::Printf("%d", m_iValue)); |
1678 | // } |
1679 | // if (m_iValue > m_IntValidator.GetMaximum()) |
1680 | // { |
1681 | // m_iValue = m_IntValidator.GetMaximum(); |
1682 | -// m_EditLine->SetText(NString::Printf("%d", m_iValue)); |
1683 | +// m_EditLine->SetText(std::string::Printf("%d", m_iValue)); |
1684 | // } |
1685 | } |
1686 | // else |
1687 | // { |
1688 | -// m_EditLine->SetText(NString::Printf("%d", m_iValue)); |
1689 | +// m_EditLine->SetText(std::string::Printf("%d", m_iValue)); |
1690 | // sigValueChanged.emit(this); |
1691 | // sigValue.emit(m_iValue); |
1692 | // } |
1693 | |
1694 | === modified file 'Nux/SpinBoxDouble.cpp' |
1695 | --- Nux/SpinBoxDouble.cpp 2012-10-02 07:32:55 +0000 |
1696 | +++ Nux/SpinBoxDouble.cpp 2012-10-11 16:27:25 +0000 |
1697 | @@ -53,7 +53,7 @@ |
1698 | m_EditLine->SetValidator(&m_DoubleValidator); |
1699 | m_EditLine->SetSuffix(""); |
1700 | m_EditLine->SetPrefix(""); |
1701 | - m_EditLine->SetText(NString::Printf("%.3f", m_DoubleValidator.GetMinimum())); |
1702 | + m_EditLine->SetText(std::to_string((long double)m_DoubleValidator.GetMinimum())); |
1703 | |
1704 | m_EditLine->SetMinimumSize(1.5 * DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT); |
1705 | m_EditLine->SetGeometry(Geometry(0, 0, DEFAULT_WIDGET_WIDTH, DEFAULT_WIDGET_HEIGHT)); |
1706 | @@ -136,7 +136,7 @@ |
1707 | // m_Value = m_DoubleValidator.GetMinimum(); |
1708 | // if (m_Value > m_DoubleValidator.GetMaximum()) |
1709 | // m_Value = m_DoubleValidator.GetMaximum(); |
1710 | - m_EditLine->SetText(NString::Printf("%.3f", m_Value)); |
1711 | + m_EditLine->SetText(std::to_string((long double)m_Value)); |
1712 | sigValueChanged.emit(this); |
1713 | sigValue.emit(m_Value); |
1714 | QueueDraw(); |
1715 | @@ -223,27 +223,27 @@ |
1716 | void SpinBoxDouble::ImplementValidateEntry() |
1717 | { |
1718 | double ret = 0; |
1719 | - ret = CharToDouble(m_EditLine->GetCleanText().GetTCharPtr()); |
1720 | + ret = CharToDouble(m_EditLine->GetCleanText().c_str()); |
1721 | { |
1722 | m_Value = m_DoubleValidator.GetClampedValue(ret); |
1723 | - m_EditLine->SetText(NString::Printf("%.3f", m_Value)); |
1724 | + m_EditLine->SetText(std::to_string((long double)m_Value)); |
1725 | sigValueChanged.emit(this); |
1726 | sigValue.emit(m_Value); |
1727 | // |
1728 | // if (m_Value < m_DoubleValidator.GetMinimum()) |
1729 | // { |
1730 | // m_Value = m_DoubleValidator.GetMinimum(); |
1731 | -// m_EditLine->SetText(NString::Printf("%.3f", m_Value)); |
1732 | +// m_EditLine->SetText(std::string::Printf("%.3f", m_Value)); |
1733 | // } |
1734 | // if (m_Value > m_DoubleValidator.GetMaximum()) |
1735 | // { |
1736 | // m_Value = m_DoubleValidator.GetMaximum(); |
1737 | -// m_EditLine->SetText(NString::Printf("%.3f", m_Value)); |
1738 | +// m_EditLine->SetText(std::string::Printf("%.3f", m_Value)); |
1739 | // } |
1740 | } |
1741 | // else |
1742 | // { |
1743 | -// m_EditLine->SetText(NString::Printf("%.3f", m_Value)); |
1744 | +// m_EditLine->SetText(std::string::Printf("%.3f", m_Value)); |
1745 | // sigValueChanged.emit(this); |
1746 | // sigValue.emit(m_Value); |
1747 | // } |
1748 | |
1749 | === modified file 'Nux/SpinBox_Logic.cpp' |
1750 | --- Nux/SpinBox_Logic.cpp 2012-09-26 06:44:12 +0000 |
1751 | +++ Nux/SpinBox_Logic.cpp 2012-10-11 16:27:25 +0000 |
1752 | @@ -166,17 +166,17 @@ |
1753 | // if (m_iValue < m_IntValidator.GetMinimum()) |
1754 | // { |
1755 | // m_iValue = m_IntValidator.GetMinimum(); |
1756 | -// m_EditLine->setCaption(NString::Printf("%d", m_iValue)); |
1757 | +// m_EditLine->setCaption(std::string::Printf("%d", m_iValue)); |
1758 | // } |
1759 | // if (m_iValue > m_IntValidator.GetMaximum()) |
1760 | // { |
1761 | // m_iValue = m_IntValidator.GetMaximum(); |
1762 | -// m_EditLine->setCaption(NString::Printf("%d", m_iValue)); |
1763 | +// m_EditLine->setCaption(std::string::Printf("%d", m_iValue)); |
1764 | // } |
1765 | // } |
1766 | // else |
1767 | // { |
1768 | -// m_EditLine->setCaption(NString::Printf("%d", m_iValue)); |
1769 | +// m_EditLine->setCaption(std::string::Printf("%d", m_iValue)); |
1770 | // } |
1771 | } |
1772 | |
1773 | |
1774 | === modified file 'Nux/StaticTextBox.cpp' |
1775 | --- Nux/StaticTextBox.cpp 2012-10-02 07:32:55 +0000 |
1776 | +++ Nux/StaticTextBox.cpp 2012-10-11 16:27:25 +0000 |
1777 | @@ -67,13 +67,13 @@ |
1778 | if (m_bDrawBackground) |
1779 | { |
1780 | GetPainter().PushDrawLayer(graphics_engine, base, m_Background); |
1781 | - GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), GetGeometry(), m_Text.m_string, m_TextColor, m_WriteAlpha, m_TextAlignment); |
1782 | + GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), GetGeometry(), m_Text, m_TextColor, m_WriteAlpha, m_TextAlignment); |
1783 | GetPainter().PopBackground(); |
1784 | } |
1785 | else |
1786 | { |
1787 | //GetPainter().PaintBackground(graphics_engine, base); |
1788 | - GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), GetGeometry(), m_Text.m_string, m_TextColor, m_WriteAlpha, m_TextAlignment); |
1789 | + GetPainter().PaintTextLineStatic(graphics_engine, GetFont(), GetGeometry(), m_Text, m_TextColor, m_WriteAlpha, m_TextAlignment); |
1790 | } |
1791 | |
1792 | graphics_engine.PopClippingRectangle(); |
1793 | @@ -85,25 +85,13 @@ |
1794 | |
1795 | } |
1796 | |
1797 | - void StaticTextBox::SetText(const char &Caption) |
1798 | - { |
1799 | - NString s(Caption); |
1800 | - SetText(s); |
1801 | - } |
1802 | - |
1803 | void StaticTextBox::SetText(const char *Caption) |
1804 | { |
1805 | - NString s(Caption); |
1806 | - SetText(s); |
1807 | - } |
1808 | - |
1809 | - void StaticTextBox::SetText(const tstring &Caption) |
1810 | - { |
1811 | - NString s(Caption); |
1812 | - SetText(s); |
1813 | - } |
1814 | - |
1815 | - void StaticTextBox::SetText(const NString &Caption) |
1816 | + std::string s(Caption); |
1817 | + SetText(s); |
1818 | + } |
1819 | + |
1820 | + void StaticTextBox::SetText(const std::string &Caption) |
1821 | { |
1822 | m_Text = Caption; |
1823 | |
1824 | @@ -128,10 +116,10 @@ |
1825 | |
1826 | void StaticTextBox::AdjustMinWidthToMatchText() |
1827 | { |
1828 | - if (m_Text.Size() == 0) |
1829 | + if (m_Text.size() == 0) |
1830 | return; |
1831 | |
1832 | - SetMinimumWidth(/*4 + */GetFont()->GetStringWidth(m_Text.GetTStringRef())); |
1833 | + SetMinimumWidth(/*4 + */GetFont()->GetStringWidth(m_Text)); |
1834 | } |
1835 | |
1836 | void StaticTextBox::SetFont(ObjectPtr<FontTexture> Font) |
1837 | |
1838 | === modified file 'Nux/StaticTextBox.h' |
1839 | --- Nux/StaticTextBox.h 2012-10-02 07:32:55 +0000 |
1840 | +++ Nux/StaticTextBox.h 2012-10-11 16:27:25 +0000 |
1841 | @@ -38,14 +38,12 @@ |
1842 | virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw); |
1843 | |
1844 | // API |
1845 | - void SetText(const char &Caption); |
1846 | void SetText(const char *Caption); |
1847 | - void SetText(const tstring &Caption); |
1848 | - void SetText(const NString &Caption); |
1849 | + void SetText(const std::string &Caption); |
1850 | const char *GetText() const; |
1851 | unsigned int GetTextSize() const |
1852 | { |
1853 | - return (unsigned int) m_Text.Length(); |
1854 | + return (unsigned int) m_Text.length(); |
1855 | } |
1856 | |
1857 | //! Change the widget minimum width whenever the text is set. |
1858 | @@ -99,7 +97,7 @@ |
1859 | virtual bool AcceptKeyNavFocus(); |
1860 | void AdjustMinWidthToMatchText(); |
1861 | |
1862 | - NString m_Text; |
1863 | + std::string m_Text; |
1864 | Color m_TextColor; |
1865 | Color m_BackgroundColor; |
1866 | tstring m_temporary_caption; |
1867 | |
1868 | === modified file 'Nux/SystemThread.h' |
1869 | --- Nux/SystemThread.h 2011-12-29 18:06:53 +0000 |
1870 | +++ Nux/SystemThread.h 2012-10-11 16:27:25 +0000 |
1871 | @@ -82,7 +82,7 @@ |
1872 | // Declare operator adress-of as private |
1873 | SystemThread *operator &(); |
1874 | |
1875 | - NString m_ThreadName; |
1876 | + std::string m_ThreadName; |
1877 | |
1878 | friend SystemThread *CreateSystemThread(AbstractThread *Parent, ThreadUserInitFunc UserInitFunc, void *InitData); |
1879 | |
1880 | |
1881 | === modified file 'Nux/TabView.cpp' |
1882 | --- Nux/TabView.cpp 2012-10-02 07:32:55 +0000 |
1883 | +++ Nux/TabView.cpp 2012-10-11 16:27:25 +0000 |
1884 | @@ -40,7 +40,7 @@ |
1885 | Color TabView::TAB_HEADER_COLOR = Color(0xFF333333); |
1886 | Color TabView::TAB_HEADER_FOCUS_COLOR = Color(0xFF5D5D5D); |
1887 | |
1888 | - TabView::TabElement::TabElement(NString TabName, Layout *TabLayout) |
1889 | + TabView::TabElement::TabElement(std::string TabName, Layout *TabLayout) |
1890 | { |
1891 | _index = 0; |
1892 | _tab_name = TabName; |
1893 | @@ -78,7 +78,7 @@ |
1894 | return _tab_area->GetGeometry(); |
1895 | } |
1896 | |
1897 | - const NString &TabView::TabElement::GetName() const |
1898 | + const std::string &TabView::TabElement::GetName() const |
1899 | { |
1900 | return _tab_name; |
1901 | } |
1902 | @@ -206,7 +206,7 @@ |
1903 | for (unsigned int i = 0; i < vector_size; i++) |
1904 | { |
1905 | Geometry tab_geo = _tab_array[i]->_tab_area->GetGeometry(); |
1906 | - const char *tab_text = _tab_array[i]->GetName().GetTCharPtr(); |
1907 | + const char *tab_text = _tab_array[i]->GetName().c_str(); |
1908 | |
1909 | if (_tab_array[i]->_index == m_FocusTabIndex) |
1910 | { |
1911 | |
1912 | === modified file 'Nux/TabView.h' |
1913 | --- Nux/TabView.h 2012-10-02 07:32:55 +0000 |
1914 | +++ Nux/TabView.h 2012-10-11 16:27:25 +0000 |
1915 | @@ -62,16 +62,16 @@ |
1916 | class TabElement |
1917 | { |
1918 | public: |
1919 | - TabElement(NString TabName, Layout *TabLayout); |
1920 | + TabElement(std::string TabName, Layout *TabLayout); |
1921 | ~TabElement(); |
1922 | |
1923 | void SetIndex(int index); |
1924 | int GetIndex() const; |
1925 | void SetGeometry(const Geometry &geo); |
1926 | Geometry const& GetGeometry() const; |
1927 | - const NString &GetName() const; |
1928 | + const std::string &GetName() const; |
1929 | |
1930 | - NString _tab_name; |
1931 | + std::string _tab_name; |
1932 | Layout *_tab_content_layout; |
1933 | BasicView *_tab_area; |
1934 | int _index; |
1935 | |
1936 | === modified file 'Nux/VLayout.cpp' |
1937 | --- Nux/VLayout.cpp 2012-09-26 06:44:12 +0000 |
1938 | +++ Nux/VLayout.cpp 2012-10-11 16:27:25 +0000 |
1939 | @@ -49,7 +49,7 @@ |
1940 | |
1941 | } |
1942 | |
1943 | - VLayout::VLayout(NString name, NUX_FILE_LINE_DECL) |
1944 | + VLayout::VLayout(std::string name, NUX_FILE_LINE_DECL) |
1945 | : LinearLayout(NUX_FILE_LINE_PARAM) |
1946 | { |
1947 | m_name = name; |
1948 | |
1949 | === modified file 'Nux/VLayout.h' |
1950 | --- Nux/VLayout.h 2011-10-21 22:06:35 +0000 |
1951 | +++ Nux/VLayout.h 2012-10-11 16:27:25 +0000 |
1952 | @@ -33,7 +33,7 @@ |
1953 | NUX_DECLARE_OBJECT_TYPE(VLayout, LinearLayout); |
1954 | public: |
1955 | VLayout(NUX_FILE_LINE_PROTO); |
1956 | - VLayout(NString name, NUX_FILE_LINE_PROTO); |
1957 | + VLayout(std::string name, NUX_FILE_LINE_PROTO); |
1958 | ~VLayout(); |
1959 | |
1960 | virtual long ComputeContentSize(); |
1961 | |
1962 | === modified file 'Nux/Validator.cpp' |
1963 | --- Nux/Validator.cpp 2011-10-10 01:52:00 +0000 |
1964 | +++ Nux/Validator.cpp 2012-10-11 16:27:25 +0000 |
1965 | @@ -38,13 +38,13 @@ |
1966 | bool Validator::InitRegExp() |
1967 | { |
1968 | #if defined(NUX_OS_WINDOWS) |
1969 | - regex_ = _regexp_str.GetTCharPtr(); |
1970 | + regex_ = _regexp_str.c_str(); |
1971 | return true; |
1972 | #else |
1973 | const char *error; |
1974 | int erroffset; |
1975 | _regexp = pcre_compile( |
1976 | - _regexp_str.GetTCharPtr(), /* the pattern */ |
1977 | + _regexp_str.c_str(), /* the pattern */ |
1978 | PCRE_MULTILINE, |
1979 | &error, /* for error message */ |
1980 | &erroffset, /* for error offset */ |
1981 | @@ -52,7 +52,7 @@ |
1982 | |
1983 | if (!_regexp) |
1984 | { |
1985 | - nuxDebugMsg("[IntegerValidator::IntegerValidator] Invalid regular expression: %s", _regexp_str.GetTCharPtr()); |
1986 | + nuxDebugMsg("[IntegerValidator::IntegerValidator] Invalid regular expression: %s", _regexp_str.c_str()); |
1987 | return false; |
1988 | } |
1989 | return true; |
1990 | |
1991 | === modified file 'Nux/Validator.h' |
1992 | --- Nux/Validator.h 2012-09-26 06:44:12 +0000 |
1993 | +++ Nux/Validator.h 2012-10-11 16:27:25 +0000 |
1994 | @@ -52,7 +52,7 @@ |
1995 | |
1996 | protected: |
1997 | bool InitRegExp(); |
1998 | - NString _regexp_str; |
1999 | + std::string _regexp_str; |
2000 | |
2001 | #if defined(NUX_OS_WINDOWS) |
2002 | std::regex regex_; |
2003 | |
2004 | === modified file 'Nux/WindowCompositor.cpp' |
2005 | --- Nux/WindowCompositor.cpp 2012-09-26 16:09:07 +0000 |
2006 | +++ Nux/WindowCompositor.cpp 2012-10-11 16:27:25 +0000 |
2007 | @@ -1418,11 +1418,11 @@ |
2008 | else |
2009 | window_thread_->GetGraphicsEngine().SetOpenGLClippingRectangle(0, 0, buffer_width, buffer_height); |
2010 | |
2011 | - if (m_TooltipText.Size()) |
2012 | + if (m_TooltipText.size()) |
2013 | { |
2014 | //SetProcessingTopView(_tooltip_window); |
2015 | GetPainter().PaintShape(window_thread_->GetGraphicsEngine(), _tooltip_geometry, Color(0xA0000000), eSHAPE_CORNER_ROUND10, true); |
2016 | - GetPainter().PaintTextLineStatic(window_thread_->GetGraphicsEngine(), GetSysBoldFont(), _tooltip_text_geometry, m_TooltipText.m_string, Color(0xFFFFFFFF)); |
2017 | + GetPainter().PaintTextLineStatic(window_thread_->GetGraphicsEngine(), GetSysBoldFont(), _tooltip_text_geometry, m_TooltipText, Color(0xFFFFFFFF)); |
2018 | //SetProcessingTopView(NULL); |
2019 | } |
2020 | |
2021 | @@ -1807,9 +1807,9 @@ |
2022 | m_TooltipX = x; |
2023 | m_TooltipY = y; |
2024 | |
2025 | - if (m_TooltipText.Size()) |
2026 | + if (m_TooltipText.size()) |
2027 | { |
2028 | - int w = GetSysBoldFont()->GetCharStringWidth(m_TooltipText.GetTCharPtr()); |
2029 | + int w = GetSysBoldFont()->GetCharStringWidth(m_TooltipText.c_str()); |
2030 | int h = GetSysBoldFont()->GetFontHeight(); |
2031 | |
2032 | _tooltip_text_geometry = Geometry( |
2033 | @@ -1910,7 +1910,7 @@ |
2034 | key_focus_area_->key_nav_focus_change.emit(key_focus_area_.GetPointer(), false, direction); |
2035 | // nuxDebugMsg("[WindowCompositor::SetKeyFocusArea] Area type '%s' named '%s': Lost key nav focus.", |
2036 | // key_focus_area_->Type().name, |
2037 | - // key_focus_area_->GetBaseString().GetTCharPtr()); |
2038 | + // key_focus_area_->GetBaseString().c_str()); |
2039 | } |
2040 | |
2041 | if (key_focus_area_->Type().IsDerivedFromType(View::StaticObjectType)) |
2042 | @@ -1938,7 +1938,7 @@ |
2043 | key_focus_area_->key_nav_focus_change.emit(key_focus_area_.GetPointer(), true, direction); |
2044 | // nuxDebugMsg("[WindowCompositor::SetKeyFocusArea] Area type '%s' named '%s': Has key nav focus.", |
2045 | // key_focus_area_->Type().name, |
2046 | - // key_focus_area_->GetBaseString().GetTCharPtr()); |
2047 | + // key_focus_area_->GetBaseString().c_str()); |
2048 | } |
2049 | |
2050 | if (key_focus_area_->Type().IsDerivedFromType(View::StaticObjectType)) |
2051 | @@ -2228,7 +2228,7 @@ |
2052 | key_focus_area_->key_nav_focus_change.emit(key_focus_area_.GetPointer(), false, KEY_NAV_NONE); |
2053 | // nuxDebugMsg("[WindowCompositor::GrabKeyboardAdd] Area type '%s' named '%s': Lost key nav focus.", |
2054 | // key_focus_area_->Type().name, |
2055 | - // key_focus_area_->GetBaseString().GetTCharPtr()); |
2056 | + // key_focus_area_->GetBaseString().c_str()); |
2057 | |
2058 | } |
2059 | |
2060 | @@ -2303,7 +2303,7 @@ |
2061 | key_focus_area_->key_nav_focus_change.emit(key_focus_area_.GetPointer(), false, KEY_NAV_NONE); |
2062 | // nuxDebugMsg("[WindowCompositor::GrabKeyboardRemove] Area type '%s' named '%s': Lost key nav focus.", |
2063 | // key_focus_area_->Type().name, |
2064 | - // key_focus_area_->GetBaseString().GetTCharPtr()); |
2065 | + // key_focus_area_->GetBaseString().c_str()); |
2066 | } |
2067 | |
2068 | if (key_focus_area_->Type().IsDerivedFromType(View::StaticObjectType)) |
2069 | |
2070 | === modified file 'Nux/WindowCompositor.h' |
2071 | --- Nux/WindowCompositor.h 2012-09-26 16:09:07 +0000 |
2072 | +++ Nux/WindowCompositor.h 2012-10-11 16:27:25 +0000 |
2073 | @@ -514,7 +514,7 @@ |
2074 | int m_Width; |
2075 | int m_Height; |
2076 | |
2077 | - NString m_TooltipText; |
2078 | + std::string m_TooltipText; |
2079 | InputArea* m_TooltipArea; |
2080 | int m_TooltipX; |
2081 | int m_TooltipY; |
2082 | |
2083 | === modified file 'NuxCore/FileIO.cpp' |
2084 | --- NuxCore/FileIO.cpp 2012-09-30 16:35:58 +0000 |
2085 | +++ NuxCore/FileIO.cpp 2012-10-11 16:27:25 +0000 |
2086 | @@ -331,7 +331,7 @@ |
2087 | bool SaveAsUnicode = false, Success = true; |
2088 | #if UNICODE |
2089 | |
2090 | - for ( int i = 0; i < String.Length(); i++ ) |
2091 | + for ( int i = 0; i < String.length(); i++ ) |
2092 | { |
2093 | // Test if the UNICODE 0xABCD is the same as the ASCII 0x00CB. |
2094 | if ( (*String) [i] != (TCHAR) (ANSIUCHAR) ConvertTCHARToAnsiChar ( (*String) [i]) ) |
2095 | |
2096 | === modified file 'NuxCore/FileIO.h' |
2097 | --- NuxCore/FileIO.h 2012-09-30 16:35:58 +0000 |
2098 | +++ NuxCore/FileIO.h 2012-10-11 16:27:25 +0000 |
2099 | @@ -23,6 +23,9 @@ |
2100 | #ifndef NFILE_H |
2101 | #define NFILE_H |
2102 | |
2103 | +#include <vector> |
2104 | +#include <string> |
2105 | + |
2106 | namespace nux |
2107 | { |
2108 | |
2109 | @@ -32,7 +35,6 @@ |
2110 | bool LoadFileToString(std::string &Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
2111 | bool SaveArrayToFile(const std::vector<BYTE>& Array, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
2112 | bool SaveStringToFile(const std::string &String, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
2113 | - |
2114 | } |
2115 | |
2116 | |
2117 | |
2118 | === modified file 'NuxCore/FileManager/NFileManagerGNU.h' |
2119 | --- NuxCore/FileManager/NFileManagerGNU.h 2012-09-26 06:44:12 +0000 |
2120 | +++ NuxCore/FileManager/NFileManagerGNU.h 2012-10-11 16:27:25 +0000 |
2121 | @@ -127,9 +127,9 @@ |
2122 | bool DeleteDirectory (const TCHAR *Path, bool DeleteContentFirst = false); |
2123 | |
2124 | |
2125 | - void FindFiles (std::vector<NString>& /* Result */, const TCHAR * /* Filename */, bool /* Files */, bool /* Directories */) {}; |
2126 | - void ListFilesInDirectory (std::vector<NString>& /* Result */, const TCHAR * /* DirName */) {}; |
2127 | - double GetFileAgeSeconds (const TCHAR * /* Filename */) |
2128 | + void FindFiles(std::vector<std::string>& /* Result */, const TCHAR* /* Filename */, bool /* Files */, bool /* Directories */) {}; |
2129 | + void ListFilesInDirectory (std::vector<std::string>& /* Result */, const TCHAR* /* DirName */) {}; |
2130 | + double GetFileAgeSeconds (const TCHAR* /* Filename */) |
2131 | { |
2132 | return 0; |
2133 | }; |
2134 | @@ -141,9 +141,9 @@ |
2135 | { |
2136 | return false; |
2137 | }; |
2138 | - NString GetCurrentDirectory() |
2139 | + std::string GetCurrentDirectory() |
2140 | { |
2141 | - return NString(); |
2142 | + return std::string(); |
2143 | }; |
2144 | bool GetTimeStamp (const TCHAR * /* Filename */, FileTimeStamp & /* Timestamp */) |
2145 | { |
2146 | |
2147 | === modified file 'NuxCore/FileManager/NFileManagerGeneric.cpp' |
2148 | --- NuxCore/FileManager/NFileManagerGeneric.cpp 2012-10-01 23:37:25 +0000 |
2149 | +++ NuxCore/FileManager/NFileManagerGeneric.cpp 2012-10-11 16:27:25 +0000 |
2150 | @@ -38,10 +38,10 @@ |
2151 | } |
2152 | |
2153 | int Result = COPY_OK; |
2154 | - NString SrcFile = InSrcFile; |
2155 | - NString DestFile = InDestFile; |
2156 | + std::string SrcFile = InSrcFile; |
2157 | + std::string DestFile = InDestFile; |
2158 | |
2159 | - NSerializer *Src = CreateFileReader (SrcFile.GetTCharPtr() ); |
2160 | + NSerializer *Src = CreateFileReader (SrcFile.c_str() ); |
2161 | |
2162 | if (!Src) |
2163 | { |
2164 | @@ -50,7 +50,7 @@ |
2165 | else |
2166 | { |
2167 | unsigned int Size = Src->GetFileSize(); |
2168 | - NSerializer *Dest = CreateFileWriter (DestFile.GetTCharPtr(), (OverWriteExisting ? 0 : FILEWRITE_NOREPLACEEXISTING) | (OverWriteReadOnly ? FILEWRITE_EVENIFREADONLY : 0) ); |
2169 | + NSerializer *Dest = CreateFileWriter (DestFile.c_str(), (OverWriteExisting ? 0 : FILEWRITE_NOREPLACEEXISTING) | (OverWriteReadOnly ? FILEWRITE_EVENIFREADONLY : 0) ); |
2170 | |
2171 | if (!Dest) |
2172 | { |
2173 | @@ -103,7 +103,7 @@ |
2174 | |
2175 | if (Result != COPY_OK) |
2176 | { |
2177 | - Delete (DestFile.GetTCharPtr() ); |
2178 | + Delete (DestFile.c_str() ); |
2179 | } |
2180 | } |
2181 | |
2182 | @@ -188,28 +188,28 @@ |
2183 | if (PathLength == 0) |
2184 | return false; |
2185 | |
2186 | - NString WildcardPath = NString (Path); |
2187 | + std::string WildcardPath = std::string (Path); |
2188 | |
2189 | if ( (WildcardPath[PathLength - 1] != NUX_BACKSLASH_CHAR) && (WildcardPath[PathLength - 1] != NUX_SLASH_CHAR) ) |
2190 | WildcardPath += NUX_BACKSLASH_CHAR; |
2191 | |
2192 | WildcardPath += TEXT ("*"); |
2193 | |
2194 | - std::vector<NString> List; |
2195 | - FindFiles (List, *WildcardPath, 1, 0); |
2196 | + std::vector<std::string> List; |
2197 | + FindFiles (List, WildcardPath.c_str(), 1, 0); |
2198 | |
2199 | for (unsigned int i = 0; i < List.size(); i++) |
2200 | { |
2201 | - if (!Delete (* (NString (Path) + NUX_BACKSLASH_CHAR + List[i]), 1) ) |
2202 | + if (!Delete ((std::string (Path) + NUX_BACKSLASH_CHAR + List[i]).c_str(), 1) ) |
2203 | return 0; |
2204 | } |
2205 | |
2206 | List.clear(); |
2207 | - FindFiles (List, *WildcardPath, 0, 1); |
2208 | + FindFiles (List, WildcardPath.c_str(), 0, 1); |
2209 | |
2210 | for (unsigned int i = 0; i < List.size(); i++) |
2211 | { |
2212 | - if (!DeleteDirectory (* (NString (Path) + NUX_BACKSLASH_CHAR + List[i]), true) ) |
2213 | + if (!DeleteDirectory ((std::string (Path) + NUX_BACKSLASH_CHAR + List[i]).c_str(), true) ) |
2214 | return 0; |
2215 | } |
2216 | |
2217 | @@ -228,13 +228,13 @@ |
2218 | } |
2219 | |
2220 | |
2221 | - int NFileManagerGeneric::CreateUniqueFileName (const TCHAR *Filename, const TCHAR *Extension, NString &OutputFilename, unsigned int BaseIndex) |
2222 | + int NFileManagerGeneric::CreateUniqueFileName (const TCHAR *Filename, const TCHAR *Extension, std::string &OutputFilename, unsigned int BaseIndex) |
2223 | { |
2224 | nuxAssert (Filename); |
2225 | nuxAssert (Extension); |
2226 | |
2227 | - NString FullPath (Filename); |
2228 | - const size_t IndexMarker = FullPath.Length(); // Marks location of the four-digit index. |
2229 | + std::string FullPath (Filename); |
2230 | + const size_t IndexMarker = FullPath.length(); // Marks location of the four-digit index. |
2231 | FullPath += TEXT ("0000."); |
2232 | FullPath += Extension; |
2233 | |
2234 | @@ -246,7 +246,7 @@ |
2235 | FullPath[IndexMarker+2] = (i / 10) % 10 + TEXT ('0'); |
2236 | FullPath[IndexMarker+3] = i % 10 + TEXT ('0'); |
2237 | |
2238 | - if (GFileManager.FileSize (FullPath.GetTCharPtr() ) == -1) |
2239 | + if (GFileManager.FileSize (FullPath.c_str() ) == -1) |
2240 | { |
2241 | // The file doesn't exist; output success. |
2242 | OutputFilename = FullPath; |
2243 | |
2244 | === modified file 'NuxCore/FileManager/NFileManagerGeneric.h' |
2245 | --- NuxCore/FileManager/NFileManagerGeneric.h 2012-09-26 06:44:12 +0000 |
2246 | +++ NuxCore/FileManager/NFileManagerGeneric.h 2012-10-11 16:27:25 +0000 |
2247 | @@ -26,7 +26,6 @@ |
2248 | namespace nux |
2249 | { |
2250 | |
2251 | - class NString; |
2252 | class NFileManagerWindows; |
2253 | |
2254 | class NFileTransferMonitor |
2255 | @@ -149,15 +148,15 @@ |
2256 | @param BaseIndex Base for index search. |
2257 | @return Index of the new file. -1 if the file couldn't be created The index has to be in the range [0, 9999]. |
2258 | */ |
2259 | - virtual int CreateUniqueFileName (const TCHAR *Filename, const TCHAR *Extension, NString &OutputFilename, unsigned int BaseIndex = 0xffffffff) = 0; |
2260 | - |
2261 | - |
2262 | - virtual void FindFiles ( std::vector<NString>& FileNames, const TCHAR *Filename, bool Files, bool Directories ) = 0; |
2263 | - virtual void ListFilesInDirectory ( std::vector<NString>& Result, const TCHAR *DirName) = 0; |
2264 | + virtual int CreateUniqueFileName (const TCHAR *Filename, const TCHAR *Extension, std::string &OutputFilename, unsigned int BaseIndex = 0xffffffff) = 0; |
2265 | + |
2266 | + |
2267 | + virtual void FindFiles ( std::vector<std::string>& FileNames, const TCHAR *Filename, bool Files, bool Directories ) = 0; |
2268 | + virtual void ListFilesInDirectory ( std::vector<std::string>& Result, const TCHAR *DirName) = 0; |
2269 | virtual time_t GetFileLastModified (const TCHAR *Filename) = 0; |
2270 | virtual double GetFileAgeSeconds (const TCHAR *Filename) = 0; |
2271 | virtual bool SetDefaultDirectory() = 0; |
2272 | - virtual NString GetCurrentDirectory() = 0; |
2273 | + virtual std::string GetCurrentDirectory() = 0; |
2274 | virtual bool GetTimeStamp ( const TCHAR *Path, FileTimeStamp &Timestamp ) = 0; |
2275 | |
2276 | |
2277 | @@ -172,7 +171,7 @@ |
2278 | bool MakeDirectory (const TCHAR *Path, bool CreateCompletePath = false); |
2279 | bool DeleteDirectory (const TCHAR *Path, bool DeleteContentFirst = false); |
2280 | bool Move (const TCHAR *Dest, const TCHAR *Src, bool OverWriteExisting = true, bool OverWriteReadOnly = false, NFileTransferMonitor *Monitor = NULL); |
2281 | - int CreateUniqueFileName (const TCHAR *Filename, const TCHAR *Extension, NString &OutputFilename, unsigned int BaseIndex = 0xffffffff); |
2282 | + int CreateUniqueFileName (const TCHAR *Filename, const TCHAR *Extension, std::string &OutputFilename, unsigned int BaseIndex = 0xffffffff); |
2283 | |
2284 | bool IsDrive (const TCHAR *Path); |
2285 | }; |
2286 | |
2287 | === modified file 'NuxCore/FileManager/NFileManagerWindows.cpp' |
2288 | --- NuxCore/FileManager/NFileManagerWindows.cpp 2012-07-30 21:21:03 +0000 |
2289 | +++ NuxCore/FileManager/NFileManagerWindows.cpp 2012-10-11 16:27:25 +0000 |
2290 | @@ -690,7 +690,7 @@ |
2291 | return true; |
2292 | } |
2293 | |
2294 | - void NFileManagerWindows::FindFiles (std::vector<NString>& Result, const TCHAR *Filename, bool Files, bool Directories) |
2295 | + void NFileManagerWindows::FindFiles (std::vector<std::string>& Result, const TCHAR *Filename, bool Files, bool Directories) |
2296 | { |
2297 | HANDLE Handle = INVALID_HANDLE_VALUE; |
2298 | WIN32_FIND_DATA SearchData; |
2299 | @@ -707,7 +707,7 @@ |
2300 | |
2301 | { |
2302 | if ( (SearchData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? Directories : Files) |
2303 | - Result.push_back (NString (SearchData.cFileName) ); |
2304 | + Result.push_back (std::string(SearchData.cFileName) ); |
2305 | } |
2306 | } |
2307 | while (::FindNextFile (Handle, &SearchData) ); |
2308 | @@ -717,13 +717,13 @@ |
2309 | ::FindClose (Handle); |
2310 | } |
2311 | |
2312 | - void NFileManagerWindows::ListFilesInDirectory (std::vector<NString>& Result, const TCHAR *DirName) |
2313 | + void NFileManagerWindows::ListFilesInDirectory (std::vector<std::string>& Result, const TCHAR *DirName) |
2314 | { |
2315 | WIN32_FIND_DATA SearchData; |
2316 | HANDLE Handle = INVALID_HANDLE_VALUE; |
2317 | - NString DirectoryName = DirName; |
2318 | + std::string DirectoryName = DirName; |
2319 | DirectoryName += TEXT ("\\*"); |
2320 | - Handle = ::FindFirstFile (DirectoryName.GetTCharPtr(), &SearchData); |
2321 | + Handle = ::FindFirstFile (DirectoryName.c_str(), &SearchData); |
2322 | |
2323 | if (Handle != INVALID_HANDLE_VALUE) |
2324 | { |
2325 | @@ -735,7 +735,7 @@ |
2326 | ! (SearchData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && |
2327 | ! (SearchData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ) |
2328 | { |
2329 | - Result.push_back (NString (SearchData.cFileName) ); |
2330 | + Result.push_back(std::string(SearchData.cFileName)); |
2331 | } |
2332 | } |
2333 | while (::FindNextFile (Handle, &SearchData) ); |
2334 | @@ -806,19 +806,19 @@ |
2335 | |
2336 | bool NFileManagerWindows::SetDefaultDirectory() |
2337 | { |
2338 | - return CALL_OS_TCHAR_FUNCTION (SetCurrentDirectoryW (GetProgramDirectory() ), SetCurrentDirectoryA (TCHAR_TO_ANSI (GetProgramDirectory().GetTCharPtr() ) ) ) != 0; |
2339 | + return CALL_OS_TCHAR_FUNCTION(SetCurrentDirectoryW(GetProgramDirectory()), SetCurrentDirectoryA(TCHAR_TO_ANSI(GetProgramDirectory().c_str()))) != 0; |
2340 | } |
2341 | |
2342 | - NString NFileManagerWindows::GetCurrentDirectory() |
2343 | + std::string NFileManagerWindows::GetCurrentDirectory() |
2344 | { |
2345 | #if UNICODE |
2346 | TCHAR Buffer[1024] = TEXT (""); |
2347 | ::GetCurrentDirectoryW (NUX_ARRAY_COUNT (Buffer), Buffer); |
2348 | - return NString (Buffer); |
2349 | + return std::string(Buffer); |
2350 | #else |
2351 | ANSICHAR Buffer[1024] = ""; |
2352 | ::GetCurrentDirectoryA (NUX_ARRAY_COUNT (Buffer), Buffer); |
2353 | - return NString (Buffer); |
2354 | + return std::string(Buffer); |
2355 | #endif |
2356 | } |
2357 | |
2358 | |
2359 | === modified file 'NuxCore/FileManager/NFileManagerWindows.h' |
2360 | --- NuxCore/FileManager/NFileManagerWindows.h 2011-10-21 22:06:35 +0000 |
2361 | +++ NuxCore/FileManager/NFileManagerWindows.h 2012-10-11 16:27:25 +0000 |
2362 | @@ -130,13 +130,13 @@ |
2363 | bool DeleteDirectory (const TCHAR *Path, bool DeleteContentFirst = false); |
2364 | |
2365 | |
2366 | - void FindFiles (std::vector<NString>& Result, const TCHAR *Filename, bool Files, bool Directories); |
2367 | - void ListFilesInDirectory (std::vector<NString>& Result, const TCHAR *DirName); |
2368 | + void FindFiles (std::vector<std::string>& Result, const TCHAR *Filename, bool Files, bool Directories); |
2369 | + void ListFilesInDirectory (std::vector<std::string>& Result, const TCHAR *DirName); |
2370 | double GetFileAgeSeconds (const TCHAR *Filename); |
2371 | time_t GetFileLastModified (const TCHAR *Filename); |
2372 | bool GetFileLastModified (const TCHAR *Filename, SYSTEMTIME &sysTime, bool bLocalTime); |
2373 | bool SetDefaultDirectory(); |
2374 | - NString GetCurrentDirectory(); |
2375 | + std::string GetCurrentDirectory(); |
2376 | bool GetTimeStamp (const TCHAR *Filename, FileTimeStamp &Timestamp); |
2377 | }; |
2378 | |
2379 | |
2380 | === modified file 'NuxCore/FileManager/NSerializer.cpp' |
2381 | --- NuxCore/FileManager/NSerializer.cpp 2012-02-18 21:32:06 +0000 |
2382 | +++ NuxCore/FileManager/NSerializer.cpp 2012-10-11 16:27:25 +0000 |
2383 | @@ -35,7 +35,7 @@ |
2384 | // } |
2385 | // } |
2386 | |
2387 | -// NSerializer& operator << (NSerializer& Sr, NString& s) |
2388 | +// NSerializer& operator << (NSerializer& Sr, std::string& s) |
2389 | // { |
2390 | // Sr.SerializeBuffer<TCHAR>(NUX_CONST_CAST(TCHAR*, s.GetTCharPtr()), s.Size()+1, sizeof(TCHAR)); |
2391 | // return Sr; |
2392 | |
2393 | === modified file 'NuxCore/FileName.cpp' |
2394 | --- NuxCore/FileName.cpp 2011-10-21 22:06:35 +0000 |
2395 | +++ NuxCore/FileName.cpp 2012-10-11 16:27:25 +0000 |
2396 | @@ -27,72 +27,59 @@ |
2397 | namespace nux |
2398 | { |
2399 | |
2400 | - NString NFileName::GetDrive() const |
2401 | + std::string NFileName::GetDrive() const |
2402 | { |
2403 | - size_t Pos = FindFirstOccurence (NUX_BACKSLASH_CHAR); |
2404 | - |
2405 | - if (Pos == tstring::npos) |
2406 | - { |
2407 | - Pos = FindFirstOccurence ("\\"); |
2408 | - |
2409 | - if (Pos != tstring::npos) |
2410 | - { |
2411 | - return GetSubString (Pos); |
2412 | - } |
2413 | - } |
2414 | - |
2415 | - return TEXT (""); |
2416 | + size_t Pos = find('\\', 0); |
2417 | + return Pos != std::string::npos ? substr(0, Pos) : ""; |
2418 | } |
2419 | |
2420 | - NString NFileName::GetExtension() const |
2421 | + std::string NFileName::GetExtension() const |
2422 | { |
2423 | - size_t Pos = FindLastOccurence (TEXT (".") ); |
2424 | - |
2425 | - if (Pos != tstring::npos) |
2426 | - { |
2427 | - return GetSubString (Pos + 1, Length() - Pos - 1); |
2428 | - } |
2429 | - |
2430 | - return TEXT (""); |
2431 | + size_t Pos = rfind('.'); |
2432 | + return Pos != std::string::npos ? substr(Pos + 1) : ""; |
2433 | } |
2434 | |
2435 | // Returns the base filename without the path |
2436 | - NString NFileName::GetCleanFilename() const |
2437 | + std::string NFileName::GetCleanFilename() const |
2438 | { |
2439 | - size_t Pos = FindLastOccurence (NUX_BACKSLASH_CHAR); |
2440 | - Pos = Max<size_t> (Pos, FindLastOccurence (TEXT ("/") ) ); // in case we are using slash and the NUX_BACKSLASH_CHAR is different. |
2441 | - Pos = Max<size_t> (Pos, FindLastOccurence (TEXT ("\\") ) ); // in case we are using backslash and the NUX_BACKSLASH_CHAR is different. |
2442 | - |
2443 | - if (Pos != tstring::npos) |
2444 | - { |
2445 | - return GetSubString (Pos + 1, Length() - Pos - 1); |
2446 | - } |
2447 | - |
2448 | - return *this; |
2449 | + size_t bsPos = rfind('\\'); |
2450 | + size_t sPos = rfind('/'); |
2451 | + size_t Pos = std::string::npos; |
2452 | + if (bsPos != std::string::npos && sPos != std::string::npos) |
2453 | + { |
2454 | + Pos = Max<size_t>(bsPos, sPos); |
2455 | + } |
2456 | + else if (bsPos != std::string::npos) |
2457 | + { |
2458 | + Pos = bsPos; |
2459 | + } |
2460 | + else if (sPos != std::string::npos) |
2461 | + { |
2462 | + Pos = sPos; |
2463 | + } |
2464 | + return Pos != std::string::npos ? (const std::string)substr(Pos + 1) : *this; |
2465 | } |
2466 | |
2467 | - NString NFileName::GetFilenameNoExtension() const |
2468 | + std::string NFileName::GetFilenameNoExtension() const |
2469 | { |
2470 | - size_t Pos = FindLastOccurence (TEXT (".") ); |
2471 | - |
2472 | - if (Pos != tstring::npos) |
2473 | + size_t Pos = rfind('.'); |
2474 | + if (Pos != std::string::npos && Pos != 0) |
2475 | { |
2476 | - return GetSubString (Pos); |
2477 | + return substr(0, Pos); |
2478 | } |
2479 | - |
2480 | return *this; |
2481 | } |
2482 | |
2483 | // Returns the base filename without the path and without the extension |
2484 | - NString NFileName::GetBaseFilename() const |
2485 | + std::string NFileName::GetBaseFilename() const |
2486 | { |
2487 | - NString Wk = GetCleanFilename(); |
2488 | - |
2489 | - size_t Pos = Wk.FindLastOccurence (TEXT (".") ); |
2490 | - |
2491 | - if (Pos != tstring::npos) |
2492 | + std::string Wk = GetCleanFilename(); |
2493 | + |
2494 | + size_t Pos = Wk.rfind('.'); |
2495 | + |
2496 | + if (Pos != std::string::npos) |
2497 | { |
2498 | - return Wk.GetSubString (Pos); |
2499 | + return Wk.substr(Pos); |
2500 | } |
2501 | |
2502 | return Wk; |
2503 | @@ -100,113 +87,124 @@ |
2504 | |
2505 | // Returns the path in front of the filename |
2506 | |
2507 | - NString NFileName::GetDirectoryPath() const |
2508 | + std::string NFileName::GetDirectoryPath() const |
2509 | { |
2510 | - size_t Pos = FindLastOccurence (NUX_BACKSLASH_CHAR); |
2511 | - Pos = Max<size_t> (Pos, FindLastOccurence (TEXT ("/") ) ); // in case we are using slash and the NUX_BACKSLASH_CHAR is different. |
2512 | - Pos = Max<size_t> (Pos, FindLastOccurence (TEXT ("\\") ) ); // in case we are using backslash and the NUX_BACKSLASH_CHAR is different. |
2513 | - |
2514 | - if (Pos != tstring::npos) |
2515 | - { |
2516 | - return GetSubString (Pos); |
2517 | - } |
2518 | - |
2519 | - return *this; |
2520 | + size_t bsPos = rfind('\\'); |
2521 | + size_t sPos = rfind('/'); |
2522 | + size_t Pos = std::string::npos; |
2523 | + if (bsPos != std::string::npos && sPos != std::string::npos) |
2524 | + { |
2525 | + Pos = Max<size_t>(bsPos, sPos); |
2526 | + } |
2527 | + else if (bsPos != std::string::npos) |
2528 | + { |
2529 | + Pos = bsPos; |
2530 | + } |
2531 | + else if (sPos != std::string::npos) |
2532 | + { |
2533 | + Pos = sPos; |
2534 | + } |
2535 | + return Pos != std::string::npos ? substr(Pos) : "."; |
2536 | } |
2537 | |
2538 | void NFileName::ChangeFileExtension (const TCHAR *ext) |
2539 | { |
2540 | - size_t Pos = FindLastOccurence (TEXT (".") ); |
2541 | - |
2542 | - if (Pos != tstring::npos) |
2543 | - { |
2544 | - (*this) = GetSubString (Pos) + NString (TEXT (".") ) + NString (ext); |
2545 | - } |
2546 | - else |
2547 | - { |
2548 | - (*this) = (*this) + NString (TEXT (".") ) + NString (ext); |
2549 | - } |
2550 | + size_t Pos = rfind('.'); |
2551 | + if (Pos != std::string::npos) |
2552 | + { |
2553 | + replace(begin() + Pos, end(), ext); |
2554 | + } |
2555 | + *this = *this + "." + ext; |
2556 | } |
2557 | |
2558 | void NFileName::ConvertSlashToBackslash() |
2559 | { |
2560 | - size_t Pos = tstring::npos; |
2561 | - Pos = FindFirstOccurence (TEXT ('/') ); |
2562 | + size_t Pos = find('/'); |
2563 | |
2564 | - while (Pos != tstring::npos) |
2565 | + while (Pos != std::string::npos) |
2566 | { |
2567 | - Replace (Pos, 1, 1, TEXT ('\\') ); |
2568 | + replace(Pos, 1, 1, '\\'); |
2569 | } |
2570 | } |
2571 | |
2572 | - |
2573 | void NFileName::ConvertBackslashToSlash() |
2574 | { |
2575 | - size_t Pos = tstring::npos; |
2576 | - Pos = FindFirstOccurence (TEXT ('\\') ); |
2577 | + size_t Pos = find('\\'); |
2578 | |
2579 | - while (Pos != tstring::npos) |
2580 | + while (Pos != std::string::npos) |
2581 | { |
2582 | - Replace (Pos, 1, 1, TEXT ('/') ); |
2583 | + replace(Pos, 1, 1, '/'); |
2584 | } |
2585 | } |
2586 | |
2587 | void NFileName::AddSlashAtEnd() |
2588 | { |
2589 | - if (GetLastChar() != TEXT ('/') ) |
2590 | - *this += TEXT ('/'); |
2591 | + if (!empty() && operator[](size() - 1) != '/') |
2592 | + append("/"); |
2593 | } |
2594 | |
2595 | void NFileName::AddBackSlashAtEnd() |
2596 | { |
2597 | - if (GetLastChar() != TEXT ('\\') ) |
2598 | - *this += TEXT ('\\'); |
2599 | + if (!empty() && operator[](size() - 1) != '\\') |
2600 | + *this += '\\'; |
2601 | } |
2602 | |
2603 | void NFileName::AddSlashAtStart() |
2604 | { |
2605 | - if (GetFirstChar() != TEXT ('/') ) |
2606 | - Insert (0, 1, TEXT ('/') ); |
2607 | + if (!empty() && operator[](0) != '/') |
2608 | + insert(0, 1, '/'); |
2609 | } |
2610 | |
2611 | void NFileName::AddBackSlashAtStart() |
2612 | { |
2613 | - if (GetFirstChar() != TEXT ('\\') ) |
2614 | - Insert (0, 1, TEXT ('\\') ); |
2615 | + if (!empty() && operator[](0) != '\\') |
2616 | + insert(0, 1, '\\'); |
2617 | } |
2618 | |
2619 | void NFileName::RemoveSlashAtEnd() |
2620 | { |
2621 | - RemoveSuffix (TEXT ('/') ); |
2622 | + if (!empty() && operator[](size() - 1) == '/') |
2623 | + { |
2624 | + erase(end() - 1); |
2625 | + } |
2626 | } |
2627 | |
2628 | void NFileName::RemoveBackSlashAtEnd() |
2629 | { |
2630 | - RemoveSuffix (TEXT ('\\') ); |
2631 | + if (!empty() && operator[](size() - 1) == '\\') |
2632 | + { |
2633 | + erase(end() - 1); |
2634 | + } |
2635 | } |
2636 | |
2637 | void NFileName::RemoveSlashAtStart() |
2638 | { |
2639 | - RemovePrefix (TEXT ('/') ); |
2640 | + if (!empty() && operator[](0) == '/') |
2641 | + { |
2642 | + erase(0, 1); |
2643 | + } |
2644 | } |
2645 | |
2646 | void NFileName::RemoveBackSlashAtStart() |
2647 | { |
2648 | - RemovePrefix (TEXT ('\\') ); |
2649 | + if (!empty() && operator[](0) == '\\') |
2650 | + { |
2651 | + erase(0, 1); |
2652 | + } |
2653 | } |
2654 | |
2655 | void NFileName::ConvertToCleanSlash() |
2656 | { |
2657 | ConvertBackslashToSlash(); |
2658 | |
2659 | - size_t size = Size(); |
2660 | + size_t count = size(); |
2661 | |
2662 | - for (size_t i = 0; i < size; ) |
2663 | + for (size_t i = 0; i < count; ) |
2664 | { |
2665 | - if ( (i < size - 1) && (operator[] (i) == TEXT ('/') ) && (operator[] (i + 1) == TEXT ('/') ) ) |
2666 | + if ( (i < count - 1) && (operator[] (i) == '/' ) && (operator[] (i + 1) == ('/') ) ) |
2667 | { |
2668 | - Erase (i + 1, 1); |
2669 | - --size; |
2670 | + erase (i + 1, 1); |
2671 | + --count; |
2672 | } |
2673 | else |
2674 | { |
2675 | @@ -219,13 +217,13 @@ |
2676 | { |
2677 | ConvertSlashToBackslash(); |
2678 | |
2679 | - size_t size = Size(); |
2680 | + size_t count = size(); |
2681 | |
2682 | - for (size_t i = 0; i < size; ) |
2683 | + for (size_t i = 0; i < count; ) |
2684 | { |
2685 | - if ( (i < size - 1) && (operator[] (i) == TEXT ('\\') ) && (operator[] (i + 1) == TEXT ('\\') ) ) |
2686 | + if ( (i < count - 1) && (operator[] (i) == '\\' ) && (operator[] (i + 1) == '\\' ) ) |
2687 | { |
2688 | - Erase (i + 1, 1); |
2689 | + erase (i + 1, 1); |
2690 | } |
2691 | else |
2692 | { |
2693 | |
2694 | === modified file 'NuxCore/FileName.h' |
2695 | --- NuxCore/FileName.h 2011-04-06 21:54:09 +0000 |
2696 | +++ NuxCore/FileName.h 2012-10-11 16:27:25 +0000 |
2697 | @@ -28,25 +28,22 @@ |
2698 | namespace nux |
2699 | { |
2700 | |
2701 | - class NFileName : public NString |
2702 | + class NFileName : public std::string |
2703 | { |
2704 | public: |
2705 | NFileName() |
2706 | - : NString() |
2707 | + : std::string() |
2708 | {} |
2709 | NFileName ( const NFileName &Filename ) |
2710 | - : NString ( Filename.GetTCharPtr() ) |
2711 | + : std::string ( Filename ) |
2712 | {} |
2713 | |
2714 | - NFileName ( const NString &str ) |
2715 | - : NString ( str ) |
2716 | + NFileName ( const std::string &str ) |
2717 | + : std::string ( str ) |
2718 | {} |
2719 | |
2720 | NFileName ( const ANSICHAR *str ) |
2721 | - : NString ( str ) |
2722 | - {} |
2723 | - NFileName ( const UNICHAR *str ) |
2724 | - : NString ( str ) |
2725 | + : std::string ( str ) |
2726 | {} |
2727 | |
2728 | //! Replace all slash with backslash. |
2729 | @@ -75,18 +72,18 @@ |
2730 | //! Replace all slash with backslash. Replace multiple consecutive backslash with one backslash. |
2731 | void ConvertToCleanBackslash(); |
2732 | |
2733 | - NString GetDrive() const; |
2734 | + std::string GetDrive() const; |
2735 | //! Returns the text following the last period. |
2736 | - NString GetExtension() const; |
2737 | + std::string GetExtension() const; |
2738 | //! Returns the base filename, minus any path information. |
2739 | - NString GetCleanFilename() const; |
2740 | + std::string GetCleanFilename() const; |
2741 | //! Returns the base filename, without the extension (keep the path) |
2742 | - NString GetFilenameNoExtension() const; |
2743 | + std::string GetFilenameNoExtension() const; |
2744 | |
2745 | //! Returns the same thing as GetCleanFilename, but without the extension |
2746 | - NString GetBaseFilename() const; |
2747 | + std::string GetBaseFilename() const; |
2748 | //! Returns the path in front of the filename |
2749 | - NString GetDirectoryPath() const; |
2750 | + std::string GetDirectoryPath() const; |
2751 | //! Change the file extension. Do not start ext with a dot character '.'. |
2752 | //! ie ext = "com" |
2753 | void ChangeFileExtension (const TCHAR *ext); |
2754 | |
2755 | === modified file 'NuxCore/FilePath.cpp' |
2756 | --- NuxCore/FilePath.cpp 2011-10-21 22:06:35 +0000 |
2757 | +++ NuxCore/FilePath.cpp 2012-10-11 16:27:25 +0000 |
2758 | @@ -40,7 +40,7 @@ |
2759 | |
2760 | } |
2761 | |
2762 | - void FilePath::AddSearchPath (const NString &searchpath) |
2763 | + void FilePath::AddSearchPath (const std::string &searchpath) |
2764 | { |
2765 | if (std::find (m_SearchPath.begin(), m_SearchPath.end(), searchpath) != m_SearchPath.end() ) |
2766 | return; |
2767 | @@ -48,7 +48,7 @@ |
2768 | m_SearchPath.push_back (searchpath); |
2769 | } |
2770 | |
2771 | - void FilePath::AddSearchPath (const std::vector<NString>& searchpath) |
2772 | + void FilePath::AddSearchPath (const std::vector<std::string>& searchpath) |
2773 | { |
2774 | for (unsigned int i = 0; i < searchpath.size(); i++) |
2775 | { |
2776 | @@ -57,51 +57,52 @@ |
2777 | } |
2778 | } |
2779 | |
2780 | - NString FilePath::GetPathToFile (const TCHAR *filename) const |
2781 | + std::string FilePath::GetPathToFile (const TCHAR *filename) const |
2782 | { |
2783 | - NString FileName = GetFile (filename); |
2784 | - |
2785 | - int loc = (int) FileName.FindLastOccurence (TEXT ('\\') ); |
2786 | - |
2787 | - if (loc == -1) |
2788 | + std::string FileName = GetFile (filename); |
2789 | + |
2790 | + size_t loc = FileName.rfind(TEXT('\\'), 0); |
2791 | + |
2792 | + if (loc == std::string::npos) |
2793 | { |
2794 | - loc = (int) FileName.FindLastOccurence (TEXT ('/') ); |
2795 | + loc = FileName.rfind(TEXT('/'), 0); |
2796 | } |
2797 | |
2798 | - if (loc != -1) |
2799 | - FileName = FileName.GetSubString (0, loc); |
2800 | + if (loc != std::string::npos) |
2801 | + FileName = FileName.substr(0, loc); |
2802 | else |
2803 | - FileName = NString (TEXT (".") ); |
2804 | + FileName = std::string(TEXT (".")); |
2805 | |
2806 | return FileName; |
2807 | } |
2808 | |
2809 | - NString FilePath::GetFile (const TCHAR *filename) const |
2810 | + std::string FilePath::GetFile (const TCHAR *filename) const |
2811 | { |
2812 | - NUX_RETURN_VALUE_IF_NULL (filename, NString (TEXT ("") ) ); |
2813 | - |
2814 | - if (NString (filename) == NString (TEXT ("") ) ) |
2815 | - return NString (TEXT ("") ); |
2816 | - |
2817 | - NString FileName = filename; |
2818 | - |
2819 | - if (GFileManager.FileExist (FileName.GetTCharPtr() ) ) |
2820 | + NUX_RETURN_VALUE_IF_NULL (filename, std::string (TEXT ("") ) ); |
2821 | + |
2822 | + if (std::string (filename) == std::string (TEXT ("") ) ) |
2823 | + return std::string (TEXT ("") ); |
2824 | + |
2825 | + std::string FileName = filename; |
2826 | + |
2827 | + if (GFileManager.FileExist(FileName.c_str() ) ) |
2828 | return FileName; |
2829 | |
2830 | for (unsigned int i = 0; i < m_SearchPath.size(); i++) |
2831 | { |
2832 | - if (m_SearchPath[i].Size() == 0) |
2833 | + if (m_SearchPath[i].size() == 0) |
2834 | continue; |
2835 | |
2836 | - NString FilePath; |
2837 | + std::string FilePath; |
2838 | |
2839 | - if ((m_SearchPath[i].GetLastChar () == TEXT('/')) || (m_SearchPath[i].GetLastChar () == TEXT('\\'))) |
2840 | + char last = m_SearchPath[i][m_SearchPath[i].size() - 1]; |
2841 | + if (last == TEXT('/') || last == TEXT('\\')) |
2842 | FilePath = m_SearchPath[i] + filename; |
2843 | else |
2844 | FilePath = m_SearchPath[i] + NUX_PATH_SEPARATOR_STRING + filename; |
2845 | |
2846 | |
2847 | - if (GFileManager.FileExist (FilePath.GetTCharPtr() ) ) |
2848 | + if (GFileManager.FileExist (FilePath.c_str() ) ) |
2849 | return FilePath; |
2850 | } |
2851 | |
2852 | @@ -123,27 +124,28 @@ |
2853 | for (size_t i = 0; i < m_SearchPath.size(); i++) |
2854 | { |
2855 | size_t pos; |
2856 | - NString PathName; |
2857 | + std::string PathName; |
2858 | |
2859 | - while (FileName.FindFirstOccurenceOf (TEXT ("\\/") ) != std::string::npos) |
2860 | + while (FileName.find_first_of(TEXT ("\\/")) != std::string::npos) |
2861 | { |
2862 | - pos = FileName.FindFirstOccurenceOf (TEXT ("\\/") ) + 1; |
2863 | - |
2864 | - FileName = FileName.GetSubString (pos, FileName.Length() - pos); |
2865 | - |
2866 | - if ((m_SearchPath[i].GetLastChar () == TEXT('/')) || (m_SearchPath[i].GetLastChar () == TEXT('\\'))) |
2867 | + pos = FileName.find_first_of(TEXT ("\\/")) + 1; |
2868 | + |
2869 | + FileName = FileName.substr(pos, FileName.length() - pos); |
2870 | + |
2871 | + char last = m_SearchPath[i][m_SearchPath[i].size() - 1]; |
2872 | + if (last == TEXT('/') || last == TEXT('\\')) |
2873 | PathName = m_SearchPath[i] + FileName; |
2874 | else |
2875 | PathName = m_SearchPath[i] + NUX_PATH_SEPARATOR_STRING + FileName; |
2876 | |
2877 | |
2878 | - if (GFileManager.FileExist (PathName.GetTCharPtr() ) ) |
2879 | + if (GFileManager.FileExist (PathName.c_str() ) ) |
2880 | return PathName; |
2881 | } |
2882 | } |
2883 | |
2884 | nuxDebugMsg (TEXT ("[FilePath::GetFile] Cannot find file: %s"), filename); |
2885 | - return NString (TEXT ("") ); |
2886 | + return std::string (TEXT ("") ); |
2887 | } |
2888 | |
2889 | } |
2890 | |
2891 | === modified file 'NuxCore/FilePath.h' |
2892 | --- NuxCore/FilePath.h 2011-04-06 21:54:09 +0000 |
2893 | +++ NuxCore/FilePath.h 2012-10-11 16:27:25 +0000 |
2894 | @@ -47,14 +47,14 @@ |
2895 | FilePath(); |
2896 | ~FilePath(); |
2897 | |
2898 | - void AddSearchPath (const NString &searchpath); |
2899 | - void AddSearchPath (const std::vector<NString>& searchpath); |
2900 | + void AddSearchPath (const std::string &searchpath); |
2901 | + void AddSearchPath (const std::vector<std::string>& searchpath); |
2902 | |
2903 | - NString GetPathToFile (const TCHAR *filename) const; |
2904 | - NString GetFile (const TCHAR *filename) const; |
2905 | + std::string GetPathToFile (const TCHAR *filename) const; |
2906 | + std::string GetFile (const TCHAR *filename) const; |
2907 | |
2908 | private: |
2909 | - std::vector<NString> m_SearchPath; |
2910 | + std::vector<std::string> m_SearchPath; |
2911 | }; |
2912 | |
2913 | } |
2914 | |
2915 | === modified file 'NuxCore/NumberConversion.cpp' |
2916 | --- NuxCore/NumberConversion.cpp 2011-10-21 22:06:35 +0000 |
2917 | +++ NuxCore/NumberConversion.cpp 2012-10-11 16:27:25 +0000 |
2918 | @@ -31,7 +31,7 @@ |
2919 | * Written by Lukás Chmela |
2920 | * Released under GPLv3. |
2921 | */ |
2922 | - NString IntegerToChar (int value, int base) |
2923 | + std::string IntegerToChar (int value, int base) |
2924 | { |
2925 | char result[65]; |
2926 | |
2927 | @@ -39,7 +39,7 @@ |
2928 | if (base < 2 || base > 36) |
2929 | { |
2930 | //*result = '\0'; |
2931 | - NString str = TEXT ('\0'); |
2932 | + std::string str = TEXT ('\0'); |
2933 | return str; |
2934 | } |
2935 | |
2936 | @@ -67,16 +67,16 @@ |
2937 | *ptr1++ = tmp_char; |
2938 | } |
2939 | |
2940 | - NString str = result; |
2941 | + std::string str = result; |
2942 | return str; |
2943 | } |
2944 | |
2945 | double CharToDouble (const TCHAR *digit) |
2946 | { |
2947 | char *endptr = NULL; |
2948 | - NString str = TCHAR_TO_ANSICHAR (digit); |
2949 | + std::string str = TCHAR_TO_ANSICHAR (digit); |
2950 | errno = 0; |
2951 | - double ret = std::strtod (str.GetTCharPtr(), &endptr); |
2952 | + double ret = std::strtod (str.c_str(), &endptr); |
2953 | unsigned int error = errno; |
2954 | |
2955 | if (error == ERANGE) |
2956 | @@ -87,13 +87,16 @@ |
2957 | return ret; |
2958 | } |
2959 | |
2960 | - NString DoubleToChar (double d) |
2961 | + std::string DoubleToChar (double d) |
2962 | { |
2963 | TCHAR *buffer = new TCHAR[64]; |
2964 | Memset (buffer, 0, 64); |
2965 | SPRINTF_S (buffer, 64, "%.39f", d); |
2966 | - NString str = buffer; |
2967 | - str = str.TrimRight (TEXT ("0") ); |
2968 | + std::string str = buffer; |
2969 | + while (!str.empty() && str[str.size() - 1] == '0') |
2970 | + { |
2971 | + str.erase(str.end() - 1); |
2972 | + } |
2973 | |
2974 | delete[] buffer; |
2975 | return str; |
2976 | @@ -101,8 +104,8 @@ |
2977 | |
2978 | int CharToInteger (const TCHAR *digit) |
2979 | { |
2980 | - NString str = TCHAR_TO_ANSICHAR (digit); |
2981 | - long long ret = std::atoi (str.GetTCharPtr() ); |
2982 | + std::string str = TCHAR_TO_ANSICHAR (digit); |
2983 | + long long ret = std::atoi (str.c_str() ); |
2984 | return ret; |
2985 | } |
2986 | |
2987 | |
2988 | === modified file 'NuxCore/NumberConversion.h' |
2989 | --- NuxCore/NumberConversion.h 2011-10-21 22:06:35 +0000 |
2990 | +++ NuxCore/NumberConversion.h 2012-10-11 16:27:25 +0000 |
2991 | @@ -26,8 +26,6 @@ |
2992 | namespace nux |
2993 | { |
2994 | |
2995 | - class NString; |
2996 | - |
2997 | //! Convert a TCHAR string to a double value. |
2998 | /*! |
2999 | @param digit A TCHAR string. |
3000 | @@ -35,12 +33,12 @@ |
3001 | */ |
3002 | double CharToDouble (const TCHAR *digit); |
3003 | |
3004 | -//! Convert a double to an NString. |
3005 | +//! Convert a double to an std::string. |
3006 | /*! |
3007 | @param d A double value. |
3008 | - @return An NString. |
3009 | + @return An std::string. |
3010 | */ |
3011 | - NString DoubleToChar (double d); |
3012 | + std::string DoubleToChar (double d); |
3013 | |
3014 | //! Convert a TCHAR string to a 32 bits long value. |
3015 | /*! |
3016 | @@ -55,7 +53,7 @@ |
3017 | @param base Base of the integer representation. |
3018 | @return A string. |
3019 | */ |
3020 | - NString IntegerToChar (int value, int base = 10); |
3021 | + std::string IntegerToChar (int value, int base = 10); |
3022 | |
3023 | //! Convert an string to an integer. |
3024 | /*! |
3025 | |
3026 | === modified file 'NuxCore/NuxCore.cpp' |
3027 | --- NuxCore/NuxCore.cpp 2012-09-26 06:44:12 +0000 |
3028 | +++ NuxCore/NuxCore.cpp 2012-10-11 16:27:25 +0000 |
3029 | @@ -43,13 +43,22 @@ |
3030 | Formatted printing and messages. |
3031 | -----------------------------------------------------------------------------*/ |
3032 | |
3033 | - unsigned int GetVariableArgs ( TCHAR *Dest, unsigned int /* Size */, unsigned int Count, const TCHAR*& Fmt, va_list ArgPtr ) |
3034 | +#if defined(NUX_OS_WINDOWS) |
3035 | + unsigned int GetVariableArgs ( TCHAR *Dest, unsigned int Size, unsigned int Count, const TCHAR*& Fmt, va_list ArgPtr) |
3036 | +#else |
3037 | + unsigned int GetVariableArgs ( TCHAR *Dest, unsigned int /* Size */, unsigned int Count, const TCHAR*& Fmt, va_list ArgPtr) |
3038 | +#endif |
3039 | { |
3040 | unsigned int Result = VSNTPRINTF_S (Dest, Size, Count, Fmt, ArgPtr); |
3041 | va_end (ArgPtr); |
3042 | return Result; |
3043 | } |
3044 | + |
3045 | +#if defined(NUX_OS_WINDOWS) |
3046 | + unsigned int GetVariableArgsAnsi(ANSICHAR *Dest, unsigned int Size, unsigned int Count, const ANSICHAR*& Fmt, va_list ArgPtr) |
3047 | +#else |
3048 | unsigned int GetVariableArgsAnsi ( ANSICHAR *Dest, unsigned int /* Size */, unsigned int Count, const ANSICHAR*& Fmt, va_list ArgPtr) |
3049 | +#endif |
3050 | { |
3051 | unsigned int Result = VSNPRINTF_S (Dest, Size, Count, Fmt, ArgPtr); |
3052 | va_end (ArgPtr); |
3053 | |
3054 | === modified file 'NuxCore/OutputDevice.cpp' |
3055 | --- NuxCore/OutputDevice.cpp 2012-09-26 06:44:12 +0000 |
3056 | +++ NuxCore/OutputDevice.cpp 2012-10-11 16:27:25 +0000 |
3057 | @@ -23,6 +23,9 @@ |
3058 | #include "NuxCore.h" |
3059 | #include "Parsing.h" |
3060 | |
3061 | +#include <sstream> |
3062 | +#include <iomanip> |
3063 | + |
3064 | namespace nux |
3065 | { |
3066 | |
3067 | @@ -38,20 +41,35 @@ |
3068 | // Create string with system time to create a unique filename. |
3069 | unsigned int Year, Month, Day, Hour, Min, Sec, MSec; |
3070 | GetLocalTime (Year, Month, Day, Hour, Min, Sec, MSec); |
3071 | - NString Name, Extension; |
3072 | - NString (Filename).SplitAtLastOccurenceOf (TEXT ("."), Name, Extension); |
3073 | - NString BackupFilename; |
3074 | - |
3075 | - if (Extension.Size() ) |
3076 | + std::string Name, Extension; |
3077 | + std::string file = Filename; |
3078 | + size_t pos = file.rfind('.'); |
3079 | + if (pos != std::string::npos) |
3080 | { |
3081 | - BackupFilename = NString::Printf (TEXT ("%s-backup-%i.%02i.%02i-%02i.%02i.%02i.%s"), Name.GetTCharPtr(), Year, Month, Day, Hour, Min, Sec, Extension.GetTCharPtr() ); |
3082 | + Name = file.substr(0, pos); |
3083 | + Extension = file.substr(pos + 1); |
3084 | } |
3085 | else |
3086 | { |
3087 | - BackupFilename = NString::Printf (TEXT ("%s-backup-%i.%02i.%02i-%02i.%02i.%02i"), Name.GetTCharPtr(), Year, Month, Day, Hour, Min, Sec); |
3088 | - } |
3089 | - |
3090 | - GFileManager.Copy (BackupFilename.GetTCharPtr(), Filename, true, true, NULL); |
3091 | + Name = file; |
3092 | + } |
3093 | + |
3094 | + std::ostringstream s; |
3095 | + s << std::setfill('0') |
3096 | + << Name << "-backup-" << Year << "." |
3097 | + << std::setw(2) << Month << "." |
3098 | + << std::setw(2) << Day << "." |
3099 | + << std::setw(2) << Hour << "." |
3100 | + << std::setw(2) << Min << "." |
3101 | + << std::setw(2) << Sec; |
3102 | + if (Extension.size() ) |
3103 | + { |
3104 | + s << "." << Extension; |
3105 | + } |
3106 | + |
3107 | + std::string BackupFilename = s.str(); |
3108 | + |
3109 | + GFileManager.Copy (BackupFilename.c_str(), Filename, true, true, NULL); |
3110 | } |
3111 | } |
3112 | #endif |
3113 | @@ -142,13 +160,13 @@ |
3114 | // The Editor requires a fully qualified directory to not end up putting the log in various directories. |
3115 | m_Filename = GetProgramDirectory(); |
3116 | |
3117 | - if ( (m_Filename[m_Filename.Size()-1] != NUX_SLASH_CHAR) || (m_Filename[m_Filename.Size()-1] != NUX_BACKSLASH_CHAR) ) |
3118 | + if ( (m_Filename[m_Filename.size()-1] != NUX_SLASH_CHAR) || (m_Filename[m_Filename.size()-1] != NUX_BACKSLASH_CHAR) ) |
3119 | m_Filename += (const TCHAR *) NUX_PATH_SEPARATOR_STRING; |
3120 | |
3121 | m_Filename += GetLogDirectory(); |
3122 | |
3123 | // Create the directory tree where the Logs file will be stored. |
3124 | - GFileManager.MakeDirectory (m_Filename.GetTCharPtr(), 1); |
3125 | + GFileManager.MakeDirectory (m_Filename.c_str(), 1); |
3126 | |
3127 | m_Filename += (const TCHAR *) NUX_PATH_SEPARATOR_STRING; |
3128 | m_Filename += TEXT ("nux"); |
3129 | @@ -157,11 +175,11 @@ |
3130 | // if the file already exists, create a backup as we are going to overwrite it |
3131 | if (!m_Opened) |
3132 | { |
3133 | - CreateBackupCopy (m_Filename.GetTCharPtr() ); |
3134 | + CreateBackupCopy (m_Filename.c_str() ); |
3135 | } |
3136 | |
3137 | // Open log file. |
3138 | - m_LogSerializer = GFileManager.CreateFileWriter (m_Filename.GetTCharPtr(), NSerializer::Read | NSerializer::Write | NSerializer::OverWriteReadOnly | (m_Opened ? NSerializer::Append : 0) ); |
3139 | + m_LogSerializer = GFileManager.CreateFileWriter (m_Filename.c_str(), NSerializer::Read | NSerializer::Write | NSerializer::OverWriteReadOnly | (m_Opened ? NSerializer::Append : 0) ); |
3140 | |
3141 | if (m_LogSerializer) |
3142 | { |
3143 | @@ -169,7 +187,7 @@ |
3144 | #if UNICODE && !NUX_LOG_FILE_ANSI |
3145 | m_LogSerializer->Serialize ( (void *) &NUX_UTF16_BE[1], NUX_UTF16_BE[0] /*size*/ ); |
3146 | #endif |
3147 | - LogFunction (NUX_MSG_SEVERITY_NONE, TEXT ("Log file open, %s"), GetFormattedLocalTime().GetTCharPtr()); |
3148 | + LogFunction (NUX_MSG_SEVERITY_NONE, TEXT ("Log file open, %s"), GetFormattedLocalTime().c_str()); |
3149 | } |
3150 | else |
3151 | { |
3152 | @@ -193,7 +211,7 @@ |
3153 | { |
3154 | if (m_LogSerializer) |
3155 | { |
3156 | - LogFunction (NUX_MSG_SEVERITY_NONE, TEXT ("Log file closed, %s"), GetFormattedLocalTime().GetTCharPtr()); |
3157 | + LogFunction (NUX_MSG_SEVERITY_NONE, TEXT ("Log file closed, %s"), GetFormattedLocalTime().c_str()); |
3158 | Flush(); |
3159 | delete m_LogSerializer; |
3160 | m_LogSerializer = NULL; |
3161 | @@ -249,8 +267,8 @@ |
3162 | |
3163 | m_LogSerializer->Serialize (ACh, i); |
3164 | #else |
3165 | - NString Raw = NString (log_prefix) + NString (TEXT (": ") ) + NString (log_data) + NString (NUX_LINE_TERMINATOR); |
3166 | - SerializeRaw (Raw.GetTCharPtr() ); |
3167 | + std::string Raw = std::string (log_prefix) + std::string (TEXT (": ") ) + std::string (log_data) + std::string (NUX_LINE_TERMINATOR); |
3168 | + SerializeRaw (Raw.c_str() ); |
3169 | #endif |
3170 | } |
3171 | } |
3172 | @@ -336,18 +354,22 @@ |
3173 | @param log_data Text to log. |
3174 | @param log_prefix Prefix for the text |
3175 | */ |
3176 | - void VisualOutputConsole::Serialize (const TCHAR * /* text */, const TCHAR * /* log_prefix */, int /* severity */) |
3177 | +#if defined(NUX_OS_WINDOWS) |
3178 | + void VisualOutputConsole::Serialize(const TCHAR* text, const TCHAR* log_prefix, int severity) |
3179 | { |
3180 | if (!_enabled) |
3181 | return; |
3182 | |
3183 | -#if defined (NUX_OS_WINDOWS) |
3184 | TCHAR Temp[4096]; |
3185 | |
3186 | Snprintf (Temp, 4096, 4096 - 1, TEXT ("%s: %s%s"), log_prefix, text, NUX_LINE_TERMINATOR); |
3187 | OutputDebugString (Temp); |
3188 | + } |
3189 | +#else |
3190 | + void VisualOutputConsole::Serialize(const TCHAR * /* text */, const TCHAR * /* log_prefix */, int /* severity */) |
3191 | + { |
3192 | + } |
3193 | #endif |
3194 | - } |
3195 | |
3196 | void PrintfOutputConsole::Constructor() {} |
3197 | |
3198 | |
3199 | === modified file 'NuxCore/OutputDevice.h' |
3200 | --- NuxCore/OutputDevice.h 2012-09-26 06:44:12 +0000 |
3201 | +++ NuxCore/OutputDevice.h 2012-10-11 16:27:25 +0000 |
3202 | @@ -84,7 +84,7 @@ |
3203 | |
3204 | private: |
3205 | NSerializer *m_LogSerializer; |
3206 | - NString m_Filename; |
3207 | + std::string m_Filename; |
3208 | bool m_Opened; |
3209 | bool m_Closed; |
3210 | |
3211 | |
3212 | === modified file 'NuxCore/Parsing.cpp' |
3213 | --- NuxCore/Parsing.cpp 2012-09-26 06:44:12 +0000 |
3214 | +++ NuxCore/Parsing.cpp 2012-10-11 16:27:25 +0000 |
3215 | @@ -133,7 +133,7 @@ |
3216 | return false; |
3217 | } |
3218 | |
3219 | - bool Parse_string (const TCHAR *Stream, const TCHAR *Match, NString &Value) |
3220 | + bool Parse_string (const TCHAR *Stream, const TCHAR *Match, std::string &Value) |
3221 | { |
3222 | TCHAR Temp[4096] = TEXT (""); |
3223 | |
3224 | @@ -336,9 +336,9 @@ |
3225 | return sz != 0; |
3226 | } |
3227 | |
3228 | - bool ParseToken (const TCHAR *Str, NString &TokenString) |
3229 | + bool ParseToken (const TCHAR *Str, std::string &TokenString) |
3230 | { |
3231 | - TokenString.Clear(); |
3232 | + TokenString.clear(); |
3233 | |
3234 | // Skip spaces and tabs. |
3235 | while (IsWhitespaceChar (*Str) ) |
3236 | @@ -367,10 +367,10 @@ |
3237 | } |
3238 | } |
3239 | |
3240 | - return TokenString.Length() > 0; |
3241 | + return TokenString.length() > 0; |
3242 | } |
3243 | |
3244 | - NString ParseToken (const TCHAR *Str, bool /* UseEscape */) |
3245 | + std::string ParseToken (const TCHAR *Str, bool /* UseEscape */) |
3246 | { |
3247 | TCHAR Buffer[1024]; |
3248 | |
3249 | @@ -398,16 +398,16 @@ |
3250 | return LineBuffer[0] != 0; |
3251 | } |
3252 | |
3253 | - bool ParseLine (const TCHAR **Stream, NString &LineString) |
3254 | + bool ParseLine (const TCHAR **Stream, std::string &LineString) |
3255 | { |
3256 | - LineString.Clear(); |
3257 | + LineString.clear(); |
3258 | |
3259 | while ( (**Stream != 0) && (**Stream != CHAR_NEW_LINE) && (**Stream != CHAR_CR) && (**Stream != CHAR_FF) ) |
3260 | { |
3261 | LineString += **Stream++; |
3262 | } |
3263 | |
3264 | - return LineString.Size() > 0; |
3265 | + return LineString.size() > 0; |
3266 | } |
3267 | |
3268 | } |
3269 | |
3270 | === modified file 'NuxCore/Parsing.h' |
3271 | --- NuxCore/Parsing.h 2011-10-21 22:06:35 +0000 |
3272 | +++ NuxCore/Parsing.h 2012-10-11 16:27:25 +0000 |
3273 | @@ -112,15 +112,15 @@ |
3274 | @return TRUE if the token is found inside the stream. |
3275 | */ |
3276 | bool Parse_int (const TCHAR *Stream, const TCHAR *Match, int &Value); |
3277 | -//! Parse a NString after the named token. |
3278 | +//! Parse a std::string after the named token. |
3279 | /*! |
3280 | - Parse a NString after the named token. |
3281 | + Parse a std::string after the named token. |
3282 | @param Stream Character stream to search. |
3283 | @param Match Token to match. |
3284 | - @param Value parsed NString |
3285 | + @param Value parsed std::string |
3286 | @return TRUE if the token is found inside the stream. |
3287 | */ |
3288 | - bool Parse_string (const TCHAR *Stream, const TCHAR *Match, NString &Value); |
3289 | + bool Parse_string (const TCHAR *Stream, const TCHAR *Match, std::string &Value); |
3290 | //! Parse a QUADWORD after the named token. |
3291 | /*! |
3292 | Parse a QUADWORD after the named token. |
3293 | @@ -168,7 +168,7 @@ |
3294 | If FALSE advanced the pointer past all the CR/LF character at the end of the string. |
3295 | @return True i a line was copied to LineString; |
3296 | */ |
3297 | - bool ParseLine (const TCHAR **Stream, NString &LineString); |
3298 | + bool ParseLine (const TCHAR **Stream, std::string &LineString); |
3299 | |
3300 | //! Parse the next space-delimited string from the input stream. If the next token starts with a quote, gets entire quoted string. |
3301 | /*! |
3302 | @@ -185,14 +185,14 @@ |
3303 | @param TokenBuffer The parsed token string. |
3304 | @return True if a token was found. |
3305 | */ |
3306 | - bool ParseToken (const TCHAR *Str, NString &TokenString); |
3307 | + bool ParseToken (const TCHAR *Str, std::string &TokenString); |
3308 | |
3309 | //! Parse the next space-delimited string from the input stream. If the next token starts with a quote, gets entire quoted string. |
3310 | /*! |
3311 | @param Str stream of characters to parse. |
3312 | - @return The next token in a NString. |
3313 | + @return The next token in a std::string. |
3314 | */ |
3315 | - NString ParseToken (const TCHAR *Str); |
3316 | + std::string ParseToken (const TCHAR *Str); |
3317 | |
3318 | //! Go to the next token in the stream. |
3319 | /*! |
3320 | |
3321 | === modified file 'NuxCore/Platform.cpp' |
3322 | --- NuxCore/Platform.cpp 2012-09-26 06:44:12 +0000 |
3323 | +++ NuxCore/Platform.cpp 2012-10-11 16:27:25 +0000 |
3324 | @@ -60,7 +60,7 @@ |
3325 | |
3326 | } |
3327 | |
3328 | - static NString _GetProgramDirectory() |
3329 | + static std::string _GetProgramDirectory() |
3330 | { |
3331 | #if defined(NUX_OS_WINDOWS) |
3332 | TCHAR RootDirectory[NUX_MAX_FILEPATH_SIZE] = TEXT (""); |
3333 | @@ -71,7 +71,7 @@ |
3334 | nuxAssertMsg (Result, TEXT ("[GetProgramDirectory] Can't get program's directory path.") ); |
3335 | |
3336 | if (Result == 0) |
3337 | - NString (TEXT ("Unknown Program Directory") ); |
3338 | + std::string (TEXT ("Unknown Program Directory") ); |
3339 | |
3340 | unsigned int i; |
3341 | |
3342 | @@ -85,7 +85,7 @@ |
3343 | RootDirectory[i] = 0; |
3344 | } |
3345 | |
3346 | - return NString (RootDirectory); |
3347 | + return std::string (RootDirectory); |
3348 | |
3349 | #elif defined(NUX_OS_LINUX) |
3350 | |
3351 | @@ -97,19 +97,19 @@ |
3352 | nuxAssertMsg (Result, TEXT ("[GetProgramDirectory] Can't get program's directory path.") ); |
3353 | |
3354 | if (Result == 0) |
3355 | - NString (TEXT ("Unknown Program Directory") ); |
3356 | + std::string (TEXT ("Unknown Program Directory") ); |
3357 | |
3358 | } |
3359 | |
3360 | nuxDebugMsg (TEXT ("[GetProgramDirectory] Program directory path: %s"), RootDirectory); |
3361 | - return NString (RootDirectory); |
3362 | + return std::string (RootDirectory); |
3363 | |
3364 | #else |
3365 | - return NString (TEXT ("Unknown Program Directory") ); |
3366 | + return std::string (TEXT ("Unknown Program Directory") ); |
3367 | #endif |
3368 | } |
3369 | |
3370 | - static NString _GetComputerName() |
3371 | + static std::string _GetComputerName() |
3372 | { |
3373 | #if defined(NUX_OS_WINDOWS) |
3374 | TCHAR ComputerName[NUX_MAX_FILEPATH_SIZE] = TEXT (""); |
3375 | @@ -130,7 +130,7 @@ |
3376 | *d++ = 0; |
3377 | } |
3378 | |
3379 | - return NString (ComputerName); |
3380 | + return std::string (ComputerName); |
3381 | |
3382 | #elif defined(NUX_OS_LINUX) |
3383 | char Buffer[NUX_MAX_FILEPATH_SIZE]; |
3384 | @@ -138,18 +138,18 @@ |
3385 | |
3386 | if (gethostname (Buffer, BufferSize) != -1) |
3387 | { |
3388 | - return NString (Buffer); |
3389 | + return std::string (Buffer); |
3390 | } |
3391 | |
3392 | - return NString (TEXT ("Unknown Computer Name") ); |
3393 | + return std::string (TEXT ("Unknown Computer Name") ); |
3394 | |
3395 | #else |
3396 | - return NString (TEXT ("Unknown Computer Name") ); |
3397 | + return std::string (TEXT ("Unknown Computer Name") ); |
3398 | #endif |
3399 | } |
3400 | |
3401 | // Get user name. NOTE: Only one return value is valid at a time! |
3402 | - static NString _GetUserName() |
3403 | + static std::string _GetUserName() |
3404 | { |
3405 | #if defined(NUX_OS_WINDOWS) |
3406 | TCHAR UserName[256] = TEXT (""); |
3407 | @@ -167,19 +167,19 @@ |
3408 | *d++ = 0; |
3409 | } |
3410 | |
3411 | - return NString (UserName); |
3412 | + return std::string (UserName); |
3413 | |
3414 | #elif defined(NUX_OS_LINUX) |
3415 | struct passwd *userinfo; |
3416 | userinfo = getpwuid (getuid() ); |
3417 | |
3418 | if (userinfo == 0) |
3419 | - return NString (TEXT ("Unknown User") ); |
3420 | + return std::string (TEXT ("Unknown User") ); |
3421 | |
3422 | - return NString (userinfo->pw_name); |
3423 | + return std::string (userinfo->pw_name); |
3424 | |
3425 | #else |
3426 | - return return NString (TEXT ("Unknown User") ); |
3427 | + return return std::string (TEXT ("Unknown User") ); |
3428 | #endif |
3429 | } |
3430 | |
3431 | @@ -203,27 +203,27 @@ |
3432 | |
3433 | } |
3434 | |
3435 | - NString GetComputerName() |
3436 | + std::string GetComputerName() |
3437 | { |
3438 | return NUX_GLOBAL_OBJECT_INSTANCE (NGlobalData).m_ComputerName; |
3439 | } |
3440 | |
3441 | - NString GetProgramDirectory() |
3442 | + std::string GetProgramDirectory() |
3443 | { |
3444 | return NUX_GLOBAL_OBJECT_INSTANCE (NGlobalData).m_ProgramDirectory; |
3445 | } |
3446 | |
3447 | - NString GetUserName() |
3448 | + std::string GetUserName() |
3449 | { |
3450 | return NUX_GLOBAL_OBJECT_INSTANCE (NGlobalData).m_UserName; |
3451 | } |
3452 | |
3453 | - NString GetCmdLine() |
3454 | + std::string GetCmdLine() |
3455 | { |
3456 | return NUX_GLOBAL_OBJECT_INSTANCE (NGlobalData).m_CommandLine; |
3457 | } |
3458 | |
3459 | - NString GetLogDirectory() |
3460 | + std::string GetLogDirectory() |
3461 | { |
3462 | return TEXT ("Logs"); |
3463 | } |
3464 | |
3465 | === modified file 'NuxCore/Platform.h' |
3466 | --- NuxCore/Platform.h 2011-10-21 22:06:35 +0000 |
3467 | +++ NuxCore/Platform.h 2012-10-11 16:27:25 +0000 |
3468 | @@ -43,28 +43,28 @@ |
3469 | Get the program command line. |
3470 | @return The program command line. |
3471 | */ |
3472 | - NString GetCmdLine(); |
3473 | + std::string GetCmdLine(); |
3474 | |
3475 | //! Get startup directory. |
3476 | /*! |
3477 | Get startup directory. |
3478 | @return The computer name. |
3479 | */ |
3480 | - NString GetProgramDirectory(); |
3481 | + std::string GetProgramDirectory(); |
3482 | |
3483 | //! Get computer name. |
3484 | /*! |
3485 | Get computer name. |
3486 | @return The computer name. |
3487 | */ |
3488 | - NString GetComputerName(); |
3489 | + std::string GetComputerName(); |
3490 | |
3491 | //! Get user name. |
3492 | /*! |
3493 | Get the user name. |
3494 | @return The user name. |
3495 | */ |
3496 | - NString GetUserName(); |
3497 | + std::string GetUserName(); |
3498 | |
3499 | |
3500 | //! Return the logs directory |
3501 | @@ -74,7 +74,7 @@ |
3502 | |
3503 | @return The logs directory |
3504 | */ |
3505 | - NString GetLogDirectory(); |
3506 | + std::string GetLogDirectory(); |
3507 | |
3508 | class NGlobalData |
3509 | { |
3510 | @@ -84,11 +84,11 @@ |
3511 | void Initialize (const TCHAR *CommandLine); |
3512 | |
3513 | unsigned int m_RandomSeed; |
3514 | - NString m_UserName; |
3515 | - NString m_ComputerName; |
3516 | - NString m_ProgramName; |
3517 | - NString m_ProgramDirectory; |
3518 | - NString m_CommandLine; |
3519 | + std::string m_UserName; |
3520 | + std::string m_ComputerName; |
3521 | + std::string m_ProgramName; |
3522 | + std::string m_ProgramDirectory; |
3523 | + std::string m_CommandLine; |
3524 | }; |
3525 | |
3526 | } |
3527 | |
3528 | === modified file 'NuxCore/Plugin/NPluginManager.cpp' |
3529 | --- NuxCore/Plugin/NPluginManager.cpp 2011-04-06 21:54:09 +0000 |
3530 | +++ NuxCore/Plugin/NPluginManager.cpp 2012-10-11 16:27:25 +0000 |
3531 | @@ -63,7 +63,7 @@ |
3532 | if (! (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) |
3533 | { |
3534 | NFileName FilePath = Path + NUX_PATH_SEPARATOR_STRING + fd.cFileName; |
3535 | - dllHandle = LoadLibrary (FilePath.GetTCharPtr() ); |
3536 | + dllHandle = LoadLibrary (FilePath.c_str() ); |
3537 | |
3538 | if (dllHandle != NULL) |
3539 | { |
3540 | @@ -73,7 +73,7 @@ |
3541 | if (funcHandle != NULL) |
3542 | { |
3543 | NPlugin *curPlugin = new NPlugin(); |
3544 | - curPlugin->SetFileName (FilePath.GetTCharPtr() ); |
3545 | + curPlugin->SetFileName (FilePath.c_str() ); |
3546 | |
3547 | PLUGIN_TEXTFUNC textFunc; |
3548 | textFunc = reinterpret_cast<PLUGIN_TEXTFUNC> (GetProcAddress (dllHandle, "getPluginType") ); |
3549 | |
3550 | === modified file 'NuxCore/Process.cpp' |
3551 | --- NuxCore/Process.cpp 2011-04-06 21:54:09 +0000 |
3552 | +++ NuxCore/Process.cpp 2012-10-11 16:27:25 +0000 |
3553 | @@ -31,13 +31,12 @@ |
3554 | // This is expected to return immediately as the URL is launched by another |
3555 | // task. |
3556 | // |
3557 | - void inlLaunchURL ( const TCHAR *URL, const TCHAR *Parms, NString *Error ) |
3558 | + void inlLaunchURL(const TCHAR *URL, const TCHAR *Parms, std::string Error) |
3559 | { |
3560 | nuxDebugMsg ( TEXT ("LaunchURL %s %s"), URL, Parms ? Parms : TEXT ("") ); |
3561 | HINSTANCE Code = CALL_OS_TCHAR_FUNCTION (ShellExecuteW (NULL, TEXT ("open"), URL, Parms ? Parms : TEXT (""), TEXT (""), SW_SHOWNORMAL), ShellExecuteA (NULL, "open", TCHAR_TO_ANSI (URL), Parms ? TCHAR_TO_ANSI (Parms) : "", "", SW_SHOWNORMAL) ); |
3562 | |
3563 | - if (Error) |
3564 | - *Error = (int) Code <= 32 ? TEXT ("UrlFailed") : TEXT (""); |
3565 | + Error = (int) Code <= 32 ? TEXT ("UrlFailed") : TEXT (""); |
3566 | } |
3567 | |
3568 | // |
3569 | |
3570 | === modified file 'NuxCore/Process.h' |
3571 | --- NuxCore/Process.h 2011-04-06 21:54:09 +0000 |
3572 | +++ NuxCore/Process.h 2012-10-11 16:27:25 +0000 |
3573 | @@ -31,8 +31,8 @@ |
3574 | * Launches a uniform resource locator (i.e. http://www.yahoo.com/finance). |
3575 | * This is expected to return immediately as the URL is launched by another task. |
3576 | */ |
3577 | - void inlLaunchURL ( const TCHAR *URL, const TCHAR *Parms = NULL, NString *Error = NULL ); |
3578 | - void *inlCreateProc ( const TCHAR *URL, const TCHAR *Parms ); |
3579 | + void inlLaunchURL ( const TCHAR* URL, const TCHAR* Parms, std::string Error); |
3580 | + void *inlCreateProc ( const TCHAR* URL, const TCHAR* Parms ); |
3581 | //! Get process termination code of a process |
3582 | BOOL inlGetProcReturnCode ( void *ProcessHandle, INT *ReturnCode ); |
3583 | |
3584 | |
3585 | === modified file 'NuxCore/TextString.cpp' |
3586 | --- NuxCore/TextString.cpp 2012-09-19 04:53:45 +0000 |
3587 | +++ NuxCore/TextString.cpp 2012-10-11 16:27:25 +0000 |
3588 | @@ -35,25 +35,6 @@ |
3589 | return Dest; |
3590 | } |
3591 | |
3592 | -// |
3593 | -// Concatenate a string with length checking |
3594 | -// |
3595 | - TCHAR *Strncat (TCHAR *Dest, size_t Size, const TCHAR *Src, size_t MaxLen) |
3596 | - { |
3597 | - size_t Len = StringLength (Dest); |
3598 | - nuxAssert (Size >= Len); |
3599 | - TCHAR *NewDest = Dest + Len; |
3600 | - |
3601 | - if ( (MaxLen -= Len) > 0) |
3602 | - { |
3603 | - Strncpy (NewDest, Size - Len, Src, MaxLen); |
3604 | - NewDest[MaxLen-1] = 0; |
3605 | - } |
3606 | - |
3607 | - return Dest; |
3608 | - } |
3609 | - |
3610 | - |
3611 | // Search a string inside a string. Return a pointer to the beginning of the searched string if it is found. Else, return NULL; |
3612 | // The shearched string must be preceded by a non alpha numeric character in Str. |
3613 | |
3614 | @@ -91,1256 +72,10 @@ |
3615 | return NULL; |
3616 | } |
3617 | |
3618 | - bool IsLastChar (const TCHAR *CharString, const TCHAR Chr) |
3619 | - { |
3620 | - nuxAssert (CharString != 0); |
3621 | - |
3622 | - if (CharString == 0) |
3623 | - return false; |
3624 | - |
3625 | - size_t Size = StringLength (CharString); |
3626 | - |
3627 | - if (Size == 0) |
3628 | - return false; |
3629 | - |
3630 | - if (CharString[Size-1] == Chr) |
3631 | - return true; |
3632 | - |
3633 | - return false; |
3634 | - } |
3635 | - |
3636 | - NString Itoa (int InNum) |
3637 | - { |
3638 | - SQWORD Num = InNum; // This avoids having to deal with negating -MaxS32 - 1 |
3639 | - NString NumberString; |
3640 | - const TCHAR *NumberChar[10] = { TEXT ("0"), TEXT ("1"), TEXT ("2"), TEXT ("3"), TEXT ("4"), TEXT ("5"), TEXT ("6"), TEXT ("7"), TEXT ("8"), TEXT ("9") }; |
3641 | - bool bIsNumberNegative = false; |
3642 | - |
3643 | - // Correctly handle negative numbers and convert to positive integer. |
3644 | - if (Num < 0) |
3645 | - { |
3646 | - bIsNumberNegative = true; |
3647 | - Num = -Num; |
3648 | - } |
3649 | - |
3650 | - // Convert to string assuming base ten and a positive integer. |
3651 | - do |
3652 | - { |
3653 | - NumberString += NumberChar[Num % 10]; |
3654 | - Num /= 10; |
3655 | - } |
3656 | - while (Num); |
3657 | - |
3658 | - // Append sign as we're going to reverse string afterwards. |
3659 | - if (bIsNumberNegative) |
3660 | - { |
3661 | - NumberString += TEXT ("-"); |
3662 | - } |
3663 | - |
3664 | - NumberString.Reverse(); |
3665 | - return NumberString; |
3666 | - } |
3667 | - |
3668 | -//! Duplicate a null terminated string using new[]. The resulting string is NULL terminated. Use delete[] to destroy. |
3669 | - TCHAR *Strdup (const TCHAR *str) |
3670 | - { |
3671 | - if (str == 0) |
3672 | - return 0; |
3673 | - |
3674 | - size_t len = StringLength (str); |
3675 | - |
3676 | - TCHAR *res = new TCHAR[len+1]; |
3677 | - Strncpy (res, len + 1, str, len); |
3678 | - return res; |
3679 | - } |
3680 | - |
3681 | -//! Duplicate a null terminated ANSICHAR string using new[]. The resulting string is NULL terminated. Use delete[] to destroy. |
3682 | - ANSICHAR *StrdupA ( const ANSICHAR *str) |
3683 | - { |
3684 | - if (str == 0) |
3685 | - return 0; |
3686 | - |
3687 | - int len = (int) strlen (str); |
3688 | - |
3689 | - if (len >= 0) |
3690 | - { |
3691 | - ANSICHAR *res = new ANSICHAR[len+1]; |
3692 | - STRNCPY_S ( (char *) res, len + 1, (const char *) str, len); |
3693 | - return res; |
3694 | - } |
3695 | - |
3696 | - return 0; |
3697 | - } |
3698 | - |
3699 | -//! Duplicate a null terminated UNICHAR string using new[]. The resulting string is NULL terminated. Use delete[] to destroy. |
3700 | - UNICHAR *StrdupU ( const UNICHAR *str) |
3701 | - { |
3702 | - if (str == 0) |
3703 | - return 0; |
3704 | - |
3705 | - int len = (int) wcslen ( (const wchar_t *) str); |
3706 | - |
3707 | - if (len >= 0) |
3708 | - { |
3709 | - UNICHAR *res = new UNICHAR[len+1]; |
3710 | - WCSNCPY_S ( (wchar_t *) res, len + 1, (const wchar_t *) str, len); |
3711 | - return res; |
3712 | - } |
3713 | - |
3714 | - return 0; |
3715 | - } |
3716 | -// /* |
3717 | -// * Standard string formatted print. |
3718 | -// */ |
3719 | -// VARARG_BODY(int, inlSprintf, const TCHAR*, VARARG_EXTRA(TCHAR* Dest)) |
3720 | -// { |
3721 | -// int Result = -1; |
3722 | -// va_list ap; |
3723 | -// va_start(ap, Fmt); |
3724 | -// //@warning: make sure code using inlSprintf allocates enough memory if the below 1024 is ever changed. |
3725 | -// GET_VARARGS_RESULT(Dest,1024/*!!*/,Fmt,Result); |
3726 | -// return Result; |
3727 | -// } |
3728 | - |
3729 | - |
3730 | - size_t ValueToLiteralString (char *buffer, unsigned int len, unsigned short value) |
3731 | - { |
3732 | - return ToCharString (buffer, len, "%hu", value); |
3733 | - } |
3734 | - size_t ValueToLiteralString (char *buffer, unsigned int len, short value) |
3735 | - { |
3736 | - return ToCharString (buffer, len, "%hi", value); |
3737 | - } |
3738 | - size_t ValueToLiteralString (char *buffer, unsigned int len, unsigned int value) |
3739 | - { |
3740 | - return ToCharString (buffer, len, "%lu", value); |
3741 | - } |
3742 | - size_t ValueToLiteralString (char *buffer, unsigned int len, int value) |
3743 | - { |
3744 | - return ToCharString (buffer, len, "%li", value); |
3745 | - } |
3746 | - size_t ValueToLiteralString (char *buffer, unsigned int len, unsigned long value) |
3747 | - { |
3748 | - return ToCharString (buffer, len, "%lu", value); |
3749 | - } |
3750 | - size_t ValueToLiteralString (char *buffer, unsigned int len, long value) |
3751 | - { |
3752 | - return ToCharString (buffer, len, "%li", value); |
3753 | - } |
3754 | - size_t ValueToLiteralString (char *buffer, unsigned int len, unsigned long long value) |
3755 | - { |
3756 | - return ToCharString (buffer, len, "%I64u", value); |
3757 | - } |
3758 | - size_t ValueToLiteralString (char *buffer, unsigned int len, long long value) |
3759 | - { |
3760 | - return ToCharString (buffer, len, "%I64i", value); |
3761 | - } |
3762 | - size_t ValueToLiteralString (char *buffer, unsigned int len, float value) |
3763 | - { |
3764 | - return ToCharString (buffer, len, "%.10g", value); |
3765 | - } |
3766 | - size_t ValueToLiteralString (char *buffer, unsigned int len, double value) |
3767 | - { |
3768 | - return ToCharString (buffer, len, "%.20lg", value); |
3769 | - } |
3770 | - size_t ValueToLiteralString (char *buffer, unsigned int len, unsigned char value) |
3771 | - { |
3772 | - return ValueToLiteralString (buffer, len, (unsigned int) value); |
3773 | - } |
3774 | - size_t ValueToLiteralString (char *buffer, unsigned int len, char value) |
3775 | - { |
3776 | - return ValueToLiteralString (buffer, len, (int) value); |
3777 | - } |
3778 | - |
3779 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, unsigned short &value) |
3780 | - { |
3781 | - return FromCharString (buffer, len, "%hu", value ); |
3782 | - } |
3783 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, short &value) |
3784 | - { |
3785 | - return FromCharString (buffer, len, "%hi", value ); |
3786 | - } |
3787 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, unsigned int &value) |
3788 | - { |
3789 | - return FromCharString (buffer, len, "%lu", value ); |
3790 | - } |
3791 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, int &value) |
3792 | - { |
3793 | - return FromCharString (buffer, len, "%li", value ); |
3794 | - } |
3795 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, unsigned long &value) |
3796 | - { |
3797 | - return FromCharString (buffer, len, "%lu", value ); |
3798 | - } |
3799 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, long &value) |
3800 | - { |
3801 | - return FromCharString (buffer, len, "%li", value ); |
3802 | - } |
3803 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, unsigned long long &value) |
3804 | - { |
3805 | - return FromCharString (buffer, len, "%I64u", value ); |
3806 | - } |
3807 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, long long &value) |
3808 | - { |
3809 | - return FromCharString (buffer, len, "%I64i", value ); |
3810 | - } |
3811 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, float &value) |
3812 | - { |
3813 | - return FromCharString (buffer, len, "%g", value ); |
3814 | - } |
3815 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, double &value) |
3816 | - { |
3817 | - return FromCharString (buffer, len, "%lg", value ); |
3818 | - } |
3819 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, unsigned char &value) |
3820 | - { |
3821 | - unsigned int tmp = 0; |
3822 | - bool result; |
3823 | - result = ValueFromLiteralString (buffer, len, tmp); |
3824 | - value = (unsigned char) tmp; |
3825 | - return result; |
3826 | - } |
3827 | - |
3828 | - bool ValueFromLiteralString (const char *buffer, unsigned int len, char &value) |
3829 | - { |
3830 | - int tmp = 0; |
3831 | - bool result; |
3832 | - result = ValueFromLiteralString (buffer, len, tmp); |
3833 | - value = (char) tmp; |
3834 | - return result; |
3835 | - } |
3836 | - |
3837 | VARARG_BODY (int, Snprintf, const TCHAR *, VARARG_EXTRA (TCHAR *Dest) VARARG_EXTRA (int Size) VARARG_EXTRA (int Count) ) |
3838 | { |
3839 | int Result = -1; |
3840 | GET_VARARGS_RESULT (Dest, Size, Count, Fmt, Result); |
3841 | return Result; |
3842 | } |
3843 | - |
3844 | - NString::NString() |
3845 | - { |
3846 | - m_string = TEXT(""); |
3847 | - } |
3848 | - |
3849 | - NString::NString (const NString &s) |
3850 | - { |
3851 | - m_string = s.m_string; |
3852 | - } |
3853 | - |
3854 | - NString &NString::operator= (const NString &s) |
3855 | - { |
3856 | - m_string = s.m_string; |
3857 | - return *this; |
3858 | - } |
3859 | - |
3860 | - NString::NString (const tstring &s) |
3861 | - { |
3862 | - m_string = s; |
3863 | - } |
3864 | - |
3865 | - NString::NString (const TCHAR &s) |
3866 | - { |
3867 | - m_string = s; |
3868 | - } |
3869 | - |
3870 | - NString::NString (const ANSICHAR *s) |
3871 | - { |
3872 | -#ifdef UNICODE |
3873 | - |
3874 | - if (s == 0) |
3875 | - m_string = TEXT (""); |
3876 | - else |
3877 | - m_string = ANSICHAR_TO_UNICHAR (s); |
3878 | - |
3879 | -#else |
3880 | - |
3881 | - if (s == 0) |
3882 | - m_string = TEXT (""); |
3883 | - else |
3884 | - m_string = s; |
3885 | - |
3886 | -#endif |
3887 | - } |
3888 | - |
3889 | - NString::NString (const UNICHAR *s) |
3890 | - { |
3891 | -#ifdef UNICODE |
3892 | - |
3893 | - if (s == 0) |
3894 | - m_string = TEXT (""); |
3895 | - else |
3896 | - m_string = s; |
3897 | - |
3898 | -#else |
3899 | - |
3900 | - if (s == 0) |
3901 | - m_string = TEXT (""); |
3902 | - else |
3903 | - m_string = UNICHAR_TO_ANSICHAR (s); |
3904 | - |
3905 | -#endif |
3906 | - } |
3907 | - |
3908 | - |
3909 | - NString::~NString() |
3910 | - { |
3911 | - } |
3912 | - |
3913 | - const tstring &NString::GetTStringRef() const |
3914 | - { |
3915 | - return m_string; |
3916 | - } |
3917 | - |
3918 | -//const TCHAR* NString::GetTChar() const |
3919 | -//{ |
3920 | -// return m_string.c_str(); |
3921 | -//} |
3922 | - |
3923 | - const TCHAR *NString::GetTCharPtr() const |
3924 | - { |
3925 | - return m_string.c_str(); |
3926 | - } |
3927 | - |
3928 | - size_t NString::Length() const |
3929 | - { |
3930 | - return m_string.length(); |
3931 | - } |
3932 | - |
3933 | - size_t NString::Size() const |
3934 | - { |
3935 | - return m_string.size(); |
3936 | - } |
3937 | - |
3938 | - void NString::Clear() |
3939 | - { |
3940 | - m_string.clear(); |
3941 | - } |
3942 | - |
3943 | - bool NString::IsEmpty() const |
3944 | - { |
3945 | - return m_string.empty(); |
3946 | - } |
3947 | - |
3948 | - void NString::Erase (size_t Pos, size_t Count) |
3949 | - { |
3950 | - m_string.erase (Pos, Count); |
3951 | - } |
3952 | - |
3953 | - NString &NString::Insert (size_t Pos, const TCHAR *Ptr) |
3954 | - { |
3955 | - m_string.insert (Pos, Ptr); |
3956 | - return *this; |
3957 | - } |
3958 | - |
3959 | - NString &NString::Insert (size_t Pos, const TCHAR *Ptr, size_t Count) |
3960 | - { |
3961 | - m_string.insert (Pos, Ptr, Count); |
3962 | - return *this; |
3963 | - } |
3964 | - |
3965 | - NString &NString::Insert (size_t Pos, const tstring &Str) |
3966 | - { |
3967 | - m_string.insert (Pos, Str); |
3968 | - return *this; |
3969 | - } |
3970 | - |
3971 | - NString &NString::Insert (size_t Pos, const tstring &Str, size_t Offset, size_t Count) |
3972 | - { |
3973 | - m_string.insert (Pos, Str, Offset, Count); |
3974 | - return *this; |
3975 | - } |
3976 | - |
3977 | - NString &NString::Insert (size_t Pos, const NString &Str) |
3978 | - { |
3979 | - m_string.insert (Pos, Str.m_string); |
3980 | - return *this; |
3981 | - } |
3982 | - |
3983 | - NString &NString::Insert (size_t Pos, const NString &Str, size_t Offset, size_t Count) |
3984 | - { |
3985 | - m_string.insert (Pos, Str.m_string, Offset, Count); |
3986 | - return *this; |
3987 | - } |
3988 | - |
3989 | - NString &NString::Insert (size_t Pos, int Count, const TCHAR &Ch) |
3990 | - { |
3991 | - m_string.insert (Pos, Count, Ch); |
3992 | - return *this; |
3993 | - } |
3994 | - |
3995 | - const TCHAR &NString::operator[] (size_t ChPos) const |
3996 | - { |
3997 | - return m_string[ChPos]; |
3998 | - } |
3999 | - |
4000 | - TCHAR &NString::operator[] (size_t ChPos) |
4001 | - { |
4002 | - return m_string[ChPos]; |
4003 | - } |
4004 | - |
4005 | - NString &NString::Replace (size_t Pos1, size_t Num1, const TCHAR *Ptr) |
4006 | - { |
4007 | - m_string.replace (Pos1, Num1, Ptr); |
4008 | - return *this; |
4009 | - } |
4010 | - |
4011 | - NString &NString::Replace (size_t Pos1, size_t Num1, const TCHAR *Ptr, size_t Num2) |
4012 | - { |
4013 | - m_string.replace (Pos1, Num1, Ptr, Num2); |
4014 | - return *this; |
4015 | - } |
4016 | - |
4017 | - NString &NString::Replace (size_t Pos1, size_t Num1, const tstring &Str) |
4018 | - { |
4019 | - m_string.replace (Pos1, Num1, Str); |
4020 | - return *this; |
4021 | - } |
4022 | - |
4023 | - NString &NString::Replace (size_t Pos1, size_t Num1, const tstring &Str, size_t Pos2, size_t Num2) |
4024 | - { |
4025 | - m_string.replace (Pos1, Num1, Str, Pos2, Num2); |
4026 | - return *this; |
4027 | - } |
4028 | - |
4029 | - NString &NString::Replace (size_t Pos1, size_t Num1, const NString &Str) |
4030 | - { |
4031 | - m_string.replace (Pos1, Num1, Str.m_string); |
4032 | - return *this; |
4033 | - } |
4034 | - |
4035 | - NString &NString::Replace (size_t Pos1, size_t Num1, const NString &Str, size_t Pos2, size_t Num2) |
4036 | - { |
4037 | - m_string.replace (Pos1, Num1, Str.m_string, Pos2, Num2); |
4038 | - return *this; |
4039 | - } |
4040 | - |
4041 | - NString &NString::Replace (size_t Pos1, size_t Num1, size_t Count, TCHAR Ch) |
4042 | - { |
4043 | - m_string.replace (Pos1, Num1, Count, Ch); |
4044 | - return *this; |
4045 | - } |
4046 | - |
4047 | - void NString::Reverse() |
4048 | - { |
4049 | - NString rev; |
4050 | - size_t l = Length(); |
4051 | - |
4052 | - for (int i = l - 1; i >= 0; i--) |
4053 | - { |
4054 | - rev += m_string[i]; |
4055 | - } |
4056 | - |
4057 | - (*this) = rev; |
4058 | - } |
4059 | - |
4060 | - NString &NString::SearchAndReplace (TCHAR ChOut, TCHAR ChIn) |
4061 | - { |
4062 | - for (size_t i = 0; i < Length(); i++) |
4063 | - if (m_string[i] == ChOut) |
4064 | - m_string[i] = ChIn; |
4065 | - |
4066 | - return *this; |
4067 | - } |
4068 | - |
4069 | -//! Return The last position of the substring suffix or -1 if it is not found. |
4070 | - size_t NString::FindLastOccurence (const TCHAR &suffix) const |
4071 | - { |
4072 | - size_t start = 0; |
4073 | - size_t pos = 0; |
4074 | - |
4075 | - do |
4076 | - { |
4077 | - pos = m_string.find (suffix, start); |
4078 | - |
4079 | - if (pos != tstring::npos) |
4080 | - start = pos + 1; |
4081 | - } |
4082 | - while (pos != tstring::npos); |
4083 | - |
4084 | - return start - 1; |
4085 | - } |
4086 | - |
4087 | -//! Return The last position of the substring suffix or -1 if it is not found. |
4088 | - size_t NString::FindLastOccurence (const TCHAR *suffix) const |
4089 | - { |
4090 | - size_t start = 0; |
4091 | - size_t pos = 0; |
4092 | - |
4093 | - do |
4094 | - { |
4095 | - pos = m_string.find (suffix, start); |
4096 | - |
4097 | - if (pos != tstring::npos) |
4098 | - start = pos + 1; |
4099 | - } |
4100 | - while (pos != tstring::npos); |
4101 | - |
4102 | - return start - 1; |
4103 | - } |
4104 | - |
4105 | -//! Return The last position of the substring suffix or -1 if it is not found. |
4106 | - size_t NString::FindLastOccurence (const tstring &suffix) const |
4107 | - { |
4108 | - size_t start = 0; |
4109 | - size_t pos = 0; |
4110 | - |
4111 | - do |
4112 | - { |
4113 | - pos = m_string.find (suffix, start); |
4114 | - |
4115 | - if (pos != tstring::npos) |
4116 | - start = pos + 1; |
4117 | - } |
4118 | - while (pos != tstring::npos); |
4119 | - |
4120 | - return start - 1; |
4121 | - } |
4122 | - |
4123 | -//! Return The last position of the substring suffix or -1 if it is not found. |
4124 | - size_t NString::FindLastOccurence (const NString &suffix) const |
4125 | - { |
4126 | - size_t start = 0; |
4127 | - size_t pos = 0; |
4128 | - |
4129 | - do |
4130 | - { |
4131 | - pos = m_string.find (suffix.m_string, start); |
4132 | - |
4133 | - if (pos != tstring::npos) |
4134 | - start = pos + 1; |
4135 | - } |
4136 | - while (pos != tstring::npos); |
4137 | - |
4138 | - return start - 1; |
4139 | - } |
4140 | - |
4141 | - |
4142 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4143 | - size_t NString::FindFirstOccurence (const TCHAR &suffix) const |
4144 | - { |
4145 | - size_t pos = 0; |
4146 | - pos = m_string.find (suffix, pos); |
4147 | - return (pos != tstring::npos) ? pos : -1; |
4148 | - } |
4149 | - |
4150 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4151 | - size_t NString::FindFirstOccurence (const TCHAR *suffix) const |
4152 | - { |
4153 | - size_t pos = 0; |
4154 | - pos = m_string.find (suffix, pos); |
4155 | - return (pos != tstring::npos) ? pos : -1; |
4156 | - } |
4157 | - |
4158 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4159 | - size_t NString::FindFirstOccurence (const tstring &suffix) const |
4160 | - { |
4161 | - size_t pos = 0; |
4162 | - pos = m_string.find (suffix, pos); |
4163 | - return (pos != tstring::npos) ? pos : -1; |
4164 | - } |
4165 | - |
4166 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4167 | - size_t NString::FindFirstOccurence (const NString &suffix) const |
4168 | - { |
4169 | - size_t pos = 0; |
4170 | - pos = m_string.find (suffix.m_string, pos); |
4171 | - return (pos != tstring::npos) ? pos : -1; |
4172 | - } |
4173 | - |
4174 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4175 | - size_t NString::FindNextOccurence (const TCHAR &suffix, size_t start) const |
4176 | - { |
4177 | - size_t pos = 0; |
4178 | - pos = m_string.find (suffix, start); |
4179 | - return (pos != tstring::npos) ? pos : -1; |
4180 | - } |
4181 | - |
4182 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4183 | - size_t NString::FindNextOccurence (const TCHAR *suffix, size_t start) const |
4184 | - { |
4185 | - size_t pos = 0; |
4186 | - pos = m_string.find (suffix, start); |
4187 | - return (pos != tstring::npos) ? pos : -1; |
4188 | - } |
4189 | - |
4190 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4191 | - size_t NString::FindNextOccurence (const tstring &suffix, size_t start) const |
4192 | - { |
4193 | - size_t pos = 0; |
4194 | - pos = m_string.find (suffix, start); |
4195 | - return (pos != tstring::npos) ? pos : -1; |
4196 | - } |
4197 | - |
4198 | -//! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4199 | - size_t NString::FindNextOccurence (const NString &suffix, size_t start) const |
4200 | - { |
4201 | - size_t pos = 0; |
4202 | - pos = m_string.find (suffix.m_string, start); |
4203 | - return (pos != tstring::npos) ? pos : -1; |
4204 | - } |
4205 | - |
4206 | -//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found. |
4207 | - size_t NString::FindFirstOccurenceOf (const TCHAR &str) const |
4208 | - { |
4209 | - size_t pos = 0; |
4210 | - pos = m_string.find_first_of (str, pos); |
4211 | - return (pos != tstring::npos) ? pos : -1; |
4212 | - } |
4213 | -//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found. |
4214 | - size_t NString::FindFirstOccurenceOf (const TCHAR *str) const |
4215 | - { |
4216 | - size_t pos = 0; |
4217 | - pos = m_string.find_first_of (str, pos); |
4218 | - return (pos != tstring::npos) ? pos : -1; |
4219 | - } |
4220 | -//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found. |
4221 | - size_t NString::FindFirstOccurenceOf (const tstring &str) const |
4222 | - { |
4223 | - size_t pos = 0; |
4224 | - pos = m_string.find_first_of (str, pos); |
4225 | - return (pos != tstring::npos) ? pos : -1; |
4226 | - } |
4227 | -//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found. |
4228 | - size_t NString::FindFirstOccurenceOf (const NString &str) const |
4229 | - { |
4230 | - size_t pos = 0; |
4231 | - pos = m_string.find_first_of (str.m_string, pos); |
4232 | - return (pos != tstring::npos) ? pos : -1; |
4233 | - } |
4234 | - |
4235 | -//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found. |
4236 | - size_t NString::FindLastOccurenceOf (const TCHAR &str) const |
4237 | - { |
4238 | - size_t pos = 0; |
4239 | - pos = m_string.find_last_of (str, pos); |
4240 | - return (pos != tstring::npos) ? pos : -1; |
4241 | - } |
4242 | -//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found. |
4243 | - size_t NString::FindLastOccurenceOf (const TCHAR *str) const |
4244 | - { |
4245 | - size_t pos = 0; |
4246 | - pos = m_string.find_last_of (str, pos); |
4247 | - return (pos != tstring::npos) ? pos : -1; |
4248 | - } |
4249 | -//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found. |
4250 | - size_t NString::FindLastOccurenceOf (const tstring &str) const |
4251 | - { |
4252 | - size_t pos = 0; |
4253 | - pos = m_string.find_last_of (str, pos); |
4254 | - return (pos != tstring::npos) ? pos : -1; |
4255 | - } |
4256 | -//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found. |
4257 | - size_t NString::FindLastOccurenceOf (const NString &str) const |
4258 | - { |
4259 | - size_t pos = 0; |
4260 | - pos = m_string.find_last_of (str.m_string, pos); |
4261 | - return (pos != tstring::npos) ? pos : -1; |
4262 | - } |
4263 | - |
4264 | - size_t NString::Find (NString str, int start) |
4265 | - { |
4266 | - size_t pos = m_string.find (str.m_string, start); |
4267 | - return (pos != tstring::npos) ? pos : -1; |
4268 | - } |
4269 | - |
4270 | - size_t NString::Find (TCHAR c, int start) |
4271 | - { |
4272 | - size_t pos = m_string.find (c, start); |
4273 | - return (pos != tstring::npos) ? pos : -1; |
4274 | - } |
4275 | - |
4276 | - bool NString::IsSuffix (const TCHAR &suffix) |
4277 | - { |
4278 | - int l = m_string.length() - 1; |
4279 | - |
4280 | - if (l < 0) |
4281 | - return false; |
4282 | - |
4283 | - size_t pos = FindLastOccurence (suffix); |
4284 | - |
4285 | - if (pos == tstring::npos) |
4286 | - return false; |
4287 | - |
4288 | - return (pos == (size_t)l); |
4289 | - } |
4290 | - |
4291 | - bool NString::IsSuffix (const TCHAR *suffix) |
4292 | - { |
4293 | - size_t sl = StringLength (suffix); |
4294 | - |
4295 | - if (sl == 0) |
4296 | - return false; |
4297 | - |
4298 | - int l = m_string.length() - sl; |
4299 | - |
4300 | - if (l < 0) |
4301 | - return false; |
4302 | - |
4303 | - size_t pos = FindLastOccurence (suffix); |
4304 | - |
4305 | - if (pos == tstring::npos) |
4306 | - return false; |
4307 | - |
4308 | - return (pos == (size_t)l); |
4309 | - } |
4310 | - |
4311 | -//! Return True is the the string is terminated by the tstring 'suffix' |
4312 | - bool NString::IsSuffix (const tstring &suffix) |
4313 | - { |
4314 | - size_t sl = suffix.length(); |
4315 | - |
4316 | - if (sl == 0) |
4317 | - return false; |
4318 | - |
4319 | - int l = m_string.length() - sl; |
4320 | - |
4321 | - if (l < 0) |
4322 | - return false; |
4323 | - |
4324 | - size_t pos = FindLastOccurence (suffix); |
4325 | - |
4326 | - if (pos == tstring::npos) |
4327 | - return false; |
4328 | - |
4329 | - return (pos == (size_t)l); |
4330 | - } |
4331 | - |
4332 | -//! Return True is the the string is terminated by the NString 'suffix' |
4333 | - bool NString::IsSuffix (const NString &suffix) |
4334 | - { |
4335 | - size_t sl = suffix.Length(); |
4336 | - |
4337 | - if (sl == 0) |
4338 | - return false; |
4339 | - |
4340 | - int l = m_string.length() - sl; |
4341 | - |
4342 | - if (l < 0) |
4343 | - return false; |
4344 | - |
4345 | - size_t pos = FindLastOccurence (suffix); |
4346 | - |
4347 | - if (pos == tstring::npos) |
4348 | - return false; |
4349 | - |
4350 | - return (pos == (size_t)l); |
4351 | - } |
4352 | - |
4353 | -//! Return True if the string start with the character contained in prefix |
4354 | - bool NString::IsPrefix (const TCHAR &prefix) |
4355 | - { |
4356 | - int l = m_string.length() - 1; |
4357 | - |
4358 | - if (l < 0) |
4359 | - return false; |
4360 | - |
4361 | - size_t pos = FindFirstOccurence (prefix); |
4362 | - |
4363 | - if (pos == tstring::npos) |
4364 | - return false; |
4365 | - |
4366 | - return (pos == 0); |
4367 | - } |
4368 | - |
4369 | -//! Return True if the string start with the character string contained in prefix |
4370 | - bool NString::IsPrefix (const TCHAR *prefix) |
4371 | - { |
4372 | - size_t sl = StringLength (prefix); |
4373 | - |
4374 | - if (sl == 0) |
4375 | - return false; |
4376 | - |
4377 | - size_t pos = FindFirstOccurence (prefix); |
4378 | - |
4379 | - if (pos == tstring::npos) |
4380 | - return false; |
4381 | - |
4382 | - return (pos == 0); |
4383 | - } |
4384 | - |
4385 | -//! Return True if the string start with the tstring contained in prefix |
4386 | - bool NString::IsPrefix (const tstring &prefix) |
4387 | - { |
4388 | - size_t sl = prefix.length(); |
4389 | - |
4390 | - if (sl == 0) |
4391 | - return false; |
4392 | - |
4393 | - size_t pos = FindFirstOccurence (prefix); |
4394 | - |
4395 | - if (pos == tstring::npos) |
4396 | - return false; |
4397 | - |
4398 | - return (pos == 0); |
4399 | - } |
4400 | -//! Return True if the string start with the NString contained in prefix |
4401 | - bool NString::IsPrefix (const NString &prefix) |
4402 | - { |
4403 | - size_t sl = prefix.Length(); |
4404 | - |
4405 | - if (sl == 0) |
4406 | - return false; |
4407 | - |
4408 | - size_t pos = FindFirstOccurence (prefix); |
4409 | - |
4410 | - if (pos == tstring::npos) |
4411 | - return false; |
4412 | - |
4413 | - return (pos == 0); |
4414 | - } |
4415 | - |
4416 | -//! Return an NString without the character contained in suffix |
4417 | - void NString::RemoveSuffix (const TCHAR &suffix) |
4418 | - { |
4419 | - if (IsSuffix (suffix) ) |
4420 | - { |
4421 | - size_t pos = FindLastOccurence (suffix); |
4422 | - *this = NString (m_string.substr (0, pos) ); |
4423 | - } |
4424 | - } |
4425 | - |
4426 | -//! Return an NString without the character string 'suffix' |
4427 | - void NString::RemoveSuffix (const TCHAR *suffix) |
4428 | - { |
4429 | - if (IsSuffix (suffix) ) |
4430 | - { |
4431 | - size_t pos = FindLastOccurence (suffix); |
4432 | - *this = NString (m_string.substr (0, pos) ); |
4433 | - } |
4434 | - } |
4435 | - |
4436 | -//! Return an NString without the tstring 'suffix' |
4437 | - void NString::RemoveSuffix (const tstring &suffix) |
4438 | - { |
4439 | - if (IsSuffix (suffix) ) |
4440 | - { |
4441 | - size_t pos = FindLastOccurence (suffix); |
4442 | - *this = NString (m_string.substr (0, pos) ); |
4443 | - } |
4444 | - } |
4445 | - |
4446 | -//! Return an NString without the NString 'suffix' |
4447 | - void NString::RemoveSuffix (const NString &suffix) |
4448 | - { |
4449 | - if (IsSuffix (suffix) ) |
4450 | - { |
4451 | - size_t pos = FindLastOccurence (suffix); |
4452 | - *this = NString (m_string.substr (0, pos) ); |
4453 | - } |
4454 | - } |
4455 | - |
4456 | -//! Return an NString striped out of the prefix contained in prefix |
4457 | - void NString::RemovePrefix (const TCHAR &prefix) |
4458 | - { |
4459 | - if (IsPrefix (prefix) ) |
4460 | - { |
4461 | - *this = NString (m_string.substr (1) ); |
4462 | - } |
4463 | - } |
4464 | - |
4465 | -//! Return an NString striped out of the prefix contained in prefix |
4466 | - void NString::RemovePrefix (const TCHAR *prefix) |
4467 | - { |
4468 | - if (IsPrefix (prefix) ) |
4469 | - { |
4470 | - size_t l = StringLength (prefix); |
4471 | - *this = NString (m_string.substr (l) ); |
4472 | - } |
4473 | - } |
4474 | - |
4475 | -//! Return an NString striped out of the prefix contained in prefix |
4476 | - void NString::RemovePrefix (const tstring &prefix) |
4477 | - { |
4478 | - if (IsPrefix (prefix) ) |
4479 | - { |
4480 | - size_t l = prefix.length(); |
4481 | - *this = NString (m_string.substr (l) ); |
4482 | - } |
4483 | - } |
4484 | - |
4485 | -//! Return an NString striped out of the prefix contained in prefix |
4486 | - void NString::RemovePrefix (const NString &prefix) |
4487 | - { |
4488 | - if (IsPrefix (prefix) ) |
4489 | - { |
4490 | - size_t l = prefix.Length(); |
4491 | - *this = NString (m_string.substr (l) ); |
4492 | - } |
4493 | - } |
4494 | - |
4495 | - NString NString::GetSubString (size_t count) const |
4496 | - { |
4497 | - return NString (m_string.substr (0, count) ); |
4498 | - } |
4499 | - |
4500 | - NString NString::GetSubString (size_t start, size_t count) const |
4501 | - { |
4502 | - return NString (m_string.substr (start, count) ); |
4503 | - } |
4504 | - |
4505 | - NString NString::Mid (size_t count) const |
4506 | - { |
4507 | - return GetSubString (count); |
4508 | - } |
4509 | - |
4510 | - NString NString::Mid (size_t start, size_t count) const |
4511 | - { |
4512 | - return GetSubString (start, count); |
4513 | - } |
4514 | - |
4515 | - NString NString::Left (size_t N) const |
4516 | - { |
4517 | - if (N >= Length() ) |
4518 | - return *this; |
4519 | - |
4520 | - return GetSubString (0, N); |
4521 | - } |
4522 | - |
4523 | - NString NString::Right (size_t N) const |
4524 | - { |
4525 | - if (N >= Length() ) |
4526 | - return *this; |
4527 | - |
4528 | - return GetSubString (Length() - N, N); |
4529 | - } |
4530 | - |
4531 | - NString NString::Trim() const |
4532 | - { |
4533 | - return TrimLeft().TrimRight(); |
4534 | - } |
4535 | - |
4536 | - NString NString::TrimLeft() const |
4537 | - { |
4538 | - size_t n = 0; |
4539 | - size_t L = Length() - 1; |
4540 | - |
4541 | - while (n <= L) |
4542 | - { |
4543 | - if (IsWhitespaceChar (m_string[n]) ) |
4544 | - { |
4545 | - n++; |
4546 | - } |
4547 | - else |
4548 | - { |
4549 | - break; |
4550 | - } |
4551 | - } |
4552 | - |
4553 | - return GetSubString (n, Length() - n); |
4554 | - } |
4555 | - |
4556 | - NString NString::TrimRight() const |
4557 | - { |
4558 | - int L = Length() - 1; |
4559 | - |
4560 | - while (0 <= L) |
4561 | - { |
4562 | - if (IsWhitespaceChar (m_string[L]) ) |
4563 | - { |
4564 | - L--; |
4565 | - } |
4566 | - else |
4567 | - { |
4568 | - break; |
4569 | - } |
4570 | - } |
4571 | - |
4572 | - return GetSubString (0, Length() + 1); |
4573 | - } |
4574 | - |
4575 | - NString NString::TrimLeft (NString str) const |
4576 | - { |
4577 | - size_t n = 0; |
4578 | - size_t L = Length(); |
4579 | - |
4580 | - if (L == 0) |
4581 | - return *this; |
4582 | - |
4583 | - while (n < L) |
4584 | - { |
4585 | - bool trim = false; |
4586 | - size_t sz = str.Length(); |
4587 | - |
4588 | - for (size_t i = 0; i < sz; i++) |
4589 | - { |
4590 | - if (m_string[n] == str[i]) |
4591 | - { |
4592 | - trim = true; |
4593 | - break; |
4594 | - } |
4595 | - } |
4596 | - |
4597 | - if (trim) |
4598 | - { |
4599 | - n++; |
4600 | - } |
4601 | - else |
4602 | - { |
4603 | - break; |
4604 | - } |
4605 | - } |
4606 | - |
4607 | - return GetSubString (n, Length() - n); |
4608 | - } |
4609 | - |
4610 | - NString NString::TrimRight (NString str) const |
4611 | - { |
4612 | - int L = Length(); |
4613 | - |
4614 | - if (L == 0) |
4615 | - return *this; |
4616 | - |
4617 | - L = L - 1; |
4618 | - |
4619 | - while (0 <= L) |
4620 | - { |
4621 | - bool trim = false; |
4622 | - size_t sz = str.Length(); |
4623 | - |
4624 | - for (size_t i = 0; i < sz; i++) |
4625 | - { |
4626 | - if (m_string[L] == str[i]) |
4627 | - { |
4628 | - trim = true; |
4629 | - break; |
4630 | - } |
4631 | - } |
4632 | - |
4633 | - if (trim) |
4634 | - { |
4635 | - L--; |
4636 | - } |
4637 | - else |
4638 | - { |
4639 | - break; |
4640 | - } |
4641 | - } |
4642 | - |
4643 | - return GetSubString (0, L + 1); |
4644 | - } |
4645 | - |
4646 | - const TCHAR *NString::operator () () const |
4647 | - { |
4648 | - if (Size() == 0) |
4649 | - return 0; |
4650 | - |
4651 | - return GetTCharPtr(); |
4652 | - } |
4653 | - |
4654 | - const TCHAR *NString::operator * () const |
4655 | - { |
4656 | - if (Size() == 0) |
4657 | - return 0; |
4658 | - |
4659 | - return GetTCharPtr(); |
4660 | - } |
4661 | - |
4662 | -// NString::operator const TCHAR*() const |
4663 | -// { |
4664 | -// return (const TCHAR*)GetTCharPtr(); |
4665 | -// } |
4666 | - |
4667 | - NString &NString::operator += (const TCHAR &sufix) |
4668 | - { |
4669 | - m_string += sufix; |
4670 | - return *this; |
4671 | - } |
4672 | - |
4673 | - NString &NString::operator += (const TCHAR *sufix) |
4674 | - { |
4675 | - m_string += sufix; |
4676 | - return *this; |
4677 | - } |
4678 | - |
4679 | - NString &NString::operator += (const tstring sufix) |
4680 | - { |
4681 | - m_string += sufix; |
4682 | - return *this; |
4683 | - } |
4684 | - |
4685 | - NString &NString::operator += (const NString sufix) |
4686 | - { |
4687 | - m_string += sufix.m_string; |
4688 | - return *this; |
4689 | - } |
4690 | - |
4691 | - void NString::SplitAtFirstOccurenceOf (const TCHAR *SplitString, NString &Left, NString &Right) |
4692 | - { |
4693 | - size_t start = FindFirstOccurence (SplitString); |
4694 | - |
4695 | - if (start != tstring::npos) |
4696 | - { |
4697 | - size_t size = StringLength (SplitString); |
4698 | - Left = GetSubString (0, start); |
4699 | - Right = GetSubString (start + size, Length() - (start + size) ); |
4700 | - } |
4701 | - else |
4702 | - { |
4703 | - Left = *this; |
4704 | - Right = ""; |
4705 | - } |
4706 | - } |
4707 | - |
4708 | - void NString::SplitAtFirstOccurenceOf (const TCHAR &SplitChar, NString &Left, NString &Right) |
4709 | - { |
4710 | - SplitAtFirstOccurenceOf (NString (SplitChar), Left, Right); |
4711 | - } |
4712 | - |
4713 | - void NString::SplitAtFirstOccurenceOf (const NString &SplitString, NString &Left, NString &Right) |
4714 | - { |
4715 | - SplitAtFirstOccurenceOf (SplitString.GetTCharPtr(), Left, Right); |
4716 | - } |
4717 | - |
4718 | - void NString::SplitAtLastOccurenceOf (const TCHAR *SplitString, NString &Left, NString &Right) |
4719 | - { |
4720 | - size_t start = FindLastOccurence (SplitString); |
4721 | - |
4722 | - if (start != tstring::npos) |
4723 | - { |
4724 | - size_t size = StringLength (SplitString); |
4725 | - Left = GetSubString (0, start); |
4726 | - Right = GetSubString (start + size, Length() - (start + size) ); |
4727 | - } |
4728 | - else |
4729 | - { |
4730 | - Left = *this; |
4731 | - Right = ""; |
4732 | - } |
4733 | - } |
4734 | - |
4735 | - void NString::SplitAtLastOccurenceOf (const TCHAR &SplitChar, NString &Left, NString &Right) |
4736 | - { |
4737 | - SplitAtLastOccurenceOf (NString (SplitChar), Left, Right); |
4738 | - } |
4739 | - |
4740 | - void NString::SplitAtLastOccurenceOf (const NString &SplitString, NString &Left, NString &Right) |
4741 | - { |
4742 | - SplitAtLastOccurenceOf (SplitString.GetTCharPtr(), Left, Right); |
4743 | - } |
4744 | - |
4745 | - void NString::ParseToArray (std::vector<NString>& StringArray, const NString &delimiter) |
4746 | - { |
4747 | - NString Left; |
4748 | - NString Right; |
4749 | - NString Temp; |
4750 | - SplitAtFirstOccurenceOf (delimiter, Left, Temp); |
4751 | - |
4752 | - if (Left.Size() ) |
4753 | - { |
4754 | - Left = Left.Trim(); |
4755 | - StringArray.push_back (Left); |
4756 | - } |
4757 | - |
4758 | - Right = Temp; |
4759 | - |
4760 | - while (Right.Size() ) |
4761 | - { |
4762 | - Right.SplitAtFirstOccurenceOf (delimiter, Left, Temp); |
4763 | - |
4764 | - if (Left.Size() ) |
4765 | - { |
4766 | - Left = Left.Trim(); |
4767 | - StringArray.push_back (Left); |
4768 | - } |
4769 | - |
4770 | - Right = Temp; |
4771 | - } |
4772 | - } |
4773 | - |
4774 | - TCHAR NString::GetFirstChar() const |
4775 | - { |
4776 | - if (IsEmpty() ) |
4777 | - return 0; |
4778 | - return m_string[0]; |
4779 | - } |
4780 | - |
4781 | - TCHAR NString::GetLastChar() const |
4782 | - { |
4783 | - if (IsEmpty() ) |
4784 | - return 0; |
4785 | - return m_string[Size()-1]; |
4786 | - } |
4787 | - |
4788 | - bool operator != (const NString &left, const NString &right) |
4789 | - { |
4790 | - return left.m_string != right.m_string; |
4791 | - } |
4792 | - bool operator == (const NString &left, const NString &right) |
4793 | - { |
4794 | - return left.m_string == right.m_string; |
4795 | - } |
4796 | - bool operator < (const NString &left, const NString &right) |
4797 | - { |
4798 | - return left.m_string < right.m_string; |
4799 | - } |
4800 | - bool operator <= (const NString &left, const NString &right) |
4801 | - { |
4802 | - return left.m_string <= right.m_string; |
4803 | - } |
4804 | - bool operator > (const NString &left, const NString &right) |
4805 | - { |
4806 | - return left.m_string > right.m_string; |
4807 | - } |
4808 | - bool operator >= (const NString &left, const NString &right) |
4809 | - { |
4810 | - return left.m_string >= right.m_string; |
4811 | - } |
4812 | - |
4813 | - NString operator+ (const NString &left, const NString &right) |
4814 | - { |
4815 | - return NString (left.m_string + right.m_string); |
4816 | - } |
4817 | - |
4818 | - NString operator+ (const NString &left, const TCHAR *right) |
4819 | - { |
4820 | - return NString (left.m_string + right); |
4821 | - } |
4822 | - |
4823 | - NString operator+ (const NString &left, const TCHAR right) |
4824 | - { |
4825 | - return NString (left.m_string + right); |
4826 | - } |
4827 | - |
4828 | - NString operator+ (const TCHAR *left, const NString &right) |
4829 | - { |
4830 | - return NString (left + right.m_string); |
4831 | - } |
4832 | - |
4833 | - NString operator+ (const TCHAR left, const NString &right) |
4834 | - { |
4835 | - return NString (left + right.m_string); |
4836 | - } |
4837 | - |
4838 | - tostream &operator << (tostream &o, const NString &s) |
4839 | - { |
4840 | - return o << s.m_string; |
4841 | - } |
4842 | - |
4843 | - /*! |
4844 | - Behave like printf. Use an internal buffer of 1024 characters. Do not use this function if you are expecting |
4845 | - the result to be more that 1024-1 characters. |
4846 | - @return A string with formated arguments in a NString. |
4847 | - */ |
4848 | - VARARG_BODY (NString, NString::Printf, const TCHAR *, VARARG_NONE) |
4849 | - { |
4850 | - unsigned int BufferSize = 1024; |
4851 | - TCHAR *Buffer = NULL; |
4852 | - size_t Result = tstring::npos; |
4853 | - |
4854 | - while (Result == tstring::npos) |
4855 | - { |
4856 | - Buffer = (TCHAR *) Realloc (Buffer, BufferSize * sizeof (TCHAR) ); |
4857 | - GET_VARARGS_RESULT (Buffer, BufferSize, BufferSize - 1, Fmt, Result); |
4858 | - BufferSize *= 2; |
4859 | - }; |
4860 | - |
4861 | - Buffer[Result] = 0; |
4862 | - |
4863 | - NString ResultString (Buffer); |
4864 | - |
4865 | - free (Buffer); |
4866 | - |
4867 | - return ResultString; |
4868 | - } |
4869 | - |
4870 | } |
4871 | |
4872 | === modified file 'NuxCore/TextString.h' |
4873 | --- NuxCore/TextString.h 2012-10-01 23:37:25 +0000 |
4874 | +++ NuxCore/TextString.h 2012-10-11 16:27:25 +0000 |
4875 | @@ -28,8 +28,6 @@ |
4876 | namespace nux |
4877 | { |
4878 | |
4879 | - class NString; |
4880 | - |
4881 | class TCharToUpperCase |
4882 | { |
4883 | TCHAR *UpperCaseString; |
4884 | @@ -640,240 +638,6 @@ |
4885 | |
4886 | bool IsLastChar (const TCHAR *CharString, const TCHAR Chr); |
4887 | |
4888 | -// |
4889 | -// Convert an integer to a string. |
4890 | -// |
4891 | - NString Itoa ( int InNum ); |
4892 | - |
4893 | - |
4894 | - |
4895 | - class NString |
4896 | - { |
4897 | - public: |
4898 | - NString(); |
4899 | - NString (const NString &s); |
4900 | - NString (const tstring &s); |
4901 | - NString (const TCHAR &s); |
4902 | - //NString(const TCHAR* s); |
4903 | - NString (const ANSICHAR *s); |
4904 | - NString (const UNICHAR *s); |
4905 | - |
4906 | - ~NString(); |
4907 | - NString &operator= (const NString &s); |
4908 | - |
4909 | - const tstring &GetTStringRef() const; |
4910 | - //const TCHAR* GetTChar() const; |
4911 | - const TCHAR *GetTCharPtr() const; |
4912 | - |
4913 | - size_t Length() const; |
4914 | - size_t Size() const; |
4915 | - void Clear(); |
4916 | - bool IsEmpty() const; |
4917 | - |
4918 | - void Erase (size_t Pos, size_t count); |
4919 | - NString &Insert (size_t Pos, const TCHAR *Ptr); |
4920 | - NString &Insert (size_t Pos, const TCHAR *Ptr, size_t Count); |
4921 | - NString &Insert (size_t Pos, const tstring &Str); |
4922 | - NString &Insert (size_t Pos, const tstring &Str, size_t Offset, size_t Count); |
4923 | - NString &Insert (size_t Pos, const NString &Str); |
4924 | - NString &Insert (size_t Pos, const NString &Str, size_t Offset, size_t Count); |
4925 | - NString &Insert (size_t Pos, int Count, const TCHAR &Ch); |
4926 | - |
4927 | - const TCHAR &operator[] (size_t ChPos) const; |
4928 | - TCHAR &operator[] (size_t ChPos); |
4929 | - |
4930 | - NString &Replace (size_t Pos1, size_t Num1, const TCHAR *Ptr); |
4931 | - NString &Replace (size_t Pos1, size_t Num1, const TCHAR *Ptr, size_t Num2); |
4932 | - NString &Replace (size_t Pos1, size_t Num1, const tstring &Str); |
4933 | - NString &Replace (size_t Pos1, size_t Num1, const tstring &Str, size_t Pos2, size_t Num2); |
4934 | - NString &Replace (size_t Pos1, size_t Num1, const NString &Str); |
4935 | - NString &Replace (size_t Pos1, size_t Num1, const NString &Str, size_t Pos2, size_t Num2); |
4936 | - NString &Replace (size_t Pos1, size_t Num1, size_t Count, TCHAR Ch); |
4937 | - |
4938 | - //! Reverse the string |
4939 | - void Reverse(); |
4940 | - |
4941 | - //! Replace character ChOut with ChIn in the string |
4942 | - NString &SearchAndReplace (TCHAR ChOut, TCHAR ChIn); |
4943 | - |
4944 | - //! Return The last position of the substring suffix or -1 if it is not found. |
4945 | - size_t FindLastOccurence (const TCHAR &suffix) const; |
4946 | - //! Return The last position of the substring suffix or -1 if it is not found. |
4947 | - size_t FindLastOccurence (const TCHAR *suffix) const; |
4948 | - //! Return The last position of the substring suffix or -1 if it is not found. |
4949 | - size_t FindLastOccurence (const tstring &suffix) const; |
4950 | - //! Return The last position of the substring suffix or -1 if it is not found. |
4951 | - size_t FindLastOccurence (const NString &suffix) const; |
4952 | - |
4953 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4954 | - size_t FindFirstOccurence (const TCHAR &suffix) const; |
4955 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4956 | - size_t FindFirstOccurence (const TCHAR *suffix) const; |
4957 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4958 | - size_t FindFirstOccurence (const tstring &suffix) const; |
4959 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4960 | - size_t FindFirstOccurence (const NString &suffix) const; |
4961 | - |
4962 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4963 | - size_t FindNextOccurence (const TCHAR &suffix, size_t start = 0) const; |
4964 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4965 | - size_t FindNextOccurence (const TCHAR *suffix, size_t start = 0) const; |
4966 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4967 | - size_t FindNextOccurence (const tstring &suffix, size_t start = 0) const; |
4968 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4969 | - size_t FindNextOccurence (const NString &suffix, size_t start = 0) const; |
4970 | - |
4971 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4972 | - size_t FindFirstOccurenceOf (const TCHAR &str) const; |
4973 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4974 | - size_t FindFirstOccurenceOf (const TCHAR *str) const; |
4975 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4976 | - size_t FindFirstOccurenceOf (const tstring &str) const; |
4977 | - //! Return the position of the first occurrence of the substring suffix or -1 if it is not found. |
4978 | - size_t FindFirstOccurenceOf (const NString &str) const; |
4979 | - |
4980 | - //! Return the position of the last occurrence of the substring suffix or -1 if it is not found. |
4981 | - size_t FindLastOccurenceOf (const TCHAR &str) const; |
4982 | - //! Return the position of the last occurrence of the substring suffix or -1 if it is not found. |
4983 | - size_t FindLastOccurenceOf (const TCHAR *str) const; |
4984 | - //! Return the position of the last occurrence of the substring suffix or -1 if it is not found. |
4985 | - size_t FindLastOccurenceOf (const tstring &str) const; |
4986 | - //! Return the position of the last occurrence of the substring suffix or -1 if it is not found. |
4987 | - size_t FindLastOccurenceOf (const NString &str) const; |
4988 | - |
4989 | - //! Searches this string for the first match of a substring. |
4990 | - size_t Find (NString str, int start = 0); |
4991 | - //! Searches this string for the first match of a character. |
4992 | - size_t Find (TCHAR c, int start = 0); |
4993 | - |
4994 | - //! Return True if the string is terminated by the character 'suffix' |
4995 | - bool IsSuffix (const TCHAR &suffix); |
4996 | - //! Return True if the string is terminated by the character string 'suffix' |
4997 | - bool IsSuffix (const TCHAR *suffix); |
4998 | - //! Return True if the string is terminated by the tstring 'suffix' |
4999 | - bool IsSuffix (const tstring &suffix); |
5000 | - //! Return True if the string is terminated by the NString 'suffix' |
The diff has been truncated for viewing.
This branch has been replaced with /code.launchpad .net/~unity- team/unity/ unity.nstring- removal/ +merge/ 129234
https:/