Loading...
Searching...
No Matches
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 "../core/encoding/CharEncoding.h"
31#include "Enums.h"
32#include "SimpleProperty.h"
33
34namespace 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 */
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 */
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 a clone of the object.
127
128 The new property will NOT have associations to other properties.
129
130 \return A clone of the object.
131 */
132 Property* clone() const;
133
134 protected:
135
136 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.
137 StringType m_strSubType; //!< The sub-type of this string property.
138 };
139
140 } // end namespace dt
141} // end namespace te
142
143#endif // __TERRALIB_DATATYPE_INTERNAL_STRINGPROPERTY_H
144
An atomic property like an integer or double.
It models a property definition.
Definition: Property.h:60
An atomic property like an integer or double.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
Property * clone() const
It returns a clone of the object.
StringProperty(const std::string &name, StringType strType=STRING, std::size_t size=0, bool isRequired=false, std::string *defaultValue=0, unsigned int id=0, Property *parent=0)
It constructs a new string property.
~StringProperty()
Destructor.
StringType m_strSubType
The sub-type of this string property.
void setSubtype(StringType t)
It sets the string property sub type.
StringProperty & operator=(const StringProperty &rhs)
Assignment operator.
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 m_size
Maximum number of characters for a varying string or the number of characters for a fixed length stri...
StringType getSubType() const
It returns the string property sub type.
std::size_t size() const
It returns the maximum number of characters for a varying string, or the number of characters for a f...
StringProperty(const StringProperty &rhs)
Copy constructor.
StringType
The subtype of string property.
Definition: Enums.h:172
TerraLib.
#define TEDATATYPEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:61
Enumerations of XML module.