You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/10/19 22:28:37 UTC

svn commit: r1024400 - in /subversion/branches/object-model/subversion/bindings/c++: Utility.cpp include/Types.h

Author: hwright
Date: Tue Oct 19 20:28:36 2010
New Revision: 1024400

URL: http://svn.apache.org/viewvc?rev=1024400&view=rev
Log:
On the object-model branch:
Expand the Nullable template by introducing a specialization for maps,
allowing users of these objects to use the Nullable maps (such as a proplist)
transparently.

* subversion/bindings/c++/include/Types.h
  (Nullable): Add a specialization for std::map.
  (PropTable): Redefine this typedef as a Nullable.

* subversion/bindings/c++/Utility.cpp
  (make_prop_table): If the object isn't valid, return NULL.

Modified:
    subversion/branches/object-model/subversion/bindings/c++/Utility.cpp
    subversion/branches/object-model/subversion/bindings/c++/include/Types.h

Modified: subversion/branches/object-model/subversion/bindings/c++/Utility.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/Utility.cpp?rev=1024400&r1=1024399&r2=1024400&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/Utility.cpp (original)
+++ subversion/branches/object-model/subversion/bindings/c++/Utility.cpp Tue Oct 19 20:28:36 2010
@@ -78,6 +78,9 @@ make_string_array(const std::vector<std:
 apr_hash_t *
 make_prop_table(const PropTable &props, Pool &pool)
 {
+  if (!props.first)
+    return NULL;
+
   apr_hash_t *hash = apr_hash_make(pool.pool());
 
   for (PropTable::const_iterator it = props.begin();

Modified: subversion/branches/object-model/subversion/bindings/c++/include/Types.h
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/include/Types.h?rev=1024400&r1=1024399&r2=1024400&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/include/Types.h (original)
+++ subversion/branches/object-model/subversion/bindings/c++/include/Types.h Tue Oct 19 20:28:36 2010
@@ -50,8 +50,39 @@ class Nullable : public std::pair<bool, 
     { }
 };
 
+template<typename T1, typename T2>
+class Nullable<std::map<T1, T2> > : public std::pair<bool, std::map<T1, T2> >
+{
+  public:
+    inline Nullable()
+      : std::pair<bool, std::map<T1, T2> >(true, std::map<T1, T2>())
+    { }
+
+    inline Nullable(bool b, std::map<T1, T2> t)
+      : std::pair<bool, std::map<T1, T2> >(b, t)
+    { }
+
+    typedef typename std::map<T1, T2>::const_iterator const_iterator;
+
+    inline T2&
+    operator [](const T1 &key)
+    { return this->second[key]; }
+
+    inline const_iterator
+    begin() const
+    { return this->second.begin(); }
+
+    inline const_iterator
+    end() const
+    { return this->second.end(); }
+
+    inline typename std::map<T1, T2>::size_type
+    size() const
+    { return this->second.size(); }
+};
+
 // Typedefs
-typedef std::map<std::string, std::string> PropTable;
+typedef Nullable<std::map<std::string, std::string> > PropTable;
 
 
 namespace Private