Loading...
Searching...
No Matches
FieldNameValidator.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/dataaccess/utils/FieldNameValidator.h
22
23 \brief This class is responsible for validating field names. It can handle size limits, fix special characters changes the form 'tableName.propertyName' into the form 'tableName_propertyName'
24 */
25
26#ifndef __TERRALIB_DATAACCESS_INTERNAL_FIELDNAMEVALIDATOR_H
27#define __TERRALIB_DATAACCESS_INTERNAL_FIELDNAMEVALIDATOR_H
28
29#include "../Config.h"
30
31#include <set>
32#include <string>
33#include <vector>
34
35namespace te
36{
37 namespace da
38 {
39 /*!
40 \class FieldNameValidator
41
42 \brief This class is responsible for validating field names. It can handle size limits, fix special characters changes the form 'tableName.propertyName' into the form 'tableName_propertyName'
43
44 */
46 {
47 public:
48
49 FieldNameValidator(int fieldNameMaxSize, bool replaceDotForUnderline, bool replaceSpecialChars);
50
51 static std::string adjustFieldNameMaxSize(const std::string& fieldName, int fieldNameMaxSize);
52 static std::string replaceDotForUnderline(const std::string& fieldName);
53 static std::string replaceSpecialCharacters(const std::string& fieldName);
54
55 bool addFieldName(const std::string& fieldName);
56 bool addFieldName(const std::string& fieldName, std::string& adjustedFieldName);
57
58 bool exists(const std::string& fieldName) const;
59
60 const std::vector<std::string>& getAdjustedNames() const;
61
62 protected:
63
64 int m_fieldNameMaxSize; //!< The field name maximum size. -1 means no limit
65 bool m_replaceDotForUnderline; //!< If TRUE, all 'dots' characters present in a "table.property" format will be replaced by an underline character
66 bool m_replaceSpecialChars; //!< If TRUE, the special chars will be replaced
67 std::vector<std::string> m_vecAdjustedNames; //!< Internal vector containing the ajusted (or the original if no adjustment hasbeen needed) names
68 std::set<std::string> m_setAdjustedNames; //!< Internal set used to make a fast check to make sure there arent repeated field names
69 };
70 } //end namespace ogr
71} //end namespace te
72
73#endif // __TERRALIB_DATAACCESS_INTERNAL_FIELDNAMEVALIDATOR_H
This class is responsible for validating field names. It can handle size limits, fix special characte...
const std::vector< std::string > & getAdjustedNames() const
bool addFieldName(const std::string &fieldName, std::string &adjustedFieldName)
bool m_replaceDotForUnderline
If TRUE, all 'dots' characters present in a "table.property" format will be replaced by an underline ...
std::vector< std::string > m_vecAdjustedNames
Internal vector containing the ajusted (or the original if no adjustment hasbeen needed) names.
bool exists(const std::string &fieldName) const
bool addFieldName(const std::string &fieldName)
static std::string adjustFieldNameMaxSize(const std::string &fieldName, int fieldNameMaxSize)
static std::string replaceSpecialCharacters(const std::string &fieldName)
std::set< std::string > m_setAdjustedNames
Internal set used to make a fast check to make sure there arent repeated field names.
FieldNameValidator(int fieldNameMaxSize, bool replaceDotForUnderline, bool replaceSpecialChars)
bool m_replaceSpecialChars
If TRUE, the special chars will be replaced.
static std::string replaceDotForUnderline(const std::string &fieldName)
int m_fieldNameMaxSize
The field name maximum size. -1 means no limit.
TerraLib.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97