ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
idoc::CTextFileLoaderComp Class Reference

Persistence component for files containing plain text. More...

#include <CTextFileLoaderComp.h>

Inheritance diagram for idoc::CTextFileLoaderComp:
icomp::CComponentBase ifile::IFilePersistence ifile::IDeviceBasedPersistence icomp::IComponent ifile::IFileTypeInfo istd::IPolymorphic istd::IPolymorphic istd::IPolymorphic

Public Types

typedef icomp::CComponentBase BaseClass
 
- Public Types inherited from ifile::IFilePersistence
enum  OperationState { OS_OK , OS_CANCELED , OS_FAILED }
 Result of operation. More...
 
enum  ErrorType { ET_NO_WRITE_PERMISSIONS , ET_NO_READ_PERMISSIONS , ET_FILE_NOT_EXIST }
 Possible file I/O errors. More...
 
enum  MessageId {
  MI_BAD_OBJECT_TYPE = 0xabf0 , MI_CANNOT_LOAD , MI_CANNOT_SAVE , MI_BAD_EXTENSION ,
  MI_FILE_NOT_EXIST , MI_UNSUPPORTED_VERSION
}
 List of possible message IDs used in context of this interface. More...
 
- Public Types inherited from ifile::IFileTypeInfo
enum  QueryFlags {
  QF_LOAD = 1 << 0 , QF_SAVE = 1 << 1 , QF_FILE = 1 << 2 , QF_DIRECTORY = 1 << 3 ,
  QF_ANONYMOUS = 1 << 4
}
 Describe detailed options of query. More...
 
- Public Types inherited from ifile::IDeviceBasedPersistence
enum  OperationState { Successful , Canceled , Failed }
 Result of device-related operation. More...
 
enum  DeviceOperation { ReadOperation = 1 , WriteOperation = 2 }
 
enum  ErrorType {
  NoWritePermissions , NoReadPermissions , NoDeviceAccess , ReadOperationFailed ,
  WriteOperationFailed , UnsupportedArchiveVersion
}
 Possible operation errors. More...
 

Public Member Functions

virtual bool IsOperationSupported (const istd::IChangeable *dataObjectPtr, const QString *filePathPtr=NULL, int flags=-1, bool beQuiet=true) const override
 Returns true if object dataObject can be loaded/saved.
 
virtual ifile::IFilePersistence::OperationState LoadFromFile (istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const override
 This function loads data data from file filePath.
 
virtual ifile::IFilePersistence::OperationState SaveToFile (const istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const override
 This function saves data data to file filePath.
 
virtual bool IsDeviceOperationSupported (const istd::IChangeable &dataObject, const QIODevice &device, int deviceOperation) const override
 Returns true if object dataObject can be processed via defined I/O-device.
 
virtual ifile::IDeviceBasedPersistence::OperationState ReadFromDevice (istd::IChangeable &data, QIODevice &device, ibase::IProgressManager *progressManagerPtr=nullptr) const override
 This function loads data data from the given I/O-device device.
 
virtual ifile::IDeviceBasedPersistence::OperationState WriteToDevice (const istd::IChangeable &data, QIODevice &device, ibase::IProgressManager *progressManagerPtr=nullptr) const override
 This function writes data data to the given I/O-device device.
 
virtual bool GetFileExtensions (QStringList &result, const istd::IChangeable *dataObjectPtr=NULL, int flags=-1, bool doAppend=false) const override
 Get file extensions supported by this loader.
 
virtual QString GetTypeDescription (const QString *extensionPtr=NULL) const override
 Get description of object type associated with single extension.
 
- Public Member Functions inherited from icomp::CComponentBase
 CComponentBase ()
 Create component and assign it to specific context.
 
virtual const icomp::IComponentGetParentComponent (bool ownerOnly=false) const override
 Get parent of this component.
 
virtual void * GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override
 Get access to specified component interface.
 
virtual IComponentContextSharedPtr GetComponentContext () const override
 Get access to component context describing all application-specified component information loaded from components registry.
 
virtual void SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override
 Set component context of this component.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Additional Inherited Members

- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual void OnComponentCreated ()
 
virtual void OnComponentDestroyed ()
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 
- Static Protected Member Functions inherited from icomp::CComponentBase
static const icomp::IRealComponentStaticInfoInitStaticInfo (IComponent *componentPtr)
 
static QByteArray GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray())
 

Detailed Description

Persistence component for files containing plain text.

This component handles loading and saving of plain text files. It implements the IFilePersistence interface to integrate with the ACF file I/O framework and IFileTypeInfo to provide file type metadata.

The loader supports multiple file extensions and can provide different type descriptions for each extension.

Component Attributes
  • FileExtensions - List of supported file extensions (default: "txt")
  • TypeDescriptions - List of human-readable descriptions for each extension (default: "Text file")
Registered Interfaces
Configuration Example
FileExtensions = ["txt", "log", "md"]
TypeDescriptions = ["Text file", "Log file", "Markdown file"]
}
Persistence component for files containing plain text.
Usage with Document Template
DocumentTypeId = "TextDocument"
DocumentFactory = CTextDocumentComp
DocumentLoader = CTextFileLoaderComp {
FileExtensions = ["txt", "text"]
TypeDescriptions = ["Text Document", "Plain Text"]
}
}
Document template component supporting only one type of the provided document.
Simple implementation of a text document model.

The component automatically handles:

See also
CTextDocumentComp, ITextDocument

Definition at line 62 of file CTextFileLoaderComp.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 65 of file CTextFileLoaderComp.h.

Member Function Documentation

◆ GetFileExtensions()

virtual bool idoc::CTextFileLoaderComp::GetFileExtensions ( QStringList &  result,
const istd::IChangeable dataObjectPtr = NULL,
int  flags = -1,
bool  doAppend = false 
) const
overridevirtual

Get file extensions supported by this loader.

Parameters
resultlist of extensions, e.g. {"txt", "doc"}.
dataObjectPtroptional pointer to data object for which all possible extensions are requested. It can be NULL if any object is meant.
flagsset of flags
See also
QueryFlags.
Parameters
doAppendif true, list of extensions should be appended to existing list.

Implements ifile::IFileTypeInfo.

◆ GetTypeDescription()

virtual QString idoc::CTextFileLoaderComp::GetTypeDescription ( const QString *  extensionPtr = NULL) const
overridevirtual

Get description of object type associated with single extension.

Implements ifile::IFileTypeInfo.

◆ IsDeviceOperationSupported()

virtual bool idoc::CTextFileLoaderComp::IsDeviceOperationSupported ( const istd::IChangeable dataObject,
const QIODevice &  device,
int  deviceOperation 
) const
overridevirtual

Returns true if object dataObject can be processed via defined I/O-device.

Parameters
dataObjectdata object should be red/written.

Implements ifile::IDeviceBasedPersistence.

◆ IsOperationSupported()

virtual bool idoc::CTextFileLoaderComp::IsOperationSupported ( const istd::IChangeable dataObjectPtr,
const QString *  filePathPtr = NULL,
int  flags = -1,
bool  beQuiet = true 
) const
overridevirtual

Returns true if object dataObject can be loaded/saved.

Parameters
dataObjectPtroptional pointer to data object should be loaded/stored. It can be NULL if any object is meant.
filePathPtroptional pointer to file should be loaded/stored. It can be NULL if any file is meant. If it points at empty string, anonymous loading is mean.
flagscombination of flags defined in QueryFlags and ifile::IFileTypeInfo::QueryFlags.
beQuietif true, no user message output is allowed.

Implements ifile::IFilePersistence.

◆ LoadFromFile()

virtual ifile::IFilePersistence::OperationState idoc::CTextFileLoaderComp::LoadFromFile ( istd::IChangeable data,
const QString &  filePath = QString(),
ibase::IProgressManager progressManagerPtr = NULL 
) const
overridevirtual

This function loads data data from file filePath.

Returns
File loading state.
See also
OperationState

Implements ifile::IFilePersistence.

◆ ReadFromDevice()

virtual ifile::IDeviceBasedPersistence::OperationState idoc::CTextFileLoaderComp::ReadFromDevice ( istd::IChangeable data,
QIODevice &  device,
ibase::IProgressManager progressManagerPtr = nullptr 
) const
overridevirtual

This function loads data data from the given I/O-device device.

Returns
State of the reading operation.
See also
OperationState

Implements ifile::IDeviceBasedPersistence.

◆ SaveToFile()

virtual ifile::IFilePersistence::OperationState idoc::CTextFileLoaderComp::SaveToFile ( const istd::IChangeable data,
const QString &  filePath = QString(),
ibase::IProgressManager progressManagerPtr = NULL 
) const
overridevirtual

This function saves data data to file filePath.

Returns
File saving state.
See also
OperationState

Implements ifile::IFilePersistence.

◆ WriteToDevice()

virtual ifile::IDeviceBasedPersistence::OperationState idoc::CTextFileLoaderComp::WriteToDevice ( const istd::IChangeable data,
QIODevice &  device,
ibase::IProgressManager progressManagerPtr = nullptr 
) const
overridevirtual

This function writes data data to the given I/O-device device.

Returns
State of the writing operation.
See also
OperationState

Implements ifile::IDeviceBasedPersistence.


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