debian: added giffgaff chatscripts
[barry.git] / src / dp_codinfo.h
blobfd5bcb0a2ee56648858af1ffac83d0bdae6dacd1
1 ///
2 /// \file dp_codinfo.h
3 /// Debug file parsing
4 ///
6 /*
7 Copyright (C) 2009, Nicolas VIVIEN
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRYJDG_CODINFO_H__
23 #define __BARRYJDG_CODINFO_H__
26 #include "dll.h"
27 #include <iosfwd>
28 #include <string>
29 #include <vector>
30 #include <stdint.h>
33 namespace Barry {
35 namespace JDG {
38 class BXEXPORT DebugFileEntry
40 private:
41 protected:
43 public:
44 std::string fileName;
45 std::string appName;
46 uint32_t uniqueId;
48 void Dump(std::ostream &os) const;
52 class BXEXPORT DebugFileList : public std::vector<DebugFileEntry>
54 public:
55 typedef std::vector<DebugFileEntry> base_type;
56 typedef base_type::iterator iterator;
57 typedef base_type::const_iterator const_iterator;
59 public:
60 void AddElement(uint32_t uniqueid, const std::string &appname, const std::string &filename);
61 void Dump(std::ostream &os) const;
63 inline std::ostream& operator<<(std::ostream &os, const DebugFileList &list) {
64 list.Dump(os);
65 return os;
69 class BXEXPORT ClassEntry
71 private:
72 protected:
74 public:
75 // For JDB
76 int index;
78 // Read from the ".debug" file
79 std::string className;
80 std::string classPath;
81 std::string sourceFile;
83 uint32_t type;
84 uint32_t unknown02;
85 uint32_t unknown03;
86 uint32_t id;
87 uint32_t unknown05;
88 uint32_t unknown06;
89 uint32_t unknown07;
90 uint32_t unknown08;
92 std::string GetFullClassName() { return classPath + "." + className; };
96 class BXEXPORT ClassList : public std::vector<ClassEntry>
98 public:
99 typedef std::vector<ClassEntry> base_type;
100 typedef base_type::iterator iterator;
101 typedef base_type::const_iterator const_iterator;
103 public:
104 void CreateDefaultEntries();
111 class BXEXPORT CodInfo
113 private:
114 uint32_t ParseNextHeaderField(std::istream &input);
115 uint32_t ParseNextTypeField(std::istream &input);
117 void ParseAppName(std::istream &input);
118 void ParseUniqueId(std::istream &input);
120 void ParseBoolean(std::istream &input);
121 void ParseByte(std::istream &input);
122 void ParseChar(std::istream &input);
123 void ParseShort(std::istream &input);
124 void ParseInt(std::istream &input);
125 void ParseLong(std::istream &input);
126 void ParseClass(std::istream &input);
127 void ParseArray(std::istream &input);
128 void ParseVoid(std::istream &input);
129 void ParseDouble(std::istream &input);
131 protected:
133 public:
134 uint32_t uniqueId;
135 std::string appName;
136 ClassList classList;
138 bool LoadDebugFile(const char *filename);
140 void ParseHeaderSection(std::istream &input);
141 void ParseTypeSection(std::istream &input);
142 void ParseResourceSection(std::istream &input);
144 uint32_t GetUniqueId();
145 std::string GetAppName();
149 BXEXPORT void SearchDebugFile(DebugFileList &list);
150 BXEXPORT bool LoadDebugInfo(const DebugFileList &list, const char *filename, CodInfo &info);
151 BXEXPORT bool LoadDebugInfo(const DebugFileList &list, const uint32_t uniqueId, const std::string module, CodInfo &info);
154 } // namespace JDG
156 } // namespace Barry
159 #endif