Skip to content

Commit 8e95b25

Browse files
compiler/cpp/src/generate/t_json_generator: namespace the output
1 parent 337a8e1 commit 8e95b25

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

compiler/cpp/src/generate/t_json_generator.cc

+13-2
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,20 @@ class t_json_generator : public t_generator {
130130
};
131131

132132
void t_json_generator::init_generator() {
133-
MKDIR(get_out_dir().c_str());
133+
string subdir = get_out_dir();
134134

135-
string f_json_name = get_out_dir() + program_->get_name() + ".json";
135+
MKDIR(subdir.c_str());
136+
137+
std::string dir = program_->get_namespace("json");
138+
string::size_type loc;
139+
140+
while ((loc = dir.find(".")) != string::npos) {
141+
subdir = subdir + underscore(dir.substr(0, loc)) + "/";
142+
MKDIR(subdir.c_str());
143+
dir = dir.substr(loc + 1);
144+
}
145+
146+
string f_json_name = subdir + program_->get_name() + ".json";
136147
f_json_.open(f_json_name.c_str());
137148

138149
// Merge all included programs into this one so we can output one big file.

0 commit comments

Comments
 (0)