Heart 1.4.984.b4712811
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
QH::TranslatableString Class Reference

The TranslatableString class is a wrapper for The QString with boolean flag isKey. More...

#include <translatablestring.h>

Inheritance diagram for QH::TranslatableString:
Inheritance graph
Collaboration diagram for QH::TranslatableString:
Collaboration graph

Public Member Functions

 TranslatableString (int data)
 TranslatableString (const QString &data="", bool isKey=true)
 TranslatableString (const QList< TranslatableString > &pack)
 TranslatableString (const TranslatableString &)=default
 TranslatableString (TranslatableString &&)=default
TranslatableString & operator= (const TranslatableString &)=default
TranslatableString & operator= (TranslatableString &&)=default
bool operator== (const TranslatableString &other) const
bool isValid () const override
bool isEmpty () const
QString text () const
 text this method return translated text.
const QString & rawText () const
 rawText return raw key source.
uint32_t calcCrc32Hash () const
 calcCrc32Hash this method calc hash from raw text.
TranslatableString & setArgs (const QList< TranslatableString > &newArgs)
 setArgs this method set args for translation.
TranslatableString & arg (const TranslatableString &newArg)
TranslatableString & arg (int newArg)
Public Member Functions inherited from QH::StreamMultiversion
 StreamMultiversion ()
 ~StreamMultiversion ()
Public Member Functions inherited from QH::StreamBase
 StreamBase ()
virtual ~StreamBase ()
bool fromBytes (const QByteArray &dataz)
 fromBytes This method provide initialization of object from byte array.
QByteArray toBytes () const
 toBytes This method convert a current object to bytes array.
bool fromBase64 (const QString &data)
 fromBase64 This method provide initialization of object from the base64 string.
bool fromBase64 (const QByteArray &data)
 fromBase64 This method provide initialization of object from the base64 string.
QByteArray toBase64 () const
 toBase64 This method convert a current object to the base64 string.
template<class T>
T & copy (const StreamBase &right)
 copy This is base copy method for all StreamBase structures. Default implementation it is copy from byteArray.
template<class T>
bool compare (const T &right)
 compare This method compare array signatures of this and right objects.

Static Public Member Functions

static TranslatableString tr (const QString &source)
 tr this method create a string translation wrapper and save translation key for lupdate tool

Protected Member Functions

QDataStream & fromStream (QDataStream &stream) override
 fromStream This method should be read all bytes from the stream object and full the current object.
QDataStream & toStream (QDataStream &stream) const override
 fromStream This method should be write all members of the current object to the stream object.
Protected Member Functions inherited from QH::StreamMultiversion
void saveVersion (char version, QDataStream &stream) const
 saveVersion save version of the object to the stream.
char readVersion (QDataStream &stream)
 readVersion read version of the object from the stream.
char versionHeader (char version, QDataStream &stream)
 versionHeader this is new function that automaticaly choose what shuld be to-do (read/wirte).
char versionHeader (char version, QDataStream &stream) const
 versionHeader this is new function that automaticaly choose what shuld be to-do (read/wirte).
template<class T>
void readWrite (QDataStream &stream, const T &data) const
 readWrite this method automaticaly choose what we need to-do read or write.
template<class T>
void readWrite (QDataStream &stream, T &data)
 readWrite this method automaticaly choose what we need to-do read or write.
template<typename... Args>
void readWritePack (QDataStream &stream, Args &&... args) const
 readWritePack - this is a pack write or read from the srting
template<typename... Args>
void readWritePack (QDataStream &stream, Args &&... args)
 readWritePack - this is a pack write or read from the srting
Protected Member Functions inherited from QH::StreamBase
virtual int parsingVersion () const
 parsingVersion this method return parsing version of Qt. By Default is 0 (last available parsing). see https://doc.qt.io/qt-6/qdatastream.html#Version-enum
virtual unsigned int typeId () const
 typeId This method return id of type.

Detailed Description

The TranslatableString class is a wrapper for The QString with boolean flag isKey.

Note
ise this class if you want to save text into file and want to get correct translations after reading.

Definition at line 21 of file translatablestring.h.

Constructor & Destructor Documentation

◆ TranslatableString() [1/5]

QH::TranslatableString::TranslatableString ( int data)

Definition at line 14 of file translatablestring.cpp.

Here is the caller graph for this function:

◆ TranslatableString() [2/5]

QH::TranslatableString::TranslatableString ( const QString & data = "",
bool isKey = true )

Definition at line 19 of file translatablestring.cpp.

◆ TranslatableString() [3/5]

QH::TranslatableString::TranslatableString ( const QList< TranslatableString > & pack)

Definition at line 24 of file translatablestring.cpp.

◆ TranslatableString() [4/5]

QH::TranslatableString::TranslatableString ( const TranslatableString & )
default
Here is the call graph for this function:

◆ TranslatableString() [5/5]

QH::TranslatableString::TranslatableString ( TranslatableString && )
default
Here is the call graph for this function:

Member Function Documentation

◆ arg() [1/2]

TranslatableString & QH::TranslatableString::arg ( const TranslatableString & newArg)

Definition at line 103 of file translatablestring.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ arg() [2/2]

TranslatableString & QH::TranslatableString::arg ( int newArg)

Definition at line 109 of file translatablestring.cpp.

Here is the call graph for this function:

◆ calcCrc32Hash()

uint32_t QH::TranslatableString::calcCrc32Hash ( ) const

calcCrc32Hash this method calc hash from raw text.

Returns

Definition at line 65 of file translatablestring.cpp.

Here is the caller graph for this function:

◆ fromStream()

QDataStream & QH::TranslatableString::fromStream ( QDataStream & stream)
overrideprotectedvirtual

fromStream This method should be read all bytes from the stream object and full the current object.

Note
The implementation of this method should be invoke a method of base class.
Parameters
streamThis is Qt stream object.
Returns
Qt stream object.

Example of base simple implementation:

QDataStream &ExampleClass::fromStream(QDataStream &stream) const {
stream >> exampleMember;
return stream;
}
virtual QDataStream & toStream(QDataStream &stream) const =0
fromStream This method should be write all members of the current object to the stream object.

Implements QH::StreamBase.

Definition at line 75 of file translatablestring.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpty()

bool QH::TranslatableString::isEmpty ( ) const

Definition at line 36 of file translatablestring.cpp.

Here is the caller graph for this function:

◆ isValid()

bool QH::TranslatableString::isValid ( ) const
override

Definition at line 32 of file translatablestring.cpp.

Here is the caller graph for this function:

◆ operator=() [1/2]

TranslatableString & QH::TranslatableString::operator= ( const TranslatableString & )
default
Here is the call graph for this function:

◆ operator=() [2/2]

TranslatableString & QH::TranslatableString::operator= ( TranslatableString && )
default
Here is the call graph for this function:

◆ operator==()

bool QH::TranslatableString::operator== ( const TranslatableString & other) const

Definition at line 28 of file translatablestring.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rawText()

const QString & QH::TranslatableString::rawText ( ) const

rawText return raw key source.

Returns
source text (key if object created with the qtTrId method)

Definition at line 61 of file translatablestring.cpp.

Here is the caller graph for this function:

◆ setArgs()

TranslatableString & QH::TranslatableString::setArgs ( const QList< TranslatableString > & newArgs)

setArgs this method set args for translation.

Parameters
newArgsthis is a list of args.
Returns
this object.

Definition at line 97 of file translatablestring.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ text()

QString QH::TranslatableString::text ( ) const

text this method return translated text.

Returns

Definition at line 40 of file translatablestring.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toStream()

QDataStream & QH::TranslatableString::toStream ( QDataStream & stream) const
overrideprotectedvirtual

fromStream This method should be write all members of the current object to the stream object.

Note
The implementation of this method should be invoke a method of base class.
Parameters
streamThis is Qt stream object.
Returns
Qt stream object.

Example of base simple implementation:

QDataStream &ExampleClass::toStream(QDataStream &stream) const {
stream << exampleMember;
return stream;
}

Implements QH::StreamBase.

Definition at line 86 of file translatablestring.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tr()

TranslatableString QH::TranslatableString::tr ( const QString & source)
static

tr this method create a string translation wrapper and save translation key for lupdate tool

Parameters
sourcethis is text source.
Returns

Definition at line 71 of file translatablestring.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

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