本文整理汇总了C++中Category类的典型用法代码示例。如果您正苦于以下问题:C++ Category类的具体用法?C++ Category怎么用?C++ Category使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Category类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void CSMPrefs::State::resetCategory(const std::string& category)
{
for (Settings::CategorySettingValueMap::iterator i = mSettings.mUserSettings.begin();
i != mSettings.mUserSettings.end(); ++i)
{
// if the category matches
if (i->first.first == category)
{
// mark the setting as changed
mSettings.mChangedSettings.insert(std::make_pair(i->first.first, i->first.second));
// reset the value to the default
i->second = mSettings.mDefaultSettings[i->first];
}
}
Collection::iterator container = mCategories.find(category);
if (container != mCategories.end())
{
Category settings = container->second;
for (Category::Iterator i = settings.begin(); i != settings.end(); ++i)
{
(*i)->updateWidget();
update(**i);
}
}
}
示例2: loadACL
void Override::loadACL(const DOMElement* e, Category& log)
{
try {
const DOMElement* acl=XMLHelper::getFirstChildElement(e,htaccess);
if (acl) {
log.info("building Apache htaccess AccessControl provider...");
m_acl=SPConfig::getConfig().AccessControlManager.newPlugin(HT_ACCESS_CONTROL,acl);
}
else {
acl=XMLHelper::getFirstChildElement(e,_AccessControl);
if (acl) {
log.info("building XML-based AccessControl provider...");
m_acl=SPConfig::getConfig().AccessControlManager.newPlugin(XML_ACCESS_CONTROL,acl);
}
else {
acl=XMLHelper::getFirstChildElement(e,AccessControlProvider);
if (acl) {
auto_ptr_char type(acl->getAttributeNS(NULL,_type));
log.info("building AccessControl provider of type %s...",type.get());
m_acl=SPConfig::getConfig().AccessControlManager.newPlugin(type.get(),acl);
}
}
}
}
catch (exception& ex) {
log.crit("exception building AccessControl provider: %s", ex.what());
m_acl = new AccessControlDummy();
}
}
示例3: file
bool Round::load(){
QFile file(roundfile);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
//QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
return false;
}
QTextStream in(&file);
Category *curcat = NULL;
while(!in.atEnd()) {
QString line = in.readLine();
if(line.startsWith('#')){
curcat = new Category(line.mid(1));
categories.append(curcat);
continue;
}
bool convok = false;
int points = line.section(':', 0, 0).trimmed().toUInt(&convok);
QString answer = line.section(':', 1).trimmed();
if(!convok || answer.length() == 0) {
if(answer.length() != 0) qWarning() << "Ignoring Line \"" << line << '"';
continue;
}
curcat->addAnswer(answer, points);
nAnswers++;
}
return true;
}
示例4: leftCell
// repaint cells that have been changed from previous generation
void Pstable::repaint_changed()
{
int rows = procview->procs.size();
int cols = procview->cats.size();
int left = leftCell(), right = lastColVisible();
int top = topCell(), bottom = lastRowVisible();
if(right >= cols) right = cols - 1;
if(bottom >= rows) bottom = rows - 1;
int far_right = right;
if(leftmostchanged != -1 && right >= leftmostchanged)
right = leftmostchanged - 1;
for(int c = right + 1; c <= far_right; c++)
updateHeading(c);
for(int r = top; r <= bottom; r++) {
for(int c = left; c <= right; c++) {
Category *cat = procview->cats[c];
Procinfo *p = procview->procs[r], *op = 0;
if(r >= procview->old_procs.size()
|| (op = procview->old_procs[r], cat->compare(p, op) != 0)
|| p->selected != op->selected) {
updateCell(r, c);
}
}
// update all cells that have moved or changed width
for(int c = right + 1; c <= far_right; c++)
updateCell(r, c);
}
if(leftmostchanged != -1)
clearRight();
}
示例5:
unique_ptr<Match> tstMatch::initMatchGroup()
{
MatchMngr* mm = Tournament::getMatchMngr();
Category ms = Tournament::getCatMngr()->getCategoryById(1);
TournamentDB db{getSqliteFileName(), false};
// fake a valid category state
TabRow catRow = db[TAB_CATEGORY][1];
catRow.update(GENERIC_STATE_FIELD_NAME, static_cast<int>(STAT_CAT_IDLE));
CPPUNIT_ASSERT(ms.getState() == STAT_CAT_IDLE);
// create a new match group
ERR e;
auto grp = mm->createMatchGroup(ms, 1, 2, &e);
CPPUNIT_ASSERT(e == OK);
CPPUNIT_ASSERT(grp != nullptr);
grp = mm->createMatchGroup(ms, 2, 3, &e);
CPPUNIT_ASSERT(e == OK);
CPPUNIT_ASSERT(grp != nullptr);
// create a new match in this group
auto ma = mm->createMatch(*grp, &e);
CPPUNIT_ASSERT(e == OK);
CPPUNIT_ASSERT(ma != nullptr);
return ma;
}
示例6: it
void CategoryMgr::savePrefs(void)
{
if (!m_changed)
return;
int count = 1;
QString section = "CategoryMgr";
QString prefBaseName;
CategoryListIterator it(m_categories);
for (Category* curCategory = it.toFirst();
curCategory != NULL;
curCategory = ++it)
{
prefBaseName.sprintf("Category%d_", count++);
pSEQPrefs->setPrefString(prefBaseName + "Name", section,
curCategory->name());
pSEQPrefs->setPrefString(prefBaseName + "Filter", section,
curCategory->filter());
pSEQPrefs->setPrefString(prefBaseName + "FilterOut", section,
curCategory->filterout());
pSEQPrefs->setPrefColor(prefBaseName + "Color", section,
curCategory->color());
}
QColor black("black");
while (count <= tMaxNumCategories)
{
prefBaseName.sprintf("Category%d_", count++);
pSEQPrefs->setPrefString(prefBaseName + "Name", section, "");
pSEQPrefs->setPrefString(prefBaseName + "Filter", section, "");
pSEQPrefs->setPrefString(prefBaseName + "FilterOut", section, "");
pSEQPrefs->setPrefColor(prefBaseName + "Color", section, black);
}
}
示例7: guard
int CategoryManager::addRule(const Rule& value)
{
bslmt::LockGuard<bslmt::Mutex> guard(&d_ruleSetMutex);
int ruleId = d_ruleSet.addRule(value);
if (ruleId < 0) {
return 0; // RETURN
}
++d_ruleSequenceNum;
const Rule *rule = d_ruleSet.getRuleById(ruleId);
for (int i = 0; i < length(); ++i) {
Category *category = d_categories[i];
if (rule->isMatch(category->categoryName())) {
CategoryManagerImpUtil::enableRule(category, ruleId);
int threshold = ThresholdAggregate::maxLevel(
rule->recordLevel(),
rule->passLevel(),
rule->triggerLevel(),
rule->triggerAllLevel());
if (threshold > category->ruleThreshold()) {
CategoryManagerImpUtil::setRuleThreshold(category, threshold);
CategoryManagerImpUtil::updateThresholdForHolders(category);
}
}
}
return 1;
}
示例8: xml
Category::List CategoryParser::parseList( const QString &xmlString )
{
Category::List categoryList;
QXmlStreamReader xml( xmlString );
while ( !xml.atEnd() ) {
xml.readNext();
if ( xml.isStartElement() && xml.name() == "category" ) {
Category category;
while ( !xml.atEnd() ) {
xml.readNext();
if ( xml.isStartElement() ) {
if ( xml.name() == "id" ) {
category.setId( xml.readElementText() );
} else if ( xml.name() == "name" ) {
category.setName( xml.readElementText() );
}
}
if ( xml.isEndElement() && xml.name() == "category" ) break;
}
categoryList.append( category );
}
}
return categoryList;
}
示例9: res
boost::shared_ptr< Base<EncodingT> > IncludeInstruction<EncodingT>::interpret(Context<EncodingT> & c)
{
typename EncodingT::string_t buf;
boost::shared_ptr< Bool<EncodingT> > res(new Bool<EncodingT>(false));
boost::shared_ptr< Base<EncodingT> > expr = m_instruction->interpret(c);
Category * logger = &Category::getInstance(LOGNAME);
if (!readFile(A(expr->toString()), buf))
{
logger->errorStream() << "Cannot open file '" << A(expr->toString()) << "'.";
}
else
{
typename EncodingT::string_t instructions;
boost::shared_ptr< Term<EncodingT> > declaration, block;
if (Declaration<EncodingT>::parse(buf, declaration, instructions) &&
Block<EncodingT>::parse(instructions, block))
{
declaration->interpret(c);
block->interpret(c);
res->setValue(true);
}
else
{
logger->errorStream() << "An error occurred during the file interpretation '" << A(expr->toString()) << "'.";
}
}
return res;
}
示例10: count
bool DbNote::existCategory(Category & category)
{
sqlite3_stmt *statement;
string stmnt = "select count(*) from KatTable where KatDesc like ? or KatKey = ?";
if (!openDB())
{
throw SQLError("Can't open the DB-Connection");
return false;
}
int req = sqlite3_prepare_v2(db, stmnt.c_str(), -1, &statement, 0);
if (req != SQLITE_OK)
{
throw SQLError("Preparing Select-Statement failed in existCategory()");
return false;
}
req = sqlite3_bind_text(statement, 1, category.getDesc().c_str(), category.getDesc().size(), 0 );
req = sqlite3_bind_int(statement, 2, category.getKatKey());
if (req != SQLITE_OK)
{
throw SQLError("Binding Date into select statement failed");
return false;
}
req = sqlite3_step(statement);
int catCount = static_cast<int>(sqlite3_column_int(statement, 0));
sqlite3_finalize(statement);
sqlite3_close(db);
if (catCount > 0)
return true;
return false;
}
示例11: stream
bool CategoryModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) {
if (action == Qt::IgnoreAction)
return true;
if (!data->hasFormat("application/editor.categorymodel.index"))
return false;
QByteArray encodedData = data->data("application/editor.categorymodel.index");
QDataStream stream(&encodedData, QIODevice::ReadOnly);
QList<Item*> items;
while (!stream.atEnd()) {
quint64 address;
stream >> address;
Item* item = reinterpret_cast<Item*>(address);
items.push_back(item);
}
Category* category = static_cast<Category*>(parent.internalPointer());
for (QList<Item*>::const_iterator it = items.begin(); it != items.end(); ++it) {
Item* item = *it;
if (!item->isCategory() || !item->toCategory()->isAncestorOf(category)) {
QModelIndex parentIndex = createIndex(item->parent()->childNumber(), 1, item->parent());
if (parentIndex != parent) {
beginMoveRows(parentIndex, item->childNumber(), item->childNumber(), parent, rowCount(parent));
category->addChild(item);
endMoveRows();
}
}
}
return true;
}
示例12: printStartMsg
void tstCatMngr::testCreateNewCategory()
{
printStartMsg("tstCatMngr::testCreateNewCategory");
TournamentDB* db = getScenario01(true);
CatMngr cmngr(db);
// try empty or invalid name
CPPUNIT_ASSERT(cmngr.createNewCategory("") == INVALID_NAME);
CPPUNIT_ASSERT(cmngr.createNewCategory(QString::null) == INVALID_NAME);
CPPUNIT_ASSERT((*db)[TAB_CATEGORY].length() == 0);
// actually create a valid category
CPPUNIT_ASSERT(cmngr.createNewCategory("c1") == OK);
CPPUNIT_ASSERT((*db)[TAB_CATEGORY].length() == 1);
TabRow r = (*db)[TAB_CATEGORY][1];
CPPUNIT_ASSERT(r[GENERIC_NAME_FIELD_NAME].toString() == "c1");
// make sure the default values are set correctly
Category c = cmngr.getCategory("c1");
CPPUNIT_ASSERT(c.getState() == STAT_CAT_CONFIG);
CPPUNIT_ASSERT(c.getMatchSystem() == GROUPS_WITH_KO);
CPPUNIT_ASSERT(c.getMatchType() == SINGLES);
CPPUNIT_ASSERT(c.getSex() == M);
// name collision
CPPUNIT_ASSERT(cmngr.createNewCategory("c1") == NAME_EXISTS);
CPPUNIT_ASSERT((*db)[TAB_CATEGORY].length() == 1);
delete db;
printEndMsg();
}
示例13: new
// PRIVATE MANIPULATORS
Category *CategoryManager::addNewCategory(const char *categoryName,
int recordLevel,
int passLevel,
int triggerLevel,
int triggerAllLevel)
{
// Create a new category and add it to the collection of categories
// and the category registry.
Category *category = new (*d_allocator_p) Category(categoryName,
recordLevel,
passLevel,
triggerLevel,
triggerAllLevel,
d_allocator_p);
// rollback on failure
CategoryProctor proctor(category, d_allocator_p);
d_categories.push_back(category);
proctor.setCategories(&d_categories);
d_registry[category->categoryName()] =
static_cast<int>(d_categories.size() - 1);
proctor.release();
return category;
}
示例14:
void CSpy360Dlg::OnBnClickedGetRubbish()
{
enum{id = 9};
Category* pCategory = NULL;
DObj* pDObj = NULL;
if(!ThisCall(gpSysSweeper->m8_pIRubbishClean,IRubbishClean__GetObj,id,&pCategory, &pDObj))
return;
CString s,s1;
if(pCategory)
{
File f;
s.Format("C:\\Rubbish%d.txt",id);
if(!f.Open(s,"wb"))
return;
VecKObj* pVecKObj = pCategory->m40_vecKObj();
for(ULONG i = 0;i<pVecKObj->m4_nItem;i++)
{
KObj* pKObj = pVecKObj->m0_ppItem[i];
s1 = pKObj->m8_pathFile;
s.Format("%s\r\n",s1);
::fwrite(s,s.GetLength(),1,f);
}
}
}
示例15: updateActivity
/*!
* \brief Updates the activity the record belongs to.
*/
void Record::updateActivity(Activity *activity)
{
if (m_activity && (m_activity->databaseId() != activity->databaseId())) {
m_activity->setDatabaseId(activity->databaseId());
m_activity->setName(activity->name());
m_activity->setMinRepeats(activity->minRepeats());
m_activity->setMaxRepeats(activity->maxRepeats());
m_activity->setUseRepeats(activity->useRepeats());
m_activity->setUseDistance(activity->useDistance());
m_activity->setRecords(activity->records());
Category *c = m_activity->category();
Category *o = activity->category();
if (c) {
c->setDatabaseId(o->databaseId());
c->setName(o->name());
c->setColor(o->color());
c->setActivities(o->activities());
}
if (!m_activity->useRepeats()) {
setRepetitions(0);
}
if (!m_activity->useDistance()) {
setDistance(0.0);
}
}
}