cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
xml_interface.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: XML Interface
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
11
12
#include "
xml_interface.h
"
13
14
#include <iostream>
15
16
#include <
util/cmdline.h
>
17
#include <
util/exception_utils.h
>
18
#include <
util/message.h
>
19
20
#include <
xmllang/xml_parser.h
>
21
23
static
void
get_xml_options
(
const
xmlt
&
xml
,
cmdlinet
&cmdline)
24
{
25
for
(
const
auto
&e :
xml
.elements)
26
{
27
// recursive call
28
get_xml_options
(e, cmdline);
29
}
30
31
if
(
xml
.name ==
"valueOption"
)
32
{
33
std::string name =
xml
.get_attribute(
"name"
);
34
std::string value =
xml
.get_attribute(
"actual"
);
35
36
if
(name.empty())
37
cmdline.
args
.push_back(value);
38
else
39
cmdline.
set
(name, value);
40
}
41
else
if
(
xml
.name ==
"flagOption"
)
42
{
43
cmdline.
set
(
xml
.get_attribute(
"name"
),
xml
.get_attribute(
"actual"
) ==
"on"
);
44
}
45
}
46
47
void
xml_interface
(
cmdlinet
&cmdline,
message_handlert
&message_handler)
48
{
49
if
(cmdline.
isset
(
"xml-interface"
))
50
{
51
xmlt
xml
;
52
53
parse_xml
(std::cin,
""
, message_handler,
xml
);
54
55
// We have to catch here because command line options are
56
// parsed in the constructor of parse_optionst and not in main()
57
try
58
{
59
get_xml_options
(
xml
, cmdline);
60
61
// Add this so that it gets propagated into optionst;
62
// the ui_message_handlert::uit has already been set on the basis
63
// of the xml-interface flag.
64
cmdline.
set
(
"xml-ui"
);
65
}
66
catch
(
const
invalid_command_line_argument_exceptiont
&e)
67
{
68
messaget
log(message_handler);
69
log.
error
() << e.
what
() <<
messaget::eom
;
70
71
// make sure we fail with a usage error
72
cmdline.
clear
();
73
}
74
}
75
}
cmdlinet
Definition
cmdline.h:20
cmdlinet::isset
virtual bool isset(char option) const
Definition
cmdline.cpp:30
cmdlinet::args
argst args
Definition
cmdline.h:154
cmdlinet::set
virtual void set(const std::string &option, bool value=true)
Set option option to value, or true if the value is omitted.
Definition
cmdline.cpp:63
cmdlinet::clear
virtual void clear()
Definition
cmdline.cpp:24
invalid_command_line_argument_exceptiont
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
Definition
exception_utils.h:51
invalid_command_line_argument_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition
exception_utils.cpp:17
message_handlert
Definition
message.h:27
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition
message.h:154
messaget::error
mstreamt & error() const
Definition
message.h:391
messaget::eom
static eomt eom
Definition
message.h:289
xmlt
Definition
xml.h:21
cmdline.h
exception_utils.h
xml
xmlt xml(const irep_idt &property_id, const property_infot &property_info)
Definition
properties.cpp:110
message.h
xml_interface
void xml_interface(cmdlinet &cmdline, message_handlert &message_handler)
Parse XML-formatted commandline options from stdin.
Definition
xml_interface.cpp:47
get_xml_options
static void get_xml_options(const xmlt &xml, cmdlinet &cmdline)
Parse commandline options from xml into cmdline.
Definition
xml_interface.cpp:23
xml_interface.h
XML Interface.
parse_xml
bool parse_xml(std::istream &in, const std::string &filename, message_handlert &message_handler, xmlt &dest)
Definition
xml_parser.cpp:29
xml_parser.h
xmllang
xml_interface.cpp
Generated by
1.17.0