as2js: as2js::Input Class Reference

#include <stream.h>

Inheritance diagram for as2js::Input:
Collaboration diagram for as2js::Input:
Public Types typedef as_char_t char_t   typedef std::shared_ptr< Inputpointer_t   Public Member Functions 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  Input (DecodingFilter::pointer_t filter=DecodingFilter::pointer_t(new DecodingFilterDetect))  Initialize an input object. More...
  virtual ~Input ()   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 DecodingFilter::pointer_t f_filter = DecodingFilter::pointer_t()   Position f_position = Position()   std::vector< char_tf_unget = std::vector<char_t>()   Detailed Description

Definition at line 149 of file stream.h.

Member Typedef Documentation

Definition at line 153 of file stream.h.

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

Definition at line 152 of file stream.h.

Constructor & Destructor Documentation
as2js::Input::Input ( DecodingFilter::pointer_t  filter = DecodingFilter::pointer_t(new DecodingFilterDetect)) protected

This function initializes the input object making it ready to be used to read data from a file, a string, or a TTY.

The filter should generally not be specified, although if you know the format of an input file, it can be useful to force the filter to the exact format. We only support Unicode formats, though.

[in]filterThe filter to use while reading the input data.

Definition at line 517 of file stream.cpp.

virtual as2js::Input::~Input ( ) inlineprotectedvirtual

Definition at line 167 of file stream.h.

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

This function reads the next character from the input. In most cases this reads one or more bytes from the input file, and then it converts those bytes in a character using a filter.

This function does not return Input::INPUT_NAC. Instead it reads as much data as it can and returns the next character, no matter what. However, it may return EOF if the end of the file is reached, or ERR if a character in the stream is not valid. There are two types of invalid characters: (1) numbers that are outside of the Unicode range (0 .. 0x010FFFF) or a UTF-16 surrogate in a format that does not support such surrogate (UTF-8, UTF-32), and (2) byte sequences that end before a valid character can be formed (missing surrogate, invalid UTF-8).

The next character, Input::INPUT_EOF, or Input::INPUT_ERR.

Reimplemented in as2js::StringInput.

Definition at line 609 of file stream.cpp.

References f_filter, get_byte(), INPUT_EOF, INPUT_ERR, and INPUT_NAC.

Referenced by getc().

Input::char_t as2js::Input::get_byte ( ) protectedvirtual

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.

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

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

Definition at line 652 of file stream.cpp.

Referenced by filter_getc().

Position & as2js::Input::get_position ( )

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

A modifiable version of the position object.

Definition at line 532 of file stream.cpp.

References 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 as2js::StringInput::StringInput().

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

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

A constant version of the position object.

Definition at line 545 of file stream.cpp.

References f_position.

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

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).

The next character available in the stream.

Definition at line 560 of file stream.cpp.

References f_unget, and filter_getc().

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

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.

[in]cThe character to unget.

Definition at line 580 of file stream.cpp.

References f_unget.

Member Data Documentation
DecodingFilter::pointer_t as2js::Input::f_filter = DecodingFilter::pointer_t() private

Definition at line 173 of file stream.h.

Referenced by filter_getc().

Position as2js::Input::f_position = Position() private

Definition at line 174 of file stream.h.

Referenced by get_position(), and as2js::Output::get_position().

std::vector<char_t> as2js::Input::f_unget = std::vector<char_t>() private

Definition at line 175 of file stream.h.

Referenced by getc(), and ungetc().

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