Utils.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled applications.
5 
6  TerraLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License,
9  or (at your option) any later version.
10 
11  TerraLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with TerraLib. See COPYING. If not, write to
18  TerraLib Team at <terralib-team@terralib.org>.
19  */
20 
21  /*!
22  \file terralib/core/uri/Utils.h
23 
24  \brief This file contains utility functions used to manipulate data from a URI.
25 
26  \author Andre Gomes de Oliveira
27  \author Gilberto Ribeiro de Queiroz
28 */
29 
30 #ifndef __TERRALIB_CORE_UTILS_URI_H__
31 #define __TERRALIB_CORE_UTILS_URI_H__
32 
33 // TerraLib
34 #include "../Config.h"
35 
36 // STL
37 #include <map>
38 #include <string>
39 
40 namespace te
41 {
42  namespace core
43  {
44  /*!
45  \brief Split a query string into its components
46 
47  \param query_str The query string that will have the data extracted.
48 
49  \exception Exception An exception can be thrown, if a parser error occurs during decomposition of the query string.
50 
51  \return A container with the key-value pairs extracted from the query string.
52  */
53  TECOREEXPORT std::map<std::string, std::string> Expand(const std::string& query_str);
54 
55  /*!
56  \brief Decodes an encoded URI. The algorithm implementation is based on
57  http://www.codeguru.com/cpp/cpp/algorithms/strings/article.php/c12759/URI-Encoding-and-Decoding.htm
58 
59  \param srcUri URI to be decoded
60 
61  \return A string with decoded URI.
62  */
63  TECOREEXPORT std::string URIDecode(const std::string& srcUri);
64 
65  /*!
66  \brief Encodes an decoded URI. The algorithm implementation is based on
67  http://www.codeguru.com/cpp/cpp/algorithms/strings/article.php/c12759/URI-Encoding-and-Decoding.htm
68 
69  \param srcUri URI to be encoded
70 
71  \return A string with encoded URI.
72  */
73  TECOREEXPORT std::string URIEncode(const std::string& srcUri);
74 
75  /*!
76  \brief Sets the given key and value to the given URI.
77  If the key already exists, it will be replaced.
78  If the key does not exists, it will be added
79 
80  \param srcUri The input URI
81  \param key The key to be added or replaced
82  \param value The new value
83 
84  \return A string with the adjusted URI.
85  */
86  TECOREEXPORT std::string SetURIParameter(const std::string& srcUri, const std::string& key, const std::string& value);
87  }
88 }
89 #endif //__TERRALIB_CORE_UTILS_URI_H__
TECOREEXPORT std::map< std::string, std::string > Expand(const std::string &query_str)
Split a query string into its components.
TECOREEXPORT std::string URIDecode(const std::string &srcUri)
Decodes an encoded URI. The algorithm implementation is based on http://www.codeguru....
TECOREEXPORT std::string SetURIParameter(const std::string &srcUri, const std::string &key, const std::string &value)
Sets the given key and value to the given URI. If the key already exists, it will be replaced....
TECOREEXPORT std::string URIEncode(const std::string &srcUri)
Encodes an decoded URI. The algorithm implementation is based on http://www.codeguru....
TerraLib.
#define TECOREEXPORT
Definition: Config.h:52