本文整理汇总了C++中NSString::printf方法的典型用法代码示例。如果您正苦于以下问题:C++ NSString::printf方法的具体用法?C++ NSString::printf怎么用?C++ NSString::printf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSString
的用法示例。
在下文中一共展示了NSString::printf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setServerXMLContextDescription
void ConfigurationServerXMLException::setServerXMLContextDescription(ServerXMLSchema::Element& element)
{
ServerXMLExceptionContext context(element);
CString tagName(element.getTagName());
NSString error;
error.append(context.getContextPrefix());
error.printf(XP_GetAdminStr(DBT_ErrorProcessingTagXPrefix),
tagName.getStringValue());
error.append(getDescription());
setDescription(error);
}
示例2: handleDatatypeError
void ServerXMLParser::handleDatatypeError(const XMLCh *systemID,
int lineNumber,
const DOMNode *node)
{
DOMElement *element = NULL;
if (node != NULL) {
if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
element = (DOMElement *)node;
} else {
DOMNode *parentNode = node->getParentNode();
if (parentNode != NULL && parentNode->getNodeType() == DOMNode::ELEMENT_NODE)
element = (DOMElement *)parentNode;
}
}
if (element == NULL)
return; // We only know how to handle invalid element content
CString tagName(element->getTagName());
char *transcodedTextContent = NULL;
const char *begin = NULL;
const char *end = NULL;
if (node->getNodeType() == DOMNode::TEXT_NODE) {
const DOMText *textNode = (const DOMText *)node;
transcodedTextContent = XMLString::transcode(textNode->getTextContent());
if (transcodedTextContent) {
begin = transcodedTextContent;
while (isspace(*begin))
begin++;
end = begin;
while (isprint(*end))
end++;
while (end > begin && isspace(*end))
end--;
}
}
NSString error;
if (end > begin) {
// Got a value with at least some printable characters
error.printf(XP_GetAdminStr(DBT_CONF1104_invalid_tag_X_value_nY),
tagName.getStringValue(),
(int)(end - begin),
begin);
} else if (end && *end) {
// There was a value, but it didn't contain any printable characters
error.printf(XP_GetAdminStr(DBT_CONF1105_invalid_tag_X_value),
tagName.getStringValue());
} else {
// Empty value. This element must require a non-empty value.
error.printf(XP_GetAdminStr(DBT_CONF1106_tag_X_must_not_be_empty),
tagName.getStringValue());
}
if (transcodedTextContent != NULL)
XMLString::release(&transcodedTextContent);
throw ServerXMLException(CString(systemID), lineNumber, node, error);
}