本文整理汇总了C++中nsIRDFService类的典型用法代码示例。如果您正苦于以下问题:C++ nsIRDFService类的具体用法?C++ nsIRDFService怎么用?C++ nsIRDFService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsIRDFService类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: switch
void
RDFContentSinkImpl::ParseText(nsIRDFNode **aResult)
{
// XXXwaterson wasteful, but we'd need to make a copy anyway to be
// able to call nsIRDFService::Get[Resource|Literal|...]().
nsAutoString value;
value.Append(mText, mTextLength);
value.Trim(" \t\n\r");
switch (mParseMode) {
case eRDFContentSinkParseMode_Literal:
{
nsIRDFLiteral *result;
gRDFService->GetLiteral(value.get(), &result);
*aResult = result;
}
break;
case eRDFContentSinkParseMode_Resource:
{
nsIRDFResource *result;
gRDFService->GetUnicodeResource(value, &result);
*aResult = result;
}
break;
case eRDFContentSinkParseMode_Int:
{
PRInt32 i, err;
i = value.ToInteger(&err);
nsIRDFInt *result;
gRDFService->GetIntLiteral(i, &result);
*aResult = result;
}
break;
case eRDFContentSinkParseMode_Date:
{
PRTime t = rdf_ParseDate(nsDependentCString(NS_LossyConvertUTF16toASCII(value).get(), value.Length()));
nsIRDFDate *result;
gRDFService->GetDateLiteral(t, &result);
*aResult = result;
}
break;
default:
NS_NOTREACHED("unknown parse type");
break;
}
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:50,代码来源:nsRDFContentSink.cpp
示例2: propertyStr
nsresult
RDFContentSinkImpl::AddProperties(const PRUnichar** aAttributes,
nsIRDFResource* aSubject,
PRInt32* aCount)
{
if (aCount)
*aCount = 0;
nsCOMPtr<nsIAtom> localName;
for (; *aAttributes; aAttributes += 2) {
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aAttributes[0], getter_AddRefs(localName));
// skip 'xmlns' directives, these are "meta" information
if (nameSpaceURI.EqualsLiteral("http://www.w3.org/2000/xmlns/")) {
continue;
}
// skip `about', `ID', `resource', and 'nodeID' attributes (either with or
// without the `rdf:' prefix); these are all "special" and
// should've been dealt with by the caller.
if (localName == kAboutAtom || localName == kIdAtom ||
localName == kResourceAtom || localName == kNodeIdAtom) {
if (nameSpaceURI.IsEmpty() ||
nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI))
continue;
}
// Skip `parseType', `RDF:parseType', and `NC:parseType'. This
// is meta-information that will be handled in SetParseMode.
if (localName == kParseTypeAtom) {
if (nameSpaceURI.IsEmpty() ||
nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI) ||
nameSpaceURI.EqualsLiteral(NC_NAMESPACE_URI)) {
continue;
}
}
const char* attrName;
localName->GetUTF8String(&attrName);
NS_ConvertUTF16toUTF8 propertyStr(nameSpaceURI);
propertyStr.Append(attrName);
// Add the assertion to RDF
nsCOMPtr<nsIRDFResource> property;
gRDFService->GetResource(propertyStr, getter_AddRefs(property));
nsCOMPtr<nsIRDFLiteral> target;
gRDFService->GetLiteral(aAttributes[1],
getter_AddRefs(target));
mDataSource->Assert(aSubject, property, target, PR_TRUE);
}
return NS_OK;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:56,代码来源:nsRDFContentSink.cpp
示例3:
nsresult
RDFContentSinkImpl::ReinitContainer(nsIRDFResource* aContainerType, nsIRDFResource* aContainer)
{
// Mega-kludge to deal with the fact that Make[Seq|Alt|Bag] is
// idempotent, and as such, containers will have state (e.g.,
// RDF:nextVal) maintained in the graph across loads. This
// re-initializes each container's RDF:nextVal to '1', and 'marks'
// the container as such.
nsresult rv;
nsCOMPtr<nsIRDFLiteral> one;
rv = gRDFService->GetLiteral(NS_LITERAL_STRING("1").get(), getter_AddRefs(one));
if (NS_FAILED(rv)) return rv;
// Re-initialize the 'nextval' property
nsCOMPtr<nsIRDFNode> nextval;
rv = mDataSource->GetTarget(aContainer, kRDF_nextVal, true, getter_AddRefs(nextval));
if (NS_FAILED(rv)) return rv;
rv = mDataSource->Change(aContainer, kRDF_nextVal, nextval, one);
if (NS_FAILED(rv)) return rv;
// Re-mark as a container. XXX should be kRDF_type
rv = mDataSource->Assert(aContainer, kRDF_instanceOf, aContainerType, true);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to mark container as such");
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:29,代码来源:nsRDFContentSink.cpp
示例4: relURI
nsresult
RDFContentSinkImpl::GetResourceAttribute(const PRUnichar** aAttributes,
nsIRDFResource** aResource)
{
nsCOMPtr<nsIAtom> localName;
nsAutoString nodeID;
for (; *aAttributes; aAttributes += 2) {
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aAttributes[0], getter_AddRefs(localName));
// We'll accept `resource' or `rdf:resource', under the spirit
// that we should be liberal towards the input that we
// receive.
if (!nameSpaceURI.IsEmpty() &&
!nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) {
continue;
}
// XXX you can't specify both, but we'll just pick up the
// first thing that was specified and ignore the other.
if (localName == kResourceAtom) {
// XXX Take the URI and make it fully qualified by
// sticking it into the document's URL. This may not be
// appropriate...
nsAutoString relURI(aAttributes[1]);
if (rdf_RequiresAbsoluteURI(relURI)) {
nsresult rv;
nsCAutoString uri;
rv = mDocumentURL->Resolve(NS_ConvertUTF16toUTF8(aAttributes[1]), uri);
if (NS_FAILED(rv)) return rv;
return gRDFService->GetResource(uri, aResource);
}
return gRDFService->GetResource(NS_ConvertUTF16toUTF8(aAttributes[1]),
aResource);
}
else if (localName == kNodeIdAtom) {
nodeID.Assign(aAttributes[1]);
}
}
// If nodeID is present, check if we already know about it. If we've seen
// the nodeID before, use the same resource, otherwise generate a new one.
if (!nodeID.IsEmpty()) {
mNodeIDMap.Get(nodeID,aResource);
if (!*aResource) {
nsresult rv;
rv = gRDFService->GetAnonymousResource(aResource);
if (NS_FAILED(rv)) {
return rv;
}
mNodeIDMap.Put(nodeID,*aResource);
}
return NS_OK;
}
return NS_ERROR_FAILURE;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:63,代码来源:nsRDFContentSink.cpp
示例5: propertyStr
nsresult
RDFContentSinkImpl::OpenProperty(const PRUnichar* aName, const PRUnichar** aAttributes)
{
nsresult rv;
// an "object" non-terminal is either a "description", a "typed
// node", or a "container", so this change the content sink's
// state appropriately.
nsCOMPtr<nsIAtom> localName;
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aName, getter_AddRefs(localName));
NS_ConvertUTF16toUTF8 propertyStr(nameSpaceURI);
propertyStr.Append(nsAtomCString(localName));
nsCOMPtr<nsIRDFResource> property;
rv = gRDFService->GetResource(propertyStr, getter_AddRefs(property));
if (NS_FAILED(rv)) return rv;
// See if they've specified a 'resource' attribute, in which case
// they mean *that* to be the object of this property.
nsCOMPtr<nsIRDFResource> target;
GetResourceAttribute(aAttributes, getter_AddRefs(target));
bool isAnonymous = false;
if (! target) {
// See if an 'ID' attribute has been specified, in which case
// this corresponds to the fourth form of [6.12].
// XXX strictly speaking, we should reject the RDF/XML as
// invalid if they've specified both an 'ID' and a 'resource'
// attribute. Bah.
// XXX strictly speaking, 'about=' isn't allowed here, but
// what the hell.
GetIdAboutAttribute(aAttributes, getter_AddRefs(target), &isAnonymous);
}
if (target) {
// They specified an inline resource for the value of this
// property. Create an RDF resource for the inline resource
// URI, add the properties to it, and attach the inline
// resource to its parent.
PRInt32 count;
rv = AddProperties(aAttributes, target, &count);
NS_ASSERTION(NS_SUCCEEDED(rv), "problem adding properties");
if (NS_FAILED(rv)) return rv;
if (count || !isAnonymous) {
// If the resource was "anonymous" (i.e., they hadn't
// explicitly set an ID or resource attribute), then we'll
// only assert this property from the context element *if*
// there were properties specified on the anonymous
// resource.
rv = mDataSource->Assert(GetContextElement(0), property, target, true);
if (NS_FAILED(rv)) return rv;
}
// XXX Technically, we should _not_ fall through here and push
// the element onto the stack: this is supposed to be a closed
// node. But right now I'm lazy and the code will just Do The
// Right Thing so long as the RDF is well-formed.
}
// Push the element onto the context stack and change state.
PushContext(property, mState, mParseMode);
mState = eRDFContentSinkState_InPropertyElement;
SetParseMode(aAttributes);
return NS_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:72,代码来源:nsRDFContentSink.cpp
示例6: if
nsresult
RDFContentSinkImpl::OpenObject(const PRUnichar* aName,
const PRUnichar** aAttributes)
{
// an "object" non-terminal is either a "description", a "typed
// node", or a "container", so this change the content sink's
// state appropriately.
nsCOMPtr<nsIAtom> localName;
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aName, getter_AddRefs(localName));
// Figure out the URI of this object, and create an RDF node for it.
nsCOMPtr<nsIRDFResource> source;
GetIdAboutAttribute(aAttributes, getter_AddRefs(source));
// If there is no `ID' or `about', then there's not much we can do.
if (! source)
return NS_ERROR_FAILURE;
// Push the element onto the context stack
PushContext(source, mState, mParseMode);
// Now figure out what kind of state transition we need to
// make. We'll either be going into a mode where we parse a
// description or a container.
bool isaTypedNode = true;
if (nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) {
isaTypedNode = false;
if (localName == kDescriptionAtom) {
// it's a description
mState = eRDFContentSinkState_InDescriptionElement;
}
else if (localName == kBagAtom) {
// it's a bag container
InitContainer(kRDF_Bag, source);
mState = eRDFContentSinkState_InContainerElement;
}
else if (localName == kSeqAtom) {
// it's a seq container
InitContainer(kRDF_Seq, source);
mState = eRDFContentSinkState_InContainerElement;
}
else if (localName == kAltAtom) {
// it's an alt container
InitContainer(kRDF_Alt, source);
mState = eRDFContentSinkState_InContainerElement;
}
else {
// heh, that's not *in* the RDF namespace: just treat it
// like a typed node
isaTypedNode = true;
}
}
if (isaTypedNode) {
NS_ConvertUTF16toUTF8 typeStr(nameSpaceURI);
typeStr.Append(nsAtomCString(localName));
nsCOMPtr<nsIRDFResource> type;
nsresult rv = gRDFService->GetResource(typeStr, getter_AddRefs(type));
if (NS_FAILED(rv)) return rv;
rv = mDataSource->Assert(source, kRDF_type, type, true);
if (NS_FAILED(rv)) return rv;
mState = eRDFContentSinkState_InDescriptionElement;
}
AddProperties(aAttributes, source);
return NS_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:73,代码来源:nsRDFContentSink.cpp
注:本文中的nsIRDFService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论