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