예제 #1
0
파일: main.cpp 프로젝트: exosite/libcql
// helper function to print query results
void
print_rows(
    cql::cql_result_t& result)
{
    while (result.next()) {
        for (size_t i = 0; i < result.column_count(); ++i) {
            cql::cql_byte_t* data = NULL;
            cql::cql_int_t size = 0;
            result.get_data(i, &data, size);
            std::cout.write(reinterpret_cast<char*>(data), size);
            std::cout << " | ";
        }
        std::cout << std::endl;
    }
}
예제 #2
0
// helper function to print query results
void
print_rows(
    cql::cql_result_t& result)
{
    while (result.next()) {
        for (size_t i = 0; i < result.column_count(); ++i) {
			std::vector< cql::cql_byte_t > data;
            result.get_data(i, data );					
            std::cout.write(reinterpret_cast<char*>(&data[0]), data.size() );
            for (int i = data.size(); i < 25; i++) {
                std::cout << ' ' ;
            }
            std::cout << " | ";
        }
        std::cout << std::endl;
    }
}
void DeviceCassandraController::buildDeviceObjectFromQueryResult(
    cql::cql_result_t &row, boost::shared_ptr<Device> &device) {
  string dname, uname, type, ip, dirIp, publicFolder, privateFolder, os,
      description, contentMeta;
  unsigned short port, dirPort;
  string strPort, strDirPort;
  int lastSeen, contentTimestamp;
  bool searchable;

  row.get_string(Device::COL_USER_NAME, uname);
  row.get_string(Device::COL_DEVICE_NAME, dname);
  row.get_string(Device::COL_TYPE, type);
  row.get_string(Device::COL_IP, ip);
  row.get_string(Device::COL_DIR_IP, dirIp);
  row.get_string(Device::COL_PORT, strPort);
  row.get_string(Device::COL_DIR_PORT, strDirPort);
  row.get_string(Device::COL_PUBLIC_FOLDER, publicFolder);
  row.get_string(Device::COL_PRIVATE_FOLDER, privateFolder);
  row.get_int(Device::COL_LAST_SEEN, lastSeen);
  row.get_string(Device::COL_OS, os);
  row.get_string(Device::COL_DESCRIPTION, description);
  row.get_string(Device::COL_CONTENT_META, contentMeta);
  row.get_bool(Device::COL_SEARCHABLE, searchable);
  row.get_int(Device::COL_CONTENT_TIME_STAMP, contentTimestamp);

  if (ControllerHelper::isNullOREmptyString(strPort))
    port = -1;
  else
    port = boost::lexical_cast<unsigned short>(strPort);
  if (ControllerHelper::isNullOREmptyString(strDirPort))
    dirPort = -1;
  else
    dirPort = boost::lexical_cast<unsigned short>(strDirPort);

  device = boost::shared_ptr<Device>(new Device(
      uname, dname, type, ip, port, dirIp, dirPort, publicFolder, privateFolder,
      lastSeen, os, description, contentMeta, searchable, contentTimestamp));
}