Utils.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 Utils.h
22 
23  \brief This file contains several utility functions for XSD support.
24 */
25 
26 #ifndef __TERRALIB_XSD_INTERNAL_UTILS_H
27 #define __TERRALIB_XSD_INTERNAL_UTILS_H
28 
29 // TerraLib
30 #include "Enums.h"
31 
32 // STL
33 #include <cassert>
34 #include <string>
35 
36 namespace te
37 {
38  namespace xsd
39  {
40  /*!
41  \brief It extracts an integer value that is a combination of: #all|list of (extension|restriction|substitution).
42 
43  \return An integer value that is a combination of: #all|list of (extension|restriction|substitution).
44 
45  \sa DerivationType
46  */
47  inline int ExtractExtension(const char* value)
48  {
49  assert(value);
50 
51  int i = 0;
52 
53 // while we didn't reach the end of the string...
54  while(*value != '\0')
55  {
56  if(strcmp(value, "#all") == 0)
57  return ALL;
58  else if(strcmp(value, "extension") == 0)
59  {
60  value += 9;
61  i |= EXTENSION;
62  }
63  else if(strcmp(value, "restriction") == 0)
64  {
65  value += 11;
66  i |= RESTRICTION;
67  }
68  else if(strcmp(value, "substitution") == 0)
69  {
70  value += 12;
71  i |= SUBSTITUTION;
72  }
73 
74 // skip white spaces
75  while(*value == ' ')
76  ++value;
77  }
78 
79  return i;
80  }
81 
82  } // end namespace xsd
83 } // end namespace te
84 
85 #endif // __TERRALIB_XSD_INTERNAL_XSDUTILS_H
URI C++ Library.
int ExtractExtension(const char *value)
It extracts an integer value that is a combination of: #all|list of (extension|restriction|substituti...
Definition: Utils.h:47