GammaLib 2.0.0
Loading...
Searching...
No Matches
GUrlString.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GUrlString.hpp - String URL class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2013-2014 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GUrlString.hpp
23 * @brief String URL class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GURLSTRING_HPP
28#define GURLSTRING_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GUrl.hpp"
33
34
35/***********************************************************************//**
36 * @class GUrlString
37 *
38 * @brief String URL class
39 *
40 * This class implements the URL interface for a string.
41 ***************************************************************************/
42class GUrlString : public GUrl {
43
44public:
45 // Constructors and destructors
46 GUrlString(void);
47 GUrlString(const std::string& string);
48 GUrlString(const GUrlString& url);
49 virtual ~GUrlString(void);
50
51 // Operators
52 GUrlString& operator=(const GUrlString& url);
53
54 // Implemented pure virtual base class methods
55 virtual void clear(void);
56 virtual GUrlString* clone(void) const;
57 virtual std::string classname(void) const;
58 virtual void open(const std::string& string, const std::string& mode = "");
59 virtual void close(void);
60 virtual int read(void* buffer, const int& nbyte);
61 virtual int write(const void* buffer, const int& nbyte);
62 virtual int get_char(void) const;
63 virtual void put_char(const int& character);
64 virtual void scanf(const char* format, ...);
65 virtual void printf(const char* format, ...);
66 virtual std::string print(const GChatter& chatter = NORMAL) const;
67
68 // Other methods
69 const std::string& string(void) const { return m_buffer; }
70 void rewind(void) { m_index=0; }
71
72protected:
73 // Protected methods
74 void init_members(void);
75 void copy_members(const GUrlString& url);
76 void free_members(void);
77
78 // Protected members
79 mutable int m_index; //!< String position indicator
80 std::string m_buffer; //!< Text string
81};
82
83
84/***********************************************************************//**
85 * @brief Return class name
86 *
87 * @return String containing the class name ("GUrlString").
88 ***************************************************************************/
89inline
90std::string GUrlString::classname(void) const
91{
92 return ("GUrlString");
93}
94
95#endif /* GURLSTRING_HPP */
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Abstract URL base class interface definition.
String URL class.
virtual int read(void *buffer, const int &nbyte)
Read block of data from string buffer.
virtual void close(void)
Close file.
virtual void open(const std::string &string, const std::string &mode="")
Open string URL.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print URL information.
virtual void printf(const char *format,...)
Write formatted data into string.
virtual int get_char(void) const
Return next character from string.
virtual ~GUrlString(void)
Destructor.
void init_members(void)
Initialise class members.
virtual std::string classname(void) const
Return class name.
virtual void clear(void)
Clear string URL.
const std::string & string(void) const
void copy_members(const GUrlString &url)
Copy class members.
virtual void scanf(const char *format,...)
Read formatted data from string.
GUrlString & operator=(const GUrlString &url)
Assignment operator.
int m_index
String position indicator.
void rewind(void)
virtual int write(const void *buffer, const int &nbyte)
Write block of data buffer into string.
virtual GUrlString * clone(void) const
Clone string URL.
std::string m_buffer
Text string.
void free_members(void)
Delete class members.
virtual void put_char(const int &character)
Write character into string.
GUrlString(void)
Void constructor.
Abstract URL base class.
Definition GUrl.hpp:44