StringProperty.h
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/StringProperty.h
22 
23  \brief The type for string types: FIXED_STRING, VAR_STRING or STRING.
24 */
25 
26 #ifndef __TERRALIB_DATATYPE_INTERNAL_STRINGPROPERTY_H
27 #define __TERRALIB_DATATYPE_INTERNAL_STRINGPROPERTY_H
28 
29 // TerraLib
30 #include "../common/CharEncodingConv.h"
31 #include "Enums.h"
32 #include "SimpleProperty.h"
33 
34 namespace te
35 {
36  namespace dt
37  {
38  /*!
39  \class StringProperty
40 
41  \brief The type for string types: FIXED_STRING, VAR_STRING or STRING.
42 
43  \ingroup datatype
44 
45  \sa SimpleProperty, Property, NumericProperty, ArrayProperty, DateTimeProperty, CompositeProperty
46  */
48  {
49  public:
50 
51  /*!
52  \brief It constructs a new string property.
53 
54  \param name The attribute name.
55  \param strType The string subtype. Must be one of: FIXED_STRING, VAR_STRING, or STRING.
56  \param size The maximum size (or 0 for unlimited strings).
57  \param isRequired It indicates if the the property is required (mandatory) or not.
58  \param defaultValue The default value to be used, if none is informed.
59  \param id The property identifier.
60  \param parent A reference to the parent Property of the new object if it has one.
61 
62  \post The string property will take the ownership of the defaultValue.
63 
64  \warning The identifier value (id) may be used by data source implementations. So, don't rely on its value!
65  */
66  StringProperty(const std::string& name,
67  StringType strType = STRING,
68  std::size_t size = 0,
69  bool isRequired = false,
70  std::string* defaultValue = 0,
71  unsigned int id = 0,
72  Property* parent = 0);
73 
74  /*!
75  \brief Copy constructor.
76 
77  \param rhs The right-hand-side copy used to copy from.
78 
79  \note This method is used by clone().
80  */
81  StringProperty(const StringProperty& rhs);
82 
83  /*! \brief Destructor. */
85 
86  /*!
87  \brief Assignment operator.
88 
89  \param rhs The right-hand-side copy used to copy from.
90 
91  \return A reference to this object.
92  */
93  StringProperty& operator=(const StringProperty& rhs);
94 
95  /*!
96  \brief It returns the string property sub type.
97 
98  \return The string property sub type.
99  */
100  StringType getSubType() const { return m_strSubType; }
101 
102  /*!
103  \brief It sets the string property sub type.
104 
105  \param t The string property sub type.
106  */
107  void setSubtype(StringType t) { m_strSubType = t; }
108 
109  /*!
110  \brief It returns the maximum number of characters for a varying string, or the number of characters for a fixed length string. No meaning for STRING.
111 
112  \return The maximum number of characters for a varying string, or the number of characters for a fixed length string. No meaning for STRING.
113  */
114  std::size_t size() const { return m_size; }
115 
116  /*!
117  \brief It sets the maximum number of characters for a varying string, or the number of characters for a fixed length string.
118 
119  This value has no meaning for a STRING.
120 
121  \param size The maximum size.
122  */
123  void setSize(std::size_t s) { m_size = s; }
124 
125  /*!
126  \brief It returns the string property character encoding.
127 
128  \return The string property character encoding.
129  */
130  te::common::CharEncoding getCharEncoding() const { return m_ce; }
131 
132  /*!
133  \brief It sets the string property character encoding.
134 
135  \param ce The character encoding type.
136  */
137  void setCharEncoding(const te::common::CharEncoding& ce) { m_ce = ce; }
138 
139  /*!
140  \brief It returns a clone of the object.
141 
142  The new property will NOT have associations to other properties.
143 
144  \return A clone of the object.
145  */
146  Property* clone() const;
147 
148  protected:
149 
150  std::size_t m_size; //!< Maximum number of characters for a varying string or the number of characters for a fixed length string. No meaning for STRING.
151  StringType m_strSubType; //!< The sub-type of this string property.
152  te::common::CharEncoding m_ce; //!< The string property character encoding.
153  };
154 
155  } // end namespace dt
156 } // end namespace te
157 
158 #endif // __TERRALIB_DATATYPE_INTERNAL_STRINGPROPERTY_H
159 
StringType
The subtype of string property.
Definition: Enums.h:171
std::size_t m_size
Maximum number of characters for a varying string or the number of characters for a fixed length stri...
te::common::CharEncoding getCharEncoding() const
It returns the string property character encoding.
An atomic property like an integer or double.
CharEncoding
Supported charsets (character encoding).
StringType getSubType() const
It returns the string property sub type.
void setSubtype(StringType t)
It sets the string property sub type.
StringType m_strSubType
The sub-type of this string property.
void setSize(std::size_t s)
It sets the maximum number of characters for a varying string, or the number of characters for a fixe...
std::size_t size() const
It returns the maximum number of characters for a varying string, or the number of characters for a f...
It models a property definition.
Definition: Property.h:59
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
URI C++ Library.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
An atomic property like an integer or double.
General enumerations for the data type module.
void setCharEncoding(const te::common::CharEncoding &ce)
It sets the string property character encoding.
~StringProperty()
Destructor.
te::common::CharEncoding m_ce
The string property character encoding.