コード例 #1
0
ファイル: struct-schema.cpp プロジェクト: vstm/capnp-php
    Php::Value StructSchema::getFieldNames() {
        Php::Value result;

        auto fields = schema.getFields();

        for(capnp::uint i = 0; i < fields.size(); ++i) {
            result.set(i, DynamicValueConverter::convertTextToPhpString(fields[i].getProto().getName()));
        }

        return result;
    }
コード例 #2
0
/**
 *  Turn into a Php::Value
 *  @return Php::Value
 */
Php::Value Array::phpValue() const
{
    // create an output value
    Php::Value output;

    // loop over the entire array
    for (int i = 0; i < size(); ++i)
    {
        // switch through all the types and add them to the php value
        switch (type(i))
        {
        case JSON::Type::Null:    output.set(i, nullptr);              break;
        case JSON::Type::Boolean: output.set(i, boolean(i));           break;
        case JSON::Type::Decimal: output.set(i, decimal(i));           break;
        case JSON::Type::Integer: output.set(i, integer(i));           break;
        case JSON::Type::String:  output.set(i, c_str(i));             break;
        case JSON::Type::Array:   output.set(i, array(i).phpValue());  break;
        case JSON::Type::Object:  output.set(i, object(i).phpValue()); break;
        default:                                                       break;
        }
    }

    // return our output
    return output;
}