void SsdbDriver::handleLoadDatabaseContentEvent(events::LoadDatabaseContentRequestEvent *ev) {
  QObject* sender = ev->sender();
  notifyProgress(sender, 0);
    events::LoadDatabaseContentResponceEvent::value_type res(ev->value());
    char patternResult[1024] = {0};
    common::SNPrintf(patternResult, sizeof(patternResult), GET_KEYS_PATTERN_1ARGS_I,
                     res.count_keys);
    FastoObjectIPtr root = FastoObject::createRoot(patternResult);
  notifyProgress(sender, 50);
    FastoObjectCommand* cmd = createCommand<SsdbCommand>(root, patternResult,
                                                         common::Value::C_INNER);
    common::Error er = execute(cmd);
    if (er && er->isError()) {
      res.setErrorInfo(er);
    } else {
      FastoObject::child_container_type rchildrens = cmd->childrens();
      if (rchildrens.size()) {
        DCHECK_EQ(rchildrens.size(), 1);
        FastoObjectArray* array = dynamic_cast<FastoObjectArray*>(rchildrens[0]);
        if (!array) {
          goto done;
        }
        common::ArrayValue* ar = array->array();
        if (!ar) {
          goto done;
        }

        for (size_t i = 0; i < ar->size(); ++i) {
          std::string key;
          bool isok = ar->getString(i, &key);
          if (isok) {
            NKey k(key);
            NDbKValue ress(k, NValue());
            res.keys.push_back(ress);
          }
        }
      }
    }
done:
  notifyProgress(sender, 75);
    reply(sender, new events::LoadDatabaseContentResponceEvent(this, res));
  notifyProgress(sender, 100);
}
Example #2
0
 NValue NDbValue::value() const
 {
     return NValue(value_, type_);
 }