-
Notifications
You must be signed in to change notification settings - Fork 10
/
dbGDS2Dumper.h
134 lines (107 loc) · 2.94 KB
/
dbGDS2Dumper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
KLayout Layout Viewer
Copyright (C) 2013-2018 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_dbGDS2Dumper
#define HDR_dbGDS2Dumper
#include "tlException.h"
#include "tlStream.h"
#include "dbTypes.h"
#include "dbPoint.h"
#include <map>
#include <set>
#include <stdint.h>
namespace db
{
class RecordDefinition;
/**
* @brief Generic base class of GDS2 reader exceptions
*/
class KLAYOUT_DLL GDS2DumperException
: public tl::Exception
{
public:
GDS2DumperException (const std::string &msg, size_t p, const std::string &cell)
: tl::Exception (tl::sprintf (tl::translate ("%s (position=%ld, cell=%s)"), msg, p, cell))
{ }
};
/**
* @brief The GDS2 format stream reader
*/
class KLAYOUT_DLL GDS2Dumper
{
public:
/**
* @brief Construct a stream reader object
*
* @param s The stream delegate from which to read stream data from
*/
GDS2Dumper (tl::InputStreamBase &s);
/**
* @brief Destructor
*/
~GDS2Dumper ();
/**
* @brief Set short mode
*/
void short_mode (bool s)
{
m_short_mode = s;
}
/**
* @brief Set the number of bytes to show per line
*/
void set_width (size_t w)
{
m_width = w;
}
/**
* @brief The basic dumper method
*/
void dump ();
/**
* @brief Issue an error with positional informations
*
* Reimplements GDS2Diagnostics
*/
void error (const std::string &txt);
/**
* @brief Issue a warning with positional informations
*
* Reimplements GDS2Diagnostics
*/
void warn (const std::string &txt);
// public dumper targets
void header (const RecordDefinition *record_def, uint16_t len);
void layer (const RecordDefinition *record_def, uint16_t len);
void datatype (const RecordDefinition *record_def, uint16_t len);
void timestamp (const RecordDefinition *record_def, uint16_t len);
void xy (const RecordDefinition *record_def, uint16_t len);
void generic (const RecordDefinition *record_def, uint16_t len);
private:
tl::InputStream m_stream;
size_t m_last_emit;
size_t m_width;
bool m_short_mode;
void emit (const std::string &msg);
int32_t get_int32 ();
uint32_t get_uint32 ();
int16_t get_int16 ();
uint16_t get_uint16 ();
uint8_t get_uint8 ();
std::string get_str (uint32_t len);
double get_double ();
};
}
#endif