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()) std::cout.write(buff.GetCPointer(), buff.GetSize()); #endif }
void VSysLogOutput::Put( std::vector< const XBOX::VValueBag* >& inValuesVector) { for (std::vector< const XBOX::VValueBag* >::iterator bagIter = inValuesVector.begin() ; bagIter != inValuesVector.end() ; ++bagIter) { EMessageLevel bagLevel = ILoggerBagKeys::level.Get( *bagIter); if ((fFilter & (1 << bagLevel)) != 0) { VString logMsg; VError errorCode = VE_OK; ILoggerBagKeys::error_code.Get( *bagIter, errorCode); VString loggerID; ILoggerBagKeys::source.Get( *bagIter, loggerID); OsType componentSignature = 0; if (!ILoggerBagKeys::component_signature.Get( *bagIter, componentSignature)) componentSignature = COMPONENT_FROM_VERROR( errorCode); if (componentSignature != 0) { if (!loggerID.IsEmpty()) loggerID.AppendUniChar( L'.'); loggerID.AppendOsType( componentSignature); } if (!loggerID.IsEmpty()) logMsg.Printf( "[%S]", &loggerID); // build message string VString message; if (errorCode != VE_OK) message.AppendPrintf( "error %d", ERRCODE_FROM_VERROR( errorCode)); VString bagMsg; if (ILoggerBagKeys::message.Get( *bagIter, bagMsg)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( bagMsg); } sLONG taskId=-1; if (ILoggerBagKeys::task_id.Get( *bagIter, taskId)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"task #"); message.AppendLong( taskId); } VString taskName; if (!ILoggerBagKeys::task_name.Get( *bagIter, taskName)) VTask::GetCurrent()->GetName( taskName); if (!taskName.IsEmpty()) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( taskName); } sLONG socketDescriptor=-1; if (ILoggerBagKeys::socket.Get( *bagIter, socketDescriptor)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"socket "); message.AppendLong(socketDescriptor); } VString localAddr; if (ILoggerBagKeys::local_addr.Get( *bagIter, localAddr)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"local addr is "); message.AppendString( localAddr); } VString peerAddr; if (ILoggerBagKeys::peer_addr.Get( *bagIter, peerAddr)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"peer addr is "); message.AppendString( peerAddr); } bool exchangeEndPointID=false; if (ILoggerBagKeys::exchange_id.Get( *bagIter, exchangeEndPointID)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( (exchangeEndPointID) ? L"exchange endpoint id" : L"do not exchange endpoint id"); } bool isBlocking=false; if (ILoggerBagKeys::is_blocking.Get( *bagIter, isBlocking)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( (isBlocking) ? L"is blocking" : L"is not blocking"); } bool isSSL=false; if (ILoggerBagKeys::is_ssl.Get( *bagIter, isSSL)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( (isSSL) ? L"with SSL" : L"without SSL"); } bool isSelectIO=false; if (ILoggerBagKeys::is_select_io.Get( *bagIter, isSelectIO)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( (isSelectIO) ? L"with SelectIO" : L"without SelectIO"); } sLONG ioTimeout=-1; if (ILoggerBagKeys::ms_timeout.Get( *bagIter, ioTimeout)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"with "); message.AppendLong( ioTimeout); message.AppendString( L"ms timeout"); } sLONG askedCount=-1; if (ILoggerBagKeys::count_bytes_asked.Get( *bagIter, askedCount)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"asked for "); message.AppendLong( askedCount); message.AppendString( L" byte(s)"); } sLONG sentCount=-1; if (ILoggerBagKeys::count_bytes_sent.Get(*bagIter, sentCount)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"sent "); message.AppendLong( sentCount); message.AppendString( L" byte(s)"); } sLONG receivedCount=-1; if (ILoggerBagKeys::count_bytes_received.Get( *bagIter, receivedCount)) { if (!message.IsEmpty()) message.AppendString( L", "); message.AppendString( L"received "); message.AppendLong( receivedCount); message.AppendString( L" byte(s)"); } 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; } } } } }
/** 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); VXMLParser vSAXParser; vSAXParser.Parse(vtext, &vsaxhandler, XML_ValidateNever); #if VERSIONWIN outPlainText.ConvertCarriageReturns(eCRM_CR); //we need to convert to CR (on any platform but Linux here) because xerces parser has converted all line endings to LF (cf W3C XML line ending uniformization while parsing) #elif VERSIONMAC outPlainText.ConvertCarriageReturns(eCRM_CR); //we need to convert to CR (on any platform but Linux here) because xerces parser has converted all line endings to LF (cf W3C XML line ending uniformization while parsing) #endif }