Skip to content

Commit 7e5bf13

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Avoid json.h include in message.h
message.h is frequently used, and not all users need to know about the jsont type hierarchy. Move the only function that requires knowing that a json_objectt is-a jsont to the cpp file.
1 parent 86a595a commit 7e5bf13

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/util/message.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, [email protected]
99

1010
#include "message.h"
1111

12+
#include "json.h"
1213
#include "string2int.h"
1314

1415
void message_handlert::print(
@@ -140,3 +141,14 @@ void messaget::conditional_output(
140141
output_generator(mstream);
141142
}
142143
}
144+
145+
messaget::mstreamt &messaget::mstreamt::operator<<(const json_objectt &data)
146+
{
147+
if(this->tellp() > 0)
148+
*this << eom; // force end of previous message
149+
if(message.message_handler)
150+
{
151+
message.message_handler->print(message_level, data);
152+
}
153+
return *this;
154+
}

src/util/message.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include "deprecate.h"
1919
#include "invariant.h"
20-
#include "json.h"
2120
#include "source_location.h"
2221

22+
class json_objectt;
23+
class jsont;
2324
class xmlt;
2425

2526
class message_handlert
@@ -248,16 +249,7 @@ class messaget
248249
return *this;
249250
}
250251

251-
mstreamt &operator << (const json_objectt &data)
252-
{
253-
if(this->tellp() > 0)
254-
*this << eom; // force end of previous message
255-
if(message.message_handler)
256-
{
257-
message.message_handler->print(message_level, data);
258-
}
259-
return *this;
260-
}
252+
mstreamt &operator<<(const json_objectt &data);
261253

262254
template <class T>
263255
mstreamt &operator << (const T &x)

0 commit comments

Comments
 (0)