summaryrefslogtreecommitdiffstats
path: root/include/plist
diff options
context:
space:
mode:
Diffstat (limited to 'include/plist')
-rw-r--r--include/plist/Array.h19
-rw-r--r--include/plist/Data.h1
-rw-r--r--include/plist/Date.h6
-rw-r--r--include/plist/Dictionary.h5
-rw-r--r--include/plist/String.h3
-rw-r--r--include/plist/Structure.h3
-rw-r--r--include/plist/plist.h84
7 files changed, 100 insertions, 21 deletions
diff --git a/include/plist/Array.h b/include/plist/Array.h
index 0239c78..f4360c5 100644
--- a/include/plist/Array.h
+++ b/include/plist/Array.h
@@ -43,6 +43,10 @@ public :
typedef std::vector<Node*>::const_iterator const_iterator;
Node* operator[](unsigned int index);
+ Node* Back();
+ Node* back();
+ Node* Front();
+ Node* front();
iterator Begin();
iterator begin();
iterator End();
@@ -52,11 +56,20 @@ public :
const_iterator End() const;
const_iterator end() const;
size_t size() const;
- void Append(Node* node);
- void Insert(Node* node, unsigned int pos);
+ void Append(const Node& node);
+ void Append(const Node* node);
+ void Insert(const Node& node, unsigned int pos);
+ void Insert(const Node* node, unsigned int pos);
void Remove(Node* node);
void Remove(unsigned int pos);
- unsigned int GetNodeIndex(Node* node) const;
+ unsigned int GetNodeIndex(const Node& node) const;
+ unsigned int GetNodeIndex(const Node* node) const;
+ template <typename T> T* at(unsigned int index) {
+ return (T*)(_array.at(index));
+ }
+ template <typename T> T* At(unsigned int index) {
+ return (T*)(_array.at(index));
+ }
private :
std::vector<Node*> _array;
diff --git a/include/plist/Data.h b/include/plist/Data.h
index b566a6c..1de88aa 100644
--- a/include/plist/Data.h
+++ b/include/plist/Data.h
@@ -36,6 +36,7 @@ public :
Data(const Data& d);
Data& operator=(const Data& b);
Data(const std::vector<char>& buff);
+ Data(const char* buff, uint64_t size);
virtual ~Data();
Node* Clone() const;
diff --git a/include/plist/Date.h b/include/plist/Date.h
index 5113cf3..7026699 100644
--- a/include/plist/Date.h
+++ b/include/plist/Date.h
@@ -40,13 +40,13 @@ public :
Date(plist_t node, Node* parent = NULL);
Date(const Date& d);
Date& operator=(const Date& d);
- Date(timeval t);
+ Date(int64_t t);
virtual ~Date();
Node* Clone() const;
- void SetValue(timeval t);
- timeval GetValue() const;
+ void SetValue(int64_t t);
+ int64_t GetValue() const;
};
};
diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h
index 583a430..37ff1c9 100644
--- a/include/plist/Dictionary.h
+++ b/include/plist/Dictionary.h
@@ -60,11 +60,12 @@ public :
void Remove(Node* node);
void Remove(const std::string& key);
std::string GetNodeKey(Node* node);
+ template <typename T> T* Get(const std::string& key) {
+ return (T*)(_map[key]);
+ }
private :
std::map<std::string,Node*> _map;
-
-
};
};
diff --git a/include/plist/String.h b/include/plist/String.h
index 9aba16b..95f8dd1 100644
--- a/include/plist/String.h
+++ b/include/plist/String.h
@@ -35,7 +35,10 @@ public :
String(plist_t node, Node* parent = NULL);
String(const String& s);
String& operator=(const String& s);
+ String& operator=(const std::string& s);
+ String& operator=(const char* s);
String(const std::string& s);
+ String(const char *s);
virtual ~String();
Node* Clone() const;
diff --git a/include/plist/Structure.h b/include/plist/Structure.h
index eded8b2..b7fbdb5 100644
--- a/include/plist/Structure.h
+++ b/include/plist/Structure.h
@@ -43,6 +43,9 @@ 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/include/plist/plist.h b/include/plist/plist.h
index aff81e9..41af8ce 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -263,12 +263,11 @@ extern "C"
/**
* Create a new plist_t type #PLIST_DATE
*
- * @param sec the number of seconds since 01/01/2001
- * @param usec the number of microseconds
+ * @param sec The number of seconds since 01/01/1970 (UNIX timestamp)
* @return the created item
* @sa #plist_type
*/
- PLIST_API plist_t plist_new_date(int32_t sec, int32_t usec);
+ PLIST_API plist_t plist_new_unix_date(int64_t sec);
/**
* Create a new plist_t type #PLIST_UID
@@ -775,10 +774,9 @@ extern "C"
* This function does nothing if node is not of type #PLIST_DATE
*
* @param node the node
- * @param sec a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001.
- * @param usec a pointer to an int32_t variable. Represents the number of microseconds
+ * @param sec a pointer to an int64_t variable. Represents the number of seconds since 01/01/1970 (UNIX timestamp).
*/
- PLIST_API void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec);
+ PLIST_API void plist_get_unix_date_val(plist_t node, int64_t *sec);
/**
* Get the value of a #PLIST_UID node.
@@ -867,10 +865,9 @@ extern "C"
* Forces type of node to #PLIST_DATE
*
* @param node the node
- * @param sec the number of seconds since 01/01/2001
- * @param usec the number of microseconds
+ * @param sec the number of seconds since 01/01/1970 (UNIX timestamp)
*/
- PLIST_API void plist_set_date_val(plist_t node, int32_t sec, int32_t usec);
+ PLIST_API void plist_set_unix_date_val(plist_t node, int64_t sec);
/**
* Set the value of a node.
@@ -1213,16 +1210,15 @@ extern "C"
/**
* Helper function to compare the value of a PLIST_DATE node against
- * a given set of seconds and fraction of a second since epoch.
+ * a given number of seconds since epoch (UNIX timestamp).
*
* @param datenode node of type PLIST_DATE
- * @param cmpsec number of seconds since epoch to compare against
- * @param cmpusec fraction of a second in microseconds to compare against
+ * @param cmpval Number of seconds to compare against (UNIX timestamp)
* @return 0 if the node's date is equal to the supplied values,
* 1 if the node's date is greater than the supplied values,
* or -1 if the node's date is less than the supplied values.
*/
- PLIST_API int plist_date_val_compare(plist_t datenode, int32_t cmpsec, int32_t cmpusec);
+ PLIST_API int plist_unix_date_val_compare(plist_t datenode, int64_t cmpval);
/**
* Helper function to compare the value of a PLIST_STRING node against
@@ -1382,6 +1378,68 @@ extern "C"
*/
PLIST_API const char* libplist_version();
+
+ /********************************************
+ * *
+ * Deprecated API *
+ * *
+ ********************************************/
+
+ /**
+ * Create a new plist_t type #PLIST_DATE
+ *
+ * @deprecated Deprecated. Use plist_new_unix_date instead.
+ *
+ * @param sec the number of seconds since 01/01/2001
+ * @param usec the number of microseconds
+ * @return the created item
+ * @sa #plist_type
+ */
+ PLIST_WARN_DEPRECATED("use plist_new_unix_date instead")
+ PLIST_API plist_t plist_new_date(int32_t sec, int32_t usec);
+
+ /**
+ * Get the value of a #PLIST_DATE node.
+ * This function does nothing if node is not of type #PLIST_DATE
+ *
+ * @deprecated Deprecated. Use plist_get_unix_date_val instead.
+ *
+ * @param node the node
+ * @param sec a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001.
+ * @param usec a pointer to an int32_t variable. Represents the number of microseconds
+ */
+ PLIST_WARN_DEPRECATED("use plist_get_unix_date_val instead")
+ PLIST_API void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec);
+
+ /**
+ * Set the value of a node.
+ * Forces type of node to #PLIST_DATE
+ *
+ * @deprecated Deprecated. Use plist_set_unix_date_val instead.
+ *
+ * @param node the node
+ * @param sec the number of seconds since 01/01/2001
+ * @param usec the number of microseconds
+ */
+ PLIST_WARN_DEPRECATED("use plist_set_unix_date_val instead")
+ PLIST_API void plist_set_date_val(plist_t node, int32_t sec, int32_t usec);
+
+ /**
+ * Helper function to compare the value of a PLIST_DATE node against
+ * a given set of seconds and fraction of a second since epoch.
+ *
+ * @deprecated Deprecated. Use plist_unix_date_val_compare instead.
+ *
+ * @param datenode node of type PLIST_DATE
+ * @param cmpsec number of seconds since epoch to compare against
+ * @param cmpusec fraction of a second in microseconds to compare against
+ * @return 0 if the node's date is equal to the supplied values,
+ * 1 if the node's date is greater than the supplied values,
+ * or -1 if the node's date is less than the supplied values.
+ */
+ PLIST_WARN_DEPRECATED("use plist_unix_date_val_compare instead")
+ PLIST_API int plist_date_val_compare(plist_t datenode, int32_t cmpsec, int32_t cmpusec);
+
/*@}*/
#ifdef __cplusplus