本文整理汇总了C++中TableColumns::size方法的典型用法代码示例。如果您正苦于以下问题:C++ TableColumns::size方法的具体用法?C++ TableColumns::size怎么用?C++ TableColumns::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TableColumns
的用法示例。
在下文中一共展示了TableColumns::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: columnDefinition
std::string columnDefinition(const TableColumns& columns) {
std::string statement = "(";
for (size_t i = 0; i < columns.size(); ++i) {
statement += columns.at(i).first + " " + columns.at(i).second;
if (i < columns.size() - 1) {
statement += ", ";
}
}
return statement += ")";
}
示例2: applyTypes
Status QueryPlanner::applyTypes(TableColumns& columns) {
std::map<size_t, ColumnType> column_types;
for (const auto& row : program_) {
if (row.at("opcode") == "ResultRow") {
// The column parsing is finished.
auto k = boost::lexical_cast<size_t>(row.at("p1"));
for (const auto& type : column_types) {
if (type.first - k < columns.size()) {
std::get<1>(columns[type.first - k]) = type.second;
}
}
}
if (row.at("opcode") == "Copy") {
// Copy P1 -> P1 + P3 into P2 -> P2 + P3.
auto from = boost::lexical_cast<size_t>(row.at("p1"));
auto to = boost::lexical_cast<size_t>(row.at("p2"));
auto size = boost::lexical_cast<size_t>(row.at("p3"));
for (size_t i = 0; i <= size; i++) {
if (column_types.count(from + i)) {
column_types[to + i] = std::move(column_types[from + i]);
column_types.erase(from + i);
}
}
}
if (kSQLOpcodes.count(row.at("opcode"))) {
const auto& op = kSQLOpcodes.at(row.at("opcode"));
auto k = boost::lexical_cast<size_t>(row.at(Opcode::regString(op.reg)));
column_types[k] = op.type;
}
}
return Status(0);
}
示例3: getTestDBC
TEST_F(SQLiteUtilTests, test_get_query_columns) {
auto dbc = getTestDBC();
TableColumns results;
std::string query = "SELECT seconds, version FROM time JOIN osquery_info";
auto status = getQueryColumnsInternal(query, results, dbc.db());
ASSERT_TRUE(status.ok());
ASSERT_EQ(2U, results.size());
EXPECT_EQ(std::make_pair(std::string("seconds"), INTEGER_TYPE), results[0]);
EXPECT_EQ(std::make_pair(std::string("version"), TEXT_TYPE), results[1]);
query = "SELECT hour + 1 AS hour1, minutes + 1 FROM time";
status = getQueryColumnsInternal(query, results, dbc.db());
ASSERT_TRUE(status.ok());
ASSERT_EQ(2U, results.size());
EXPECT_EQ(std::make_pair(std::string("hour1"), UNKNOWN_TYPE), results[0]);
EXPECT_EQ(std::make_pair(std::string("minutes + 1"), UNKNOWN_TYPE),
results[1]);
query = "SELECT * FROM foo";
status = getQueryColumnsInternal(query, results, dbc.db());
ASSERT_FALSE(status.ok());
}
示例4: getTestDBC
TEST_F(SQLiteUtilTests, test_get_query_columns) {
auto dbc = getTestDBC();
TableColumns results;
std::string query = "SELECT seconds, version FROM time JOIN osquery_info";
auto status = getQueryColumnsInternal(query, results, dbc->db());
ASSERT_TRUE(status.ok());
ASSERT_EQ(2U, results.size());
EXPECT_EQ(std::make_tuple(std::string("seconds"), INTEGER_TYPE, DEFAULT),
results[0]);
EXPECT_EQ(std::make_tuple(std::string("version"), TEXT_TYPE, DEFAULT),
results[1]);
query = "SELECT * FROM foo";
status = getQueryColumnsInternal(query, results, dbc->db());
ASSERT_FALSE(status.ok());
}
示例5: setTable
void GUITable::setTable(const TableOptions &options,
const TableColumns &columns,
std::vector<std::string> &content)
{
clear();
// Naming conventions:
// i is always a row index, 0-based
// j is always a column index, 0-based
// k is another index, for example an option index
// Handle a stupid error case... (issue #1187)
if (columns.empty()) {
TableColumn text_column;
text_column.type = "text";
TableColumns new_columns;
new_columns.push_back(text_column);
setTable(options, new_columns, content);
return;
}
// Handle table options
video::SColor default_color(255, 255, 255, 255);
s32 opendepth = 0;
for (size_t k = 0; k < options.size(); ++k) {
const std::string &name = options[k].name;
const std::string &value = options[k].value;
if (name == "color")
parseColorString(value, m_color, false);
else if (name == "background")
parseColorString(value, m_background, false);
else if (name == "border")
m_border = is_yes(value);
else if (name == "highlight")
parseColorString(value, m_highlight, false);
else if (name == "highlight_text")
parseColorString(value, m_highlight_text, false);
else if (name == "opendepth")
opendepth = stoi(value);
else
errorstream<<"Invalid table option: \""<<name<<"\""
<<" (value=\""<<value<<"\")"<<std::endl;
}
// Get number of columns and rows
// note: error case columns.size() == 0 was handled above
s32 colcount = columns.size();
assert(colcount >= 1);
// rowcount = ceil(cellcount / colcount) but use integer arithmetic
s32 rowcount = (content.size() + colcount - 1) / colcount;
assert(rowcount >= 0);
// Append empty strings to content if there is an incomplete row
s32 cellcount = rowcount * colcount;
while (content.size() < (u32) cellcount)
content.push_back("");
// Create temporary rows (for processing columns)
struct TempRow {
// Current horizontal position (may different between rows due
// to indent/tree columns, or text/image columns with width<0)
s32 x;
// Tree indentation level
s32 indent;
// Next cell: Index into m_strings or m_images
s32 content_index;
// Next cell: Width in pixels
s32 content_width;
// Vector of completed cells in this row
std::vector<Cell> cells;
// Stores colors and how long they last (maximum column index)
std::vector<std::pair<video::SColor, s32> > colors;
TempRow(): x(0), indent(0), content_index(0), content_width(0) {}
};
TempRow *rows = new TempRow[rowcount];
// Get em width. Pedantically speaking, the width of "M" is not
// necessarily the same as the em width, but whatever, close enough.
s32 em = 6;
if (m_font)
em = m_font->getDimension(L"M").Width;
s32 default_tooltip_index = allocString("");
std::map<s32, s32> active_image_indices;
// Process content in column-major order
for (s32 j = 0; j < colcount; ++j) {
// Check column type
ColumnType columntype = COLUMN_TYPE_TEXT;
if (columns[j].type == "text")
columntype = COLUMN_TYPE_TEXT;
else if (columns[j].type == "image")
columntype = COLUMN_TYPE_IMAGE;
else if (columns[j].type == "color")
columntype = COLUMN_TYPE_COLOR;
else if (columns[j].type == "indent")
columntype = COLUMN_TYPE_INDENT;
else if (columns[j].type == "tree")
columntype = COLUMN_TYPE_TREE;
//.........这里部分代码省略.........