optional Configuration::GetBool()

in src/hbase/client/configuration.cc [203:218]


optional<bool> Configuration::GetBool(const std::string &key) const {
  optional<std::string> raw = Get(key);
  if (raw) {
    if (!strcasecmp((*raw).c_str(), "true") || !strcasecmp((*raw).c_str(), "1")) {
      return true;
    } else if (!strcasecmp((*raw).c_str(), "false") || !strcasecmp((*raw).c_str(), "0")) {
      return false;
    } else {
      boost::format what("Unexpected value \"%s\" found being converted to bool for key \"%s\"");
      what % (*raw);
      what % key;
      throw std::runtime_error(what.str());
    }
  }
  return none;
}