Qore Programming Language 1.14.2
Loading...
Searching...
No Matches
QoreStringValueHelper Class Reference

this class is used to safely manage calls to AbstractQoreNode::getStringRepresentation() when a simple QoreString value is needed, stack only, may not be dynamically allocated More...

#include <QoreStringNode.h>

Public Member Methods

DLLEXPORT QoreStringValueHelper (const QoreValue n)
 creates the object and acquires a pointer to the QoreString representation of the QoreValue passed
 
DLLEXPORT QoreStringValueHelper (const QoreValue n, const QoreEncoding *enc, ExceptionSink *xsink)
 gets the QoreString representation and ensures that it's in the desired encoding More...
 
DLLEXPORT ~QoreStringValueHelper ()
 destroys the object and deletes the QoreString pointer being managed if it was a temporary pointer
 
DLLEXPORT char * giveBuffer ()
 returns a char* string that the caller owns and must free() More...
 
DLLEXPORT QoreStringgiveString ()
 returns a copy of the QoreString that the caller owns More...
 
DLLEXPORT bool is_temp () const
 returns true if the pointer being managed is temporary
 
DLLEXPORT const QoreStringoperator* ()
 returns the object being managed More...
 
DLLEXPORT const QoreStringoperator-> ()
 returns the object being managed More...
 

Detailed Description

this class is used to safely manage calls to AbstractQoreNode::getStringRepresentation() when a simple QoreString value is needed, stack only, may not be dynamically allocated

the QoreString value returned by this function is managed safely in an exception-safe way with this class

printf("str='%s'\n", str->getBuffer());
DLLEXPORT const char * getBuffer() const
returns the string's buffer; this data should not be changed
this class is used to safely manage calls to AbstractQoreNode::getStringRepresentation() when a simpl...
Definition: QoreStringNode.h:309

Constructor & Destructor Documentation

◆ QoreStringValueHelper()

DLLEXPORT QoreStringValueHelper::QoreStringValueHelper ( const QoreValue  n,
const QoreEncoding enc,
ExceptionSink xsink 
)

gets the QoreString representation and ensures that it's in the desired encoding

a Qore-language exception may be thrown if an encoding error occurs

// get a QoreString value from "node" and ensure it's in UTF-8 encoding
// return if there was an exception converting the encoding to UTF-8
if (*xsink)
return 0;
// use the string value
return new MStringData(t->getBuffer(), MEncoding::M_ASCII);
DLLEXPORT const QoreEncoding * QCS_UTF8
UTF-8 multi-byte encoding (only UTF-8 and UTF-16 are multi-byte encodings)
Definition: QoreEncoding.h:247

Member Function Documentation

◆ giveBuffer()

DLLEXPORT char * QoreStringValueHelper::giveBuffer ( )

returns a char* string that the caller owns and must free()

the object is empty after this call

◆ giveString()

DLLEXPORT QoreString * QoreStringValueHelper::giveString ( )

returns a copy of the QoreString that the caller owns

the object may be left empty after this call

Returns
a QoreString pointer owned by the caller

◆ operator*()

DLLEXPORT const QoreString * QoreStringValueHelper::operator* ( )

returns the object being managed

Returns
the object being managed

◆ operator->()

DLLEXPORT const QoreString * QoreStringValueHelper::operator-> ( )

returns the object being managed

Returns
the object being managed

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