/** * Generate and return the help string for the given arguement. * @param arg Define the arguement for wich to generate the help line. * @param columns Define the term width to consider for line splitting. * @return Return the generated string. **/ string svutArgp::formatArgumentHelp(svutArgDef arg,int columns) const { stringstream res; stringstream tmp; //setup keys mode bool hasShort = isValidKey(arg.key); bool hasLong = ! arg.name.empty(); //base padding res << SVUT_HELP_BASE_PADDING; //short arg if (hasShort) res << '-' << arg.key; else res << " "; //separator if (hasShort && hasLong) res << ", --"; else res << " --"; //long name res.width(25); res.fill(' '); res.setf(ios::left); tmp << arg.name; if (arg.valueType != "NONE") tmp << '=' << arg.valueType; res << tmp.str(); //description res << arg.descr; //cut lines on columns and return return breakLines(res.str(),columns,SVUT_HELP_PADDING); }
/** * Generate the help usage string, it will print all available options. * @param columns Define the number of columns to consider to cut lines. * @return Return the usage line as a string. **/ string svutArgp::getUsage ( int columns ) const { stringstream res; string shortNotArgGrouped; //show program name. res << "Usage: " << this->projectName; //usage for grouped short options for (svutArgpOptionMap::const_iterator it = options.begin() ; it != options.end() ; ++it) if (this->isValidKey(it->second.key) && it->second.valueType == "NONE") shortNotArgGrouped += it->second.key; if ( ! shortNotArgGrouped.empty() ) res << " [-" << shortNotArgGrouped << "]"; //usage for short option with values for (svutArgpOptionMap::const_iterator it = options.begin() ; it != options.end() ; ++it) if (this->isValidKey(it->second.key) && it->second.valueType != "NONE") res << genUsageParam(it->second,true); //usage for long option without values for (svutArgpOptionMap::const_iterator it = options.begin() ; it != options.end() ; ++it) if (it->second.valueType == "NONE") res << genUsageParam(it->second,false); //usage for long option with values for (svutArgpOptionMap::const_iterator it = options.begin() ; it != options.end() ; ++it) if (it->second.valueType != "NONE") res << genUsageParam(it->second,false); //usage for short option without values for (svutArgpOptionMap::const_iterator it = options.begin() ; it != options.end() ; ++it) if (this->isValidKey(it->second.key) && it->second.valueType == "NONE") res << genUsageParam(it->second,true); return breakLines(res.str(),columns," "); }
char * CERT_GetCertCommentString(CERTCertificate *cert) { char *retstring = NULL; SECStatus rv; SECItem policyItem; CERTCertificatePolicies *policies = NULL; CERTPolicyInfo **policyInfos; CERTPolicyQualifier **policyQualifiers, *qualifier; policyItem.data = NULL; rv = CERT_FindCertExtension(cert, SEC_OID_X509_CERTIFICATE_POLICIES, &policyItem); if ( rv != SECSuccess ) { goto nopolicy; } policies = CERT_DecodeCertificatePoliciesExtension(&policyItem); if ( policies == NULL ) { goto nopolicy; } policyInfos = policies->policyInfos; /* search through policyInfos looking for the verisign policy */ while (*policyInfos != NULL ) { if ( (*policyInfos)->oid == SEC_OID_VERISIGN_USER_NOTICES ) { policyQualifiers = (*policyInfos)->policyQualifiers; /* search through the policy qualifiers looking for user notice */ while ( policyQualifiers != NULL && *policyQualifiers != NULL ) { qualifier = *policyQualifiers; if ( qualifier->oid == SEC_OID_PKIX_USER_NOTICE_QUALIFIER ) { retstring = stringFromUserNotice(&qualifier->qualifierValue); break; } policyQualifiers++; } break; } policyInfos++; } nopolicy: if ( policyItem.data != NULL ) { PORT_Free(policyItem.data); } if ( policies != NULL ) { CERT_DestroyCertificatePoliciesExtension(policies); } if ( retstring == NULL ) { retstring = CERT_FindNSStringExtension(cert, SEC_OID_NS_CERT_EXT_COMMENT); } if ( retstring != NULL ) { breakLines(retstring); } return(retstring); }
//-------------------------------------------------------------- void ofxMuiTextBlock::update() { if(needsUpdate) { displayText = text; applyCaps(displayText,capsStyle); ofRectangle goalBox(0,0,getTextWidth(),getTextHeight()); float wrappedWidth = 0; float wrappedHeight = 0; vector<string> lines; vector<int> breakPos; vector<ofVec2f> charPos; vector<float> lineWidths; ofRectangle boundingBox; string delimiters = " "; breakLines(font, displayText, breakPos, charPos, lineWidths, lines, boundingBox, goalBox, lineBreakMode, delimiters, truncationMode, truncationString); string::iterator begin = displayText.begin(); vector<int>::iterator bpBegin = breakPos.begin(); vector<int>::iterator bpIt = breakPos.begin(); vector<int>::iterator bpEnd = breakPos.end(); while(bpIt != bpEnd) { //int i = *bpIt; displayText.insert(*bpIt,"\n"); ++bpIt; } //cout << "lines=" << lines.size() << endl; /* applyLineTruncationMode(font, displayText, sWidth, getTextWidth(), lineBreakMode, truncationString); */ /* if(lineBreakMode != LINE_BREAK_MODE_WORD_NONE && isFixedWidth()) { // TODO // TODO, this CAN depend on alignent as well switch (lineBreakMode) { case LINE_BREAK_MODE_WORD_NONE: case LINE_BREAK_MODE_WORD_WRAP: case LINE_BREAK_MODE_CHARACTER_WRAP: case LINE_BREAK_MODE_CLIP: case LINE_BREAK_MODE_HEAD_TRUNCATION: case LINE_BREAK_MODE_TAIL_TRUNCATION: case LINE_BREAK_MODE_MIDDLE_TRUNCATION: break; } //string testString = displayText; } */ // displayStringBoundingBox = font->getStringBoundingBox(displayText,0,0); //cout << "display text rect for (displayText)=>" << displayText << "<| " << ofxMuiRectUtils::toString(&displayTextRect) << endl; /* switch(orientation) { case OF_ORIENTATION_UNKNOWN: // if unknown, use default case OF_ORIENTATION_DEFAULT: case OF_ORIENTATION_180: //cout << labelFont ->getSize() << endl; // place anchor on upper left corner displayStringBoundingBox.x = 0;// displayStringBoundingBox.y = 0;//y += displayTextRect.height; break; case OF_ORIENTATION_90_RIGHT: case OF_ORIENTATION_90_LEFT: float tmp = displayStringBoundingBox.width; displayStringBoundingBox.width = displayStringBoundingBox.height; displayStringBoundingBox.height = tmp; displayStringBoundingBox.y = 0; break; } */ //cout << "display text rect: " << ofxMuiRectUtils::toString(&displayTextRect) << endl; // setContentBoxWidth(displayStringBoundingBox.width); // should always be 0,0 //setContentBoxHeight(displayStringBoundingBox.height); // should always be 0,0 // setHitBox(getContentBox()); // the whole thing //TODO PARENT NEEDS LAYOUT UPDATE WHEN LABEL PROPOERTIES ARE SET DURING SETUP //setParentNeedsLayoutUpdate(true); } needsUpdate = false; // just did it! }