]> git.cworth.org Git - apitrace/blob - trace_parser.hpp
Fix a few more arrays args in D3D9.
[apitrace] / trace_parser.hpp
1 /**************************************************************************
2  *
3  * Copyright 2010 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 #ifndef _TRACE_PARSER_HPP_
27 #define _TRACE_PARSER_HPP_
28
29
30 #include <iostream>
31 #include <map>
32 #include <list>
33 #include <string>
34
35 #include "trace_format.hpp"
36 #include "trace_model.hpp"
37
38
39 namespace Trace {
40
41
42 class Parser
43 {
44 protected:
45     void *file;
46
47     typedef std::list<Call *> CallList;
48     CallList calls;
49
50     typedef std::vector<Call::Signature *> FunctionMap;
51     FunctionMap functions;
52
53     typedef std::vector<Struct::Signature *> StructMap;
54     StructMap structs;
55
56     typedef std::vector<Enum::Signature *> EnumMap;
57     EnumMap enums;
58
59     typedef std::vector<Bitmask::Signature *> BitmaskMap;
60     BitmaskMap bitmasks;
61
62     unsigned next_call_no;
63
64 public:
65     static unsigned long long version;
66
67     Parser();
68
69     ~Parser();
70
71     bool open(const char *filename);
72
73     void close(void);
74
75     Call *parse_call(void);
76
77 protected:
78     void parse_enter(void);
79
80     Call *parse_leave(void);
81
82     void parse_call_details(Call *call);
83
84     void parse_arg(Call *call);
85
86     Value *parse_value(void);
87
88     Value *parse_sint();
89
90     Value *parse_uint();
91
92     Value *parse_float();
93
94     Value *parse_double();
95
96     Value *parse_string();
97
98     Value *parse_enum();
99
100     Value *parse_bitmask();
101
102     Value *parse_array(void);
103
104     Value *parse_blob(void);
105
106     Value *parse_struct();
107
108     Value *parse_opaque();
109
110     std::string read_string(void);
111
112     unsigned long long read_uint(void);
113
114     inline int read_byte(void);
115 };
116
117
118 } /* namespace Trace */
119
120 #endif /* _TRACE_PARSER_HPP_ */