All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/datatype/Utils.cpp
22 
23  \brief Utilitary function for data type module.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "CompositeProperty.h"
29 #include "Property.h"
30 #include "Utils.h"
31 
32 void te::dt::GetPropertiesPosition(const std::vector<Property*>& properties,
33  const CompositeProperty* cp,
34  std::vector<std::size_t>& poslist)
35 {
36  const std::size_t size = properties.size();
37 
38  for(std::size_t i = 0; i < size; ++i)
39  poslist.push_back(cp->getPropertyPosition(properties[i]));
40 }
41 
42 int te::dt::Convert2Terralib(const std::string& dataType)
43 {
44  if(dataType == "VOID_TYPE")
45  return te::dt::VOID_TYPE;
46  else if(dataType == "BIT_TYPE")
47  return te::dt::BIT_TYPE;
48  else if(dataType == "CHAR_TYPE")
49  return te::dt::CHAR_TYPE;
50  else if(dataType == "UCHAR_TYPE")
51  return te::dt::UCHAR_TYPE;
52  else if(dataType == "INT16_TYPE")
53  return te::dt::INT16_TYPE;
54  else if(dataType == "INT32_TYPE")
55  return te::dt::INT32_TYPE;
56  else if(dataType == "UINT32_TYPE")
57  return te::dt::UINT32_TYPE;
58  else if(dataType == "INT64_TYPE")
59  return te::dt::INT64_TYPE;
60  else if(dataType == "UINT16_TYPE")
61  return te::dt::UINT16_TYPE;
62  else if(dataType == "UINT64_TYPE")
63  return te::dt::UINT64_TYPE;
64  else if(dataType == "BOOLEAN_TYPE")
65  return te::dt::BOOLEAN_TYPE;
66  else if(dataType == "FLOAT_TYPE")
67  return te::dt::FLOAT_TYPE;
68  else if(dataType == "DOUBLE_TYPE")
69  return te::dt::DOUBLE_TYPE;
70  else if(dataType == "NUMERIC_TYPE")
71  return te::dt::NUMERIC_TYPE;
72  else if(dataType == "STRING_TYPE")
73  return te::dt::STRING_TYPE;
74  else if(dataType == "BYTE_ARRAY_TYPE")
76  else if(dataType == "GEOMETRY_TYPE")
77  return te::dt::GEOMETRY_TYPE;
78  else if(dataType == "DATETIME_TYPE")
79  return te::dt::DATETIME_TYPE;
80  else if(dataType == "ARRAY_TYPE")
81  return te::dt::ARRAY_TYPE;
82  else if(dataType == "COMPOSITE_TYPE")
84  else if(dataType == "DATASET_TYPE")
85  return te::dt::DATASET_TYPE;
86  else if(dataType == "RASTER_TYPE")
87  return te::dt::RASTER_TYPE;
88  else if(dataType == "CINT16_TYPE")
89  return te::dt::CINT16_TYPE;
90  else if(dataType == "CINT32_TYPE")
91  return te::dt::CINT32_TYPE;
92  else if(dataType == "CFLOAT_TYPE")
93  return te::dt::CFLOAT_TYPE;
94  else if(dataType == "CDOUBLE_TYPE")
95  return te::dt::CDOUBLE_TYPE;
96  else if(dataType == "XML_TYPE")
97  return te::dt::XML_TYPE;
98  else if(dataType == "DATASETITEM_TYPE")
100  else if(dataType == "POLYMORPHIC_TYPE")
102  else if(dataType == "R4BITS_TYPE")
103  return te::dt::R4BITS_TYPE;
104  else if(dataType == "R2BITS_TYPE")
105  return te::dt::R2BITS_TYPE;
106  else if(dataType == "R1BIT_TYPE")
107  return te::dt::R1BIT_TYPE;
108  else
109  return te::dt::UNKNOWN_TYPE;
110 }
111 
112 std::string te::dt::ConvertDataTypeToString(const int& dataType)
113 {
114  if(dataType == te::dt::VOID_TYPE)
115  return TE_TR("Void");
116  else if(dataType == te::dt::BIT_TYPE)
117  return TE_TR("Bit");
118  else if(dataType == te::dt::CHAR_TYPE)
119  return TE_TR("Char");
120  else if(dataType == te::dt::UCHAR_TYPE)
121  return TE_TR("Unsigned Char");
122  else if(dataType == te::dt::INT16_TYPE)
123  return TE_TR("Integer 16");
124  else if(dataType == te::dt::INT32_TYPE)
125  return TE_TR("Integer 32");
126  else if(dataType == te::dt::UINT32_TYPE)
127  return TE_TR("Unsigned Integer 32");
128  else if(dataType == te::dt::INT64_TYPE)
129  return TE_TR("Integer 64");
130  else if(dataType == te::dt::UINT16_TYPE)
131  return TE_TR("Unsigned Integer 16");
132  else if(dataType == te::dt::UINT64_TYPE)
133  return TE_TR("Unsigned Integer 64");
134  else if(dataType == te::dt::BOOLEAN_TYPE)
135  return TE_TR("Boolean");
136  else if(dataType == te::dt::FLOAT_TYPE)
137  return TE_TR("Float");
138  else if(dataType == te::dt::DOUBLE_TYPE)
139  return TE_TR("Double");
140  else if(dataType == te::dt::NUMERIC_TYPE)
141  return TE_TR("Numeric");
142  else if(dataType == te::dt::STRING_TYPE)
143  return TE_TR("String");
144  else if(dataType == te::dt::BYTE_ARRAY_TYPE)
145  return TE_TR("Byte Array");
146  else if(dataType == te::dt::GEOMETRY_TYPE)
147  return TE_TR("Geometry");
148  else if(dataType == te::dt::DATETIME_TYPE)
149  return TE_TR("Date Time");
150  else if(dataType == te::dt::ARRAY_TYPE)
151  return TE_TR("Array");
152  else if(dataType == te::dt::COMPOSITE_TYPE)
153  return TE_TR("Composite");
154  else if(dataType == te::dt::DATASET_TYPE)
155  return TE_TR("Dataset");
156  else if(dataType == te::dt::RASTER_TYPE)
157  return TE_TR("Raster");
158  else if(dataType == te::dt::CINT16_TYPE)
159  return TE_TR("Complex Integer 16");
160  else if(dataType == te::dt::CINT32_TYPE)
161  return TE_TR("Complex Integer 32");
162  else if(dataType == te::dt::CFLOAT_TYPE)
163  return TE_TR("Complex Float");
164  else if(dataType == te::dt::CDOUBLE_TYPE)
165  return TE_TR("Complex Double");
166  else if(dataType == te::dt::XML_TYPE)
167  return TE_TR("XML");
168  else if(dataType == te::dt::DATASETITEM_TYPE)
169  return TE_TR("Dataset Item");
170  else if(dataType == te::dt::POLYMORPHIC_TYPE)
171  return TE_TR("Polymorphic");
172  else if(dataType == te::dt::R4BITS_TYPE)
173  return TE_TR("Raster 4 Bits");
174  else if(dataType == te::dt::R2BITS_TYPE)
175  return TE_TR("Raster 2 Bits");
176  else if(dataType == te::dt::R1BIT_TYPE)
177  return TE_TR("Raster 1 Bit");
178  else
179  return TE_TR("Unknown");
180 }
TEDATATYPEEXPORT std::string ConvertDataTypeToString(const int &dataType)
Function used to convert from a int (Data Type Enum) to a string.
Definition: Utils.cpp:112
A base class for a compound property (non-atomic properties).
A base class for a compound properties (non-atomic properties).
Utilitary function for data type module.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
TEDATATYPEEXPORT void GetPropertiesPosition(const std::vector< Property * > &properties, const CompositeProperty *cp, std::vector< std::size_t > &poslist)
It creates a list with the properties position in the composite property.
Definition: Utils.cpp:32
std::size_t getPropertyPosition(const std::string &name) const
It returns the property position based on its name.
It models a property definition.
TEDATATYPEEXPORT int Convert2Terralib(const std::string &dataType)
It convert a string to a DataType.
Definition: Utils.cpp:42