diff options
author | 2025-04-06 11:36:18 +0200 | |
---|---|---|
committer | 2025-04-06 11:36:18 +0200 | |
commit | 8e310421adfa157a0a62c903b0bcd83cf27c3f46 (patch) | |
tree | 4b5822d46eb5be76109f3cc3fa879ad376176312 | |
parent | 636ec1f53bf3087cdd33eb447d8a066ba80ae8f5 (diff) | |
download | libplist-8e310421adfa157a0a62c903b0bcd83cf27c3f46.tar.gz libplist-8e310421adfa157a0a62c903b0bcd83cf27c3f46.tar.bz2 |
C++: Add new Structure::FromMemory()
-rw-r--r-- | include/plist/Structure.h | 2 | ||||
-rw-r--r-- | src/Structure.cpp | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/plist/Structure.h b/include/plist/Structure.h index d85b17a..b7fbdb5 100644 --- a/include/plist/Structure.h +++ b/include/plist/Structure.h @@ -44,6 +44,8 @@ public : static Structure* FromXml(const std::string& xml); static Structure* FromBin(const std::vector<char>& bin); static Structure* FromBin(const char* bin, uint64_t size); + static Structure* FromMemory(const std::vector<char>& buf, plist_format_t* format = NULL); + static Structure* FromMemory(const char* buf, uint64_t size, plist_format_t* format = NULL); protected: Structure(Node* parent = NULL); diff --git a/src/Structure.cpp b/src/Structure.cpp index f56b0e6..65e5ca8 100644 --- a/src/Structure.cpp +++ b/src/Structure.cpp @@ -127,4 +127,17 @@ Structure* Structure::FromBin(const char* bin, uint64_t size) 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 |