OpenASIP  2.0
WxConversion.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2013 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file WxConversion.cc
26  *
27  * Implementation on the WxConversion class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2013
31  * @note rating: red
32  */
33 
34 #include "WxConversion.hh"
35 #include "Conversion.hh"
36 
37 using std::string;
38 
39 /**
40  * Converts an int to a wxString.
41  *
42  * @param source int to convert.
43  * @return The int as a wxString.
44  */
45 wxString
46 WxConversion::toWxString(const int& source) {
47  return wxString((Conversion::toString(source)).c_str(), *wxConvCurrent);
48 }
49 
50 /**
51  * Converts an unsigned int to a wxString.
52  *
53  * @param source unsigned int to convert.
54  * @return The unsigned int as a wxString.
55  */
56 wxString
57 WxConversion::toWxString(const unsigned int& source) {
58  return wxString((Conversion::toString(source)).c_str(), *wxConvCurrent);
59 }
60 
61 /**
62  * Converts an long to a wxString.
63  *
64  * @param source int to convert.
65  * @return The int as a wxString.
66  */
67 wxString
69  return wxString((Conversion::toString(source)).c_str(), *wxConvCurrent);
70 }
71 
72 /**
73  * Converts an unsigned long to a wxString.
74  *
75  * @param source unsigned int to convert.
76  * @return The unsigned int as a wxString.
77  */
78 wxString
80  return wxString((Conversion::toString(source)).c_str(), *wxConvCurrent);
81 }
82 
83 /**
84  * Converts char to a wxString.
85  *
86  * @param source char to convert.
87  * @return The char as a wxString.
88  */
89 wxString
90 WxConversion::toWxString(const char& source) {
91  return wxString((Conversion::toString(source)).c_str(), *wxConvCurrent);
92 }
93 
94 
95 /**
96  * Converts a floating point value to wxString.
97  *
98  * @param source float to convert.
99  * @return The floating point value as a wxString.
100  */
101 wxString
102 WxConversion::toWxString(const float& source) {
103  return wxString((Conversion::toString(source)).c_str(), *wxConvCurrent);
104 }
105 
106 /**
107  * Converts a double precission floating point value to wxString.
108  *
109  * @param source double to convert.
110  * @return The double value as a wxString.
111  */
112 wxString
113 WxConversion::toWxString(const double& source) {
114  return wxString((Conversion::toString(source)).c_str(), *wxConvCurrent);
115 }
116 
117 /**
118  * Converts an wxChar* array (zero terminated strings) to a char* array.
119  *
120  * Assumes the client frees the array after use.
121  */
122 char**
123 WxConversion::toCStringArray(size_t elements, wxChar** source) {
124  char** cstringArray = new char*[elements];
125  for (size_t i = 0; i < elements; ++i) {
126  wxString wxStr(source[i]);
127  cstringArray[i] = new char[wxStr.size()];
128  cstringArray[i] = strndup((const char*)wxStr.mb_str(), wxStr.size());
129  }
130  return cstringArray;
131 }
WxConversion::toWxString
static wxString toWxString(const std::string &source)
Conversion::toString
static std::string toString(const T &source)
Conversion.hh
ULongWord
unsigned long ULongWord
Definition: BaseType.hh:51
WxConversion.hh
SLongWord
long SLongWord
Definition: BaseType.hh:52
WxConversion::toCStringArray
static char ** toCStringArray(size_t elements, wxChar **source)
Definition: WxConversion.cc:123