8#ifndef H_ALIB_FILES_TEXTFILE
9#define H_ALIB_FILES_TEXTFILE
26template <
typename TNString= NString,
typename TAllocator= MonoAllocator>
61 Path tFilePath(filePath);
63 std::ifstream iFile( nFilePath );
64 if ( !iFile.is_open() )
67 ALIB_WARNING(
"FILES/TEXTFILE",
"Error <{}: \"{}\"> opening input file \"{}\"",
68 errno, result, filePath)
71 ALIB_MESSAGE(
"FILES/TEXTFILE",
"file \"{}\" opened for reading", filePath)
75 while( !readOp.
IsEOF )
81 ALIB_MESSAGE(
"FILES/TEXTFILE",
"File \"{}\", {} lines read", filePath, Vector::size() )
83 return system::SystemErrors::OK;
93 file.
AsCursor().AssemblePath(filePath);
94 return Read(filePath);
105 Path tFilePath(filePath);
107 std::ofstream oFile( nTFilePath.Terminate() );
108 if ( !oFile.is_open() )
111 ALIB_WARNING(
"FILES/TEXTFILE",
"Error <{}: \"{}\"> opening output file \"{}\"",
112 errno, result, filePath)
115 ALIB_MESSAGE(
"FILES/TEXTFILE",
"file \"{}\" opened for writing", filePath)
117 for(
auto& line : *
this )
118 oFile << line << std::endl;
120 ALIB_MESSAGE(
"FILES/TEXTFILE",
"File \"{}\", {} lines written", filePath, Vector::size() )
122 return system::SystemErrors::OK;
TTextFile(MonoAllocator &ma)
TAllocator AllocatorType
Type definition publishing template parameter TAllocator.
StdVectorMono< TNString > Vector
Type definition publishing the base container type.
system::SystemErrors Read(const CString &filePath)
MonoAllocator & allocator
ALIB_DLL system::SystemErrors Write(const String &filePath)
system::SystemErrors Read(files::File file)
void DbgDisableBufferReplacementWarning()
#define ALIB_MESSAGE(domain,...)
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
#define ALIB_WARNING(domain,...)
std::vector< T, SCAMono< T > > StdVectorMono
Type alias in namespace alib.
strings::compatibility::std::TISReadLine< char > ISReadLineN
Type alias in namespace alib.
strings::TCString< character > CString
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
system::Path Path
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
NLocalString< 4096 > NString4K
Type alias name for TLocalString<nchar,8192>.
files::TTextFile< NString > TextFile
Type alias in namespace alib.