1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsRDFXMLSerializer_h__
#define nsRDFXMLSerializer_h__
#include "nsIRDFLiteral.h"
#include "nsIRDFXMLSerializer.h"
#include "nsIRDFXMLSource.h"
#include "nsNameSpaceMap.h"
#include "nsXPIDLString.h"
#include "nsDataHashtable.h"
#include "rdfITripleVisitor.h"
class nsIOutputStream;
class nsIRDFContainerUtils;
/**
* A helper class that can serialize RDF/XML from a
* datasource. Implements both nsIRDFXMLSerializer and
* nsIRDFXMLSource.
*/
class nsRDFXMLSerializer : public nsIRDFXMLSerializer,
public nsIRDFXMLSource
{
public:
static nsresult
Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
NS_DECL_ISUPPORTS
NS_DECL_NSIRDFXMLSERIALIZER
NS_DECL_NSIRDFXMLSOURCE
protected:
nsRDFXMLSerializer();
virtual ~nsRDFXMLSerializer();
// Implementation methods
nsresult
RegisterQName(nsIRDFResource* aResource);
nsresult
GetQName(nsIRDFResource* aResource, nsCString& aQName);
already_AddRefed<nsIAtom>
EnsureNewPrefix();
nsresult
SerializeInlineAssertion(nsIOutputStream* aStream,
nsIRDFResource* aResource,
nsIRDFResource* aProperty,
nsIRDFLiteral* aValue);
nsresult
SerializeChildAssertion(nsIOutputStream* aStream,
nsIRDFResource* aResource,
nsIRDFResource* aProperty,
nsIRDFNode* aValue);
nsresult
SerializeProperty(nsIOutputStream* aStream,
nsIRDFResource* aResource,
nsIRDFResource* aProperty,
bool aInline,
int32_t* aSkipped);
bool
IsContainerProperty(nsIRDFResource* aProperty);
nsresult
SerializeDescription(nsIOutputStream* aStream,
nsIRDFResource* aResource);
nsresult
SerializeMember(nsIOutputStream* aStream,
nsIRDFResource* aContainer,
nsIRDFNode* aMember);
nsresult
SerializeContainer(nsIOutputStream* aStream,
nsIRDFResource* aContainer);
nsresult
SerializePrologue(nsIOutputStream* aStream);
nsresult
SerializeEpilogue(nsIOutputStream* aStream);
nsresult
CollectNamespaces();
bool
IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType);
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsNameSpaceMap mNameSpaces;
nsXPIDLCString mBaseURLSpec;
// hash mapping resources to utf8-encoded QNames
nsDataHashtable<nsISupportsHashKey, nsCString> mQNames;
friend class QNameCollector;
uint32_t mPrefixID;
static int32_t gRefCnt;
static nsIRDFResource* kRDF_instanceOf;
static nsIRDFResource* kRDF_type;
static nsIRDFResource* kRDF_nextVal;
static nsIRDFResource* kRDF_Bag;
static nsIRDFResource* kRDF_Seq;
static nsIRDFResource* kRDF_Alt;
static nsIRDFContainerUtils* gRDFC;
};
#endif // nsRDFXMLSerializer_h__
|