当前位置: 首页>>代码示例>>C++>>正文


C++ MyString::Tokenize方法代码示例

本文整理汇总了C++中MyString::Tokenize方法的典型用法代码示例。如果您正苦于以下问题:C++ MyString::Tokenize方法的具体用法?C++ MyString::Tokenize怎么用?C++ MyString::Tokenize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyString的用法示例。


在下文中一共展示了MyString::Tokenize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getKeyValue

int Pigeon::getKeyValue(MyString line, MyString *key, MyString *value) {
  int type = AD_NULL;
  int tokenno = -1;
  char *s1 = 0;

  line.Tokenize();

  while( (s1 = const_cast<char*>(line.GetNextToken(" ", true))) != NULL) {
    tokenno++;

    if (strlen(s1) < 1)
      goto end;

    //dprintf(D_FULLDEBUG, "Tokens %d: %s\n", tokenno, s1);
    switch (tokenno) {
      case 0:
        if (strcmp(s1, "START_AD") != 0) 
          goto end;

        break;

      case 1:                          

        if (s1[0] == 'S')
          type = AD_STRING;
        else if (s1[0] == 'I')
          type = AD_INT;
        else if (s1[0] == 'D')
          type = AD_DOUBLE;
        else if (s1[0] == 'B')
          type = AD_BOOLEAN;

        break;

      case 2:
        *key = s1;
        break;

      case 3:
        *value = s1;
        break;

      case 4:
        if (strcmp(s1, "END_AD") != 0)
          type = AD_NULL;

        break;
    }
  }

  //wrong number of tokens
  if (tokenno < 4)
    type = AD_NULL;

end:
  return type;
}
开发者ID:bbockelm,项目名称:htcondor,代码行数:57,代码来源:pigeon.cpp

示例2: tag

//---------------------------------------------------------------------------
// This does only partial parsing -- only what we need for recovery mode
// and rescue initialization.
bool
JobstateLog::ParseLine( MyString &line, time_t &timestamp,
			MyString &nodeName, int &seqNum )
{
	line.chomp();
	line.Tokenize();
	const char* timestampTok = line.GetNextToken( " ", false );
	const char* nodeNameTok = line.GetNextToken( " ", false );
	(void)line.GetNextToken( " ", false ); // event name
	(void)line.GetNextToken( " ", false ); // condor id
	(void)line.GetNextToken( " ", false ); // job tag (pegasus site)
	(void)line.GetNextToken( " ", false ); // unused
	const char* seqNumTok = line.GetNextToken( " ", false );

	if ( (timestampTok == NULL) || (nodeNameTok == NULL) ) {
		debug_printf( DEBUG_QUIET, "Warning: error parsing "
					"jobstate.log file line <%s>\n", line.Value() );
		check_warning_strictness( DAG_STRICT_1 );
		return false;
	}

		// fetch the number, and get a pointer to the first char after
		// if the pointer did not advance, then there was no number to parse.
	char *pend;
	timestamp = (time_t)strtoll(timestampTok, &pend, 10);

	if (pend == timestampTok) {
		debug_printf( DEBUG_QUIET, "Warning: error reading "
					"timestamp in jobstate.log file line <%s>\n",
					line.Value() );
		check_warning_strictness( DAG_STRICT_1 );
		return false;
	}

	nodeName = nodeNameTok;

	seqNum = 0;
	if ( seqNumTok ) {
		seqNum = (int)strtol(seqNumTok, &pend, 10);
		if (pend == seqNumTok) {
			debug_printf( DEBUG_QUIET, "Warning: error reading "
						"sequence number in jobstate.log file line <%s>\n",
						line.Value() );
			check_warning_strictness( DAG_STRICT_1 );
			return false;
		}
	}

	return true;
}
开发者ID:Clusterforge,项目名称:htcondor,代码行数:53,代码来源:jobstate_log.cpp

示例3:

MyString
MultiLogFiles::getParamFromSubmitLine(MyString &submitLine,
		const char *paramName)
{
	MyString	paramValue("");

	const char *DELIM = "=";

	submitLine.Tokenize();
	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 ) {
				paramValue = rawToken;
				paramValue.trim();
			}
		}
	}

	return paramValue;
}
开发者ID:AlanDeSmet,项目名称:htcondor,代码行数:24,代码来源:read_multiple_logs.cpp

示例4: token

/**
 * This is the logic that is used to take a parameter string
 * given for a specific field in the cron schedule and expand it
 * out into a range of int's that can be looked up quickly later on
 * We must be given the index number of the field we're going to parse
 * and a min/max for the range of values allowed for the attribute.
 * If the parameter is invalid, we will report an error and return false
 * This will prevent them from querying nextRunTime() for runtimes
 * 
 * @param attribute_idx - the index for the parameter in CronTab::attributes
 * @param min - the mininum value in the range for this parameter
 * @param max - the maximum value in the range for this parameter
 * @return true if we were able to create the range of values
 **/
bool
CronTab::expandParameter( int attribute_idx, int min, int max )
{
	MyString *param = this->parameters[attribute_idx];
	ExtArray<int> *list	= this->ranges[attribute_idx];
	
		//
		// Make sure the parameter is valid
		// The validation method will have already printed out
		// the error message to the log
		//
	MyString error;
	if ( ! CronTab::validateParameter(	attribute_idx,
										param->Value(),
										error ) ) {
		dprintf( D_ALWAYS, "%s", error.Value() );
			//
			// Store the error in case they want to email
			// the user to tell them that they goofed
			//
		CronTab::errorLog += error;
		return ( false );
	}
		//
		// Remove any spaces
		//
	param->replaceString(" ", "");
	
		//
		// Now here's the tricky part! We need to expand their parameter
		// out into a range that can be put in array of integers
		// First start by spliting the string by commas
		//
	param->Tokenize();
	const char *_token;
	while ( ( _token = param->GetNextToken( CRONTAB_DELIMITER, true ) ) != NULL ) {
		MyString token( _token );
		int cur_min = min, cur_max = max, cur_step = 1;
		
			// -------------------------------------------------
			// STEP VALUES
			// The step value is independent of whether we have
			// a range, the wildcard, or a single number.
			// -------------------------------------------------
		if ( token.find( CRONTAB_STEP ) > 0 ) {
				//
				// Just look for the step value to replace 
				// the current step value. The other code will
				// handle the rest
				//
			token.Tokenize();
			const char *_temp;
				//
				// Take out the numerator, keep it for later
				//
			const char *_numerator = token.GetNextToken( CRONTAB_STEP, true );
			if ( ( _temp = token.GetNextToken( CRONTAB_STEP, true ) ) != NULL ) {
				MyString stepStr( _temp );
				stepStr.trim();
				cur_step = atoi( stepStr.Value() );
			}
				//
				// Now that we have the denominator, put the numerator back
				// as the token. This makes it easier to parse later on
				//
			token = _numerator;
		} // STEP
		
			// -------------------------------------------------
			// RANGE
			// If it's a range, expand the range but make sure we 
			// don't go above/below our limits
			// Note that the find will ignore the token if the
			// range delimiter is in the first character position
			// -------------------------------------------------
		if ( token.find( CRONTAB_RANGE ) > 0 ) {
				//
				// Split out the integers
				//
			token.Tokenize();
			MyString *_temp;
			int value;
			
				//
				// Min
				//
//.........这里部分代码省略.........
开发者ID:dcbradley,项目名称:htcondor,代码行数:101,代码来源:condor_crontab.cpp


注:本文中的MyString::Tokenize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。