YBORM_DECL ElementTree::ElementPtr xmlize_row(const Row &row, const String &entry_name) { ElementTree::ElementPtr entry = ElementTree::new_element(entry_name); Row::const_iterator it = row.begin(), end = row.end(); for (; it != end; ++it) entry->sub_element(mk_xml_name(it->first, _T("")), it->second.nvl(Value(String(_T("")))).as_string()); return entry; }
bool Database::add(std::string tablename, string keyValue, Row &object) { Table* table = getTable(tablename); if (table == NULL || get(tablename, keyValue) != NULL) return false; Row* row = new Row(object.begin(), object.end()); row->insert(make_pair("key", keyValue)); table->insert(row); return true; }
bool Database::modify(std::string tablename, std::string keyValue, Row &object) { Row* row = get(tablename, keyValue); if (row == NULL) { return false; } for (Row::iterator i = object.begin(), temp; i != object.end(); i++) { temp = row->find(i->first); if (temp != row->end()) { temp->second = i->second; } else { row->insert(make_pair(i->first, i->second)); } } return true; }
Status serializeRow(const Row& r, const ColumnNames& cols, JSON& doc, rj::Value& obj) { if (cols.empty()) { for (const auto& i : r) { doc.addRef(i.first, i.second, obj); } } else { for (const auto& c : cols) { auto i = r.find(c); if (i != r.end()) { doc.addRef(c, i->second, obj); } } } return Status(); }