Exemplo n.º 1
0
bool XMLWrapper::convertToString(const xmlChar *xmlText, std::string &text)
{
	bool result = false;

	xmlBufferPtr in = xmlBufferCreateStatic((void*) xmlText, xmlStrlen(xmlText));
	xmlBufferPtr out = xmlBufferCreate();
	int ret = xmlCharEncOutFunc(mCharEncodingHandler, out, in);
	if (ret >= 0) {
		result = true;
		text = (char*) xmlBufferContent(out);
	}

	xmlBufferFree(in);
	xmlBufferFree(out);

	return result;
}
Exemplo n.º 2
0
bool XMLWrapper::convertFromString(const char *text, xmlChar *&xmlText)
{
	bool result = false;

	xmlBufferPtr in = xmlBufferCreateStatic((void*) text, strlen(text));
	xmlBufferPtr out = xmlBufferCreate();
	int ret = xmlCharEncInFunc(mCharEncodingHandler, out, in);
	if (ret >= 0) {
		result = true;
		xmlText = xmlBufferDetach(out);
	}

	xmlBufferFree(in);
	xmlBufferFree(out);

	return result;
}
Exemplo n.º 3
0
bool XMLWrapper::convertFromString(const char *text, xmlChar *&xmlText)
{
	bool result = false;

	xmlBufferPtr in = xmlBufferCreateStatic((void*) text, strlen(text));
	xmlBufferPtr out = xmlBufferCreate();
	int ret = xmlCharEncInFunc(mCharEncodingHandler, out, in);
	if (ret >= 0) {
		result = true;
#if LIBXML_VERSION >= 20800
		xmlText = xmlBufferDetach(out);
#else
		xmlText = xmlStrdup(xmlBufferContent(out));
#endif
	}

	xmlBufferFree(in);
	xmlBufferFree(out);

	return result;
}