#include <QoreStringNode.h>
Public Member Functions | |
DLLLOCAL | QoreStringValueHelper (const AbstractQoreNode *n) |
creates the object and acquires a pointer to the QoreString representation of the AbstractQoreNode passed | |
DLLLOCAL | QoreStringValueHelper (const AbstractQoreNode *n, const QoreEncoding *enc, ExceptionSink *xsink) |
gets the QoreString representation and ensures that it's in the desired encoding | |
DLLLOCAL | ~QoreStringValueHelper () |
destroys the object and deletes the QoreString pointer being managed if it was a temporary pointer | |
DLLLOCAL const QoreString * | operator-> () |
returns the object being managed | |
DLLLOCAL const QoreString * | operator* () |
returns the object being managed | |
DLLLOCAL QoreString * | giveString () |
returns a copy of the QoreString that the caller owns | |
DLLLOCAL bool | is_temp () const |
returns true if the pointer being managed is temporary |
the QoreString value returned by this function is managed safely in an exception-safe way with this class
QoreStringValueHelper str(n); printf("str='%s'\n", str->getBuffer());
DLLLOCAL QoreStringValueHelper::QoreStringValueHelper | ( | const AbstractQoreNode * | n, | |
const QoreEncoding * | enc, | |||
ExceptionSink * | xsink | |||
) | [inline] |
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 QoreStringValueHelper t(node, QCS_UTF8, xsink); // 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);
References QoreString::convertEncoding(), QoreString::getEncoding(), AbstractQoreNode::getStringRepresentation(), AbstractQoreNode::getType(), and NT_STRING.
DLLLOCAL const QoreString* QoreStringValueHelper::operator-> | ( | ) | [inline] |
returns the object being managed
DLLLOCAL const QoreString* QoreStringValueHelper::operator* | ( | ) | [inline] |
returns the object being managed
DLLLOCAL QoreString* QoreStringValueHelper::giveString | ( | ) | [inline] |
returns a copy of the QoreString that the caller owns
the object may be left empty after this call
References QoreString::copy().