as2js: as2js::FileInput Class Reference

#include <stream.h>

Inheritance diagram for as2js::FileInput:
Collaboration diagram for as2js::FileInput:
Public Types typedef as_char_t char_t   typedef std::shared_ptr< FileInputpointer_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...
  bool open (String const &filename)  Use the named file as the input stream. 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 ()  Get the next byte from the file. More...
  Protected Attributes std::ifstream f_file = std::ifstream()   Detailed Description

Definition at line 198 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<FileInput> as2js::FileInput::pointer_t

Definition at line 202 of file stream.h.

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

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

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

Reimplemented in as2js::StringInput.

Definition at line 609 of file stream.cpp.

References as2js::Input::f_filter, as2js::Input::get_byte(), as2js::Input::INPUT_EOF, as2js::Input::INPUT_ERR, and as2js::Input::INPUT_NAC.

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

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

This function reads one byte from the input file and returns it.

Returns
The read byte.

Reimplemented from as2js::Input.

Definition at line 752 of file stream.cpp.

References as2js::Input::INPUT_EOF.

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(), open(), as2js::FileOutput::open(), as2js::StandardInput::StandardInput(), as2js::StandardOutput::StandardOutput(), and as2js::StringInput::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().

bool as2js::FileInput::open ( String const &  filename)

This function sets up the named file as the input stream of this FileInput object.

The function first calls close() to make sure that any previous call to standard_input() or open() get cleaned up.

Note
This function is not placed in the constructor because we want to return false if the file cannot be opened.
Parameters
[in]filenameThe name of the file to open.
Returns
true if the file could be opened.

Definition at line 727 of file stream.cpp.

References as2js::Input::get_position(), as2js::Position::set_filename(), and as2js::String::to_utf8().

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
std::ifstream as2js::FileInput::f_file = std::ifstream() protected

Definition at line 209 of file stream.h.


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