示例#1
0
ValueType StringToValueType(std::string str) {
  if (str == "INVALID") {
    return VALUE_TYPE_INVALID;
  } else if (str == "NULL") {
    return VALUE_TYPE_NULL;
  } else if (str == "TINYINT") {
    return VALUE_TYPE_TINYINT;
  } else if (str == "SMALLINT") {
    return VALUE_TYPE_SMALLINT;
  } else if (str == "INTEGER") {
    return VALUE_TYPE_INTEGER;
  } else if (str == "BIGINT") {
    return VALUE_TYPE_BIGINT;
  } else if (str == "DOUBLE") {
    return VALUE_TYPE_DOUBLE;
  } else if (str == "STRING") {
    return VALUE_TYPE_VARCHAR;
  } else if (str == "VARBINARY") {
    return VALUE_TYPE_VARBINARY;
  } else if (str == "TIMESTAMP") {
    return VALUE_TYPE_TIMESTAMP;
  } else if (str == "DECIMAL") {
    return VALUE_TYPE_DECIMAL;
  } else {
    throw ConversionException("No conversion from string :" + str);
  }
  return VALUE_TYPE_INVALID;
}
示例#2
0
void ListResponse::inflate(const std::string& data)
{
	std::stringstream ss(data);
	std::string line;

	int title_count = 0;
	std::getline(ss, line, '\n');
	try
	{
		title_count = boost::lexical_cast<int>(line);
	}
	catch(const boost::bad_lexical_cast& e)
	{
		throw ConversionException("Failed to convert to int.");
	}

	DEBUG("num titles is " << titles_.size());

	while(title_count-- != 0)
	{
		std::getline(ss, line, '\n');
		titles_.push_back(line);
	}
}