ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::files::TTextFile< TNString, TAllocator > Class Template Reference

Description:

template<typename TNString = NString, typename TAllocator = MonoAllocator>
class alib::files::TTextFile< TNString, TAllocator >

A rather simple text file reader and writer.

See also
Reading is performed using helper type class TextFileLineReader, which be used as a standalone helper, i.e. in cases where a text file is read but does not need to be stored in a vector.
Template Parameters
TNStringThe string-type. This may also be a type derived from NString which contains further fields available with each line of the file.
TAllocatorThe allocator type to use.

Definition at line 88 of file ALib.Files.TextFile.H.

#include <ALib.Files.TextFile.H>

Inheritance diagram for alib::files::TTextFile< TNString, TAllocator >:
[legend]
Collaboration diagram for alib::files::TTextFile< TNString, TAllocator >:
[legend]

Public Type Index:

using AllocatorType = TAllocator
 Type definition publishing template parameter TAllocator.
 
using StoredType = TNString
 
using Vector = StdVectorMA<TNString>
 Type definition publishing the base container type.
 
- Public Type Index: inherited from alib::lang::AllocatorMember< MonoAllocator >
using AllocatorType
 Exposes the allocator type.
 

Public Method Index:

 TTextFile (MonoAllocator &ma)
 
template<typename TIntegral>
constexpr const StoredTypeAt (TIntegral idx) const noexcept
 
template<typename TIntegral>
constexpr StoredTypeAt (TIntegral idx) noexcept
 
system::SystemErrors Read (const CString &filePath)
 
system::SystemErrors Read (files::File file)
 
constexpr integer Size () const noexcept
 
ALIB_DLL system::SystemErrors Write (const String &filePath)
 
- Public Method Index: inherited from alib::lang::AllocatorMember< MonoAllocator >
 AllocatorMember ()
 
 AllocatorMember (MonoAllocator &pAllocator) noexcept
 
AllocatorInterface< MonoAllocatorAI () const noexcept
 
MonoAllocatorGetAllocator () const noexcept
 

Protected Field Index:

MonoAllocatorallocator
 The given allocator.
 
- Protected Field Index: inherited from alib::lang::AllocatorMember< MonoAllocator >
MonoAllocatorallocator
 The allocator stored.
 

Type Definition Details:

◆ AllocatorType

template<typename TNString = NString, typename TAllocator = MonoAllocator>
using alib::files::TTextFile< TNString, TAllocator >::AllocatorType = TAllocator

Type definition publishing template parameter TAllocator.

Definition at line 97 of file ALib.Files.TextFile.H.

◆ StoredType

template<typename TNString = NString, typename TAllocator = MonoAllocator>
using alib::files::TTextFile< TNString, TAllocator >::StoredType = TNString

Type definition publishing the type in the std::vector that this type is derived of. (As is defined with template parameter TNString.)

Definition at line 102 of file ALib.Files.TextFile.H.

◆ Vector

template<typename TNString = NString, typename TAllocator = MonoAllocator>
using alib::files::TTextFile< TNString, TAllocator >::Vector = StdVectorMA<TNString>

Type definition publishing the base container type.

Definition at line 105 of file ALib.Files.TextFile.H.

Field Details:

◆ allocator

template<typename TNString = NString, typename TAllocator = MonoAllocator>
MonoAllocator& alib::files::TTextFile< TNString, TAllocator >::allocator
protected

The given allocator.

Definition at line 93 of file ALib.Files.TextFile.H.

Constructor(s) / Destructor Details:

◆ TTextFile()

template<typename TNString = NString, typename TAllocator = MonoAllocator>
alib::files::TTextFile< TNString, TAllocator >::TTextFile ( MonoAllocator & ma)
inline

Constructor.

Parameters
maThe allocator to use.

Definition at line 109 of file ALib.Files.TextFile.H.

Method Details:

◆ At() [1/2]

template<typename TNString = NString, typename TAllocator = MonoAllocator>
template<typename TIntegral>
const StoredType & alib::files::TTextFile< TNString, TAllocator >::At ( TIntegral idx) const
inlineconstexprnoexcept

const-version of At.

Template Parameters
TIntegralThe integral type that the index is provided by.
Parameters
idxThe index to retrieve an element for.
Returns
A const reference to the element stored at the given idx.

Definition at line 136 of file ALib.Files.TextFile.H.

◆ At() [2/2]

template<typename TNString = NString, typename TAllocator = MonoAllocator>
template<typename TIntegral>
StoredType & alib::files::TTextFile< TNString, TAllocator >::At ( TIntegral idx)
inlineconstexprnoexcept

Returns the element in the vector at the given position.
Note that this is the same as calling inherited std::vector::at(), but this method accepts any integral type for parameter idx.
Furthermore, this method raises an ALib Assertion in debug-builds, instead of throwing an exception.

Template Parameters
TIntegralThe integral type that the index is provided by.
Parameters
idxThe index to retrieve an element for.
Returns
A reference to the element stored at the given idx.

Definition at line 128 of file ALib.Files.TextFile.H.

◆ Read() [1/2]

template<typename TNString = NString, typename TAllocator = MonoAllocator>
system::SystemErrors alib::files::TTextFile< TNString, TAllocator >::Read ( const CString & filePath)
inline

Reads the file into this vector of lines.

Parameters
filePathThe path of the file.
Returns
SystemErrors::OK if all went well, otherwise an error code.

Definition at line 142 of file ALib.Files.TextFile.H.

◆ Read() [2/2]

template<typename TNString = NString, typename TAllocator = MonoAllocator>
system::SystemErrors alib::files::TTextFile< TNString, TAllocator >::Read ( files::File file)
inline

Reads the file into this vector of lines.

Parameters
fileThe file to read.
Returns
SystemErrors::OK if all went well, otherwise an error code.

Definition at line 160 of file ALib.Files.TextFile.H.

◆ Size()

template<typename TNString = NString, typename TAllocator = MonoAllocator>
integer alib::files::TTextFile< TNString, TAllocator >::Size ( ) const
inlineconstexprnoexcept

Returns the vector's size as ALib's signed integral type.

Returns
The number of lines in this source file.

Definition at line 116 of file ALib.Files.TextFile.H.

◆ Write()

template<typename TNString = NString, typename TAllocator = MonoAllocator>
ALIB_DLL system::SystemErrors alib::files::TTextFile< TNString, TAllocator >::Write ( const String & filePath)
inline

Writes this text file to the given filePath.

Parameters
filePathThe path of the file.
Returns
SystemErrors::OK if all went well, otherwise an error code.

Definition at line 171 of file ALib.Files.TextFile.H.


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