本文整理汇总了C++中XMP_VarString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ XMP_VarString::c_str方法的具体用法?C++ XMP_VarString::c_str怎么用?C++ XMP_VarString::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMP_VarString
的用法示例。
在下文中一共展示了XMP_VarString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleConstAlias
bool HandleConstAlias( const spIMetadata & meta, spINode & destNode, const XMP_ExpandedXPath & expandedXPath, sizet & nodeIndex ) {
if ( expandedXPath.empty() ) NOTIFY_ERROR( IError::kEDGeneral, kGECLogicalError, "Empty XPath", IError::kESOperationFatal, false, false );
if ( !( expandedXPath[ kSchemaStep ].options & kXMP_SchemaNode ) ) {
return false;
} else {
XMP_VarString namespaceName = expandedXPath[ kSchemaStep ].step.c_str();
size_t colonPos = expandedXPath[ kRootPropStep ].step.find( ":" );
assert( colonPos != std::string::npos );
XMP_VarString propertyName = expandedXPath[ kRootPropStep ].step.substr( colonPos + 1 );
// here find the node with this name
destNode = meta->GetNode( namespaceName.c_str(), namespaceName.size(), propertyName.c_str(), propertyName.size() );
if ( !destNode ) return false;
if ( expandedXPath.size() == 2 ) return true;
assert( destNode->GetNodeType() == INode::kNTArray );
if ( expandedXPath[ 2 ].options == kXMP_ArrayIndexStep ) {
assert( expandedXPath[ 2 ].step == "[1]" );
destNode = destNode->ConvertToArrayNode()->GetNodeAtIndex( 1 );
auto actualNodeType = destNode->GetNodeType();
if ( destNode ) {
if ( nodeIndex ) nodeIndex = 1;
return true;
}
return false;
} else if ( expandedXPath[ 2 ].options == kXMP_QualSelectorStep ) {
assert( expandedXPath[ 2 ].step == "[?xml:lang=\"x-default\"]" );
if ( !destNode || destNode->GetNodeType() != INode::kNTArray ) return false;
spINodeIterator iter = destNode->ConvertToArrayNode()->Iterator();
sizet index = 1;
while ( iter ) {
spINode node = iter->GetNode();
try {
spISimpleNode qualNode = node->GetSimpleQualifier( "http://www.w3.org/XML/1998/namespace", AdobeXMPCommon::npos, "lang", AdobeXMPCommon::npos );
if ( qualNode->GetValue()->compare( "x-default" ) == 0 ) {
destNode = node;
if ( nodeIndex ) nodeIndex = index;
return true;
}
} catch ( spcIError err ) {
} catch ( ... ) {}
index++;
iter = iter->Next();
}
return false;
}
return false;
}
}
示例2: AddResourceIfExists
// =================================================================================================
// PackageFormat_Support::AddResourceIfExists
// ================================
bool PackageFormat_Support::AddResourceIfExists ( XMP_StringVector * resourceList, const XMP_VarString & folderPath,
XMP_StringPtr prefix, XMP_StringPtr postfix )
{
Host_IO::FolderRef folderHandle = Host_IO::OpenFolder ( folderPath.c_str() );
if ( folderHandle == Host_IO::noFolderRef || !prefix || !postfix )
return false;// can't open folder.
XMP_VarString fileName, filePath;
size_t fileNameLength;
size_t prefixLength = strlen ( prefix );
size_t postfixLength = strlen ( postfix );
bool atleastOneFileAdded = false;
while ( Host_IO::GetNextChild ( folderHandle, &fileName ) )
{
fileNameLength = fileName.length();
// Check if the file name starts with prefix and ends with postfix
if ( fileNameLength >= ( prefixLength + postfixLength ) &&
fileName.compare ( fileNameLength-postfixLength, postfixLength, postfix ) == 0 &&
fileName.compare ( 0, prefixLength, prefix ) == 0)
{
filePath = folderPath + kDirChar + fileName;
PackageFormat_Support::AddResourceIfExists ( resourceList, filePath );
atleastOneFileAdded = true;
}
}
// close folder
Host_IO::CloseFolder ( folderHandle );
return atleastOneFileAdded;
} // PackageFormat_Support::AddResourceIfExists
示例3: options
IterNode ( XMP_OptionBits _options, const XMP_VarString& _fullPath, size_t _leafOffset )
: options(_options), fullPath(_fullPath), leafOffset(_leafOffset), visitStage(kIter_BeforeVisit)
{
#if 0 // *** XMP_DebugBuild
_pathPtr = fullPath.c_str();
_leafPtr = _pathPtr + leafOffset;
#endif
};
示例4: zGenericLang
bool
XMPMeta::GetLocalizedText ( XMP_StringPtr schemaNS,
XMP_StringPtr arrayName,
XMP_StringPtr _genericLang,
XMP_StringPtr _specificLang,
XMP_StringPtr * actualLang,
XMP_StringLen * langSize,
XMP_StringPtr * itemValue,
XMP_StringLen * valueSize,
XMP_OptionBits * options ) const
{
XMP_Assert ( (schemaNS != 0) && (arrayName != 0) && (_genericLang != 0) && (_specificLang != 0) ); // Enforced by wrapper.
XMP_Assert ( (actualLang != 0) && (langSize != 0) ); // Enforced by wrapper.
XMP_Assert ( (itemValue != 0) && (valueSize != 0) && (options != 0) ); // Enforced by wrapper.
XMP_VarString zGenericLang ( _genericLang );
XMP_VarString zSpecificLang ( _specificLang );
NormalizeLangValue ( &zGenericLang );
NormalizeLangValue ( &zSpecificLang );
XMP_StringPtr genericLang = zGenericLang.c_str();
XMP_StringPtr specificLang = zSpecificLang.c_str();
XMP_ExpandedXPath arrayPath;
ExpandXPath ( schemaNS, arrayName, &arrayPath );
const XMP_Node * arrayNode = FindConstNode ( &tree, arrayPath ); // *** This expand/find idiom is used in 3 Getters.
if ( arrayNode == 0 ) return false; // *** Should extract it into a local utility.
XMP_CLTMatch match;
const XMP_Node * itemNode;
match = ChooseLocalizedText ( arrayNode, genericLang, specificLang, &itemNode );
if ( match == kXMP_CLT_NoValues ) return false;
*actualLang = itemNode->qualifiers[0]->value.c_str();
*langSize = static_cast<XMP_Index>( itemNode->qualifiers[0]->value.size() );
*itemValue = itemNode->value.c_str();
*valueSize = static_cast<XMP_Index>( itemNode->value.size() );
*options = itemNode->options;
return true;
} // GetLocalizedText
示例5: nsPrefix
static void
DeclareElemNamespace ( const XMP_VarString & elemName,
XMP_VarString & usedNS,
XMP_VarString & outputStr,
XMP_StringPtr newline,
XMP_StringPtr indentStr,
XMP_Index indent )
{
size_t colonPos = elemName.find ( ':' );
if ( colonPos != XMP_VarString::npos ) {
XMP_VarString nsPrefix ( elemName.substr ( 0, colonPos+1 ) );
XMP_StringPtr nsURI;
bool nsFound = sRegisteredNamespaces->GetURI ( nsPrefix.c_str(), &nsURI, 0 );
XMP_Enforce ( nsFound );
DeclareOneNamespace ( nsPrefix.c_str(), nsURI, usedNS, outputStr, newline, indentStr, indent );
}
} // DeclareElemNamespace
示例6: if
static void
AppendNodeValue ( XMP_VarString & outputStr, const XMP_VarString & value, bool forAttribute )
{
unsigned char * runStart = (unsigned char *) value.c_str();
unsigned char * runLimit = runStart + value.size();
unsigned char * runEnd;
unsigned char ch;
while ( runStart < runLimit ) {
for ( runEnd = runStart; runEnd < runLimit; ++runEnd ) {
ch = *runEnd;
if ( forAttribute && (ch == '"') ) break;
if ( (ch < 0x20) || (ch == '&') || (ch == '<') || (ch == '>') ) break;
}
outputStr.append ( (char *) runStart, (runEnd - runStart) );
if ( runEnd < runLimit ) {
if ( ch < 0x20 ) {
XMP_Assert ( (ch == kTab) || (ch == kLF) || (ch == kCR) );
char hexBuf[16];
memcpy ( hexBuf, "&#xn;", 6 ); // AUDIT: Length of "&#xn;" is 5, hexBuf size is 16.
hexBuf[3] = kHexDigits[ch&0xF];
outputStr.append ( hexBuf, 5 );
} else {
if ( ch == '"' ) {
outputStr += """;
} else if ( ch == '<' ) {
outputStr += "<";
} else if ( ch == '>' ) {
outputStr += ">";
} else {
XMP_Assert ( ch == '&' );
outputStr += "&";
}
}
++runEnd;
}
runStart = runEnd;
}
} // AppendNodeValue
示例7:
void
XMPMeta::DeleteArrayItem ( XMP_StringPtr schemaNS,
XMP_StringPtr arrayName,
XMP_Index itemIndex )
{
XMP_Assert ( (schemaNS != 0) && (arrayName != 0) ); // Enforced by wrapper.
XMP_VarString itemPath;
XMPUtils::ComposeArrayItemPath ( schemaNS, arrayName, itemIndex, &itemPath );
DeleteProperty ( schemaNS, itemPath.c_str() );
} // DeleteArrayItem
示例8: DoesPropertyExist
bool
XMPMeta::DoesArrayItemExist ( XMP_StringPtr schemaNS,
XMP_StringPtr arrayName,
XMP_Index itemIndex ) const
{
XMP_Assert ( (schemaNS != 0) && (arrayName != 0) ); // Enforced by wrapper.
XMP_VarString itemPath;
XMPUtils::ComposeArrayItemPath ( schemaNS, arrayName, itemIndex, &itemPath );
return DoesPropertyExist ( schemaNS, itemPath.c_str() );
} // DoesArrayItemExist
示例9: ParseBuffer
void ExpatAdapter::ParseBuffer ( const void * buffer, size_t length, bool last /* = true */ )
{
enum XML_Status status;
if ( length == 0 ) { // Expat does not like empty buffers.
if ( ! last ) return;
buffer = kOneSpace;
length = 1;
}
status = XML_Parse ( this->parser, (const char *)buffer, length, last );
#if BanAllEntityUsage
if ( this->isAborted ) {
XMP_Error error(kXMPErr_BadXML, "DOCTYPE is not allowed" )
this->NotifyClient ( kXMPErrSev_Recoverable, error );
}
#endif
if ( status != XML_STATUS_OK ) {
XMP_StringPtr errMsg = "XML parsing failure";
#if 0 // XMP_DebugBuild // Disable for now to make test output uniform. Restore later with thread safety.
// *** This is a good candidate for a callback error notification mechanism.
// *** This code is not thread safe, the sExpatMessage isn't locked. But that's OK for debug usage.
enum XML_Error expatErr = XML_GetErrorCode ( this->parser );
const char * expatMsg = XML_ErrorString ( expatErr );
int errLine = XML_GetCurrentLineNumber ( this->parser );
char msgBuffer[1000];
// AUDIT: Use of sizeof(msgBuffer) for snprintf length is safe.
snprintf ( msgBuffer, sizeof(msgBuffer), "# Expat error %d at line %d, \"%s\"", expatErr, errLine, expatMsg );
sExpatMessage = msgBuffer;
errMsg = sExpatMessage.c_str();
#if DumpXMLParseEvents
if ( this->parseLog != 0 ) fprintf ( this->parseLog, "%s\n", errMsg, expatErr, errLine, expatMsg );
#endif
#endif
XMP_Error error(kXMPErr_BadXML, errMsg);
this->NotifyClient ( kXMPErrSev_Recoverable, error );
}
} // ExpatAdapter::ParseBuffer
示例10: GetProperty
bool
XMPMeta::GetStructField ( XMP_StringPtr schemaNS,
XMP_StringPtr structName,
XMP_StringPtr fieldNS,
XMP_StringPtr fieldName,
XMP_StringPtr * fieldValue,
XMP_StringLen * valueSize,
XMP_OptionBits * options ) const
{
XMP_Assert ( (schemaNS != 0) && (structName != 0) && (fieldNS != 0) && (fieldName != 0) ); // Enforced by wrapper.
XMP_Assert ( (fieldValue != 0) && (options != 0) ); // Enforced by wrapper.
XMP_VarString fieldPath;
XMPUtils::ComposeStructFieldPath ( schemaNS, structName, fieldNS, fieldName, &fieldPath );
return GetProperty ( schemaNS, fieldPath.c_str(), fieldValue, valueSize, options );
} // GetStructField
示例11: prefix
static void
VerifyQualName ( XMP_StringPtr qualName, XMP_StringPtr nameEnd )
{
if ( qualName >= nameEnd ) XMP_Throw ( "Empty qualified name", kXMPErr_BadXPath );
XMP_StringPtr colonPos = qualName;
while ( (colonPos < nameEnd) && (*colonPos != ':') ) ++colonPos;
if ( (colonPos == qualName) || (colonPos >= nameEnd) ) XMP_Throw ( "Ill-formed qualified name", kXMPErr_BadXPath );
VerifySimpleXMLName ( qualName, colonPos );
VerifySimpleXMLName ( colonPos+1, nameEnd );
size_t prefixLen = colonPos - qualName + 1; // ! Include the colon.
XMP_VarString prefix ( qualName, prefixLen );
bool nsFound = sRegisteredNamespaces->GetURI ( prefix.c_str(), 0, 0 );
if ( ! nsFound ) XMP_Throw ( "Unknown namespace prefix for qualified name", kXMPErr_BadXPath );
} // VerifyQualName
示例12: GetMatchingChildren
void IOUtils::GetMatchingChildren ( XMP_StringVector & matchingChildList, const XMP_VarString & rootPath,
const XMP_StringVector & regExStringVec, XMP_Bool includeFolders, XMP_Bool includeFiles, XMP_Bool prefixRootPath )
{
try
{
XMP_StringVector listOfAllResources;
ListAllChildren (rootPath.c_str(), listOfAllResources, includeFolders, includeFiles, true);
XMP_Bool matchRequired = !regExStringVec.empty();
if ( matchRequired )
{
size_t childCount = listOfAllResources.size();
for ( size_t index = 0; index < childCount; index++ )
{
XMP_Bool match = false;
size_t regExpCount = regExStringVec.size();
for ( size_t index2 = 0; index2 < regExpCount; index2++ )
{
XMP_RegExp regexObj ( regExStringVec[index2].c_str() );
match = regexObj.Match ( listOfAllResources[index].c_str() );
if ( match )
{
if ( prefixRootPath )
{
std::string fullPath = rootPath;
if (fullPath[fullPath.length() - 1] != kDirChar )
fullPath += kDirChar;
fullPath += listOfAllResources[index];
matchingChildList.push_back ( fullPath );
}
else
matchingChildList.push_back ( listOfAllResources[index] );
break;
}
}
}
}
} catch ( XMP_Error & ) {
// do nothing
}
} // GetMatchingChildren
示例13: FindNode
void
XMPMeta::SetQualifier ( XMP_StringPtr schemaNS,
XMP_StringPtr propName,
XMP_StringPtr qualNS,
XMP_StringPtr qualName,
XMP_StringPtr qualValue,
XMP_OptionBits options )
{
XMP_Assert ( (schemaNS != 0) && (propName != 0) && (qualNS != 0) && (qualName != 0) ); // Enforced by wrapper.
XMP_ExpandedXPath expPath;
ExpandXPath ( schemaNS, propName, &expPath );
XMP_Node * propNode = FindNode ( &tree, expPath, kXMP_ExistingOnly );
if ( propNode == 0 ) XMP_Throw ( "Specified property does not exist", kXMPErr_BadXPath );
XMP_VarString qualPath;
XMPUtils::ComposeQualifierPath ( schemaNS, propName, qualNS, qualName, &qualPath );
SetProperty ( schemaNS, qualPath.c_str(), qualValue, options );
} // SetQualifier
示例14:
static void
SplitNameAndValue ( const XMP_VarString & selStep, XMP_VarString * nameStr, XMP_VarString * valueStr )
{
XMP_StringPtr partBegin = selStep.c_str();
XMP_StringPtr partEnd;
const XMP_StringPtr valueEnd = partBegin + (selStep.size() - 2);
const char quote = *valueEnd;
XMP_Assert ( (*partBegin == '[') && (*(valueEnd+1) == ']') );
XMP_Assert ( (selStep.size() >= 6) && ((quote == '"') || (quote == '\'')) );
// Extract the name part.
++partBegin; // Skip the opening '['.
if ( *partBegin == '?' ) ++partBegin;
for ( partEnd = partBegin+1; *partEnd != '='; ++partEnd ) {};
nameStr->assign ( partBegin, (partEnd - partBegin) );
// Extract the value part, reducing doubled quotes.
XMP_Assert ( *(partEnd+1) == quote );
partBegin = partEnd + 2;
valueStr->erase();
valueStr->reserve ( valueEnd - partBegin ); // Maximum length, don't optimize doubled quotes.
for ( partEnd = partBegin; partEnd < valueEnd; ++partEnd ) {
if ( (*partEnd == quote) && (*(partEnd+1) == quote) ) {
++partEnd;
valueStr->append ( partBegin, (partEnd - partBegin) );
partBegin = partEnd+1; // ! Loop will increment partEnd again.
}
}
valueStr->append ( partBegin, (partEnd - partBegin) ); // ! The loop does not add the last part.
} // SplitNameAndValue
示例15: HandleNonConstAlias
bool HandleNonConstAlias( const spIMetadata & meta, XMP_ExpandedXPath & expandedXPath, bool createNodes, XMP_OptionBits leafOptions, spINode & destNode, sizet & nodeIndex, bool ignoreLastStep, const spINode & inputNode ) {
destNode = meta;
spcIUTF8String inputNodeValue;
if ( inputNode && inputNode->GetNodeType() == INode::kNTSimple ) {
inputNodeValue = inputNode->ConvertToSimpleNode()->GetValue();
}
bool isAliasBeingCreated = expandedXPath.size() == 2;
if ( expandedXPath.empty() )
NOTIFY_ERROR( IError::kEDDataModel, kDMECBadXPath, "Empty XPath", IError::kESOperationFatal, false, false );
if ( !( expandedXPath[ kSchemaStep ].options & kXMP_SchemaNode ) ) {
return false;
} else {
XMP_VarString namespaceName = expandedXPath[ kSchemaStep ].step.c_str();
size_t colonPos = expandedXPath[ kRootPropStep ].step.find( ":" );
assert( colonPos != std::string::npos );
XMP_VarString propertyName = expandedXPath[ kRootPropStep ].step.substr( colonPos + 1 );
spcINode childNode = meta->GetNode( namespaceName.c_str(), namespaceName.size(), propertyName.c_str(), propertyName.size() );
if ( !childNode && !createNodes ) return false;
if ( expandedXPath.size() == 2 ) {
if ( childNode ) return true;
XMP_OptionBits createOptions = 0;
spINode tempNode;
if ( isAliasBeingCreated ) tempNode = CreateTerminalNode( namespaceName.c_str(), propertyName.c_str(), leafOptions );
else tempNode = CreateTerminalNode( namespaceName.c_str(), propertyName.c_str(), createOptions );
if ( !tempNode ) return false;
if ( inputNodeValue ) tempNode->ConvertToSimpleNode()->SetValue( inputNodeValue->c_str(), inputNodeValue->size() );
if ( destNode == meta ) {
meta->InsertNode( tempNode );
} else {
destNode->ConvertToStructureNode()->AppendNode( tempNode );
}
destNode = tempNode;
if ( destNode ) return true;
return false;
}
XMP_Assert( expandedXPath.size() == 3 );
if ( expandedXPath[ 2 ].options == kXMP_ArrayIndexStep ) {
XMP_Assert( expandedXPath[ 2 ].step == "[1]" );
destNode = meta->GetNode( namespaceName.c_str(), namespaceName.size(), propertyName.c_str(), propertyName.size() );
if ( !destNode && !createNodes ) return false;
if ( !destNode ) {
spINode arrayNode = CreateTerminalNode( namespaceName.c_str(), propertyName.c_str(), kXMP_PropArrayIsOrdered | kXMP_PropValueIsArray );
meta->AppendNode( arrayNode );
destNode = arrayNode;
}
if ( destNode->ConvertToArrayNode()->GetNodeAtIndex( 1 ) ) {
destNode = destNode->ConvertToArrayNode()->GetNodeAtIndex( 1 );
if ( nodeIndex ) nodeIndex = 1;
return true;
} else {
spISimpleNode indexNode = ISimpleNode::CreateSimpleNode( namespaceName.c_str(), namespaceName.size(), propertyName.c_str(), propertyName.size() );
if ( inputNodeValue ) {
indexNode->SetValue( inputNodeValue->c_str(), inputNodeValue->size() );
}
destNode->ConvertToArrayNode()->InsertNodeAtIndex( indexNode, 1 );
destNode = indexNode;
return true;
}
return false;
} else if ( expandedXPath[ 2 ].options == kXMP_QualSelectorStep ) {
assert( expandedXPath[ 2 ].step == "[?xml:lang=\"x-default\"]" );
destNode = meta->GetNode( namespaceName.c_str(), namespaceName.size(), propertyName.c_str(), propertyName.size() );
if ( !destNode && !createNodes ) return false;
spINode arrayNode = CreateTerminalNode( namespaceName.c_str(), propertyName.c_str(), kXMP_PropValueIsArray | kXMP_PropArrayIsAltText);
meta->AppendNode( arrayNode );
destNode = arrayNode;
auto iter = destNode->ConvertToArrayNode()->Iterator();
XMP_Index index = 1;
while ( iter ) {
spINode node = iter->GetNode();
spINode qualNode = node->GetQualifier( "http://www.w3.org/XML/1998/namespace", AdobeXMPCommon::npos, "lang", AdobeXMPCommon::npos );
if ( qualNode->GetNodeType() == INode::kNTSimple ) {
if ( !qualNode->ConvertToSimpleNode()->GetValue()->compare( "x-default" ) ) {
destNode = node;
if ( nodeIndex ) nodeIndex = index;
return true;
}
}
index++;
iter = iter->Next();
}
spISimpleNode qualifierNode = ISimpleNode::CreateSimpleNode( "http://www.w3.org/XML/1998/namespace", AdobeXMPCommon::npos, "lang", AdobeXMPCommon::npos, "x-default", AdobeXMPCommon::npos );
if ( destNode->ConvertToArrayNode()->GetNodeAtIndex( 1 ) ) {
destNode = destNode->ConvertToArrayNode()->GetNodeAtIndex( 1 );
if ( nodeIndex ) nodeIndex = 1;
destNode->InsertQualifier( qualifierNode );
return true;
} else {
spISimpleNode indexNode = ISimpleNode::CreateSimpleNode( namespaceName.c_str(), AdobeXMPCommon::npos, propertyName.c_str(), AdobeXMPCommon::npos );
if ( inputNodeValue ) {
indexNode->SetValue( inputNodeValue->c_str(), inputNodeValue->size() );
}
destNode->ConvertToArrayNode()->InsertNodeAtIndex( indexNode, 1 );
destNode->InsertQualifier( qualifierNode );
destNode = indexNode;
return true;
}
//.........这里部分代码省略.........