本文整理汇总了C++中QueryResult::numCols方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::numCols方法的具体用法?C++ QueryResult::numCols怎么用?C++ QueryResult::numCols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::numCols方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: query
/*
* Pass a query to the catalog and return the number of objects found.
* Only the given columns are retrieved.
*
* Args:
* q - (in) object describing the query
*
* filename - (in) filename to hold results, or null
*
* result - (out) reference to object used to access the results
*
* The return value is the number of rows found, or 0 if none were found.
* A return value of -1 indicates an error.
*/
int AstroCatalog::query(const AstroQuery& q, const char* filename, QueryResult& result)
{
if (! isCatalog(entry_))
return wrongServType(entry_);
// generate the URL for a standard query in buf (using ostringstream)
char* result_buf = NULL;
int nlines = 0;
// if the first URL doesn't work, try the others, if specified
const char* urls[3];
urls[0] = entry_->url();
urls[1] = entry_->backup1();
urls[2] = entry_->backup2();
char url[10000];
char* ctype = (char *)"";
for (int i = 0; i < 3 && urls[i]; i++) {
if (genHttpQuery(url, sizeof(url), q, urls[i]) != 0)
return -1;
// send the query
result_buf = http_.get(url, nlines);
ctype = http_.content_type();
if (!ctype)
ctype = (char *)"";
if (result_buf != NULL && strcmp(ctype, "text/html") != 0)
break;
// don't go to backup URL if it was a request for authorization
if (http_.authorizationRequired())
break;
}
if (result_buf == NULL)
return -1; // error in http get
// check the Content-type of the return data
if (strcmp(ctype, "text/html") == 0) {
// most likely an error message
http_.html_error(result_buf);
return -1;
}
// note the catalog config entry in the results
// (This contains important info, such as the location of the id, a and dec cols)
result.entry(entry_, result_buf);
if (result.init(result_buf) != 0)
return -1; // error
// sort result ?
// note: do this before truncating to maxRows to get correct results
if (q.numSortCols())
result.sort(q.numSortCols(), q.sortCols(), q.sortOrder());
if (q.maxRows() && result.numRows() > q.maxRows()) {
more_ = 1;
result.numRows(q.maxRows());
} else {
more_ = 0;
}
// if we didn't already, note the catalog's column heading info
if (info_.numCols() <= 0
&& info_.init(result.numCols(), result.colNames(), "", 1) != 0)
return -1;
if (filename && result.save(filename) != 0)
return -1;
return result.numRows();
}