本文整理汇总了C++中Record函数的典型用法代码示例。如果您正苦于以下问题:C++ Record函数的具体用法?C++ Record怎么用?C++ Record使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Record函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Record
bool Equation_Array::Add_Equation (int type, char *parameters)
{
static char *eq_text [] = {"BPR", "BPR_PLUS", "EXPONENTIAL", "CONICAL", "AKCELIK", "BPR+", "EXP", "CON", NULL};
static Equation_Type eq_map [] = { BPR, BPR_PLUS, EXP, CONICAL, AKCELIK, BPR_PLUS, EXP, CONICAL };
Equation *eq_ptr = (Equation *) Record (type);
if (eq_ptr == NULL) return (false);
if (parameters != NULL) {
int i;
char buffer [FIELD_BUFFER];
parameters = Get_Token (parameters, buffer);
for (i=0; eq_text [i] != NULL; i++) {
if (str_cmp (buffer, eq_text [i]) == 0) {
eq_ptr->type = eq_map [i];
break;
}
}
if (eq_text [i] == NULL) {
if (Send_Messages ()) {
exe->Error ("Unrecognized Equation Type = %s", buffer);
}
return (false);
}
parameters = Get_Double (parameters, &(eq_ptr->a));
parameters = Get_Double (parameters, &(eq_ptr->b));
parameters = Get_Double (parameters, &(eq_ptr->c));
parameters = Get_Double (parameters, &(eq_ptr->d));
if (eq_ptr->type == BPR || eq_ptr->type == BPR_PLUS) {
if (eq_ptr->a < 0.01 || eq_ptr->b < 1.0 || eq_ptr->c < 0.4) {
if (Send_Messages ()) {
exe->Error ("BPR Equation Parameters %.2lf, %.2lf, %.2lf are Out of Range", eq_ptr->a, eq_ptr->b, eq_ptr->c);
}
return (false);
}
if (eq_ptr->type == BPR_PLUS) {
if (eq_ptr->d <= 0.0) eq_ptr->d = 1.0;
if (eq_ptr->d > 7.0) {
if (Send_Messages ()) {
exe->Error ("BPR Plus Equation Minimum Speed %.2lf is Out of Range", eq_ptr->d);
}
return (false);
}
}
} else if (eq_ptr->type == EXP) {
if (eq_ptr->a < 0.07 || eq_ptr->a > 7.5 || eq_ptr->b < 1.0 || eq_ptr->b > 20.0 ||
eq_ptr->c < 30.0 || eq_ptr->c > 750.0) {
if (Send_Messages ()) {
exe->Error ("Exponential Equation Parameters %.2lf, %.2lf, %.1lf are Out of Range", eq_ptr->a, eq_ptr->b, eq_ptr->c);
}
}
} else if (eq_ptr->type == CONICAL) {
if (eq_ptr->a <= 1.0 || eq_ptr->a > 20.0) {
if (Send_Messages ()) {
exe->Error ("Conical Equation Parameter %.2lf is Out of Range (1..20)", eq_ptr->a);
}
return (false);
}
eq_ptr->b = (2 * eq_ptr->a - 1) / (2 * eq_ptr->a - 2);
} else if (eq_ptr->type == AKCELIK) {
if (eq_ptr->a <= 0.05 || eq_ptr->a > 2.5) {
if (Send_Messages ()) {
exe->Error ("AKCELIK Equation Parameter *.2lf is Out of Range (0.05..2.5)", eq_ptr->a);
}
return (false);
}
}
} else if (type == 1) {
eq_ptr->type = BPR;
eq_ptr->a = 0.15;
eq_ptr->b = 4.0;
eq_ptr->c = 0.75;
eq_ptr->d = 0.0;
} else {
Equation *prev_ptr = (Equation *) Record (type-1);
if (prev_ptr == NULL) return (false);
*eq_ptr = *prev_ptr;
return (true);
}
if (Send_Messages ()) {
exe->Print (1, "Equation Parameters %d = %s, A=%0.2lf",
type, eq_text [eq_ptr->type], eq_ptr->a);
if (eq_ptr->type != CONICAL && eq_ptr->type != AKCELIK) {
exe->Print (0, ", B=%0.2lf, C=%.2lf", eq_ptr->b, eq_ptr->c);
}
if (eq_ptr->type == BPR_PLUS) {
exe->Print (0, ", D=%.2lf", eq_ptr->d);
}
}
//.........这里部分代码省略.........
示例2: computePerformance
void computePerformance(double threshold = 0.8)
{
QVector<Record> records;
QString datasetPath = "C:/Users/XXX/Dropbox/DDTT-dataset/evaluation/userstudy/group matching";
QString endText = ".gmatch";
QString extension = "*.gmatch";
QDir datasetDir(datasetPath);
QStringList subdirs = datasetDir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
QStringList users;
for (QString subdir : subdirs)
{
QDir d(datasetPath + "/" + subdir);
auto matchFiles = d.entryList(QStringList() << extension, QDir::Files);
if (matchFiles.isEmpty()) continue;
users << subdir;
for (QString matchFile : matchFiles)
{
// Get matches from file
QFile ff(d.absolutePath() + "/" + matchFile);
ff.open(QFile::ReadOnly | QFile::Text);
QTextStream in(&ff);
auto matches = in.readAll().split("\n", QString::SkipEmptyParts);
// Shape names
QStringList shapes = matchFile.replace(endText, "").split("-", QString::SkipEmptyParts);
if(shapes.back() == "g") shapes.removeLast();
bool isSwap = shapes.front() > shapes.back();
// Add to vector
QVector< QPair<QString, QString> > pairMatches;
for (QString matchLine : matches)
{
QStringList match = matchLine.split(" ", QString::SkipEmptyParts);
QString p = match.front();
QString q = match.back();
if (isSwap) std::swap(p, q);
pairMatches << qMakePair(p, q);
}
//qDebug() << pairMatches;
// Add record
if (isSwap) std::reverse(shapes.begin(), shapes.end());
for (auto a : pairMatches) records << Record(shapes.front(), shapes.back(), a.first, a.second, subdir);
}
}
// Debug records:
qSort(records);
for (Record & record : records)
{
//qDebug() << record.p << " " << record.q << " " << record.shapeA << " " << record.shapeB << " " << record.user;
}
//qDebug() << "Num records =" << records.size();
// ShapePairs/part_p/part_q/users
QMap<QString, QMap<QString, QMap<QString, QStringList> > > part_matches;
// Extract set of good pair-wise part correspondences
for (Record r : records)
{
part_matches[r.shapeA + "|" + r.shapeB][r.p][r.q] << r.user;
}
// Passed threshold
int num_users = users.size();
QVector<Record> C, badC;
for (QString shapePair : part_matches.keys())
{
auto cur_shape_pairs = shapePair.split("|");
for (auto p : part_matches[shapePair].keys())
{
auto part_matching = part_matches[shapePair][p];
for (auto q : part_matching.keys())
{
auto match = part_matching[q];
int num_assigned = match.size();
double v = double(num_assigned) / num_users;
if (v >= threshold)
{
//.........这里部分代码省略.........
示例3: Info
static inline void Info(Event event, Args&& ...args) {
Record(EventSeverity::Info, event, ::std::forward<Args>(args)...);
}
示例4: Record
bool Db_Record::Set_Field_Number (int number, char *string)
{
char *rec = Record ();
if (rec == NULL) return (Status (RECORD_SIZE));
int len, size, shift;
char *ptr, *field, buffer [FIELD_BUFFER];
//---- remove trailing blanks ----
len = (int) strlen (string);
ptr = string + len - 1;
while (ptr > string) {
if (*ptr != ' ') break;
len--;
*ptr-- = '\0';
}
//---- set the record pointer ----
size = 0;
field = ptr = rec;
//---- locate the field number ----
for (int i=0; i < number; i++) {
ptr = Parse_String (ptr, buffer, sizeof (buffer));
//---- if the field was not found add a dummy field ----
if (ptr == NULL) {
size = (int) strlen (rec);
if (size + 3 >= max_size) return (Status (RECORD_SIZE));
ptr = rec + size;
if (*delimiters == ' ') {
*ptr++ = '\"';
*ptr++ = '\"';
}
*ptr++ = *delimiters;
*ptr = '\0';
}
//---- set the field pointer ----
if (i == number - 2) {
field = ptr;
}
}
//---- check the size of the string after the field ----
shift = (int) strlen (ptr);
size = (int) (field - rec);
if (size + 2 >= max_size) return (Status (RECORD_SIZE));
if (size + len + shift + 3 >= max_size) {
shift -= (max_size - size - len - 3);
if (shift < 0) shift = 0;
}
if (strstr (string, delimiters)) {
if (shift) {
memmove (field + len + 3, ptr, shift+1);
}
*field++ = '"';
memcpy (field, string, len);
*(field + len) = '"';
*(field + len + 1) = (shift) ? *delimiters : '\0';
} else {
if (shift) {
memmove (field + len + 1, ptr, shift+1);
}
memcpy (field, string, len);
*(field + len) = (shift) ? *delimiters : '\0';
}
rec [max_size + 1] = '\0';
return (true);
}
示例5: return
Trip_Data * operator[] (int index) { return (Record (index)); }
示例6: QApplication
App::App(int &argc, char **argv)
: QApplication(argc, argv), d(new Data(this)) {
#ifdef Q_OS_LINUX
setlocale(LC_NUMERIC,"C");
#endif
setOrganizationName("xylosper");
setOrganizationDomain("xylosper.net");
setApplicationName(Info::name());
setApplicationVersion(Info::version());
setLocale(Record(APP_GROUP).value("locale", QLocale::system()).toLocale());
d->addOption(LineCmd::Open, "open", tr("Open given %1 for file path or URL."), "mrl");
d->addOption(LineCmd::Wake, QStringList() << "wake", tr("Bring the application window in front."));
d->addOption(LineCmd::Action, "action", tr("Exectute %1 action or open %1 menu."), "id");
d->addOption(LineCmd::LogLevel, "log-level", tr("Maximum verbosity for log. %1 should be one of nexts:")
% "\n " % Log::options().join(", "), "lv");
d->addOption(LineCmd::OpenGLDebug, "opengl-debug", tr("Turn on OpenGL debug logger."));
d->addOption(LineCmd::Debug, "debug", tr("Turn on options for debugging."));
d->getCommandParser(&d->cmdParser)->process(arguments());
d->getCommandParser(&d->msgParser);
d->execute(&d->cmdParser);
#if defined(Q_OS_MAC) && defined(CMPLAYER_RELEASE)
static const QByteArray path = QApplication::applicationDirPath().toLocal8Bit();
_Debug("Set $LIBQUVI_SCRIPTSDIR=\"%%\"", QApplication::applicationDirPath());
if (setenv("LIBQUVI_SCRIPTSDIR", path.data(), 1) < 0)
_Error("Cannot set $LIBQUVI_SCRIPTSDIR. Some streaming functions won't work.");
#endif
setQuitOnLastWindowClosed(false);
#ifndef Q_OS_MAC
setWindowIcon(defaultIcon());
#endif
auto makeStyleNameList = [this] () {
auto names = QStyleFactory::keys();
const auto defaultName = style()->objectName();
for (auto it = ++names.begin(); it != names.end(); ++it) {
if (defaultName.compare(*it, Qt::CaseInsensitive) == 0) {
const auto name = *it;
names.erase(it);
names.prepend(name);
break;
}
}
return names;
};
auto makeStyle = [this]() {
Record r(APP_GROUP);
auto name = r.value("style", styleName()).toString();
if (style()->objectName().compare(name, Qt::CaseInsensitive) == 0)
return;
if (!d->styleNames.contains(name, Qt::CaseInsensitive))
return;
setStyle(QStyleFactory::create(name));
};
d->styleNames = makeStyleNameList();
makeStyle();
connect(&d->connection, &LocalConnection::messageReceived, [this] (const QString &message) {
d->msgParser.parse(message.split("[:sep:]")); d->execute(&d->msgParser);
});
}
示例7: assert
DB2FileLoaderRegularImpl::Record DB2FileLoaderRegularImpl::getRecord(size_t id)
{
assert(data);
return Record(*this, data + id * _header->RecordSize);
}
示例8: Record
SystemMethodTimer::~SystemMethodTimer()
{
Record();
Report();
}
示例9: return
Group_Link * operator[] (int index) { return (Record (index)); }
示例10: calc_algric_tree
void calc_algric_tree(algbric_node *root) {
if (root->flag == true)
return;
string table_name;
int blockNum, offset;
auto new_col_list = new vector<table_column *>, old_col_list = new_col_list, old_col_list2 = new_col_list;
// auto old_col_list = catm.exist_relation((root->left->table))->cols;
switch ( root->op ) {
case algbric_node::DIRECT :
root->flag = true;
return;
case algbric_node::PROJECTION :
{
if (!root->left->flag) calc_algric_tree(root->left);
old_col_list = catm.exist_relation((root->left->table))->cols;
for( auto x : *(root->projection_list) ) {
auto att = catm.exist_relation(x->relation_name)->get_column(x->attribute_name);
new_col_list->push_back(new table_column((root->left->op == algbric_node::DIRECT ? x->attribute_name.c_str() : x->full_name.c_str()), att->data_type, att->str_len, 0 ));
}
table_name = create_temp_table(new_col_list);
root->table = table_name;
auto cursor = RecordManager.getCursor(root->left->table, catm.calc_record_size(root->left->table));
while (cursor->next()) {
Record r = cursor->getRecord();
vector<record_value> result;
for(auto i = new_col_list->begin(); i != new_col_list->end(); i++) {
for(auto j = old_col_list->begin(); j != old_col_list->end(); j++ ) {
if ( (*i)->name == (*j)->name ) {
result.push_back(r.values[j-old_col_list->begin()]);
}
}
}
RecordManager.insertRecord(table_name, Record(result, new_col_list), blockNum, offset);
}
if (root->left->op != algbric_node::DIRECT) catm.drop_table(root->left->table);
root->flag = true;
return;
}
case algbric_node::SELECTION :
{
string left_name = root->left->table;
old_col_list = catm.exist_relation(left_name)->cols;
for( auto x : *(old_col_list) ) {
new_col_list->push_back( new table_column(x->name.c_str(), x->data_type, x->str_len, x->flag ));
}
table_name = create_temp_table(new_col_list);
root->table = table_name;
condition *p = NULL, *eq = NULL;
for(auto x : (root->conditions)) {
if ( catm.is_indexed(x->left_attr) ) {
p = x;
if (x->op == condition::EQUALTO)
eq = x;
}
}
if ( eq != NULL ) p = eq;
if ( p != NULL ) {
cout << "Index used: " << p->left_attr->full_name << endl;
int record_size = catm.calc_record_size(root->left->table);
auto t = p->left_attr;
indexIterator cursor;
int asdf = IndexManager.selectNode(cursor, t->relation_name + "/index_" + t->attribute_name + ".db",
p->op, (p->v).to_str(catm.get_data_type(t)));
if ( asdf == 0 ) {
int b = 0, c = 0;
while (cursor.next(b, c) == 0) {
Record a = RecordManager.getRecord(t->relation_name, b, c, record_size);
if (calc_conditions(&(root->conditions), a))
RecordManager.insertRecord(table_name, a, blockNum, offset);
}
}
} else {
string t = root->left->table;
int record_size = catm.calc_record_size(t);
indexIterator cursor;
int asdf = IndexManager.getStarter(cursor, t + "/index_" + catm.get_primary(t) + ".db");
if ( asdf == 0 ) {
int b = 0, c = 0;
while (cursor.next(b, c) == 0) {
Record a = RecordManager.getRecord(t, b, c, record_size);
if (calc_conditions(&(root->conditions), a))
RecordManager.insertRecord(table_name, a, blockNum, offset);
}
}
}
root->flag = true;
return;
}
case algbric_node::JOIN :
{
//.........这里部分代码省略.........
示例11: switch
bool Db_Base::Write_Field (Db_Field *fld, void *data, Field_Type type)
{
if (data == 0) return (Status (NULL_POINTER));
if (fld == 0) return (Status (NO_FIELD, false));
if (!Record ().OK ()) return (Status (RECORD_SIZE));
int lvalue = 0;
unsigned uvalue = 0;
double dvalue = 0.0;
Dtime tvalue;
String svalue;
Field_Type fld_type;
//---- convert the input data type to generic variables ----
fld_type = fld->Type ();
switch (fld_type) {
default:
return (Status (DB_ERROR));
case DB_INTEGER:
switch (type) {
case DB_INTEGER:
lvalue = *((int *) data);
break;
case DB_DOUBLE:
dvalue = *((double *) data);
if (dvalue > MAX_INTEGER) {
lvalue = MAX_INTEGER;
} else if (dvalue < -MAX_INTEGER) {
lvalue = -MAX_INTEGER;
} else {
lvalue = DTOI (dvalue);
}
break;
case DB_STRING:
lvalue = ((String *) data)->Integer ();
break;
case DB_TIME:
lvalue = (int) (*((Dtime *) data));
break;
default:
return (Status (DB_ERROR));
}
break;
case DB_UNSIGNED:
switch (type) {
case DB_INTEGER:
uvalue = *((unsigned *) data);
break;
case DB_DOUBLE:
dvalue = *((double *) data);
if (dvalue > 2.0 * MAX_INTEGER) {
uvalue = MAX_INTEGER;
uvalue *= 2;
} else if (dvalue < 0.0) {
uvalue = 0;
} else {
uvalue = (unsigned) (dvalue + 0.5);
}
break;
case DB_STRING:
uvalue = ((String *) data)->Integer ();
break;
case DB_TIME:
uvalue = (unsigned) (*((Dtime *) data));
break;
default:
return (Status (DB_ERROR));
}
break;
case DB_FIXED:
case DB_DOUBLE:
switch (type) {
case DB_INTEGER:
dvalue = (double) *((int *) data);
break;
case DB_DOUBLE:
dvalue = *((double *) data);
break;
case DB_STRING:
dvalue = ((String *) data)->Double ();
break;
case DB_TIME:
dvalue = (double) *((Dtime *) data);
break;
default:
return (Status (DB_ERROR));
}
break;
case DB_STRING:
case DB_CHAR:
switch (type) {
case DB_INTEGER:
if (fld->Units () >= FACILITY_CODE) {
External_Units (*((int *) data), fld->Units (), svalue);
//.........这里部分代码省略.........
示例12: Error
static inline void Error(Event event, Args&& ...args) {
Record(EventSeverity::Error, event, ::std::forward<Args>(args)...);
}
示例13: return
Route_Legs * operator[] (int index) { return ((Route_Legs *) Record (index)); }
示例14: while
void Maze::search() {
size_t row = entrance_row;
size_t col = entrance_col;
while (1) {
int right = 0;
int down = 0;
int left = 0;
int up = 0;
// Ah! We have landed on a new tile
// but haven't left our footprints!
// First let's find out our situation:
// Is it the exit?!
if (row == exit_row && col == exit_col) {
maze[row][col] = touched;
records.push(Record(row, col, touched));
return;
}
// Search for the directions we can go.
if (col < width - 1 && maze[row][col + 1] == not_touched) {
right = 1;
}
if (row < height - 1 && maze[row + 1][col] == not_touched) {
down = 1;
}
if (col > 0 && maze[row][col - 1] == not_touched) {
left = 1;
}
if (row > 0 && maze[row - 1][col] == not_touched) {
up = 1;
}
if (right + down + left + up == 1) {
// If we has exactly one way to go, then go!
maze[row][col] = touched;
records.push(Record(row, col, touched));
if (right == 1) {
++col;
} else if (down == 1) {
++row;
} else if (left == 1) {
--col;
} else {
--row;
}
} else if (right + down + left + up > 1) {
// If we have multiple directions available,
// then it is an intercection.
maze[row][col] = intersection;
records.push(Record(row, col, intersection));
if (right == 1) {
++col;
} else if (down == 1) {
++row;
} else if (left == 1) {
--col;
} else {
--row;
}
} else if (right + down + left + up == 0) {
// Too bad! We don't have any way to go.
// Just get back.
while (maze[row][col] != intersection && !records.empty()) {
maze[row][col] = wall;
Record record = records.pop();
row = record.row;
col = record.col;
}
if (maze[row][col] != intersection && records.empty()) {
// Oops! Dead maze!
return;
}
maze[row][col] = not_touched;
// Notice we even erase the record of the intersection.
}
}
}
示例15: return
Coordinator_Data * operator[] (int index) { return (Record (index)); }