MADNESS 0.10.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
madness::archive::TextFstreamInputArchive Class Reference

Wraps an archive around a text filestream for input. More...

#include <text_fstream_archive.h>

Inheritance diagram for madness::archive::TextFstreamInputArchive:
Inheritance graph
[legend]
Collaboration diagram for madness::archive::TextFstreamInputArchive:
Collaboration graph
[legend]

Public Member Functions

 TextFstreamInputArchive (const char *filename=nullptr, std::ios_base::openmode mode=std::ios_base::in)
 Default constructor.
 
template<class T >
void check_end_tag () const
 Read the closing "cookie" tag.
 
template<class T >
void check_start_tag (bool end=false) const
 Check the "cookie" tag in the archive for runtime type-checking.
 
void close ()
 Close the filestream.
 
void load (char *t, long n) const
 Load characters from the filestream, without converting escaped characters.
 
template<class T >
std::enable_if< madness::is_istreammable_v< T > >::type load (T *t, long n) const
 Load from the filestream.
 
void load (unsigned char *t, long n) const
 Load characters from the filestream, interpreting escaped characters along the way.
 
void open (const char *filename, std::ios_base::openmode mode=std::ios_base::in)
 Open the filestream.
 
- Public Member Functions inherited from madness::archive::BaseArchive
 BaseArchive ()
 

Private Member Functions

void eat_eol () const
 Eat the EOL after each entry to enable a char-by-char read of strings.
 

Private Attributes

std::ifstream is
 The filestream.
 

Additional Inherited Members

- Public Types inherited from madness::archive::BaseInputArchive
using is_loading = std::true_type
 Type used by Boost.Serialization to determine if this object is an input archive.
 
- Public Types inherited from madness::archive::BaseArchive
using is_loading = std::false_type
 Type used by Boost.Serialization to determine if this object is an input archive.
 
using is_saving = std::false_type
 Type used by Boost.Serialization to determine if this object is an output archive.
 
- Static Public Attributes inherited from madness::archive::BaseInputArchive
static constexpr bool is_input_archive = true
 Flag to determine if this object is an input archive.
 
- Static Public Attributes inherited from madness::archive::BaseArchive
static constexpr bool is_archive = true
 Flag to determine if this object is an archive.
 
static constexpr bool is_input_archive = false
 Flag to determine if this object is an input archive.
 
static constexpr bool is_output_archive = false
 Flag to determine if this object is an output archive.
 
static constexpr bool is_parallel_archive = false
 Flag to determine if this object is a parallel archive.
 

Detailed Description

Wraps an archive around a text filestream for input.

Constructor & Destructor Documentation

◆ TextFstreamInputArchive()

madness::archive::TextFstreamInputArchive::TextFstreamInputArchive ( const char *  filename = nullptr,
std::ios_base::openmode  mode = std::ios_base::in 
)
inline

Default constructor.

The filename and open modes are optional here; they can be specified later by calling open().

Parameters
[in]filenameName of the file to read from.
[in]modeI/O attributes for opening the file.

References madness::filename, and open().

Member Function Documentation

◆ check_end_tag()

template<class T >
void madness::archive::TextFstreamInputArchive::check_end_tag ( ) const
inline

Read the closing "cookie" tag.

Template Parameters
TThe expected data type between the tags.

Referenced by madness::archive::ArchivePrePostImpl< TextFstreamInputArchive, T >::postamble_load().

◆ check_start_tag()

template<class T >
void madness::archive::TextFstreamInputArchive::check_start_tag ( bool  end = false) const
inline

Check the "cookie" tag in the archive for runtime type-checking.

Template Parameters
TThe expected data type.
Exceptions
MadnessExceptionif the tag does not match that of the expected type.

References madness::archive::archive_type_names, bufsize, is, and MADNESS_EXCEPTION.

Referenced by madness::archive::ArchivePrePostImpl< TextFstreamInputArchive, T >::preamble_load().

◆ close()

void madness::archive::TextFstreamInputArchive::close ( )
inline

Close the filestream.

References is.

Referenced by main().

◆ eat_eol()

void madness::archive::TextFstreamInputArchive::eat_eol ( ) const
private

Eat the EOL after each entry to enable a char-by-char read of strings.

References is, and MADNESS_EXCEPTION.

Referenced by load(), load(), and load().

◆ load() [1/3]

void madness::archive::TextFstreamInputArchive::load ( char *  t,
long  n 
) const

Load characters from the filestream, without converting escaped characters.

Parameters
[out]tWhere to put the loaded characters.
[in]nThe number of characters to be loaded.

References eat_eol(), is, and MADNESS_EXCEPTION.

◆ load() [2/3]

template<class T >
std::enable_if< madness::is_istreammable_v< T > >::type madness::archive::TextFstreamInputArchive::load ( T t,
long  n 
) const
inline

Load from the filestream.

The function only appears (due to enable_if) if T is serializable.

Template Parameters
TThe type of data to be read.
Parameters
[out]tWhere to put the loaded data.
[in]nThe number of data items to be loaded.

References eat_eol().

◆ load() [3/3]

void madness::archive::TextFstreamInputArchive::load ( unsigned char *  t,
long  n 
) const

Load characters from the filestream, interpreting escaped characters along the way.

Parameters
[out]tWhere to put the loaded characters.
[in]nThe number of characters to be loaded.

References eat_eol(), and is.

◆ open()

void madness::archive::TextFstreamInputArchive::open ( const char *  filename,
std::ios_base::openmode  mode = std::ios_base::in 
)

Open the filestream.

Parameters
[in]filenameThe name of the file.
[in]modeI/O attributes for opening the file.

References ARCHIVE_MAJOR_VERSION, ARCHIVE_MINOR_VERSION, bufsize, madness::filename, is, and MADNESS_EXCEPTION.

Referenced by TextFstreamInputArchive().

Member Data Documentation

◆ is

std::ifstream madness::archive::TextFstreamInputArchive::is
mutableprivate

The filestream.

Referenced by check_start_tag(), close(), eat_eol(), load(), load(), and open().


The documentation for this class was generated from the following files: