void search_contacts_response::serialize_contacts(core::coll_helper _root_coll) const
{
    if (contacts_data_.empty())
        return;

    ifptr<iarray> array(_root_coll->create_array());
    array->reserve((int32_t)contacts_data_.size());
    for (const auto& c : contacts_data_)
    {
        coll_helper coll(_root_coll->create_collection(), true);

        coll.set_value_as_string("aimid", c.aimid_);
        coll.set_value_as_string("stamp", c.stamp_);
        coll.set_value_as_string("type", c.type_);
        if (c.score_ >= 0)
        {
            coll.set_value_as_int("score", c.score_);
        }
        coll.set_value_as_string("first_name", c.first_name_);
        coll.set_value_as_string("last_name", c.last_name_);
        coll.set_value_as_string("nick_name", c.nick_name_);
        coll.set_value_as_string("city", c.city_);
        coll.set_value_as_string("state", c.state_);
        coll.set_value_as_string("country", c.country_);
        coll.set_value_as_string("gender", c.gender_);
        if (c.birthdate_.year_ >= 0 && c.birthdate_.month_ >= 0 && c.birthdate_.day_ >= 0)
        {
            coll_helper b(_root_coll->create_collection(), true);
            b.set_value_as_int("year", c.birthdate_.year_);
            b.set_value_as_int("month", c.birthdate_.month_);
            b.set_value_as_int("day", c.birthdate_.day_);
            coll.set_value_as_collection("birthdate", b.get());
        }
        coll.set_value_as_string("about", c.about_);
        coll.set_value_as_int("mutual_count", c.mutual_friend_count_);

        ifptr<ivalue> val(_root_coll->create_value());
        val->set_as_collection(coll.get());
        array->push_back(val.get());
    }

    _root_coll.set_value_as_array("data", array.get());
}
void core::wim::search_contacts_response::serialize_chats(core::coll_helper _root_coll) const
{
    if (chats_data_.empty())
        return;

    ifptr<iarray> array(_root_coll->create_array());
    array->reserve((int32_t)chats_data_.size());

    for (const auto& c : chats_data_)
    {
        coll_helper coll(_root_coll->create_collection(), true);
        c.serialize(coll);

        ifptr<ivalue> val(_root_coll->create_value());
        val->set_as_collection(coll.get());
        array->push_back(val.get());
    }

    _root_coll.set_value_as_array("chats", array.get());
}
Exemple #3
0
void gui_settings::serialize(core::coll_helper _collection) const
{
    ifptr<iarray> values_array(_collection->create_array(), true);

    for (auto iter = values_.begin(); iter != values_.end(); ++iter)
    {
        coll_helper coll_value(_collection->create_collection(), true);

        ifptr<istream> value_data_stream(_collection->create_stream(), true);
        auto bs_value_data = iter->second;
        int32_t len = bs_value_data.available();
        value_data_stream->write((const uint8_t*) bs_value_data.read(len), len);

        coll_value.set_value_as_string("name", iter->first);
        coll_value.set_value_as_stream("value", value_data_stream.get());

        ifptr<ivalue> ival(_collection->create_value(), true);
        ival->set_as_collection(coll_value.get());

        values_array->push_back(ival.get());
    }
    _collection.set_value_as_array("values", values_array.get());
}