Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2ed1c222
Commit
2ed1c222
authored
Jan 09, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ExpatParser: add helper class CommonExpatParser
parent
eb23ef17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
Expat.hxx
src/Expat.hxx
+48
-0
No files found.
src/Expat.hxx
View file @
2ed1c222
...
...
@@ -60,4 +60,52 @@ private:
void
SetError
(
Error
&
error
);
};
/**
* A specialization of #ExpatParser that provides the most common
* callbacks as virtual methods.
*/
class
CommonExpatParser
{
ExpatParser
parser
;
public
:
CommonExpatParser
()
:
parser
(
this
)
{
parser
.
SetElementHandler
(
StartElement
,
EndElement
);
parser
.
SetCharacterDataHandler
(
CharacterData
);
}
bool
Parse
(
InputStream
&
is
,
Error
&
error
)
{
return
parser
.
Parse
(
is
,
error
);
}
gcc_pure
static
const
char
*
GetAttributeCase
(
const
XML_Char
**
atts
,
const
char
*
name
)
{
return
ExpatParser
::
GetAttributeCase
(
atts
,
name
);
}
protected
:
virtual
void
StartElement
(
const
XML_Char
*
name
,
const
XML_Char
**
atts
)
=
0
;
virtual
void
EndElement
(
const
XML_Char
*
name
)
=
0
;
virtual
void
CharacterData
(
const
XML_Char
*
s
,
int
len
)
=
0
;
private
:
static
void
XMLCALL
StartElement
(
void
*
user_data
,
const
XML_Char
*
name
,
const
XML_Char
**
atts
)
{
CommonExpatParser
&
p
=
*
(
CommonExpatParser
*
)
user_data
;
p
.
StartElement
(
name
,
atts
);
}
static
void
XMLCALL
EndElement
(
void
*
user_data
,
const
XML_Char
*
name
)
{
CommonExpatParser
&
p
=
*
(
CommonExpatParser
*
)
user_data
;
p
.
EndElement
(
name
);
}
static
void
XMLCALL
CharacterData
(
void
*
user_data
,
const
XML_Char
*
s
,
int
len
)
{
CommonExpatParser
&
p
=
*
(
CommonExpatParser
*
)
user_data
;
p
.
CharacterData
(
s
,
len
);
}
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment