summaryrefslogtreecommitdiffstats
path: root/src/Structure.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Structure.cpp')
-rw-r--r--src/Structure.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/Structure.cpp b/src/Structure.cpp
index 18b19ef..65e5ca8 100644
--- a/src/Structure.cpp
+++ b/src/Structure.cpp
@@ -18,7 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <stdlib.h>
+#include <cstdlib>
+#include "plist.h"
#include <plist/Structure.h>
namespace PList
@@ -35,7 +36,7 @@ Structure::~Structure()
{
}
-uint32_t Structure::GetSize()
+uint32_t Structure::GetSize() const
{
uint32_t size = 0;
plist_type type = plist_get_node_type(_node);
@@ -50,7 +51,7 @@ uint32_t Structure::GetSize()
return size;
}
-std::string Structure::ToXml()
+std::string Structure::ToXml() const
{
char* xml = NULL;
uint32_t length = 0;
@@ -60,7 +61,7 @@ std::string Structure::ToXml()
return ret;
}
-std::vector<char> Structure::ToBin()
+std::vector<char> Structure::ToBin() const
{
char* bin = NULL;
uint32_t length = 0;
@@ -76,7 +77,7 @@ void Structure::UpdateNodeParent(Node* node)
if ( NULL != node->_parent )
{
plist_type type = plist_get_node_type(node->_parent);
- if (PLIST_ARRAY ==type || PLIST_DICT == type )
+ if (PLIST_ARRAY == type || PLIST_DICT == type)
{
Structure* s = static_cast<Structure*>(node->_parent);
s->Remove(node);
@@ -116,8 +117,27 @@ Structure* Structure::FromBin(const std::vector<char>& bin)
plist_from_bin(&bin[0], bin.size(), &root);
return ImportStruct(root);
+}
+
+Structure* Structure::FromBin(const char* bin, uint64_t size)
+{
+ plist_t root = NULL;
+ plist_from_bin(bin, size, &root);
+
+ return ImportStruct(root);
+}
+Structure* Structure::FromMemory(const std::vector<char>& buf, plist_format_t *format)
+{
+ return Structure::FromMemory(&buf[0], buf.size(), format);
+}
+
+Structure* Structure::FromMemory(const char* buf, uint64_t size, plist_format_t *format)
+{
+ plist_t root = NULL;
+ plist_from_memory(buf, size, &root, format);
+ return ImportStruct(root);
}
-};
+} // namespace PList