as2js: as2js::FileOutput Class Reference

#include <stream.h>

Inheritance diagram for as2js::FileOutput:
Collaboration diagram for as2js::FileOutput:
Public Types typedef std::shared_ptr< FileOutputpointer_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...
  bool open (String const &filename)  Open the output file. More...
  void write (String const &data)  Write data to this output stream. More...
  Protected Member Functions virtual void internal_write (String const &data)  Write to the output file. More...
  Protected Attributes std::ofstream f_file = std::ofstream()   Position f_position = Position()   Detailed Description

Definition at line 285 of file stream.h.

Member Typedef Documentation
typedef std::shared_ptr<FileOutput> as2js::FileOutput::pointer_t

Definition at line 289 of file stream.h.

Member Function Documentation
Position & as2js::Output::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 825 of file stream.cpp.

References as2js::Input::f_position.

Position const & as2js::Output::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 838 of file stream.cpp.

References as2js::Input::f_position.

void as2js::FileOutput::internal_write ( String const &  data) protectedvirtual

This function writes the specified data string to this output file.

If an error occurs, the process writes a fatal error in stderr and exists.

Parameters
[in]dataThe string to write to the output file.

Implements as2js::Output.

Definition at line 953 of file stream.cpp.

References as2js::AS_ERR_IO_ERROR, as2js::Input::get_position(), as2js::MESSAGE_LEVEL_FATAL, and as2js::String::to_utf8().

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

This function is used to open the output file.

One FileOutput object can only be used to output to one file. Trying to reuse the same object with a different filename will generate an exception.

Todo:
Generate an error message for why the file could not be opened.
Parameters
[in]filenameThe name of the file to open for output.
Returns
true if the file was successfully opened, false if an error occured.

Definition at line 925 of file stream.cpp.

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

void as2js::Output::write ( String const &  data) inherited

This function writes the specified string to the output stream. Since we pretty much only support text based files, we just use this format.

All outputs are done in UTF-8.

If the function cannot write to the destination, then it throws an error.

Parameters
[in]dataThe string to be written to the output stream.

Definition at line 857 of file stream.cpp.

Member Data Documentation
std::ofstream as2js::FileOutput::f_file = std::ofstream() protected

Definition at line 296 of file stream.h.

Position as2js::Output::f_position = Position() protectedinherited

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