void Array::output(std::ostream &output, unsigned int &level,
					   bool indent, bool escapeAll) const {
		output << '[';
		
		if(indent) {
			output << std::endl;
			++level;
		}
		
		for(Array::const_iterator i = begin(); i != end(); ++i) {
			
			if(i != begin()) {
				output << ",";
				if(indent) {
					output << std::endl;
				}
			}
			
			if(indent) {
				Value::outputNbTabs(output, level);
			}
			i->output(output, level, indent, escapeAll);
		}
		
		if(indent) {
			--level;
			output << std::endl;
			Value::outputNbTabs(output, level);
		}
		output << ']';
	}
Exemple #2
0
bool fillVectorInt(const Array& array, std::vector<int>* pVector)
{
   for (Array::const_iterator it = array.begin();
        it != array.end();
        ++it)
   {
      if (!isType<int>(*it))
         return false;
      pVector->push_back(it->get_int());
   }

   return true;
}
Exemple #3
0
void
JSONConfiguration::GetArray(IN const string &name, OUT list<any> &out_list)
{
    const Array &val_array =
        find_array(_rootValue.get_obj(),name);

    out_list.clear();

    for (Array::const_iterator iter = val_array.begin();
            iter != val_array.end();
            iter++)
    {
        Value_type vt = iter->type();
        switch (vt)
        {
        case str_type:
        {
            out_list.push_back(iter->get_str());
            break;
        }
        case bool_type:
        {
            out_list.push_back(iter->get_bool());
            break;
        }
        case int_type:
        {
            out_list.push_back(iter->get_int());
            break;
        }
        case real_type:
        {
            out_list.push_back(iter->get_real());
            break;
        }
        case obj_type:
        case null_type:
        case array_type:
        default:
        {
            throw new configuration_exception("not supported JSON type. (TBD)");

        }
        } // switch
    }
}
 virtual void Visit(const Array& array) {
     for (Array::const_iterator itr = array.Begin(); itr != array.End(); ++itr)
         itr->Accept(*this);
     stat.arrayCount++;
     stat.elementCount += array.Size();
 }