Leonardus
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SOF Class Reference

Semantic Object File. More...

#include <sof.h>

+ Inheritance diagram for SOF:
+ Collaboration diagram for SOF:

Classes

struct  SOFData
 Semantic Object File - data member class. More...
 

Public Member Functions

 SOF (const std::string &p_name, const std::string &p_mode)
 Ctor from a name.
 
 SOF (const SOF &p_other)
 Copy ctor.
 
 ~SOF () override
 Dtor.
 
 SOF (SOF &&)=delete
 
SOF & operator= (const SOF &)=delete
 
SOF & operator= (SOF &&)=delete
 
std::string getFName () const
 Returns the file name.
 
std::string getFMode () const
 Returns the file mode.
 
SOF * dup () const override
 Creates a new instance as copy following the red book definition.
 
std::string opequalequal () const override
 String representation for operators '==' and 'pstack'.
 
OTCode ot () const override
 Returns an OTCode.
 
std::string_view type () const override
 Returns a type name.
 
bool isOpen () const
 Checks if the file is open.
 
bool readLeonLine (std::string &p_str)
 Our std::getline( istream, string ) version.
 
OpError open ()
 Opens the file.
 
OpError flush ()
 Flushes the file.
 
OpError close (int(*p_fclose)(FILE *)=fclose)
 Closes the file.
 
OpError readline (std::string &p_str, bool &p_eof)
 Reads a line of text from file.
 
OpError readstring (std::string &p_str, bool &p_eof)
 Reads text from file.
 
OpError writestring (const std::string &p_data)
 Writes to file.
 
OpError writestring (std::string_view p_data)
 Writes to file.
 
OpError writestring (const char *p_data)
 Writes to file.
 
- Public Member Functions inherited from SOshptr
std::string opequal () const override
 String representation of object for operators '=', 'cvs' and 'stack'.
 
bool equal (const SO *p_other) const override
 Checks if this SO is equal to another SO.
 
 SO ()
 Ctor.
 
 SO (bool p_exec)
 Ctor.
 
 SO (const SO &p_other)
 Copy ctor.
 
 SO (SO &&)=delete
 
- Public Member Functions inherited from SO
 SO ()
 Ctor.
 
 SO (bool p_exec)
 Ctor.
 
 SO (const SO &p_other)
 Copy ctor.
 
virtual ~SO ()=default
 Virtual dtor.
 
 SO (SO &&)=delete
 
SO & operator= (const SO &)=delete
 
SO & operator= (SO &&)=delete
 
bool getExec () const
 Getter for exec_.
 
void setExec (bool p_exec)
 Setter for exec_.
 
virtual size_t getSize () const
 Returns the size of the SO.
 
virtual SO * clone () const
 Creates a new instance as copy with deep cloning.
 
virtual bool gt (OpError &p_ec, const SO *) const
 Greater than.
 
virtual bool ge (OpError &p_ec, const SO *) const
 Greater or equal.
 
- Public Member Functions inherited from Counter< SO >
 Counter (Counter< SO > &&)=delete
 
Counter< SO > & operator= (const Counter< SO > &)=delete
 
Counter< SO > & operator= (Counter< SO > &&)=delete
 

Protected Member Functions

void * shptr () const override
 Pointer to the shared object.
 
- Protected Member Functions inherited from SOshptr
bool invariant () const noexcept override
 Checks class invariants.
 
- Protected Member Functions inherited from Counter< SO >
 Counter ()
 Ctor.
 
 Counter (const Counter< SO > &)
 Copy ctor.
 
 ~Counter ()
 Dtor.
 
- Protected Member Functions inherited from DbC
 ~DbC ()=default
 Protected dtor.
 

Private Attributes

std::shared_ptr< SOFData > f_
 The data.
 

Additional Inherited Members

- Static Public Member Functions inherited from Counter< SO >
static size_t getTotalCounter ()
 Static getter for totaly created objects.
 
static size_t getAliveCounter ()
 Static getter for objects alive.
 
static size_t getWatermarkCounter ()
 Static getter for the object counter watermark.
 

Detailed Description

Semantic Object File.

Invariant
inherited from SOcomposite

Constructor & Destructor Documentation

◆ SOF()

SOF::SOF ( const std::string &  p_name,
const std::string &  p_mode 
)
inlineexplicit

Ctor from a name.

Parameters
[in]p_nameThe file name.
[in]p_modeThe file open mode.

Member Function Documentation

◆ close()

OpError SOF::close ( int(*)(FILE *)  p_fclose = fclose)

Closes the file.

Can be called for already closed files.

Parameters
[in]p_fcloseCan be set to a fclose() function for mocking in unit tests.
Returns
OpError ... The error code or success.

◆ dup()

SOF * SOF::dup ( ) const
inlineoverridevirtual

Creates a new instance as copy following the red book definition.

Returns
SO * ... A copy.

Implements SO.

◆ flush()

OpError SOF::flush ( )

Flushes the file.

Precondition
f_->file_ == nullptr
Returns
OpError ... The error code or success.

◆ isOpen()

bool SOF::isOpen ( ) const
inline

Checks if the file is open.

Precondition
f_->file_ != nullptr
Returns
bool ... true, if the file is open.

◆ open()

OpError SOF::open ( )

Opens the file.

Precondition
f_->file_ == nullptr
Returns
OpError ... The error code or success.

◆ opequalequal()

std::string SOF::opequalequal ( ) const
inlineoverridevirtual

String representation for operators '==' and 'pstack'.

This function attempts to produce a result that resembles the red book syntax
for creating the object.

Returns
std::string ... The representation.

Reimplemented from SO.

◆ ot()

OTCode SOF::ot ( ) const
inlineoverridevirtual

Returns an OTCode.

A "manual" implementation of polymorphism, where C++-polymorphisms fail

Returns
OTCode ... The OTCode of the instance.

Implements SO.

◆ readLeonLine()

bool SOF::readLeonLine ( std::string &  p_str)

Our std::getline( istream, string ) version.

Precondition
f_->file_ != nullptr
Parameters
[out]p_strWill be cleared and filled.
Returns
bool ... Success or not.

◆ readline()

OpError SOF::readline ( std::string &  p_str,
bool &  p_eof 
)

Reads a line of text from file.

Precondition
p_str size <= max_int
Parameters
[in,out]p_strBuffer to write the text to. Limited by its size.
[out]p_eofEOF status of file after the operation.
Returns
OpError ... The error code or success.

◆ readstring()

OpError SOF::readstring ( std::string &  p_str,
bool &  p_eof 
)

Reads text from file.

Precondition
p_str ist not empty
Parameters
[in,out]p_strBuffer to write the text to. Limited by its size.
[out]p_eofEOF status of file after the operation.
Returns
OpError ... The error code or success.

◆ shptr()

void * SOF::shptr ( ) const
inlineoverrideprotectedvirtual

Pointer to the shared object.

Returns
void * ... The naked pointer.

Implements SOshptr.

◆ type()

std::string_view SOF::type ( ) const
inlineoverridevirtual

Returns a type name.

Returns
std::string_view ... The type name of the instance.

Implements SO.

◆ writestring() [1/3]

OpError SOF::writestring ( const char *  p_data)

Writes to file.

Precondition
p_data != nullptr
Parameters
[in]p_dataText to write.
Returns
OpError ... The error code or success.

◆ writestring() [2/3]

OpError SOF::writestring ( const std::string &  p_data)

Writes to file.

Parameters
[in]p_dataText to write.
Returns
OpError ... The error code or success.

◆ writestring() [3/3]

OpError SOF::writestring ( std::string_view  p_data)

Writes to file.

Parameters
[in]p_dataText to write.
Returns
OpError ... The error code or success.

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