A rather simple text file reader and writer.
| TNString | The string-type. This may also be a type derived from alib::NString which contains further fields available with each line of the file. |
| TAllocator | The allocator type to use. In the presence of module ALib Monomem, this defaults to MonoAllocator, and to HeapAllocator otherwise. |
| TLocalBufferSize | The size of the local buffer. If lines are wider and the local buffer is exceeded, it will be replaced by an heap-allocated buffer, which is then reused for any further line. Defaults to 1024. |
Definition at line 94 of file textfile.hpp.
#include <textfile.hpp>
Public Type Index: | |
| using | AllocatorType = TAllocator |
| Type definition publishing template parameter TAllocator. | |
| using | StoredType = TNString |
| using | Vector = std::vector<TNString, lang::StdAllocator<TNString, TEXTFILE_DEFAULT_ALLOCATOR>> |
| Type definition publishing the base container type. | |
| Public Type Index: inherited from alib::lang::AllocatorMember< TEXTFILE_DEFAULT_ALLOCATOR > | |
| using | AllocatorType |
| Exposes the allocator type. | |
Public Method Index: | |
| TTextFile (AllocatorType &ma) | |
| template<typename TIntegral> | |
| constexpr const StoredType & | At (TIntegral idx) const noexcept |
| template<typename TIntegral> | |
| constexpr StoredType & | At (TIntegral idx) noexcept |
| std::errc | Read (const CPathString &filePath) |
| constexpr integer | Size () const noexcept |
| std::errc | Write (const PathString &filePath) |
| Public Method Index: inherited from alib::lang::AllocatorMember< TEXTFILE_DEFAULT_ALLOCATOR > | |
| AllocatorMember () | |
| AllocatorInterface< TEXTFILE_DEFAULT_ALLOCATOR > | AIF () const noexcept |
| TEXTFILE_DEFAULT_ALLOCATOR & | GetAllocator () const noexcept |
Protected Type Index: | |
| using | base = lang::AllocatorMember<TAllocator> |
| The allocator member base-type. | |
Additional Inherited Members | |
| Protected Field Index: inherited from alib::lang::AllocatorMember< TEXTFILE_DEFAULT_ALLOCATOR > | |
| TEXTFILE_DEFAULT_ALLOCATOR * | allocator |
| The allocator stored. | |
| using alib::system::TTextFile< TNString, TAllocator, TLocalBufferSize >::AllocatorType = TAllocator |
Type definition publishing template parameter TAllocator.
Definition at line 101 of file textfile.hpp.
|
protected |
The allocator member base-type.
Definition at line 98 of file textfile.hpp.
| using alib::system::TTextFile< TNString, TAllocator, TLocalBufferSize >::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 106 of file textfile.hpp.
| using alib::system::TTextFile< TNString, TAllocator, TLocalBufferSize >::Vector = std::vector<TNString, lang::StdAllocator<TNString, TEXTFILE_DEFAULT_ALLOCATOR>> |
Type definition publishing the base container type.
Definition at line 109 of file textfile.hpp.
|
inline |
|
inlinenodiscardconstexprnoexcept |
const-version of At.
| TIntegral | The integral type that the index is provided by. |
| idx | The index to retrieve an element for. |
const reference to the element stored at the given idx. Definition at line 139 of file textfile.hpp.
|
inlinenodiscardconstexprnoexcept |
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.
| TIntegral | The integral type that the index is provided by. |
| idx | The index to retrieve an element for. |
Definition at line 131 of file textfile.hpp.
|
inline |
Reads the file into this vector of lines.
| filePath | The path of the file. |
std::errc(0) if all went well, otherwise an error code. Definition at line 144 of file textfile.hpp.
|
inlineconstexprnoexcept |
Returns the vector's size as ALib's signed integral type.
Definition at line 119 of file textfile.hpp.
|
inline |
Writes this text file to the given filePath.
| filePath | The path of the file. |
std::errc(0) if all went well, otherwise an error code. Definition at line 168 of file textfile.hpp.