1. Tommaso Urli
  2. JSON++

Commits

Tommaso Urli  committed 47b0412

Updated interface, fixed docs.

  • Participants
  • Parent commits e0a9abb
  • Branches default

Comments (0)

Files changed (2)

File json_st.cc

View file
  • Ignore whitespace
 Value& Value::operator[] (const string& key)
 {
     if (type() != OBJECT)
-        throw std::logic_error("Value not subscriptable");
+        throw std::logic_error("Value not an object");
     return object_v[key];
 }
 
 const Value& Value::operator[] (const string& key) const
 {
     if (type() != OBJECT)
-        throw std::logic_error("Value not subscriptable");
+        throw std::logic_error("Value not an object");
     return object_v[key];
 }
 
 Value& Value::operator[] (size_t i)
 {
     if (type() != ARRAY)
-        throw std::logic_error("Value not subscriptable");
+        throw std::logic_error("Value not an array");
     return array_v[i];
 }
 
 const Value& Value::operator[] (size_t i) const
 {
     if (type() != ARRAY)
-        throw std::logic_error("Value not subscriptable");
+        throw std::logic_error("Value not an array");
     return array_v[i];
 }
 

File json_st.hh

View file
  • Ignore whitespace
         /** Cast operator for float */
         explicit operator long double() const { return float_v; }
     
-        /** Cast operator for float */
+        /** Cast operator for int */
         explicit operator long long int() const { return int_v; }
     
-        /** Cast operator for float */
+        /** Cast operator for bool */
         explicit operator bool() const { return bool_v; }
     
-        /** Cast operator for float */
+        /** Cast operator for string */
         explicit operator std::string () const { return string_v; }
     
         /** Cast operator for Object */
         operator Array () const { return array_v; }
         
         /** Cast operator for float */
-        long double to_float() const { return float_v; }
+        long double as_float() const { return float_v; }
     
-        /** Cast operator for float */
-        long long int to_int() const { return int_v; }
+        /** Cast operator for int */
+        long long int as_int() const { return int_v; }
     
-        /** Cast operator for float */
-        bool to_bool() const { return bool_v; }
+        /** Cast operator for bool */
+        bool as_bool() const { return bool_v; }
     
-        /** Cast operator for float */
-        std::string to_string() const { return string_v; }
+        /** Cast operator for string */
+        std::string as_string() const { return string_v; }
 
 
     protected:
 /** Output operator for Arrays */
 std::ostream& operator<<(std::ostream&, const JSON::Array&);
 
-
-
 #endif