Safir SDK Core
Loading...
Searching...
No Matches
Safir::Dob::Typesystem::StringContainer Class Reference

Container for strings (std::wstring). More...

#include <Safir/Dob/Typesystem/ValueContainers.h>

Inheritance diagram for Safir::Dob::Typesystem::StringContainer:
[legend]
Collaboration diagram for Safir::Dob::Typesystem::StringContainer:
[legend]

Public Types

typedef std::wstring ContainedType
 

Public Member Functions

 StringContainer ()
 Default constructor.
 
void SetVal (const std::wstring &value)
 Set the value of the container.
 
const std::wstring & GetVal () const
 Get the value of the container.
 
bool IsNull () const override
 Is the container set to null?
 
void SetNull () override
 Set the container to null.
 
void Copy (const ContainerBase &that) override
 Virtual assignment.
 
UTF8 encoding methods.

These methods are really only meant for the blob serialization and deserialization, but it is quite safe to use them if you really need them.

Int32 Utf8StringLength () const
 Calculate the length needed for this string in UTF8 encoding.
 
const std::string & Utf8String () const
 Convert the string to a UTF8 encoded std::string.
 
- Public Member Functions inherited from Safir::Dob::Typesystem::ContainerBase
constexpr ContainerBase ()
 Default Constructor.
 
constexpr ContainerBase (const ContainerBase &)=default
 Copy constructor.
 
virtual ~ContainerBase ()
 Virtual destructor.
 
virtual bool IsChanged () const
 Is the change flag set on the container?
 
virtual void SetChanged (const bool changed)
 Set the containers change flag.
 

Friends

class Safir::Dob::Typesystem::Internal::BlobOperations
 

Additional Inherited Members

- Protected Member Functions inherited from Safir::Dob::Typesystem::ContainerBase
ContainerBaseoperator= (const ContainerBase &other)
 Copy assignment operator.
 
- Protected Attributes inherited from Safir::Dob::Typesystem::ContainerBase
bool m_bIsChanged
 The variable containing the change flag.
 

Detailed Description

Container for strings (std::wstring).

This is a container for strings. It differs from the ordinary ValueContainer in that it has methods for converting to UTF8 strings. These are really only meant for blob serialization to use.

Member Typedef Documentation

◆ ContainedType

Constructor & Destructor Documentation

◆ StringContainer()

Safir::Dob::Typesystem::StringContainer::StringContainer ( )

Default constructor.

Creates a null and not changed container.

Member Function Documentation

◆ Copy()

void Safir::Dob::Typesystem::StringContainer::Copy ( const ContainerBase & that)
overridevirtual

Virtual assignment.

Copy all the members from "that" into "this". Types must be the same for this to work!

Parameters
that[in] - The object to copy into this.
Exceptions
SoftwareViolationExceptionIf the types are not of the same kind.

Implements Safir::Dob::Typesystem::ContainerBase.

References __WFILE__.

◆ GetVal()

const std::wstring & Safir::Dob::Typesystem::StringContainer::GetVal ( ) const

Get the value of the container.

Returns
The value of the container.
Exceptions
NullExceptionThe container is null.

References __WFILE__.

◆ IsNull()

bool Safir::Dob::Typesystem::StringContainer::IsNull ( ) const
overridevirtual

Is the container set to null?

Returns
True if the container is set to null.

Implements Safir::Dob::Typesystem::ContainerBase.

Referenced by Utf8String(), and Utf8StringLength().

Here is the caller graph for this function:

◆ SetNull()

void Safir::Dob::Typesystem::StringContainer::SetNull ( )
overridevirtual

◆ SetVal()

void Safir::Dob::Typesystem::StringContainer::SetVal ( const std::wstring & value)

Set the value of the container.

Null and change flags are updated accordingly.

Parameters
value[in] - The new value.

References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

◆ Utf8String()

const std::string & Safir::Dob::Typesystem::StringContainer::Utf8String ( ) const

Convert the string to a UTF8 encoded std::string.

This method converts the string to utf8 (and caches it) and returns the result.

Returns
UTF8 string
Exceptions
NullExceptionThe container is null.

References __WFILE__, IsNull(), and Safir::Dob::Typesystem::Utilities::ToUtf8().

Here is the call graph for this function:

◆ Utf8StringLength()

Int32 Safir::Dob::Typesystem::StringContainer::Utf8StringLength ( ) const

Calculate the length needed for this string in UTF8 encoding.

This method converts the string to utf8 (and caches it) and returns the length of the converted string.

The returned value includes space for null termination (adds 1 to string length).

Returns
The length of the string when converted to UTF8, or 0 if the container is null.

References IsNull(), and Safir::Dob::Typesystem::Utilities::ToUtf8().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ Safir::Dob::Typesystem::Internal::BlobOperations

friend class Safir::Dob::Typesystem::Internal::BlobOperations
friend