Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
423b2109
Commit
423b2109
authored
7 years ago
by
Markus Frank
Committed by
MarkusFrankATcernch
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add possibility to parse XML from string. Imporve DDCond manual. Start to adapt DDAlign manual
parent
f44eea72
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DDCore/src/XML/DocumentHandler.cpp
+33
-13
33 additions, 13 deletions
DDCore/src/XML/DocumentHandler.cpp
with
33 additions
and
13 deletions
DDCore/src/XML/DocumentHandler.cpp
+
33
−
13
View file @
423b2109
...
...
@@ -527,20 +527,40 @@ Document DocumentHandler::parse(const char* bytes, size_t /* length */, const ch
"[URI Resolution is not supported by TiXML]"
);
}
TiXmlDocument
*
doc
=
new
TiXmlDocument
();
try
{
if
(
0
==
doc
->
Parse
(
bytes
)
)
{
return
(
XmlDocument
*
)
doc
;
}
if
(
doc
->
Error
()
)
{
printout
(
FATAL
,
"DocumentHandler"
,
"+++ Error (TinyXML) while parsing XML string [%s]"
,
doc
->
ErrorDesc
());
printout
(
FATAL
,
"DocumentHandler"
,
"+++ XML Document error: %s Location Line:%d Column:%d"
,
doc
->
Value
(),
doc
->
ErrorRow
(),
doc
->
ErrorCol
());
throw
runtime_error
(
string
(
"dd4hep: "
)
+
doc
->
ErrorDesc
());
try
{
if
(
bytes
)
{
size_t
len
=
::
strlen
(
bytes
);
// TiXml does not support white spaces at the end. Check and remove.
if
(
bytes
[
len
-
1
]
!=
0
||
::
isspace
(
bytes
[
len
-
2
])
)
{
char
*
buff
=
new
char
[
len
+
1
];
try
{
::
memcpy
(
buff
,
bytes
,
len
+
1
);
buff
[
len
]
=
0
;
for
(
size_t
i
=
len
-
1
;
::
isspace
(
buff
[
i
]);
--
i
)
buff
[
i
]
=
0
;
if
(
0
==
doc
->
Parse
(
buff
)
)
{
delete
[]
buff
;
return
(
XmlDocument
*
)
doc
;
}
}
catch
(...)
{
}
delete
[]
buff
;
}
if
(
0
==
doc
->
Parse
(
bytes
)
)
{
return
(
XmlDocument
*
)
doc
;
}
if
(
doc
->
Error
()
)
{
printout
(
FATAL
,
"DocumentHandler"
,
"+++ Error (TinyXML) while parsing XML string [%s]"
,
doc
->
ErrorDesc
());
printout
(
FATAL
,
"DocumentHandler"
,
"+++ XML Document error: %s Location Line:%d Column:%d"
,
doc
->
Value
(),
doc
->
ErrorRow
(),
doc
->
ErrorCol
());
throw
runtime_error
(
string
(
"dd4hep: "
)
+
doc
->
ErrorDesc
());
}
throw
runtime_error
(
"dd4hep: Unknown error while parsing XML document string with TiXml."
);
}
throw
runtime_error
(
"dd4hep:
Unknown error while parsing XML document
with TiXml."
);
throw
runtime_error
(
"dd4hep:
FAILED to parse invalid document string [NULL]
with TiXml."
);
}
catch
(
exception
&
e
)
{
printout
(
ERROR
,
"DocumentHandler"
,
"+++ Exception (TinyXML): parse(string):%s"
,
e
.
what
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment