as2js: as2js::DecodingFilterDetect Class Reference

#include <stream.h>

Inheritance diagram for as2js::DecodingFilterDetect:
Collaboration diagram for as2js::DecodingFilterDetect:
Public Types typedef unsigned char byte_t   typedef std::vector< byte_tbyte_vector_t   typedef std::shared_ptr< DecodingFilterpointer_t   Public Member Functions as_char_t getc ()  Retrieve the next character. More...
  void putc (byte_t c)  Push one byte in the decoder. More...
  Protected Member Functions virtual as_char_t get_char ()  Read the next character in any format. More...
  Protected Attributes byte_vector_t f_buffer = byte_vector_t()   Private Attributes DecodingFilter::pointer_t f_filter = DecodingFilter::pointer_t()   Detailed Description

Definition at line 126 of file stream.h.

Member Typedef Documentation
typedef unsigned char as2js::DecodingFilter::byte_t inherited

Definition at line 52 of file stream.h.

typedef std::vector<byte_t> as2js::DecodingFilter::byte_vector_t inherited

Definition at line 53 of file stream.h.

typedef std::shared_ptr<DecodingFilter> as2js::DecodingFilter::pointer_t inherited

Definition at line 51 of file stream.h.

Member Function Documentation
Input::char_t as2js::DecodingFilterDetect::get_char ( ) protectedvirtual

This function reads one character from the input stream. At first the stream is considered to be undefined (no specific filter defined).

Once we have an least 4 bytes of data, we try to detect a BOM. If no BOM is detected, make sure that the characters are valid UTF-8, and if so, use the UTF-8 filter, otherwise fallback on the ISO-8859-1 filter unless we notice many zeroes in which case we use one of the UTF-16 or UTF-32 decoders.

Known bug: if the input file is less than 4 bytes it cannot be used because this filter will always return a NAC. So even a valid source of 1, 2, or 3 characters fails. However, the likelihood of such a script to be useful are probably negative so we do not care too much.
The following characters, Input::INPUT_NAC, or Input::INPUT_ERR.

Implements as2js::DecodingFilter.

Definition at line 412 of file stream.cpp.

References as2js::DecodingFilter::f_buffer, as2js::String::from_utf8(), as2js::Input::INPUT_EOF, as2js::Input::INPUT_NAC, as2js::String::STRING_END, and as2js::String::STRING_GOOD.

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

This function retrieves the next input character.

If there is data, but not enough of it, it returns Input::INPUT_NAC. Processing can safely continue.

If possible, the function avoids returning with the Input::INPUT_NAC result (i.e. if a filter returns that value when there is still data available in the buffer, their get_char() function gets called again.)

If there is data, but it cannot properly be converted to a valid character, it returns Input::INPUT_ERR.

If there is no data, then Input::INPUT_EOF is returned.

The next character available or one of the Input::INPUT_... result (EOF, NAC, ERR).

Definition at line 96 of file stream.cpp.

References as2js::DecodingFilter::f_buffer, as2js::DecodingFilter::get_char(), and as2js::Input::INPUT_EOF.

void as2js::DecodingFilter::putc ( byte_t  c) inherited

This function pushes exactly one byte in the decoder.

In most cases decoders expects their getc() function to be called right after each putc(), although it is not mandatory.

[in]cThe character to append to this decoding filter.

Definition at line 71 of file stream.cpp.

References as2js::DecodingFilter::f_buffer.

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

Definition at line 133 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