e8f24d2d25dbd946bf351b063ace27bf555d995e
1 /**
2 * Copyright (C) ARM Limited 2011-2012. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #include <string.h>
10 #include <stdlib.h>
11 #include <limits.h>
12 #include "RequestXML.h"
13 #include "Logging.h"
15 extern void handleException();
17 static const char* TAG_REQUEST = "request";
19 static const char* ATTR_PROTOCOL = "protocol";
20 static const char* ATTR_EVENTS = "events";
21 static const char* ATTR_CONFIGURATION = "configuration";
22 static const char* ATTR_COUNTERS = "counters";
23 static const char* ATTR_SESSION = "session";
24 static const char* ATTR_CAPTURED = "captured";
25 static const char* ATTR_DEFAULTS = "defaults";
27 RequestXML::RequestXML(const char * str) {
28 parameters.protocol = false;
29 parameters.events = false;
30 parameters.configuration = false;
31 parameters.counters = false;
32 parameters.session = false;
33 parameters.captured = false;
34 parameters.defaults = false;
36 XMLReader reader(str);
37 char * tag = reader.nextTag();
38 while(tag != 0) {
39 if (strcmp(tag, TAG_REQUEST) == 0) {
40 requestTag(&reader);
41 return;
42 }
43 tag = reader.nextTag();
44 }
46 logg->logError(__FILE__, __LINE__, "No request tag found in the request.xml file");
47 handleException();
48 }
50 RequestXML::~RequestXML() {
51 }
53 void RequestXML::requestTag(XMLReader* in) {
54 parameters.protocol = in->getAttributeAsBoolean(ATTR_PROTOCOL, false);
55 parameters.events = in->getAttributeAsBoolean(ATTR_EVENTS, false);
56 parameters.configuration = in->getAttributeAsBoolean(ATTR_CONFIGURATION, false);
57 parameters.counters = in->getAttributeAsBoolean(ATTR_COUNTERS, false);
58 parameters.session = in->getAttributeAsBoolean(ATTR_SESSION, false);
59 parameters.captured = in->getAttributeAsBoolean(ATTR_CAPTURED, false);
60 parameters.defaults = in->getAttributeAsBoolean(ATTR_DEFAULTS, false);
61 }