本文整理汇总了C++中Match函数的典型用法代码示例。如果您正苦于以下问题:C++ Match函数的具体用法?C++ Match怎么用?C++ Match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Match函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ParseLoad
AST* ParseLoad(ParserState* parser) {
Match(parser, TOKEN_LOAD);
return CreateASTNode(SEM_LOAD, Match(parser, TOKEN_STRING));
}
开发者ID:feelout,项目名称:toyint,代码行数:4,代码来源:parser.c
示例2: ProcessChatEvent
void CBNET :: ProcessChatEvent( CIncomingChatEvent *chatEvent )
{
CBNETProtocol :: IncomingChatEvent Event = chatEvent->GetChatEvent( );
string User = chatEvent->GetUser( ), lowerUser = chatEvent->GetUser( ), Message = chatEvent->GetMessage( );
transform( lowerUser.begin( ), lowerUser.end( ), lowerUser.begin( ), (int(*)(int))tolower );
unsigned char Access = m_CCBot->m_DB->AccessCheck( m_Server, lowerUser );
if( Access == 255 )
Access = 0;
bool Output = ( Event == CBNETProtocol :: CONSOLE_INPUT );
bool Whisper = ( Event == CBNETProtocol :: EID_WHISPER );
bool ClanMember = IsClanMember( m_UserName );
if( Event == CBNETProtocol :: EID_TALK )
CONSOLE_Print( "[LOCAL: " + m_ServerAlias + ":" + m_CurrentChannel + "][" + User + "] " + Message );
else if( Event == CBNETProtocol :: EID_WHISPER )
CONSOLE_Print( "[WHISPER: " + m_ServerAlias + "][" + User + "] " + Message );
else if( Event == CBNETProtocol :: EID_EMOTE )
CONSOLE_Print( "[EMOTE: " + m_ServerAlias + ":" + m_CurrentChannel + "][" + User + "] " + Message );
if( Event == CBNETProtocol :: EID_TALK || Event == CBNETProtocol :: EID_WHISPER || Event == CBNETProtocol :: EID_EMOTE || Event == CBNETProtocol :: CONSOLE_INPUT )
{
// Anti-Spam
// TODO: improve this to be more robust and efficient
if( m_AntiSpam && !Message.empty( ) && Message[0] != m_CommandTrigger[0] && Access < 5 && IsInChannel( User ) && User != m_UserName )
{
string message = Message;
transform( message.begin( ), message.end( ), message.begin( ), (int(*)(int))tolower );
uint32_t SpamCacheSize = m_Channel.size( ) * 3;
if( m_SpamCache.size( ) > SpamCacheSize )
m_SpamCache.erase( m_SpamCache.begin( ) );
m_SpamCache.insert( pair<string, string>( lowerUser, message ) );
int mesgmatches = 0, nickmatches = 0;
for( multimap<string, string> :: iterator i = m_SpamCache.begin( ); i != m_SpamCache.end( ); ++i )
{
if( (*i).first == lowerUser )
++nickmatches;
if( (*i).second.find( message ) )
++mesgmatches;
}
if( mesgmatches > 2 || nickmatches > 3 )
SendChatCommand( "/kick " + User + " Anti-Spam", Output );
}
// Swearing kick
if ( m_SwearingKick && !Message.empty( ) && !Match( User, m_HostbotName ) && !m_CCBot->m_DB->SafelistCheck( m_Server, User ) && IsInChannel( User ) && Access < 5 )
{
string message = Message;
transform( message.begin( ), message.end( ), message.begin( ), (int(*)(int))tolower );
for( uint32_t i = 0; i < m_CCBot->m_SwearList.size( ); ++i )
{
if( message.find( m_CCBot->m_SwearList[i] ) != string :: npos )
QueueChatCommand( m_CCBot->m_Language->SwearKick( User, m_CCBot->m_SwearList[i] ), Output );
}
}
// ?TRIGGER
if( Match( Message, "?trigger" ) )
{
QueueChatCommand( m_CCBot->m_Language->CommandTrigger( m_CommandTrigger ), User, Whisper, Output );
}
else if( !Message.empty( ) && Message[0] == m_CommandTrigger[0] && Event != CBNETProtocol :: EID_EMOTE )
{
// extract the command trigger, the command, and the payload
// e.g. "!say hello world" -> command: "say", payload: "hello world"
string Command, Payload;
string :: size_type PayloadStart = Message.find( " " );
if( PayloadStart != string :: npos )
{
Command = Message.substr( 1, PayloadStart - 1 );
Payload = Message.substr( PayloadStart + 1 );
}
else
Command = Message.substr( 1 );
transform( Command.begin( ), Command.end( ), Command.begin( ), (int(*)(int))tolower );
/********************************
************ COMMANDS ***********
********************************/
//
// !ACCEPT
//
//.........这里部分代码省略.........
开发者ID:Danteoriginal,项目名称:ccbot,代码行数:101,代码来源:chatevent.cpp
示例3: BdsLibEnumerateAllBootOption
/**
Set the boot order based on configuration retrieved from QEMU.
Attempt to retrieve the "bootorder" fw_cfg file from QEMU. Translate the
OpenFirmware device paths therein to UEFI device path fragments. Match the
translated fragments against BootOptionList, and rewrite the BootOrder NvVar
so that it corresponds to the order described in fw_cfg.
@param[in] BootOptionList A boot option list, created with
BdsLibEnumerateAllBootOption ().
@retval RETURN_SUCCESS BootOrder NvVar rewritten.
@retval RETURN_UNSUPPORTED QEMU's fw_cfg is not supported.
@retval RETURN_NOT_FOUND Empty or nonexistent "bootorder" fw_cfg
file, or no match found between the
"bootorder" fw_cfg file and BootOptionList.
@retval RETURN_INVALID_PARAMETER Parse error in the "bootorder" fw_cfg file.
@retval RETURN_OUT_OF_RESOURCES Memory allocation failed.
@return Values returned by gBS->LocateProtocol ()
or gRT->SetVariable ().
**/
RETURN_STATUS
SetBootOrderFromQemu (
IN CONST LIST_ENTRY *BootOptionList
)
{
RETURN_STATUS Status;
FIRMWARE_CONFIG_ITEM FwCfgItem;
UINTN FwCfgSize;
CHAR8 *FwCfg;
CONST CHAR8 *FwCfgPtr;
BOOT_ORDER BootOrder;
ACTIVE_OPTION *ActiveOption;
UINTN ActiveCount;
UINTN TranslatedSize;
CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);
if (Status != RETURN_SUCCESS) {
return Status;
}
if (FwCfgSize == 0) {
return RETURN_NOT_FOUND;
}
FwCfg = AllocatePool (FwCfgSize);
if (FwCfg == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
QemuFwCfgSelectItem (FwCfgItem);
QemuFwCfgReadBytes (FwCfgSize, FwCfg);
if (FwCfg[FwCfgSize - 1] != '\0') {
Status = RETURN_INVALID_PARAMETER;
goto ErrorFreeFwCfg;
}
DEBUG ((DEBUG_VERBOSE, "%a: FwCfg:\n", __FUNCTION__));
DEBUG ((DEBUG_VERBOSE, "%a\n", FwCfg));
DEBUG ((DEBUG_VERBOSE, "%a: FwCfg: <end>\n", __FUNCTION__));
FwCfgPtr = FwCfg;
BootOrder.Produced = 0;
BootOrder.Allocated = 1;
BootOrder.Data = AllocatePool (
BootOrder.Allocated * sizeof (*BootOrder.Data)
);
if (BootOrder.Data == NULL) {
Status = RETURN_OUT_OF_RESOURCES;
goto ErrorFreeFwCfg;
}
Status = CollectActiveOptions (BootOptionList, &ActiveOption, &ActiveCount);
if (RETURN_ERROR (Status)) {
goto ErrorFreeBootOrder;
}
//
// translate each OpenFirmware path
//
TranslatedSize = sizeof (Translated) / sizeof (Translated[0]);
Status = TranslateOfwPath (&FwCfgPtr, Translated, &TranslatedSize);
while (Status == RETURN_SUCCESS ||
Status == RETURN_UNSUPPORTED ||
Status == RETURN_BUFFER_TOO_SMALL) {
if (Status == RETURN_SUCCESS) {
UINTN Idx;
//
//.........这里部分代码省略.........
开发者ID:JohnTroony,项目名称:vector-edk,代码行数:101,代码来源:QemuBootOrder.c
示例4: Match
bool Match(const std::string& s, match_flag_type flags = match_default) { return Match(s.c_str(), flags); }
开发者ID:BioinformaticsArchive,项目名称:MulRFRepo,代码行数:1,代码来源:cregex.hpp
示例5: acsmSearch
/*
* Search Text or Binary Data for Pattern matches
*/
int
acsmSearch (ACSM_STRUCT * acsm, unsigned char *Tx, int n,
#ifdef DETECTION_OPTION_TREE
int (*Match)(void * id, void *tree, int index, void *data),
#else
int (*Match) (void * id, int index, void *data),
#endif
void *data, int* current_state )
{
unsigned char Tc[64*1024];
int state = 0;
ACSM_PATTERN * mlist;
unsigned char *Tend;
ACSM_STATETABLE * StateTable = acsm->acsmStateTable;
int nfound = 0;
unsigned char *T;
int index;
/* Case conversion */
ConvertCaseEx (Tc, Tx, n);
T = Tc;
Tend = T + n;
if ( !current_state )
{
return 0;
}
state = *current_state;
for (; T < Tend; T++)
{
state = StateTable[state].NextState[*T];
if( StateTable[state].MatchList != NULL )
{
#ifdef DETECTION_OPTION_TREE
mlist = StateTable[state].MatchList;
index = T - mlist->n + 1 - Tc;
nfound++;
if (Match (mlist->id, mlist->rule_option_tree, index, data) > 0)
{
*current_state = state;
return nfound;
}
#else
for( mlist=StateTable[state].MatchList; mlist!=NULL;
mlist=mlist->next )
{
index = T - mlist->n + 1 - Tc;
if( mlist->nocase )
{
nfound++;
if (Match (mlist->id, index, data) > 0)
{
*current_state = state;
return nfound;
}
}
else
{
if( memcmp (mlist->casepatrn, Tx + index, mlist->n) == 0 )
{
nfound++;
if (Match (mlist->id, index, data) > 0)
{
*current_state = state;
return nfound;
}
}
}
}
#endif
}
}
*current_state = state;
return nfound;
}
开发者ID:shengxinking,项目名称:xxx,代码行数:81,代码来源:acsmx.c
示例6: Discid
// static
bool Cddb::Query(Matches& res, const Toc& toc)
{
if (toc.size() < 2)
return false;
const unsigned totalTracks = toc.size() - 1;
unsigned secs = 0;
const discid_t discID = Discid(secs, toc.data(), totalTracks);
// Is it cached?
if (Dbase::Search(res, discID))
return res.matches.size() > 0;
// Construct query
// cddb query discid ntrks off1 off2 ... nsecs
QString URL2 = URL + QString("cddb+query+%1+%2+").arg(discID,0,16).arg(totalTracks);
for (unsigned t = 0; t < totalTracks; ++t)
URL2 += QString("%1+").arg(msf2lsn(toc[t]));
URL2 += QString::number(secs);
// Send the request
URL2 += "&hello=" + helloID() + "&proto=5";
LOG(VB_MEDIA, LOG_INFO, "CDDB lookup: " + URL2);
QString cddb;
QByteArray data;
if (!GetMythDownloadManager()->download(URL2, &data))
return false;
cddb = data;
// Check returned status
const uint stat = cddb.left(3).toUInt(); // Extract 3 digit status:
cddb = cddb.mid(4);
switch (stat)
{
case 200: // Unique match
LOG(VB_MEDIA, LOG_INFO, "CDDB match: " + cddb.trimmed());
// e.g. "200 rock 960b5e0c Nichole Nordeman / Woven & Spun"
res.discID = discID;
res.isExact = true;
res.matches.push_back(Match(
cddb.section(' ', 0, 0), // genre
cddb.section(' ', 1, 1).toUInt(nullptr,16), // discID
cddb.section(' ', 2).section(" / ", 0, 0), // artist
cddb.section(' ', 2).section(" / ", 1) // title
));
break;
case 202: // No match for disc ID...
LOG(VB_MEDIA, LOG_INFO, "CDDB no match");
Dbase::New(discID, toc); // Stop future lookups
return false;
case 210: // Multiple exact matches
case 211: // Multiple inexact matches
// 210 Found exact matches, list follows (until terminating `.')
// 211 Found inexact matches, list follows (until terminating `.')
res.discID = discID;
res.isExact = 210 == stat;
// Remove status line
cddb = cddb.section('\n', 1);
// Append all matches
while (!cddb.isEmpty() && !cddb.startsWith("."))
{
LOG(VB_MEDIA, LOG_INFO, QString("CDDB %1 match: %2").
arg(210 == stat ? "exact" : "inexact").
arg(cddb.section('\n',0,0)));
res.matches.push_back(Match(
cddb.section(' ', 0, 0), // genre
cddb.section(' ', 1, 1).toUInt(nullptr,16), // discID
cddb.section(' ', 2).section(" / ", 0, 0), // artist
cddb.section(' ', 2).section(" / ", 1) // title
));
cddb = cddb.section('\n', 1);
}
if (res.matches.size() <= 0)
Dbase::New(discID, toc); // Stop future lookups
break;
default:
// TODO try a (telnet 8880) CDDB lookup
LOG(VB_GENERAL, LOG_INFO, QString("CDDB query error: %1").arg(stat) +
cddb.trimmed());
return false;
}
return true;
}
开发者ID:faginbagin,项目名称:mythtv,代码行数:92,代码来源:cddb.cpp
示例7: SetClassName
void MatchEditor::Init () {
SetClassName("MatchEditor");
Match("%[]", true);
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:4,代码来源:matcheditor.c
示例8: TraverseCXXOperatorCallExpr
// Use Traverse, not Visit, to check that data recursion optimization isn't
// bypassing the call of this function.
bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *CE) {
Match(getOperatorSpelling(CE->getOperator()), CE->getExprLoc());
return ExpectedLocationVisitor<CXXOperatorCallExprTraverser>::
TraverseCXXOperatorCallExpr(CE);
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:7,代码来源:RecursiveASTVisitorTest.cpp
示例9: VisitParenExpr
bool VisitParenExpr(ParenExpr *Parens) {
Match("", Parens->getExprLoc());
return true;
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:4,代码来源:RecursiveASTVisitorTest.cpp
示例10: VisitVarDecl
bool VisitVarDecl(VarDecl *Variable) {
Match(Variable->getNameAsString(), Variable->getLocStart());
return true;
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:4,代码来源:RecursiveASTVisitorTest.cpp
示例11: VisitCXXMemberCallExpr
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *Call) {
Match(Call->getMethodDecl()->getQualifiedNameAsString(),
Call->getLocStart());
return true;
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:5,代码来源:RecursiveASTVisitorTest.cpp
示例12: VisitDeclRefExpr
bool VisitDeclRefExpr(DeclRefExpr *Reference) {
Match(Reference->getNameInfo().getAsString(), Reference->getLocation());
return true;
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:4,代码来源:RecursiveASTVisitorTest.cpp
示例13: VisitTypeLoc
bool VisitTypeLoc(TypeLoc TypeLocation) {
Match(TypeLocation.getType().getAsString(), TypeLocation.getBeginLoc());
return true;
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:4,代码来源:RecursiveASTVisitorTest.cpp
示例14: Match
Match Match::flip() const {
return Match(second, first);
}
开发者ID:jvlmdr,项目名称:non-rigid-tracking,代码行数:3,代码来源:match.cpp
示例15: Constants
void Constants(){
Match('c');
}
开发者ID:naveen246,项目名称:tiny_compiler,代码行数:3,代码来源:9.c
示例16: Match
AdminRegionVisitor::Action LocationService::AdminRegionMatchVisitor::Visit(const AdminRegion& region)
{
bool atLeastOneAliasMatch=false;
bool regionMatch;
bool regionCandidate;
Match(region.name,
regionMatch,
regionCandidate);
if (!regionMatch) {
for (const auto& alias : region.aliases) {
bool match;
bool candidate;
Match(alias.name,
match,
candidate);
if (match || candidate) {
AdminRegionResult result;
result.adminRegion=std::make_shared<AdminRegion>(region);
result.isMatch=match;
result.adminRegion->aliasName=alias.name;
result.adminRegion->aliasObject.Set(alias.objectOffset,refNode);
//std::cout << pattern << " => (alias) " << result.adminRegion->aliasName << " " << match << " " << regionCandidate << " " << std::endl;
results.push_back(result);
if (match) {
atLeastOneAliasMatch=true;
}
limitReached=results.size()>=limit;
}
}
}
// If we have a perfect match for an alias, we not not try to regionMatch
// the region name itself
if (!atLeastOneAliasMatch) {
if (regionMatch || regionCandidate) {
AdminRegionResult result;
result.adminRegion=std::make_shared<AdminRegion>(region);
result.isMatch=regionMatch;
//std::cout << pattern << " => (region) " << result.adminRegion->name << " " << regionMatch << " " << regionCandidate << std::endl;
results.push_back(result);
}
}
if (limitReached) {
return stop;
}
else {
return visitChildren;
}
}
开发者ID:AQbernhard,项目名称:OSMScout-ubuntu,代码行数:64,代码来源:LocationService.cpp
示例17: Types
void Types(){
Match('t');
}
开发者ID:naveen246,项目名称:tiny_compiler,代码行数:3,代码来源:9.c
示例18: GetProperty
void GetProperty (){
Match('"');
while ( Look!='"' )
GetChar();
Match('"');
}
开发者ID:BuckRogers1965,项目名称:Examples,代码行数:6,代码来源:xml.c
示例19: refreshFolders
void DocumentCatalog::queryChanged()
{
int newStatus = 0;
if(query() == "")
{
// reset query
dir = QDir::home();
currentPath = "";
queryMatched = 0;
refreshFolders();
} else {
if(query().length() >= minQueryLen())
{
QString path = query().lower().remove(0, queryMatched);
int index;
while((index = path.find('/')) != -1) {
QString folderQuery = path.left(index);
QString guess = QString::null;
for(QStringList::Iterator it = folders.begin(); it != folders.end(); ++it) {
QString folderName = *it;
if(folderName.lower().startsWith(folderQuery) && (guess.isNull() || folderName.length() < guess.length()))
guess = folderName;
}
if(guess == QString::null) {
path = QString::null;
break;
}
if(!dir.cd(guess)) {
path = QString::null;
break;
}
refreshFolders();
queryMatched += folderQuery.length() + 1;
currentPath += guess + "/";
path = path.remove(0, index+1);
}
Match newBestMatch;
if(path.isNull()) {
files.clear();
} else {
if(!filesListed) {
refreshFiles();
}
if(!path.isEmpty()) {
if(currentDirDoc != 0) {
files.removeRef(currentDirDoc);
currentDirDoc = 0;
}
QPtrListIterator<Document> it(files);
Document *document;
while((document = it.current()) != 0) {
++it;
if(document->name().lower().startsWith(path)) {
int rank = 100*query().length()/document->text().length();
if(newBestMatch.isNull() || rank > newBestMatch.rank())
newBestMatch = Match(document, rank, currentPath.length() + path.length());
} else {
files.removeRef(document);
}
}
}
}
if(currentDirDoc != 0 && path.isEmpty())
newBestMatch = Match(currentDirDoc, 100, currentPath.length());
newStatus |= S_Active;
if(files.count() > 0)
{
newStatus |= S_HasResults;
if(files.count() > 1 || files.at(0)->className() == "Directory")
newStatus |= S_Multiple;
} else
newStatus |= S_NoResults;
setBestMatch(newBestMatch);
} else {
setBestMatch(Match());
}
}
setStatus(newStatus);
}
开发者ID:iegor,项目名称:kdesktop,代码行数:89,代码来源:documentcatalog.cpp
示例20: Variables
void Variables(){
Match('v');
}
开发者ID:naveen246,项目名称:tiny_compiler,代码行数:3,代码来源:9.c
注:本文中的Match函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论