Exemple #1
0
void Log::printValue(const xmlrpc_c::value & value)
{
	std::clog<<" :";
	int vi;
	double vd;
	bool vb;
	time_t vt;
	std::string vs;
	std::map<std::string, xmlrpc_c::value> vstruct;
	std::vector<xmlrpc_c::value> va;
	switch (value.type())
    {
        case xmlrpc_c::value::TYPE_INT:
            fromXmlrpcValue(value, vi);
			std::clog<<" "<<vi<<"\n";
			break;
        case xmlrpc_c::value::TYPE_BOOLEAN:
            fromXmlrpcValue(value, vb);
			std::clog<<" "<<vb<<"\n";
			break;
        case xmlrpc_c::value::TYPE_DOUBLE:
            fromXmlrpcValue(value, vd);
			std::clog<<" "<<vd<<"\n";
			break;
        case xmlrpc_c::value::TYPE_DATETIME:
            fromXmlrpcValue(value, vt);
			std::clog<<" "<<vt<<"\n";
			break;
        case xmlrpc_c::value::TYPE_STRING:
            fromXmlrpcValue(value, vs);
			std::clog<<" "<<vs<<"\n";
			break;
		case xmlrpc_c::value::TYPE_STRUCT:
			fromXmlrpcValue(value, vstruct);
			std::clog<<" struct begin {\n";
			printValues(vstruct);
			std::clog<<"} struct end\n";
            break;
		case xmlrpc_c::value::TYPE_ARRAY:
			fromXmlrpcValue(value, va);
			std::clog<<" array begin {\n";
			printValues(va);
			std::clog<<"} array end\n";
            break;
		/*
        case xmlrpc_c::value::TYPE_BYTESTRING:
            return std::string("TYPE_BYTESTRING");
        case xmlrpc_c::value::TYPE_C_PTR:
            return std::string("TYPE_C_PTR");
        case xmlrpc_c::value::TYPE_NIL:
            return std::string("TYPE_NIL");
        case xmlrpc_c::value::TYPE_DEAD:*/
        default:
            std::clog<<" unknown\n";
    }
}
// *****************************************************************************
FilterBy &FilterBy::op(const std::string &logicOperator,
                       const std::string &path,
                       const std::string &relation,
                       const xmlrpc_c::value &value)
{
    // -------------------------------------------------------------------
    // The new simple condition
    Dict newCondition = Dict("path", path)
                        .add("relation", relation);

    // The value has to be converted to an array
    List valueList;
    if (value.type() == xmlrpc_c::value::TYPE_ARRAY)
    {
        fromXmlrpcValue(value, valueList);
    }
    else
    {
        valueList.append(value);
    }
    newCondition.add("values", valueList);
 
    // -------------------------------------------------------------------
    // Add the new simple condition to the conditions list
    List conditions;
    if (!m_filters.empty()) 
    {
        // The Original m_filters map now becomes a condition
        conditions.append(m_filters);
    }
    conditions.append(newCondition);

    // -------------------------------------------------------------------
    // Update the filters
    m_filters.clear();
    m_filters.add("logical_operator", logicOperator)
             .add("conditions", conditions);

    return *this;
}