as2js: as2js::StringInput Class Reference

#include <stream.h>

Inheritance diagram for as2js::StringInput:
Collaboration diagram for as2js::StringInput:
Public Types typedef as_char_t char_t   typedef std::shared_ptr< StringInputpointer_t   Public Member Functions  StringInput (String const &str, Position::counter_t line=1)  Initliaze the string input. More...
  Positionget_position ()  Get the position object of the input object. More...
  Position const & get_position () const  Get the position object of the input object. More...
  char_t getc ()  Get one character. More...
  void ungetc (char_t c)  Unget one character. More...
  Static Public Attributes static char_t const INPUT_EOF = -1   static char_t const INPUT_ERR = -3   static char_t const INPUT_NAC = -2   Protected Member Functions virtual char_t filter_getc ()  Get the next character. More...
  virtual char_t get_byte ()  Function used to get the following byte of data. More...
  Private Attributes String::size_type f_pos = 0   String f_str = String()   Detailed Description

Definition at line 216 of file stream.h.

Member Typedef Documentation
typedef as_char_t as2js::Input::char_t inherited

Definition at line 153 of file stream.h.

typedef std::shared_ptr<StringInput> as2js::StringInput::pointer_t

Definition at line 220 of file stream.h.

Constructor & Destructor Documentation
as2js::StringInput::StringInput ( String const &  str, Position::counter_t  line = 1  )

This function initialize a StringInput object with the specified string and line number. By default, line is set to 1 since strings represent code from the start of a file.

Parameters
[in]strThe string parameter which we will read characters from. [in]lineThe start line for the Position object.

Definition at line 780 of file stream.cpp.

References as2js::Input::get_position(), and as2js::Position::reset_counters().

Member Function Documentation
Input::char_t as2js::StringInput::filter_getc ( ) protectedvirtual

This function bypasses the Input filter since we already have UTF-32 characters in the input string.

Returns
The next character from the string or Input::INPUT_EOF.

Reimplemented from as2js::Input.

Definition at line 796 of file stream.cpp.

References f_pos, f_str, and as2js::Input::INPUT_EOF.

Input::char_t as2js::Input::get_byte ( ) protectedvirtualinherited

This virtual function is used by the filter_getc() function to retrieve the next character of data from the input stream. The default implementation of the function throws because it should never get called.

Note that it is possible to bypass this function by implementing instead the filter_getc() in your own class.

Exceptions
exception_internal_errorThis function always raises this exception because it should not be called.
Returns
The next byte from the input stream.

Reimplemented in as2js::FileInput, and as2js::StandardInput.

Definition at line 652 of file stream.cpp.

Referenced by as2js::Input::filter_getc().

Position & as2js::Input::get_position ( ) inherited

The stream manages a position object. The call can use this function to retrieve a read/write version of the current position.

Returns
A modifiable version of the position object.

Definition at line 532 of file stream.cpp.

References as2js::Input::f_position.

Referenced by as2js::StandardOutput::internal_write(), as2js::FileOutput::internal_write(), as2js::FileInput::open(), as2js::FileOutput::open(), as2js::StandardInput::StandardInput(), as2js::StandardOutput::StandardOutput(), and StringInput().

Position const & as2js::Input::get_position ( ) const inherited

The stream manages a position object. The call can use this function to retrieve a read-only version of the current position.

Returns
A constant version of the position object.

Definition at line 545 of file stream.cpp.

References as2js::Input::f_position.

Input::char_t as2js::Input::getc ( ) inherited

This function retrieves the next character from the input object.

If the caller used the ungetc() function, then the characters that were ungotten are returned first in the opposite order (FILO).

Returns
The next character available in the stream.

Definition at line 560 of file stream.cpp.

References as2js::Input::f_unget, and as2js::Input::filter_getc().

void as2js::Input::ungetc ( char_t  c) inherited

This function saves the specified character c in a buffer of the Input object. The next getc() call will first return that last character the caller unget.

Parameters
[in]cThe character to unget.

Definition at line 580 of file stream.cpp.

References as2js::Input::f_unget.

Member Data Documentation
String::size_type as2js::StringInput::f_pos = 0 private

Definition at line 229 of file stream.h.

Referenced by filter_getc().

String as2js::StringInput::f_str = String() private

Definition at line 228 of file stream.h.

Referenced by filter_getc().


The documentation for this class was generated from the following files:
  • /home/snapwebsites/snapcpp/contrib/as2js/include/as2js/stream.h
  • /home/snapwebsites/snapcpp/contrib/as2js/lib/stream.cpp

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly