summaryrefslogtreecommitdiff
path: root/src/pugixpath.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:22:54 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:22:54 +0000
commit053a4c0ea79fa2b18d693ad683b8dd22ffea9f49 (patch)
tree7f6d044ea636a66ce03c14b2fc8df692a380097e /src/pugixpath.cpp
parent0c5b9341bc7c49ebfba2da0e52dd9cda96f2931c (diff)
XPath: Introduced new evaluate_string API (without STL), enabled XPath without STL
git-svn-id: http://pugixml.googlecode.com/svn/trunk@659 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixpath.cpp')
-rw-r--r--src/pugixpath.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp
index 0a3aadf..378138d 100644
--- a/src/pugixpath.cpp
+++ b/src/pugixpath.cpp
@@ -28,6 +28,12 @@
# include <wchar.h>
#endif
+#include <new>
+
+#ifndef PUGIXML_NO_STL
+# include <string>
+#endif
+
// int32_t
#if !defined(_MSC_VER) || _MSC_VER >= 1600
# include <stdint.h>
@@ -50,8 +56,6 @@ typedef __int32 int32_t;
# pragma diag_suppress=237 // controlling expression is constant
#endif
-#include <string>
-
// String utilities prototypes
namespace pugi
{
@@ -3762,6 +3766,7 @@ namespace pugi
return _root->eval_number(c);
}
+#ifndef PUGIXML_NO_STL
string_t xpath_query::evaluate_string(const xml_node& n) const
{
if (!_root) return string_t();
@@ -3770,7 +3775,21 @@ namespace pugi
return _root->eval_string(c).c_str();
}
+#endif
+ size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xml_node& n) const
+ {
+ xpath_context c(n, 1, 1);
+ xpath_string r = _root ? _root->eval_string(c) : xpath_string();
+
+ size_t size = r.length() + 1;
+
+ // $$ zero-terminate?
+ if (capacity > 0) memcpy(buffer, r.c_str(), size < capacity ? size : capacity);
+
+ return size;
+ }
+
xpath_node_set xpath_query::evaluate_node_set(const xml_node& n) const
{
if (!_root) return xpath_node_set();