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


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

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


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

示例1: attr

void stats_entry_recent<Probe>::PublishDebug(ClassAd & ad, const char * pattr, int flags) const
{
   MyString str;
   MyString var1;
   MyString var2;
   ProbeToStringDebug(var1, this->value);
   ProbeToStringDebug(var2, this->recent);

   str.sprintf_cat("(%s) (%s)", var1.Value(), var2.Value());
   str.sprintf_cat(" {h:%d c:%d m:%d a:%d}", 
                   this->buf.ixHead, this->buf.cItems, this->buf.cMax, this->buf.cAlloc);
   if (this->buf.pbuf) {
      for (int ix = 0; ix < this->buf.cAlloc; ++ix) {
         ProbeToStringDebug(var1, this->buf.pbuf[ix]);
         str.sprintf_cat(!ix ? "[%s" : (ix == this->buf.cMax ? "|%s" : ",%s"), var1.Value());
         }
      str += "]";
      }

   MyString attr(pattr);
   if (flags & this->PubDecorateAttr)
      attr += "Debug";

   ad.Assign(pattr, str);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: strcspn

void
Env::WriteToDelimitedString(char const *input,MyString &output) {
	// Append input to output.
	// Would be nice to escape special characters here, but the
	// existing syntax does not support it, so we leave the
	// "specials" strings blank.

	char const inner_specials[] = {'\0'};
	char const first_specials[] = {'\0'};

	char const *specials = first_specials;
	char const *end;
	bool ret;

	if(!input) return;

	while(*input) {
		end = input + strcspn(input,specials);
		ret = output.sprintf_cat("%.*s", (int)(end-input), input);
		ASSERT(ret);
		input = end;

		if(*input != '\0') {
			// Escape this special character.
			// Escaping is not yet implemented, so we will never get here.
			ret = output.sprintf_cat("%c",*input);
			ASSERT(ret);
			input++;
		}

		// Switch out of first-character escaping mode.
		specials = inner_specials;
	}
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例3:

MyString
AvailStats::serialize()
{
	MyString state;

	state.sprintf( "%ld %d %d", (long)(time(0)-as_birthdate),
				   as_tot_avail_time, as_last_avail_interval );
	as_avail_periods.Rewind();
	int item;
	while( as_avail_periods.Next(item) ) {
		state.sprintf_cat( " %d", item );
	}

	return state;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例4: GetName

bool
StartdCronJobParams::Initialize( void )
{
	if ( !ClassAdCronJobParams::Initialize() ) {
		return false;
	}

	MyString	slots_str;
	Lookup( "SLOTS", slots_str );

	m_slots.clear();
	StringList	slot_list( slots_str.Value() );
	slot_list.rewind();
	const char *slot;
	while( ( slot = slot_list.next()) != NULL ) {
		if( !isdigit(*slot)) {
			dprintf( D_ALWAYS,
					 "Cron Job '%s': INVALID slot # '%s': ignoring slot list",
					 GetName(), slot );
			m_slots.clear();
			break;
		}
		unsigned	slotno = atoi( slot );
		m_slots.push_back( slotno );
	}

	// Print out the slots for D_FULLDEBUG
	if ( IsFulldebug(D_FULLDEBUG) ) {
		MyString	s;
		s.sprintf( "CronJob '%s' slots: ", GetName() );
		if ( m_slots.empty() ) {
			s += "ALL";
		}
		else {
			list<unsigned>::iterator iter;
			for( iter = m_slots.begin(); iter != m_slots.end(); iter++ ) {
				s.sprintf_cat( "%u ", *iter );
			}
		}
		dprintf( D_ALWAYS, "%s\n", s.Value() );
	}

	return true;
};
开发者ID:,项目名称:,代码行数:44,代码来源:

示例5: while

// make query
int GenericQuery::
makeQuery (ExprTree *&tree)
{
    int		i, value;
    char	*item;
    float   fvalue;
    MyString req = "";

    tree = NULL;

    // construct query requirement expression
    bool firstCategory = true;

    // add string constraints
    for (i = 0; i < stringThreshold; i++)
    {
        stringConstraints [i].Rewind ();
        if (!stringConstraints [i].AtEnd ())
        {
            bool firstTime = true;
            req += firstCategory ? "(" : " && (";
            while ((item = stringConstraints [i].Next ()))
            {
                req.sprintf_cat ("%s(%s == \"%s\")",
                                 firstTime ? " " : " || ",
                                 stringKeywordList [i], item);
                firstTime = false;
                firstCategory = false;
            }
            req += " )";
        }
    }

    // add integer constraints
    for (i = 0; i < integerThreshold; i++)
    {
        integerConstraints [i].Rewind ();
        if (!integerConstraints [i].AtEnd ())
        {
            bool firstTime = true;
            req += firstCategory ? "(" : " && (";
            while (integerConstraints [i].Next (value))
            {
                req.sprintf_cat ("%s(%s == %d)",
                                 firstTime ? " " : " || ",
                                 integerKeywordList [i], value);
                firstTime = false;
                firstCategory = false;
            }
            req += " )";
        }
    }

    // add float constraints
    for (i = 0; i < floatThreshold; i++)
    {
        floatConstraints [i].Rewind ();
        if (!floatConstraints [i].AtEnd ())
        {
            bool firstTime = true;
            req += firstCategory ? "(" : " && (";
            while (floatConstraints [i].Next (fvalue))
            {
                req.sprintf_cat ("%s(%s == %f)",
                                 firstTime ? " " : " || ",
                                 floatKeywordList [i], fvalue);
                firstTime = false;
                firstCategory = false;
            }
            req += " )";
        }
    }

    // add custom AND constraints
    customANDConstraints.Rewind ();
    if (!customANDConstraints.AtEnd ())
    {
        bool firstTime = true;
        req += firstCategory ? "(" : " && (";
        while ((item = customANDConstraints.Next ()))
        {
            req.sprintf_cat ("%s(%s)", firstTime ? " " : " && ", item);
            firstTime = false;
            firstCategory = false;
        }
        req += " )";
    }

    // add custom OR constraints
    customORConstraints.Rewind ();
    if (!customORConstraints.AtEnd ())
    {
        bool firstTime = true;
        req += firstCategory ? "(" : " && (";
        while ((item = customORConstraints.Next ()))
        {
            req.sprintf_cat ("%s(%s)", firstTime ? " " : " || ", item);
            firstTime = false;
            firstCategory = false;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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