コード例 #1
0
ファイル: photopart.cpp プロジェクト: ratwix/PhototwixMirror
void PhotoPart::Serialize(PrettyWriter<StringBuffer> &writer) const
{
    writer.StartObject();
    writer.Key("photoPartUrl");
    writer.String(m_path.toString().toStdString().c_str());
    writer.EndObject();
}
コード例 #2
0
ファイル: effect.cpp プロジェクト: ratwix/PhototwixMirror
void Effect::Serialize(PrettyWriter<StringBuffer> &writer, Parameters *p) const
{
    p->updateEffect(m_effectName, m_effectEnable, m_effectTwitterDefault);

    writer.StartObject();

    writer.Key("effect_name");
    writer.String(m_effectName.toStdString().c_str());

    writer.Key("effect_enable");
    writer.Bool(m_effectEnable);

    writer.Key("effect_twitterDefault");
    writer.Bool(m_effectTwitterDefault);

    writer.EndObject();
}
コード例 #3
0
bool Model_Report::get_objects_from_sql(const wxString& query, PrettyWriter<StringBuffer>& json_writer)
{
    wxSQLite3Statement stmt;
    try
    {
        stmt = this->db_->PrepareStatement(query);
        if (!stmt.IsReadOnly())
        {
            json_writer.Key("msg");
            json_writer.String("the sql is not readonly");
            return false;
        }
    }
    catch (const wxSQLite3Exception& e)
    {
        json_writer.Key("msg");
        json_writer.String(e.GetMessage().c_str());
        return false;
    }

    try
    {
        json_writer.Key("results");
        json_writer.StartArray();

        wxSQLite3ResultSet q = stmt.ExecuteQuery();
        int columns = q.GetColumnCount();
        while (q.NextRow())
        {
            json_writer.StartObject();

            for (int i = 0; i < columns; ++i)
            {
                wxString column_name = q.GetColumnName(i);

                switch (q.GetColumnType(i))
                {
                    case WXSQLITE_INTEGER:
                        json_writer.Key(column_name.c_str());
                        json_writer.Int(q.GetInt(i));
                        break;
                    case WXSQLITE_FLOAT:
                        json_writer.Key(column_name.c_str());
                        json_writer.Double(q.GetDouble(i));
                        break;
                    default:
                        json_writer.Key(column_name.c_str());
                        json_writer.String(q.GetString(i).c_str());
                        break;
                }
            }

            json_writer.EndObject();
        }
        q.Finalize();

        json_writer.EndArray();
    }
    catch (const wxSQLite3Exception& e)
    {
        json_writer.Key("msg");
        json_writer.String(e.GetMessage().c_str());
        return false;
    }

    return true;
}