GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUrlString Class Reference

String URL class. More...

#include <GUrlString.hpp>

Inheritance diagram for GUrlString:
GUrl GBase

Public Member Functions

 GUrlString (void)
 Void constructor. More...
 
 GUrlString (const std::string &string)
 Text string constructor. More...
 
 GUrlString (const GUrlString &url)
 Copy constructor. More...
 
virtual ~GUrlString (void)
 Destructor. More...
 
GUrlStringoperator= (const GUrlString &url)
 Assignment operator. More...
 
virtual void clear (void)
 Clear string URL. More...
 
virtual GUrlStringclone (void) const
 Clone string URL. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual void open (const std::string &string, const std::string &mode="")
 Open string URL. More...
 
virtual void close (void)
 Close file. More...
 
virtual int read (void *buffer, const int &nbyte)
 Read block of data from string buffer. More...
 
virtual int write (const void *buffer, const int &nbyte)
 Write block of data buffer into string. More...
 
virtual int get_char (void) const
 Return next character from string. More...
 
virtual void put_char (const int &character)
 Write character into string. More...
 
virtual void scanf (const char *format,...)
 Read formatted data from string. More...
 
virtual void printf (const char *format,...)
 Write formatted data into string. More...
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print URL information. More...
 
const std::string & string (void) const
 
void rewind (void)
 
- Public Member Functions inherited from GUrl
 GUrl (void)
 Void constructor. More...
 
 GUrl (const GUrl &url)
 Copy constructor. More...
 
virtual ~GUrl (void)
 Destructor. More...
 
GUrloperator= (const GUrl &url)
 Assignment operator. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GUrlString &url)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from GUrl
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GUrl &url)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Protected Attributes

int m_index
 String position indicator. More...
 
std::string m_buffer
 Text string. More...
 

Detailed Description

String URL class.

This class implements the URL interface for a string.

Definition at line 42 of file GUrlString.hpp.

Constructor & Destructor Documentation

GUrlString::GUrlString ( void  )

Void constructor.

Definition at line 57 of file GUrlString.cpp.

References init_members().

Referenced by clone().

GUrlString::GUrlString ( const std::string &  string)

Text string constructor.

Parameters
[in]stringText string.

Constructs GUrlString object by assigning a text string to the object's buffer.

Definition at line 75 of file GUrlString.cpp.

References init_members(), and open().

GUrlString::GUrlString ( const GUrlString url)

Copy constructor.

Parameters
[in]urlUnified Resource Locator.

Definition at line 93 of file GUrlString.cpp.

References copy_members(), and init_members().

GUrlString::~GUrlString ( void  )
virtual

Destructor.

Definition at line 109 of file GUrlString.cpp.

References free_members().

Member Function Documentation

std::string GUrlString::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GUrlString").

Implements GUrl.

Definition at line 90 of file GUrlString.hpp.

void GUrlString::clear ( void  )
virtual

Clear string URL.

Implements GUrl.

Definition at line 164 of file GUrlString.cpp.

References GUrl::free_members(), free_members(), GUrl::init_members(), and init_members().

GUrlString * GUrlString::clone ( void  ) const
virtual

Clone string URL.

Returns
Pointer to deep copy of string URL.

Implements GUrl.

Definition at line 184 of file GUrlString.cpp.

References GUrlString().

void GUrlString::close ( void  )
virtual

Close file.

Implements GUrl.

Definition at line 214 of file GUrlString.cpp.

References m_buffer, and m_index.

Referenced by free_members(), GXml::GXml(), and open().

void GUrlString::copy_members ( const GUrlString url)
protected

Copy class members.

Parameters
[in]urlURL.

Definition at line 543 of file GUrlString.cpp.

References m_buffer, and m_index.

Referenced by GUrlString(), and operator=().

void GUrlString::free_members ( void  )
protected

Delete class members.

Definition at line 557 of file GUrlString.cpp.

References close().

Referenced by clear(), operator=(), and ~GUrlString().

int GUrlString::get_char ( void  ) const
virtual

Return next character from string.

Returns
Next character in string.

Returns the character currently pointed by the internal position indicator. The internal position indicator is then advanced to the next character.

If the indicator is at the end of the string when called, the function returns EOF.

If no string exists, the method returns EOF.

Implements GUrl.

Definition at line 351 of file GUrlString.cpp.

References m_buffer, and m_index.

void GUrlString::init_members ( void  )
protected

Initialise class members.

Definition at line 527 of file GUrlString.cpp.

References m_buffer, and m_index.

Referenced by clear(), GUrlString(), and operator=().

void GUrlString::open ( const std::string &  string,
const std::string &  mode = "" 
)
virtual

Open string URL.

Parameters
[in]stringText string.
[in]modeMode parameter (ignored).

Implements GUrl.

Definition at line 197 of file GUrlString.cpp.

References close(), m_buffer, m_index, and string().

Referenced by GUrlString().

GUrlString & GUrlString::operator= ( const GUrlString url)

Assignment operator.

Parameters
[in]urlUnified Resource Locator.
Returns
Unified Resource Locator.

Definition at line 131 of file GUrlString.cpp.

References copy_members(), free_members(), init_members(), and GUrl::operator=().

std::string GUrlString::print ( const GChatter chatter = NORMAL) const
virtual

Print URL information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing URL information.

Implements GUrl.

Definition at line 492 of file GUrlString.cpp.

References m_buffer, m_index, gammalib::parformat(), SILENT, and gammalib::str().

void GUrlString::printf ( const char *  format,
  ... 
)
virtual

Write formatted data into string.

Parameters
[in]formatFormat.
[in]...Optional parameters.

Writes the C string pointed by format to the string. If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

After the format parameter, the function expects at least as many additional arguments as specified by format.

Implements GUrl.

Definition at line 451 of file GUrlString.cpp.

References m_buffer, and m_index.

void GUrlString::put_char ( const int &  character)
virtual

Write character into string.

Parameters
[in]characterCharacter.

Writes a character to the string and advances the position indicator.

Implements GUrl.

Definition at line 380 of file GUrlString.cpp.

References m_buffer, and m_index.

int GUrlString::read ( void *  buffer,
const int &  nbyte 
)
virtual

Read block of data from string buffer.

Parameters
[in]bufferData buffer.
[in]nbyteNumber of Bytes to be read.
Returns
Number of Bytes that were effectively read.

Reads nbyte Bytes from the string into a buffer. The position indicator of the string is advanced by the total amount of bytes read.

The total number of Bytes successfully read is returned. If this number differs from the nbyte parameter, the end of the string was reached. The proper indicator is set.

If either buffer is NULL or nbyte is zero, the method returns zero and both the string state and the content pointed by buffer remain unchanged.

If no string exists, the method returns zero and both the string state and the content pointed by buffer remain unchanged.

Implements GUrl.

Definition at line 248 of file GUrlString.cpp.

References m_buffer, and m_index.

void GUrlString::rewind ( void  )
inline

Definition at line 70 of file GUrlString.hpp.

References m_index.

void GUrlString::scanf ( const char *  format,
  ... 
)
virtual

Read formatted data from string.

Parameters
[in]formatFormat.
[in]...Optional parameters.

Reads data from a string and stores them according to the parameter format into the locations pointed by the additional arguments. The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier within the format string.

If no string exists, the method does nothing.

Todo:
The position indicator is not forwared as I have no idea how to do this in fact!!!

Implements GUrl.

Definition at line 409 of file GUrlString.cpp.

References m_buffer, and m_index.

const std::string& GUrlString::string ( void  ) const
inline

Definition at line 69 of file GUrlString.hpp.

References m_buffer.

Referenced by open().

int GUrlString::write ( const void *  buffer,
const int &  nbyte 
)
virtual

Write block of data buffer into string.

Parameters
[in]bufferData buffer.
[in]nbyteNumber of Bytes to be written.
Returns
Number of Bytes that were effectively written.

Writes nbyte Bytes from a buffer into the string. The position indicator of the string is advanced by the total amount of bytes written.

The total number of Bytes successfully written is returned.

If either buffer is NULL or nbyte is zero, the method returns zero and both the string state and the content pointed by buffer remain unchanged.

Implements GUrl.

Definition at line 305 of file GUrlString.cpp.

References m_buffer, and m_index.

Member Data Documentation

std::string GUrlString::m_buffer
protected

Text string.

Definition at line 80 of file GUrlString.hpp.

Referenced by close(), copy_members(), get_char(), init_members(), open(), print(), printf(), put_char(), read(), scanf(), string(), and write().

int GUrlString::m_index
mutableprotected

String position indicator.

Definition at line 79 of file GUrlString.hpp.

Referenced by close(), copy_members(), get_char(), init_members(), open(), print(), printf(), put_char(), read(), rewind(), scanf(), and write().


The documentation for this class was generated from the following files: