<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,6 +2,8 @@ CXXFLAGS=-Werror -Wall
 
 jsonxx_test: jsonxx_test.cc jsonxx.o
 
+jsonxx.o: jsonxx.h jsonxx.cc
+
 test: jsonxx_test
 	./jsonxx_test
 </diff>
      <filename>Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -134,6 +134,7 @@ bool Value::parse(std::istream&amp; input) {
         return true;
     }
     if (parse_number(input, &amp;integer_value_)) {
+        type_ = INTEGER_;
         return true;
     }
 
@@ -148,16 +149,24 @@ bool Value::parse(std::istream&amp; input) {
     return false;
 }
 
+Array::~Array() {
+    for (unsigned int i = 0; i &lt; values_.size(); ++i) {
+        delete values_[i];
+    }
+}
+
 bool Array::parse(std::istream&amp; input) {
     if (!match(&quot;[&quot;, input)) {
         return false;
     }
 
     do {
-        Value v;
-        if (!v.parse(input)) {
+        Value* v = new Value();
+        if (!v-&gt;parse(input)) {
+            delete v;
             break;
         }
+        values_.push_back(v);
     } while (match(&quot;,&quot;, input));
 
     if (!match(&quot;]&quot;, input)) {</diff>
      <filename>jsonxx.cc</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 
 #include &lt;cassert&gt;
 #include &lt;iostream&gt;
+#include &lt;vector&gt;
 
 namespace jsonxx {
 
@@ -11,9 +12,23 @@ class Object {
     bool parse(std::istream&amp; input);
 };
 
+class Value;
+
 class Array {
   public:
+    ~Array();
     bool parse(std::istream&amp; input);
+
+    unsigned int size() { return values_.size(); }
+
+    template &lt;typename T&gt;
+    bool is(unsigned int i);
+
+    template &lt;typename T&gt;
+    T&amp; get(unsigned int i);
+
+  private:
+    std::vector&lt;Value*&gt; values_;
 };
 
 // A value could be a number, an array, a string, an object, a
@@ -28,7 +43,7 @@ class Value {
     template&lt;typename T&gt;
     bool is();
     template&lt;typename T&gt;
-    T get();
+    T&amp; get();
   private:
     Value(const Value&amp;);
     Value&amp; operator=(const Value&amp;);
@@ -46,6 +61,18 @@ class Value {
     };
 };
 
+template &lt;typename T&gt;
+bool Array::is(unsigned int i) {
+    assert(i &lt; size());
+    return values_[i]-&gt;is&lt;T&gt;();
+}
+
+template &lt;typename T&gt;
+T&amp; Array::get(unsigned int i) {
+    assert(i &lt; size());
+    return values_[i]-&gt;get&lt;T&gt;();
+}
+
 template&lt;&gt;
 inline bool Value::is&lt;Value::Null&gt;() {
     return type_ == NULL_;
@@ -62,15 +89,26 @@ inline bool Value::is&lt;std::string&gt;() {
 }
 
 template&lt;&gt;
-inline bool Value::get&lt;bool&gt;() {
+inline bool Value::is&lt;long&gt;() {
+    return type_ == INTEGER_;
+}
+
+template&lt;&gt;
+inline bool&amp; Value::get&lt;bool&gt;() {
     assert(is&lt;bool&gt;());
     return bool_value_;
 }
 
 template&lt;&gt;
-inline std::string Value::get&lt;std::string&gt;() {
+inline std::string&amp; Value::get&lt;std::string&gt;() {
     assert(is&lt;std::string&gt;());
     return *string_value_;
 }
 
+template&lt;&gt;
+inline long&amp; Value::get&lt;long&gt;() {
+    assert(is&lt;long&gt;());
+    return integer_value_;
+}
+
 }  // namespace jsonxx</diff>
      <filename>jsonxx.h</filename>
    </modified>
    <modified>
      <diff>@@ -104,5 +104,9 @@ int main() {
         istringstream input(teststr);
         Array v;
         assert(v.parse(input));
+        assert(v.is&lt;std::string&gt;(0));
+        assert(&quot;field1&quot; == v.get&lt;std::string&gt;(0));
+        assert(v.is&lt;long&gt;(1));
+        assert(6 == v.get&lt;long&gt;(1));
     }
 }</diff>
      <filename>jsonxx_test.cc</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4e519afbba3e7c67c509b757501b7f0fc5a660bc</id>
    </parent>
  </parents>
  <author>
    <name>Hong Jiang</name>
    <email>hjiang@glaptop.local</email>
  </author>
  <url>http://github.com/hjiang/jsonxx/commit/357da1eb054dd119a8ab87eb6eedd6cd321b2212</url>
  <id>357da1eb054dd119a8ab87eb6eedd6cd321b2212</id>
  <committed-date>2008-12-04T18:05:00-08:00</committed-date>
  <authored-date>2008-12-04T18:05:00-08:00</authored-date>
  <message>Added accessors for Array.</message>
  <tree>27c5a9457c25a0beecb6919272175349ad7af323</tree>
  <committer>
    <name>Hong Jiang</name>
    <email>hjiang@glaptop.local</email>
  </committer>
</commit>
