QoreStringNodeValueHelper Class Reference

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

`#include <QoreStringNode.h>`

## Public Member Functions

DLLEXPORT | QoreStringNodeValueHelper (const QoreValue n, const QoreEncoding *enc, ExceptionSink *xsink)
| gets the QoreString representation and ensures that it's in the desired encoding More...
DLLEXPORT | ~QoreStringNodeValueHelper ()
| destroys the object and dereferences the QoreStringNode if it is a temporary pointer
DLLEXPORT QoreStringNode * | getReferencedValue ()
| returns a referenced value - the caller will own the reference More...
DLLLOCAL bool | is_temp () const
| returns true if the referenced being managed is temporary
DLLLOCAL const QoreStringNode * | operator* ()
| returns the object being managed More...
DLLLOCAL const QoreStringNode * | operator-> ()
| returns the object being managed More...

## Detailed Description

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

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

QoreStringNodeValueHelper str(n);
printf("str='%s'\n", str->getBuffer());
return str.getReferencedValue();

## Constructor & Destructor Documentation

## QoreStringNodeValueHelper()

DLLEXPORT QoreStringNodeValueHelper::QoreStringNodeValueHelper | ( | 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
QoreStringNodeValueHelper 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);

## Member Function Documentation

## getReferencedValue()

DLLEXPORT QoreStringNode* QoreStringNodeValueHelper::getReferencedValue | ( |  | ) |

returns a referenced value - the caller will own the reference

The string is referenced if necessary (if it was a not a temporary value)

Returns
  the string value, where the caller will own the reference count

## operator*()

DLLLOCAL const QoreStringNode* QoreStringNodeValueHelper::operator* | ( |  | ) |

inline

returns the object being managed

Returns
  the object being managed

## operator->()

DLLLOCAL const QoreStringNode* QoreStringNodeValueHelper::operator-> | ( |  | ) |

inline

returns the object being managed

Returns
  the object being managed

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

- include/qore/QoreStringNode.h

QoreStringNodeValueHelper
this class is used to safely manage calls to AbstractQoreNode::getStringRepresentation() when a QoreS...
Definition: QoreStringNode.h:401
QCS_UTF8
DLLEXPORT const QoreEncoding * QCS_UTF8
UTF-8 multi-byte encoding (only UTF-8 and UTF-16 are multi-byte encodings)
Definition: QoreEncoding.h:250
QoreString::getBuffer
DLLEXPORT const char * getBuffer() const
returns the string's buffer; this data should not be changed