本文整理汇总了C++中StringList::next方法的典型用法代码示例。如果您正苦于以下问题:C++ StringList::next方法的具体用法?C++ StringList::next怎么用?C++ StringList::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringList
的用法示例。
在下文中一共展示了StringList::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: directory
/** Parse a JOB or SUBDAG line from a DAG file.
@param dagLine: the line we're parsing
@param tokens: tokens of this line
@param fileType: "submit" or "DAG" (to be used in error message)
@param submitOrDagFile: if successful, this will point to submit or
nested DAG file name
@param directory: if successful, this will point to directory (NULL
if not specified)
@return 0 if successful, 1 if failed
*/
int
parseJobOrDagLine( const char *dagLine, StringList &tokens,
const char *fileType, const char *&submitOrDagFile,
const char *&directory )
{
const char *nodeName = tokens.next();
if ( !nodeName) {
fprintf( stderr, "No node name specified in line: <%s>\n", dagLine );
return 1;
}
submitOrDagFile = tokens.next();
if ( !submitOrDagFile ) {
fprintf( stderr, "No %s file specified in "
"line: <%s>\n", fileType, dagLine );
return 1;
}
directory = NULL;
const char *dirKeyword = tokens.next();
if ( dirKeyword && !strcasecmp( dirKeyword, "DIR" ) ) {
directory = tokens.next();
if ( !directory ) {
fprintf( stderr, "No directory specified in "
"line: <%s>\n", dagLine );
return 1;
}
}
return 0;
}
示例2: buildDaemon
void
DaemonList::init( daemon_t type, const char* host_list, const char* pool_list )
{
Daemon* tmp;
char* host;
char const *pool = NULL;
StringList foo;
StringList pools;
if( host_list ) {
foo.initializeFromString( host_list );
foo.rewind();
}
if( pool_list ) {
pools.initializeFromString( pool_list );
pools.rewind();
}
while( true ) {
host = foo.next();
pool = pools.next();
if( !host && !pool ) {
break;
}
tmp = buildDaemon( type, host, pool );
append( tmp );
}
}
示例3: if
bool
IpVerify::lookup_user(NetStringList *hosts, UserHash_t *users, char const *user, char const *ip, char const *hostname, bool is_allow_list)
{
if( !hosts || !users ) {
return false;
}
ASSERT( user );
// we look up by ip OR by hostname, not both
ASSERT( !ip || !hostname );
ASSERT( ip || hostname);
StringList hostmatches;
if( ip ) {
hosts->find_matches_withnetwork(ip,&hostmatches);
}
else if( hostname ) {
hosts->find_matches_anycase_withwildcard(hostname,&hostmatches);
}
char const * hostmatch;
hostmatches.rewind();
while( (hostmatch=hostmatches.next()) ) {
StringList *userlist;
ASSERT( users->lookup(hostmatch,userlist) != -1 );
if (userlist->contains_anycase_withwildcard(user)) {
dprintf ( D_SECURITY, "IPVERIFY: matched user %s from %s to %s list\n",
user, hostmatch, is_allow_list ? "allow" : "deny" );
return true;
}
}
return false;
}
示例4: tokens
/** Get the command-line options we want to preserve from the .condor.sub
file we're overwriting, and plug them into the shallowOpts structure.
Note that it's *not* an error for the .condor.sub file to not exist.
@param shallowOpts: the condor_submit_dag shallow options
@return 0 if successful, 1 if failed
*/
int
getOldSubmitFlags(SubmitDagShallowOptions &shallowOpts)
{
// It's not an error for the submit file to not exist.
if ( fileExists( shallowOpts.strSubFile ) ) {
StringList logicalLines;
MyString error = MultiLogFiles::fileNameToLogicalLines(
shallowOpts.strSubFile, logicalLines );
if ( error != "" ) {
fprintf( stderr, "Error reading submit file: %s\n",
error.Value() );
return 1;
}
logicalLines.rewind();
const char *subLine;
while ( (subLine = logicalLines.next()) ) {
StringList tokens( subLine, " \t" );
tokens.rewind();
const char *first = tokens.next();
if ( first && !strcasecmp( first, "arguments" ) ) {
if ( parseArgumentsLine( subLine, shallowOpts ) != 0 ) {
return 1;
}
}
}
}
return 0;
}
示例5: StartBatchStatus
DCloudResource::BatchStatusResult DCloudResource::StartBatchStatus()
{
ASSERT(status_gahp);
StringList instance_ids;
StringList statuses;
const char *instance_id;
const char *status;
int rc = status_gahp->dcloud_status_all( ResourceName(), m_username,
m_password, instance_ids,
statuses );
if ( rc == GAHPCLIENT_COMMAND_PENDING ) {
return BSR_PENDING;
}
if ( rc != 0 ) {
dprintf( D_ALWAYS, "Error attempting a Deltacloud batch status query: %s\n", status_gahp->getErrorString() );
return BSR_ERROR;
}
DCloudJob *next_job;
List<DCloudJob> my_jobs;
registeredJobs.Rewind();
while ( (next_job = (DCloudJob *)registeredJobs.Next()) ) {
my_jobs.Insert( next_job );
}
instance_ids.rewind();
statuses.rewind();
while ( (instance_id = instance_ids.next()) &&
(status = statuses.next()) ) {
MyString hashname;
hashname.formatstr( "%s#%s", ResourceName(), instance_id );
DCloudJob *job = NULL;
// TODO We can get rid of the hashtable.
rc = DCloudJob::JobsByInstanceId.lookup(
HashKey( hashname.Value() ), job );
if ( rc != 0 ) {
// Job not found. Probably okay; we might see jobs
// submitted via other means, or jobs we've abandoned.
dprintf( D_FULLDEBUG, "Job %s on remote host is unknown. Skipping.\n", hashname.Value() );
continue;
}
ASSERT( job );
job->StatusUpdate( status );
my_jobs.Delete( job );
}
my_jobs.Rewind();
while ( (next_job = my_jobs.Next()) ) {
next_job->StatusUpdate( NULL );
}
return BSR_DONE;
}
示例6: set_status_print_mask_from_stream
int set_status_print_mask_from_stream (
const char * streamid,
bool is_filename,
const char ** pconstraint)
{
std::string where_expr;
std::string messages;
StringList attrs;
printmask_aggregation_t aggregation;
SimpleInputStream * pstream = NULL;
*pconstraint = NULL;
FILE *file = NULL;
if (MATCH == strcmp("-", streamid)) {
pstream = new SimpleFileInputStream(stdin, false);
} else if (is_filename) {
file = safe_fopen_wrapper_follow(streamid, "r");
if (file == NULL) {
fprintf(stderr, "Can't open select file: %s\n", streamid);
return -1;
}
pstream = new SimpleFileInputStream(file, true);
} else {
pstream = new StringLiteralInputStream(streamid);
}
ASSERT(pstream);
int err = SetAttrListPrintMaskFromStream(
*pstream,
*getCondorStatusPrintFormats(),
pm,
pmHeadFoot,
aggregation,
group_by_keys,
where_expr,
attrs,
messages);
delete pstream; pstream = NULL;
if ( ! err) {
if (aggregation != PR_NO_AGGREGATION) {
fprintf(stderr, "print-format aggregation not supported\n");
return -1;
}
if ( ! where_expr.empty()) {
*pconstraint = pm.store(where_expr.c_str());
//if ( ! validate_constraint(*pconstraint)) {
// formatstr_cat(messages, "WHERE expression is not valid: %s\n", *pconstraint);
//}
}
// convert projection list into the format that condor status likes. because programmers.
attrs.rewind();
const char * attr;
while ((attr = attrs.next())) { projList.AppendArg(attr); }
}
if ( ! messages.empty()) { fprintf(stderr, "%s", messages.c_str()); }
return err;
}
示例7: getParamFromSubmitLine
MyString
MultiLogFiles::loadValueFromSubFile(const MyString &strSubFilename,
const MyString &directory, const char *keyword)
{
dprintf( D_FULLDEBUG, "MultiLogFiles::loadValueFromSubFile(%s, %s, %s)\n",
strSubFilename.Value(), directory.Value(), keyword );
TmpDir td;
if ( directory != "" ) {
MyString errMsg;
if ( !td.Cd2TmpDir(directory.Value(), errMsg) ) {
dprintf(D_ALWAYS, "Error from Cd2TmpDir: %s\n", errMsg.Value());
return "";
}
}
StringList logicalLines;
if ( fileNameToLogicalLines( strSubFilename, logicalLines ) != "" ) {
return "";
}
MyString value("");
// Now look through the submit file logical lines to find the
// value corresponding to the keyword.
const char *logicalLine;
while( (logicalLine = logicalLines.next()) != NULL ) {
MyString submitLine(logicalLine);
MyString tmpValue = getParamFromSubmitLine(submitLine, keyword);
if ( tmpValue != "" ) {
value = tmpValue;
}
}
//
// Check for macros in the value -- we currently don't
// handle those.
//
if ( value != "" ) {
if ( strchr(value.Value(), '$') ) {
dprintf(D_ALWAYS, "MultiLogFiles: macros not allowed "
"in %s in DAG node submit files\n", keyword);
value = "";
}
}
if ( directory != "" ) {
MyString errMsg;
if ( !td.Cd2MainDir(errMsg) ) {
dprintf(D_ALWAYS, "Error from Cd2MainDir: %s\n", errMsg.Value());
return "";
}
}
return value;
}
示例8: execute_dir
void
cleanup_execute_dirs( StringList &list )
{
char const *exec_path;
list.rewind();
while( (exec_path = list.next()) ) {
#if defined(WIN32)
dynuser nobody_login;
// remove all users matching this prefix
nobody_login.cleanup_condor_users("condor-run-");
// get rid of everything in the execute directory
Directory execute_dir(exec_path);
execute_dir.Rewind();
while ( execute_dir.Next() ) {
check_recovery_file( execute_dir.GetFullPath() );
}
execute_dir.Remove_Entire_Directory();
#else
// if we're using PrivSep, the Switchboard will only allow
// us to remove subdirectories of EXECUTE - so we need to
// list them and ask the Switchboard to delete each one
//
pair_strings_vector root_dirs = root_dir_list();
for (pair_strings_vector::const_iterator it=root_dirs.begin(); it != root_dirs.end(); ++it) {
const char * exec_path_full = dirscat(it->second.c_str(), exec_path);
if(exec_path_full) {
dprintf(D_FULLDEBUG, "Looking at %s\n",exec_path_full);
}
Directory execute_dir( exec_path_full, PRIV_ROOT );
execute_dir.Rewind();
while ( execute_dir.Next() ) {
check_recovery_file( execute_dir.GetFullPath() );
}
if (privsep_enabled()) {
execute_dir.Rewind();
while (execute_dir.Next()) {
dprintf(D_FULLDEBUG, "Attempting to remove %s\n",execute_dir.GetFullPath());
privsep_remove_dir(execute_dir.GetFullPath());
}
}
else {
execute_dir.Remove_Entire_Directory();
}
delete [] exec_path_full;
}
#endif
}
}
示例9:
void
check_execute_dir_perms( StringList &list )
{
char const *exec_path;
list.rewind();
while( (exec_path = list.next()) ) {
check_execute_dir_perms( exec_path );
}
}
示例10: MyString
MyString
MultiLogFiles::CombineLines(StringList &listIn, char continuation,
const MyString &filename, StringList &listOut)
{
dprintf( D_FULLDEBUG, "MultiLogFiles::CombineLines(%s, %c)\n",
filename.Value(), continuation );
listIn.rewind();
// Physical line is one line in the file.
const char *physicalLine;
while ( (physicalLine = listIn.next()) != NULL ) {
// Logical line is physical lines combined as needed by
// continuation characters (backslash).
MyString logicalLine(physicalLine);
while ( logicalLine[logicalLine.Length()-1] == continuation ) {
// Remove the continuation character.
logicalLine.setChar(logicalLine.Length()-1, '\0');
// Append the next physical line.
physicalLine = listIn.next();
if ( physicalLine ) {
logicalLine += physicalLine;
} else {
MyString result = MyString("Improper file syntax: ") +
"continuation character with no trailing line! (" +
logicalLine + ") in file " + filename;
dprintf(D_ALWAYS, "MultiLogFiles: %s\n", result.Value());
return result;
}
}
listOut.append(logicalLine.Value());
}
return ""; // blank means okay
}
示例11: TestClear
bool TestClear() {
BEGIN_TEST;
StringList list;
list.push_front("bar");
EXPECT_NONNULL(list.first());
list.clear();
EXPECT_NULL(list.next());
EXPECT_NULL(list.first());
EXPECT_EQ(list.length(), 0);
END_TEST;
}
示例12: atoi
int
MultiLogFiles::getQueueCountFromSubmitFile(const MyString &strSubFilename,
const MyString &directory, MyString &errorMsg)
{
dprintf( D_FULLDEBUG,
"MultiLogFiles::getQueueCountFromSubmitFile(%s, %s)\n",
strSubFilename.Value(), directory.Value() );
int queueCount = 0;
errorMsg = "";
MyString fullpath("");
if ( directory != "" ) {
fullpath = directory + DIR_DELIM_STRING + strSubFilename;
} else {
fullpath = strSubFilename;
}
StringList logicalLines;
if ( (errorMsg = fileNameToLogicalLines( strSubFilename,
logicalLines)) != "" ) {
return -1;
}
// Now look through the submit file logical lines to find any
// queue commands, and count up the total number of job procs
// to be queued.
const char * paramName = "queue";
const char *logicalLine;
while( (logicalLine = logicalLines.next()) != NULL ) {
MyString submitLine(logicalLine);
submitLine.Tokenize();
const char *DELIM = " ";
const char *rawToken = submitLine.GetNextToken( DELIM, true );
if ( rawToken ) {
MyString token(rawToken);
token.trim();
if ( !strcasecmp(token.Value(), paramName) ) {
rawToken = submitLine.GetNextToken( DELIM, true );
if ( rawToken ) {
queueCount += atoi( rawToken );
} else {
queueCount++;
}
}
}
}
return queueCount;
}
示例13:
// Utility function.
void
pushStringListBack( std::vector< YourString > & v, StringList & sl ) {
const char * text = NULL;
sl.rewind();
int count = 0;
if( sl.number() > 0 ) {
while( (text = sl.next()) ) {
v.push_back( text );
++count;
}
}
ASSERT( count == sl.number() );
v.push_back( NULLSTRING );
}
示例14: while
bool
isSuperUser( const char* user )
{
if( ! (user)) {
return false;
}
super_users.rewind();
char * next;
while ((next = super_users.next())) {
if (strcmp (user, next ) == 0) {
return true;
}
}
return false;
}
示例15: while
// passing over REPLICATION_LIST configuration parameter, turning all the
// addresses into canonical <ip:port> form and inserting them all, except for
// the address of local replication daemon, into 'm_replicationDaemonsList'.
void
AbstractReplicatorStateMachine::initializeReplicationList( char* buffer )
{
StringList replicationAddressList;
char* replicationAddress = NULL;
bool isMyAddressPresent = false;
Sinful my_addr( daemonCore->InfoCommandSinfulString( ) );
replicationAddressList.initializeFromString( buffer );
// initializing a list unrolls it, that's why the rewind is needed to bring
// it to the beginning
replicationAddressList.rewind( );
/* Passing through the REPLICATION_LIST configuration parameter, stripping
* the optional <> brackets off, and extracting the host name out of
* either ip:port or hostName:port entries
*/
while( (replicationAddress = replicationAddressList.next( )) ) {
char* sinfulAddress = utilToSinful( replicationAddress );
if( sinfulAddress == NULL ) {
char bufArray[BUFSIZ];
sprintf( bufArray,
"AbstractReplicatorStateMachine::initializeReplicationList"
" invalid address %s\n", replicationAddress );
utilCrucialError( bufArray );
continue;
}
if( my_addr.addressPointsToMe( Sinful(sinfulAddress) ) ) {
isMyAddressPresent = true;
}
else {
m_replicationDaemonsList.insert( sinfulAddress );
}
// pay attention to release memory allocated by malloc with free and by
// new with delete here utilToSinful returns memory allocated by malloc
free( sinfulAddress );
}
if( !isMyAddressPresent ) {
utilCrucialError( "ReplicatorStateMachine::initializeReplicationList "
"my address is not present in REPLICATION_LIST" );
}
}