Version: 9.12.0
QtxResourceMgr::Format Class Referenceabstract

Generic resources files reader/writer class. More...

#include <QtxResourceMgr.h>

Inheritance diagram for QtxResourceMgr::Format:
Inheritance graph

Public Member Functions

 Format (const QString &)
 Constructor. More...
 
virtual ~Format ()
 Destructor. More...
 
QString format () const
 Get the format name. More...
 
QStringList options () const
 Get options names. More...
 
QString option (const QString &) const
 Get the value of the option with specified name. More...
 
void setOption (const QString &, const QString &)
 Set the value of the option with specified name. More...
 
bool load (Resources *)
 Load resources from the resource file. More...
 
bool save (Resources *)
 Save resources to the resource file. More...
 

Protected Member Functions

virtual bool load (const QString &, QMap< QString, Section > &)=0
 Load resources from the specified resources file. More...
 
virtual bool save (const QString &, const QMap< QString, Section > &)=0
 Save resources to the specified resources file. More...
 

Private Attributes

QString myFmt
 format name More...
 
QMap< QString, QString > myOpt
 options map More...
 

Detailed Description

Generic resources files reader/writer class.

Constructor & Destructor Documentation

◆ Format()

QtxResourceMgr::Format::Format ( const QString &  fmt)

Constructor.

Parameters
fmtformat name (for example, "xml" or "ini")

◆ ~Format()

QtxResourceMgr::Format::~Format ( )
virtual

Destructor.

Member Function Documentation

◆ format()

QString QtxResourceMgr::Format::format ( ) const

Get the format name.

Returns
format name

◆ load() [1/2]

bool QtxResourceMgr::Format::load ( const QString &  fname,
QMap< QString, Section > &  secMap 
)
protectedpure virtual

Load resources from the specified resources file.

Should be implemented in the successors.

Parameters
fnameresources file name
secMapresources map to be filled in
Returns
true on success and false on error

Implemented in QtxResourceMgr::JsonFormat, QtxResourceMgr::XmlFormat, and QtxResourceMgr::IniFormat.

◆ load() [2/2]

bool QtxResourceMgr::Format::load ( Resources res)

Load resources from the resource file.

Parameters
resresources object
Returns
true on success and false on error

References QtxResourceMgr::load(), QtxResourceMgr::Resources::myFileName, QtxResourceMgr::Resources::mySections, and QtxResourceMgr::sections().

◆ option()

QString QtxResourceMgr::Format::option ( const QString &  opt) const

Get the value of the option with specified name.

If option doesn't exist then null QString is returned.

Parameters
optoption name
Returns
option value

◆ options()

QStringList QtxResourceMgr::Format::options ( ) const

Get options names.

Returns
list of the format options

◆ save() [1/2]

bool QtxResourceMgr::Format::save ( const QString &  fname,
const QMap< QString, Section > &  secMap 
)
protectedpure virtual

Save resources to the specified resources file.

Should be implemented in the successors.

Parameters
fnameresources file name
secMapresources map
Returns
true on success and false on error

Implemented in QtxResourceMgr::JsonFormat, QtxResourceMgr::XmlFormat, and QtxResourceMgr::IniFormat.

◆ save() [2/2]

bool QtxResourceMgr::Format::save ( Resources res)

Save resources to the resource file.

Parameters
resresources object
Returns
true on success and false on error

References QtxResourceMgr::appName(), Qtx::dir(), Qtx::mkDir(), QtxResourceMgr::Resources::myFileName, QtxResourceMgr::Resources::mySections, QtxResourceMgr::Resources::resMgr(), QtxResourceMgr::save(), and QtxResourceMgr::userFileName().

◆ setOption()

void QtxResourceMgr::Format::setOption ( const QString &  opt,
const QString &  val 
)

Set the value of the option with specified name.

Parameters
optoption name
valoption value

Member Data Documentation

◆ myFmt

QString QtxResourceMgr::Format::myFmt
private

format name

◆ myOpt

QMap<QString, QString> QtxResourceMgr::Format::myOpt
private

options map


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