本文整理汇总了C++中nsCOMPtr::ArcLabelsOut方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::ArcLabelsOut方法的具体用法?C++ nsCOMPtr::ArcLabelsOut怎么用?C++ nsCOMPtr::ArcLabelsOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::ArcLabelsOut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
NS_IMETHODIMP
nsRDFDataSourceDataSource::GetTargets(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
bool aTruthValue,
nsISimpleEnumerator **_retval)
{
nsXPIDLCString sourceval;
aSource->GetValue(getter_Copies(sourceval));
nsXPIDLCString propval;
aProperty->GetValue(getter_Copies(propval));
#ifdef DEBUG_alecf
printf("GetTargets(%s, %s,..)\n", (const char*)sourceval,
(const char*)propval);
#endif
nsresult rv;
bool isProp;
nsCOMPtr<nsISupportsArray> arcs;
nsISimpleEnumerator *enumerator;
if (NS_SUCCEEDED(aProperty->EqualsNode(kNC_Child, &isProp)) &&
isProp) {
// here we need to determine if we need to extract out the source
// or use aSource?
if (StringBeginsWith(sourceval, NS_LITERAL_CSTRING("dsresource:"))) {
// somehow get the source
// XXX ? rv = mDataSource->ArcLabelsOut(realsource, &enumerator);
rv = mDataSource->ArcLabelsOut(aSource, &enumerator);
} else {
rv = mDataSource->ArcLabelsOut(aSource, &enumerator);
}
// enumerate all the children and create the composite resources
bool hasMoreArcs=false;
rv = enumerator->HasMoreElements(&hasMoreArcs);
while (NS_SUCCEEDED(rv) && hasMoreArcs) {
// get the next arc
nsCOMPtr<nsISupports> arcSupports;
rv = enumerator->GetNext(getter_AddRefs(arcSupports));
nsCOMPtr<nsIRDFResource> arc = do_QueryInterface(arcSupports, &rv);
// get all the resources on the ends of the arc arcs
nsCOMPtr<nsISimpleEnumerator> targetEnumerator;
rv = mDataSource->GetTargets(aSource, arc, true,
getter_AddRefs(targetEnumerator));
bool hasMoreTargets;
rv = targetEnumerator->HasMoreElements(&hasMoreTargets);
while (NS_SUCCEEDED(rv) && hasMoreTargets) {
// get the next target
nsCOMPtr<nsISupports> targetSupports;
rv = enumerator->GetNext(getter_AddRefs(targetSupports));
nsCOMPtr<nsIRDFResource> target=do_QueryInterface(targetSupports, &rv);
// now we have an (arc, target) tuple that will be our node
// arc will become #Name
// target will become #Value
#ifdef DEBUG_alecf
nsXPIDLString arcValue;
nsXPIDLString targetValue;
arc->GetValue(getter_Copies(arcValue));
target->GetValue(getter_Copies(targetValue));
printf("#child of %s:\n\t%s = %s\n",
(const char*)sourceval
#endif
}
rv = enumerator->HasMoreElements(&hasMoreArcs);
}
} else if (NS_SUCCEEDED(aProperty->EqualsNode(kNC_Name, &isProp)) &&
示例2: rdf_printArcLabels
void rdf_printArcLabels(nsCOMPtr<nsIRDFResource> currentResource)
{
if (!currentResource) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3, ("resource: null\n"));
}
return;
}
nsCOMPtr<nsISimpleEnumerator> labels;
nsCOMPtr<nsISupports> supportsResult;
nsCOMPtr<nsIRDFResource> resourceResult;
nsresult rv;
PRBool result;
const char *arcLabel;
const char *currentResourceValue;
rv = currentResource->GetValueConst(¤tResourceValue);
if (NS_SUCCEEDED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("resource: %s\n", currentResourceValue));
}
}
else {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("printArcLabels: can't get value from current resource.\n"));
}
}
rv = gBookmarksDataSource->ArcLabelsOut(currentResource,
getter_AddRefs(labels));
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("printArcLabels: currentResource has no outgoing arcs.\n"));
}
return;
}
rv = labels->HasMoreElements(&result);
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("printArcLabels: can't get elements from currentResource's enum.\n"));
}
return;
}
while (result) {
rv = labels->GetNext(getter_AddRefs(supportsResult));
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("printArcLabels: Can't get next arc from enumerator.\n"));
}
return;
}
// make sure it's an RDFResource
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFResource),
getter_AddRefs(resourceResult));
if (NS_SUCCEEDED(rv)) {
rv = resourceResult->GetValueConst(&arcLabel);
if (NS_SUCCEEDED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("\tarc label: %s\n", arcLabel));
}
}
else {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("printArcLabels: can't get value from current arc.\n"));
}
}
}
else {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("printArcLabels: next arc from enumerator is not an nsIRDFResource.\n"));
}
}
rv = labels->HasMoreElements(&result);
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("printArcLabels: can't get elements from currentResource's enum.\n"));
}
return;
}
}
}