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


C++ VString::ExchangeAll方法代码示例

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


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

示例1: HelpUsage

	void StOptionsInfos::HelpUsage(const VString& inArgv0) const
	{
		HelpUsagePrinter printer;

		// first line
		printer.out += CVSTR("Usage: ");
		printer.out += inArgv0; // FIXME : extractFilePath(inArgv0)
		printer.out += CVSTR(" [OPTION]...");
		if (remainingOption)
			printer.out += CVSTR(" [FILE]...");
		printer.out += '\n';

		// iterating through all options
		if (! options.empty())
		{
			Private::CommandLineParser::VOptionBase::Vector::const_iterator end = options.end();
			Private::CommandLineParser::VOptionBase::Vector::const_iterator i   = options.begin();

			// Add a space if the first option is not a paragraph
			// (otherwise the user would do what he wants)
			if (! (*i)->IsParagraph())
			{
				// deal with hidden options at the beginning
				if ((*i)->IsVisibleFromHelpUsage())
				{
					printer.out += '\n';
				}
				else
				{
					// the first element is not visible, thus we can not determine what to do
					// trying to find the first visible element
					for (; i != end; ++i)
					{
						if ((*i)->IsVisibleFromHelpUsage())
						{
							if (! (*i)->IsParagraph())
								printer.out += '\n';
							break;
						}
					}

					// reset the iterator
					i = options.begin();
				}
			}

			// temporary string for description manipulation
			VString tmpDesc;

			for (; i != end; ++i)
			{
				const Private::CommandLineParser::VOptionBase& opt = *(*i);

				if (opt.IsVisibleFromHelpUsage())
				{
					// we should remove all \t produced by end-of-line backslashes
					// (used for writing long text on several lines)
					// anyway the tab-character should not be used within descriptions
					tmpDesc = opt.GetDescription();
					tmpDesc.ExchangeAll(CVSTR("\t"), VString());

					if (! opt.IsParagraph())
					{
						printer.ExportOptionHelpUsage(opt.GetShortName(), opt.GetLongName(), tmpDesc, opt.IsRequiresParameter());
					}
					else
						printer.ExportParagraph(tmpDesc);
				}
			}
		}

		// determining if the --help option is implicit or not
		if (0 == byLongNames.count(CVSTR("help")))
		{
			// --help is implicit
			VString desc = CVSTR("Display the help and exit");

			#if VERSIONWIN
			{
				if (byShortNames.count('h') == 0)
					printer.ExportOptionHelpUsage('?', CVSTR("h, /help"), desc, false);
				else
					printer.ExportOptionHelpUsage('?', CVSTR("help"), desc, false);
			}
			#else
			{
				if (byShortNames.count('h') == 0)
					printer.ExportOptionHelpUsage('h', CVSTR("help"), desc, false);
				else
					printer.ExportOptionHelpUsage(' ', CVSTR("help"), desc, false);
			}
			#endif
		}

		// display the help usage to the console
		#if VERSIONWIN
		std::wcout.write(printer.out.GetCPointer(), printer.out.GetLength());
		#else
		StStringConverter<char> buff(printer.out, VTC_UTF_8);
		if (buff.IsOK())
//.........这里部分代码省略.........
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:101,代码来源:VCommandLineParserHelp.cpp

示例2: Put


//.........这里部分代码省略.........
			
			sLONG ioSpent=-1;
			if (ILoggerBagKeys::ms_spent.Get( *bagIter, ioSpent))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"done in ");
				message.AppendLong( ioSpent);
				message.AppendString( L"ms");
			}
			
			sLONG dumpOffset=-1;
			if (ILoggerBagKeys::dump_offset.Get( *bagIter, dumpOffset))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"offset ");
				message.AppendLong( dumpOffset);
			}
			
			VString dumpBuffer;
			if (ILoggerBagKeys::dump_buffer.Get( *bagIter, dumpBuffer))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"data : ");
				message.AppendString( dumpBuffer);
			}
			
			VString fileName;
			if (ILoggerBagKeys::file_name.Get( *bagIter, fileName))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( fileName);
			}
			
			sLONG lineNumber;
			if (ILoggerBagKeys::line_number.Get( *bagIter, lineNumber))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendLong( lineNumber);
			}
			
			VString stackCrawl;
			if (ILoggerBagKeys::stack_crawl.Get( *bagIter, stackCrawl))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L", {");
				stackCrawl.ExchangeAll( L"\n", L" ; ");
				message.AppendString( stackCrawl);
				message.AppendUniChar( L'}');
			}
			
			if (!logMsg.IsEmpty())
				logMsg.AppendUniChar( L' ');
			logMsg.AppendString( message);
			
			if (!logMsg.IsEmpty())
			{
				StStringConverter<char> messageConverter( VTC_StdLib_char);
		
				switch( bagLevel)
				{
					case EML_Dump:
					case EML_Assert:
					case EML_Debug:
						syslog( LOG_DEBUG, messageConverter.ConvertString( logMsg));
						break;
						
					case EML_Trace:
						syslog( LOG_NOTICE, messageConverter.ConvertString( logMsg));
						break;

					case EML_Information:
						syslog( LOG_INFO, messageConverter.ConvertString( logMsg));
						break;
							   
					case EML_Warning:
						syslog( LOG_WARNING, messageConverter.ConvertString( logMsg));
						break;
							   
					case EML_Error:
						syslog( LOG_ERR, messageConverter.ConvertString( logMsg));
						break;
						
					case EML_Fatal:
						syslog( LOG_CRIT, messageConverter.ConvertString( logMsg));
						break;
							   
				   default:
					   assert(false);
					   break;
				}
			}
		}
	}
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:101,代码来源:VSysLogOutput.cpp

示例3: ParseSpanText

/** parse span text element or XHTML fragment 
@param inTaggedText
	tagged text to parse (span element text only if inParseSpanOnly == true, XHTML fragment otherwise)
@param outStyles
	parsed styles
@param outPlainText
	parsed plain text
@param inParseSpanOnly
	true (default): only <span> element(s) with CSS styles are parsed
	false: all XHTML text fragment is parsed (parse also mandatory HTML text styles)
*/
void VSpanTextParser::ParseSpanText( const VString& inTaggedText, VTreeTextStyle*& outStyles, VString& outPlainText, bool inParseSpanOnly)
{
	outPlainText = "";
	if(outStyles)
		outStyles->Release();
	outStyles = NULL;
	if (inTaggedText.IsEmpty())
		return;
	//fixed ACI0076343: for compatibility with older bases which do not have support for multistyle var or field
	//					we need to convert to xml text the text which is not bracketed with SPAN 
	//					otherwise parser would fail
	VString vtext;
	sLONG posStartSPAN = 1; //pos of first SPAN tag
	sLONG posEndSPAN = inTaggedText.GetLength()+1; //pos of character following ending SPAN tag
	if (inParseSpanOnly)
	{
		//search for opening SPAN tag
		posStartSPAN = inTaggedText.Find("<SPAN", 1, false);
		if (!posStartSPAN)
		{
			//convert full text to xml
			inTaggedText.GetXMLString( vtext, XSO_Default); 
			vtext = VString("<SPAN>")+vtext+"</SPAN>";
		}
		else 
		{
			VString before, after;
			if (posStartSPAN > 1)
			{
				//convert to XML text preceeding first SPAN 
				VString temp;
				inTaggedText.GetSubString( 1, posStartSPAN-1, temp);
				temp.GetXMLString( before, XSO_Default);
			}
			//search for ending SPAN tag
			const UniChar *c = inTaggedText.GetCPointer()+inTaggedText.GetLength()-1;
			sLONG pos = inTaggedText.GetLength()-1;
			VString spanEndTag = "</SPAN>";
			VString spanEndTag2 = "</span>";
			do
			{
				while (pos >= 0 && *c != '>')
				{
					pos--;
					if (pos >= 0)
						c--;
				}
				if (pos >= 0)
				{
					if (memcmp( (void*)(c+1-spanEndTag.GetLength()), spanEndTag.GetCPointer(), spanEndTag.GetLength()*sizeof(UniChar)) == 0
						||
						memcmp( (void*)(c+1-spanEndTag2.GetLength()), spanEndTag2.GetCPointer(), spanEndTag2.GetLength()*sizeof(UniChar)) == 0)
					{
						posEndSPAN = pos+2;
						break;
					}	
					else
					{
						pos--;
						if (pos >= 0)
							c--;
					}
				}
			} while (pos >= 0);
			if (posEndSPAN <= inTaggedText.GetLength())
			{
				//convert to XML text following ending SPAN tag
				VString temp;
				inTaggedText.GetSubString( posEndSPAN, inTaggedText.GetLength()-posEndSPAN+1, temp);
				temp.GetXMLString( after, XSO_Default);
			}
			if (!before.IsEmpty() || !after.IsEmpty())
			{
				inTaggedText.GetSubString( posStartSPAN, posEndSPAN-posStartSPAN, vtext);
				vtext = VString("<SPAN>")+before+vtext+after+"</SPAN>";
			}
			else
				vtext = VString("<SPAN>")+inTaggedText+"</SPAN>";
		}
	}
	else
		vtext = inTaggedText;

	vtext.ExchangeAll(0x0B,0x0D);//[MI] le 28/12/2010 ACI0069253
#if VERSIONWIN
	vtext.ConvertCarriageReturns(eCRM_CR); //important here on Windows before parsing because styles are assumed to use one character size for line ending on any platform 
										   //and so pair of 0x0D 0x0A should be treated as a single 0x0D character
#endif											
	VTaggedTextSAXHandler vsaxhandler(outStyles, &outPlainText, inParseSpanOnly);
//.........这里部分代码省略.........
开发者ID:sanyaade-mobiledev,项目名称:core-XToolbox,代码行数:101,代码来源:VSpanText.cpp


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