rdf/base/src/nsRDFXMLSerializer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rdf/base/src/nsRDFXMLSerializer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,118 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsRDFXMLSerializer_h__
    1.11 +#define nsRDFXMLSerializer_h__
    1.12 +
    1.13 +#include "nsIRDFLiteral.h"
    1.14 +#include "nsIRDFXMLSerializer.h"
    1.15 +#include "nsIRDFXMLSource.h"
    1.16 +#include "nsNameSpaceMap.h"
    1.17 +#include "nsXPIDLString.h"
    1.18 +
    1.19 +#include "nsDataHashtable.h"
    1.20 +#include "rdfITripleVisitor.h"
    1.21 +
    1.22 +class nsString;
    1.23 +class nsIOutputStream;
    1.24 +class nsIRDFContainerUtils;
    1.25 +
    1.26 +/**
    1.27 + * A helper class that can serialize RDF/XML from a
    1.28 + * datasource. Implements both nsIRDFXMLSerializer and
    1.29 + * nsIRDFXMLSource.
    1.30 + */
    1.31 +class nsRDFXMLSerializer : public nsIRDFXMLSerializer,
    1.32 +                           public nsIRDFXMLSource
    1.33 +{
    1.34 +public:
    1.35 +    static nsresult
    1.36 +    Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
    1.37 +
    1.38 +    NS_DECL_ISUPPORTS
    1.39 +    NS_DECL_NSIRDFXMLSERIALIZER
    1.40 +    NS_DECL_NSIRDFXMLSOURCE
    1.41 +
    1.42 +protected:
    1.43 +    nsRDFXMLSerializer();
    1.44 +    virtual ~nsRDFXMLSerializer();
    1.45 +
    1.46 +    // Implementation methods
    1.47 +    nsresult
    1.48 +    RegisterQName(nsIRDFResource* aResource);
    1.49 +    nsresult
    1.50 +    GetQName(nsIRDFResource* aResource, nsCString& aQName);
    1.51 +    already_AddRefed<nsIAtom>
    1.52 +    EnsureNewPrefix();
    1.53 +
    1.54 +    nsresult
    1.55 +    SerializeInlineAssertion(nsIOutputStream* aStream,
    1.56 +                             nsIRDFResource* aResource,
    1.57 +                             nsIRDFResource* aProperty,
    1.58 +                             nsIRDFLiteral* aValue);
    1.59 +
    1.60 +    nsresult
    1.61 +    SerializeChildAssertion(nsIOutputStream* aStream,
    1.62 +                            nsIRDFResource* aResource,
    1.63 +                            nsIRDFResource* aProperty,
    1.64 +                            nsIRDFNode* aValue);
    1.65 +
    1.66 +    nsresult
    1.67 +    SerializeProperty(nsIOutputStream* aStream,
    1.68 +                      nsIRDFResource* aResource,
    1.69 +                      nsIRDFResource* aProperty,
    1.70 +                      bool aInline,
    1.71 +                      int32_t* aSkipped);
    1.72 +
    1.73 +    bool
    1.74 +    IsContainerProperty(nsIRDFResource* aProperty);
    1.75 +
    1.76 +    nsresult
    1.77 +    SerializeDescription(nsIOutputStream* aStream,
    1.78 +                         nsIRDFResource* aResource);
    1.79 +
    1.80 +    nsresult
    1.81 +    SerializeMember(nsIOutputStream* aStream,
    1.82 +                    nsIRDFResource* aContainer,
    1.83 +                    nsIRDFNode* aMember);
    1.84 +
    1.85 +    nsresult
    1.86 +    SerializeContainer(nsIOutputStream* aStream,
    1.87 +                       nsIRDFResource* aContainer);
    1.88 +
    1.89 +    nsresult
    1.90 +    SerializePrologue(nsIOutputStream* aStream);
    1.91 +
    1.92 +    nsresult
    1.93 +    SerializeEpilogue(nsIOutputStream* aStream);
    1.94 +
    1.95 +    nsresult
    1.96 +    CollectNamespaces();
    1.97 +
    1.98 +    bool
    1.99 +    IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType);
   1.100 +
   1.101 +    nsCOMPtr<nsIRDFDataSource> mDataSource;
   1.102 +    nsNameSpaceMap mNameSpaces;
   1.103 +    nsXPIDLCString mBaseURLSpec;
   1.104 +
   1.105 +    // hash mapping resources to utf8-encoded QNames
   1.106 +    nsDataHashtable<nsISupportsHashKey, nsCString> mQNames;
   1.107 +    friend class QNameCollector;
   1.108 +
   1.109 +    uint32_t mPrefixID;
   1.110 +
   1.111 +    static int32_t gRefCnt;
   1.112 +    static nsIRDFResource* kRDF_instanceOf;
   1.113 +    static nsIRDFResource* kRDF_type;
   1.114 +    static nsIRDFResource* kRDF_nextVal;
   1.115 +    static nsIRDFResource* kRDF_Bag;
   1.116 +    static nsIRDFResource* kRDF_Seq;
   1.117 +    static nsIRDFResource* kRDF_Alt;
   1.118 +    static nsIRDFContainerUtils* gRDFC;
   1.119 +};
   1.120 +
   1.121 +#endif // nsRDFXMLSerializer_h__

mercurial