COPASI API  4.16.103
CRDFParser.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/MIRIAM/CRDFParser.h,v $
3 // $Revision: 1.6 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2009/04/21 16:16:41 $
7 // End CVS Header
8 
9 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
11 // and The University of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 #ifndef COPASI_CRDFParser
19 #define COPASI_CRDFParser
20 
21 #include <raptor.h>
22 
23 #include <iostream>
24 
26 
27 class CRDFGraph;
28 
29 class CRDFParser : private CRaptorInit
30 {
31  // Methods
32 public:
33  /**
34  * Convert an RDF/XML syntax string to an RDF Graph. If the conversion fails a
35  * NULL pointer is returned. Otherwise a pointer to the resulting graph is
36  * returned. It is the responsibility of the caller to destroy the created graph.
37  * @param const std::string & xml
38  * @return CRDFGraph * graphFromXml
39  */
40  static CRDFGraph * graphFromXml(const std::string & xml);
41 
42  /**
43  * Default Constructor
44  */
45  CRDFParser();
46 
47  /**
48  * Destructor
49  */
50  ~CRDFParser();
51 
52  /**
53  * Parse the stream. If the parsing fails a NULL pointer is returned. Otherwise
54  * a pointer to the resulting graph is returned. It is the responsibility of the
55  * caller to destroy the created graph.
56  * &param std::istream & stream
57  * @return CRDFGraph * pGraph
58  */
59  CRDFGraph * parse(std::istream & stream);
60 
61  /**
62  * A static handler to interface with the C parser library. This is called
63  * whenever an RDF triple is created. Its only purpose is to add the triple
64  * to the graph which must provide addTriplet(CRDFSubject, std::string, CRDFObject);
65  * @param void * pGraph
66  * @param const raptor_statement * pTriple
67  */
68  static void TripleHandler(void * pGraph, const raptor_statement * pTriple);
69 
70  /**
71  * A static handler to interface with the C parser library. This is called
72  * whenever a namespace is declared.
73  * @param void * pGraph
74  * @param raptor_namespace * pNameSpace
75  */
76  static void NameSpaceHandler(void * pGraph, raptor_namespace * pNameSpace);
77 
78  /**
79  * A static handler to interface with the C parser library. This is called
80  * whenever a node id needs to be generated.
81  * @param void * pGraph
82  * @param raptor_genid_type type
83  * @param unsigned char * userNodeId
84  * @return unsigned char * generatedId
85  */
86  static unsigned char * GenerateIdHandler(void * pGraph,
87  raptor_genid_type type,
88  unsigned char * userNodeId);
89 
90  /**
91  * A static handler to interface with the C parser library. This is called
92  * whenever the parser encounters a fatal error;
93  * @param void * userdata (ignored)
94  * @param raptor_locator * pLocator
95  * @param const char * message
96  */
97  static void FatalErrorHandler(void *, raptor_locator * pLocator, const char * message);
98 
99  /**
100  * A static handler to interface with the C parser library. This is called
101  * whenever the parser encounters an error;
102  * @param void * userdata (ignored)
103  * @param raptor_locator * pLocator
104  * @param const char * message
105  */
106  static void ErrorHandler(void *, raptor_locator * pLocator, const char * message);
107 
108  /**
109  * A static handler to interface with the C parser library. This is called
110  * whenever the parser encounters a warning;
111  * @param void * userdata (ignored)
112  * @param raptor_locator * pLocator
113  * @param const char * message
114  */
115  static void WarningHandler(void *, raptor_locator * pLocator, const char * message);
116 
117  // Attributes
118 private:
119  /**
120  * Pointer to the underlying C parser from the Raptor library
121  */
122  raptor_parser * mpParser;
123 };
124 
125 #endif // COPASI_CRDFParser
static void TripleHandler(void *pGraph, const raptor_statement *pTriple)
Definition: CRDFParser.cpp:121
static void NameSpaceHandler(void *pGraph, raptor_namespace *pNameSpace)
Definition: CRDFParser.cpp:199
static void ErrorHandler(void *, raptor_locator *pLocator, const char *message)
Definition: CRDFParser.cpp:241
static void WarningHandler(void *, raptor_locator *pLocator, const char *message)
Definition: CRDFParser.cpp:250
CRDFGraph * parse(std::istream &stream)
Definition: CRDFParser.cpp:57
raptor_parser * mpParser
Definition: CRDFParser.h:122
static void FatalErrorHandler(void *, raptor_locator *pLocator, const char *message)
Definition: CRDFParser.cpp:232
static CRDFGraph * graphFromXml(const std::string &xml)
Definition: CRDFParser.cpp:30
static unsigned char * GenerateIdHandler(void *pGraph, raptor_genid_type type, unsigned char *userNodeId)
Definition: CRDFParser.cpp:217