THRIFT-5766 Replace std::endl with "\n"
Patch: Carel Combrink
This closes #2943
diff --git a/compiler/cpp/src/thrift/generate/go_validator_generator.cc b/compiler/cpp/src/thrift/generate/go_validator_generator.cc
index 1f5a3ad..0adff2e 100644
--- a/compiler/cpp/src/thrift/generate/go_validator_generator.cc
+++ b/compiler/cpp/src/thrift/generate/go_validator_generator.cc
@@ -82,19 +82,19 @@
}
if (type->is_enum()) {
if (context.tgt[0] == '*') {
- out << indent() << "if " << context.tgt.substr(1) << " != nil {" << endl;
+ out << indent() << "if " << context.tgt.substr(1) << " != nil {" << '\n';
indent_up();
}
generate_enum_field_validator(out, context);
if (context.tgt[0] == '*') {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
return;
} else if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
if (context.tgt[0] == '*') {
- out << indent() << "if " << context.tgt.substr(1) << " != nil {" << endl;
+ out << indent() << "if " << context.tgt.substr(1) << " != nil {" << '\n';
indent_up();
}
switch (tbase) {
@@ -119,7 +119,7 @@
}
if (context.tgt[0] == '*') {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
return;
} else if (type->is_list()) {
@@ -146,7 +146,7 @@
if (key == "vt.in") {
if (values.size() > 1) {
std::string exist = GenID("_exist");
- out << indent() << "var " << exist << " bool" << endl;
+ out << indent() << "var " << exist << " bool" << '\n';
std::string src = GenID("_src");
out << indent() << src << " := []int64{";
@@ -162,19 +162,19 @@
}
out << ")";
}
- out << "}" << endl;
+ out << "}" << '\n';
- out << indent() << "for _, src := range " << src << " {" << endl;
+ out << indent() << "for _, src := range " << src << " {" << '\n';
indent_up();
- out << indent() << "if int64(" << context.tgt << ") == src {" << endl;
+ out << indent() << "if int64(" << context.tgt << ") == src {" << '\n';
indent_up();
- out << indent() << exist << " = true" << endl;
- out << indent() << "break" << endl;
+ out << indent() << exist << " = true" << '\n';
+ out << indent() << "break" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "if " << exist << " == false {" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "if " << exist << " == false {" << '\n';
} else {
out << indent() << "if int64(" << context.tgt << ") != int64(";
if (values[0]->is_field_reference()) {
@@ -182,18 +182,18 @@
} else {
out << values[0]->get_enum()->get_value();
}
- out << ") {" << endl;
+ out << ") {" << '\n';
}
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.in\", \""
<< context.field_symbol << "\", \"" << context.field_symbol
- << " not valid, rule vt.in check failed\")" << endl;
+ << " not valid, rule vt.in check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (values.size() > 1) {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
} else if (key == "vt.not_in") {
if (values.size() > 1) {
@@ -211,11 +211,11 @@
}
out << ")";
}
- out << "}" << endl;
+ out << "}" << '\n';
- out << indent() << "for _, src := range " << src << " {" << endl;
+ out << indent() << "for _, src := range " << src << " {" << '\n';
indent_up();
- out << indent() << "if int64(" << context.tgt << ") == src {" << endl;
+ out << indent() << "if int64(" << context.tgt << ") == src {" << '\n';
} else {
out << indent() << "if int64(" << context.tgt << ") == ";
out << "int64(";
@@ -224,18 +224,18 @@
} else {
out << values[0]->get_enum()->get_value();
}
- out << ") {" << endl;
+ out << ") {" << '\n';
}
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.not_in\", \""
<< context.field_symbol << "\", \"" << context.field_symbol
- << " not valid, rule vt.not_in check failed\")" << endl;
+ << " not valid, rule vt.not_in check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (values.size() > 1) {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
} else if (key == "vt.defined_only") {
if (values[0]->get_bool()) {
@@ -243,14 +243,14 @@
} else {
continue;
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \""
<< context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key
- << " check failed\")" << endl;
+ << " check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
}
@@ -276,14 +276,14 @@
}
}
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \""
<< context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key
- << " check failed\")" << endl;
+ << " check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
@@ -308,19 +308,19 @@
} else {
out << values[0]->get_double();
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \""
<< context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key
- << " check failed\")" << endl;
+ << " check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
continue;
} else if (key == "vt.in") {
if (values.size() > 1) {
std::string exist = GenID("_exist");
- out << indent() << "var " << exist << " bool" << endl;
+ out << indent() << "var " << exist << " bool" << '\n';
std::string src = GenID("_src");
out << indent() << src << " := []float64{";
@@ -334,19 +334,19 @@
out << (*it)->get_double();
}
}
- out << "}" << endl;
+ out << "}" << '\n';
- out << indent() << "for _, src := range " << src << " {" << endl;
+ out << indent() << "for _, src := range " << src << " {" << '\n';
indent_up();
- out << indent() << "if " << context.tgt << " == src {" << endl;
+ out << indent() << "if " << context.tgt << " == src {" << '\n';
indent_up();
- out << indent() << exist << " = true" << endl;
- out << indent() << "break" << endl;
+ out << indent() << exist << " = true" << '\n';
+ out << indent() << "break" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "if " << exist << " == false {" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "if " << exist << " == false {" << '\n';
} else {
out << indent() << "if " << context.tgt << " != ";
if (values[0]->is_field_reference()) {
@@ -354,16 +354,16 @@
} else {
out << values[0]->get_double();
}
- out << "{" << endl;
+ out << "{" << '\n';
}
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.in\", \""
<< context.field_symbol << "\", \"" << context.field_symbol
- << " not valid, rule vt.in check failed\")" << endl;
+ << " not valid, rule vt.in check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else if (key == "vt.not_in") {
if (values.size() > 1) {
std::string src = GenID("_src");
@@ -378,11 +378,11 @@
out << (*it)->get_double();
}
}
- out << "}" << endl;
+ out << "}" << '\n';
- out << indent() << "for _, src := range " << src << " {" << endl;
+ out << indent() << "for _, src := range " << src << " {" << '\n';
indent_up();
- out << indent() << "if " << context.tgt << " == src {" << endl;
+ out << indent() << "if " << context.tgt << " == src {" << '\n';
} else {
out << indent() << "if " << context.tgt << " == ";
if (values[0]->is_field_reference()) {
@@ -390,18 +390,18 @@
} else {
out << values[0]->get_double();
}
- out << "{" << endl;
+ out << "{" << '\n';
}
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.not_in\", \""
<< context.field_symbol << "\", \"" << context.field_symbol
- << " not valid, rule vt.not_in check failed\")" << endl;
+ << " not valid, rule vt.not_in check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (values.size() > 1) {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
}
@@ -460,18 +460,18 @@
} else {
out << values[0]->get_int();
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \""
<< context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key
- << " check failed\")" << endl;
+ << " check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else if (key == "vt.in") {
if (values.size() > 1) {
std::string exist = GenID("_exist");
- out << indent() << "var " << exist << " bool" << endl;
+ out << indent() << "var " << exist << " bool" << '\n';
std::string src = GenID("_src");
out << indent() << src << " := []";
@@ -499,19 +499,19 @@
out << (*it)->get_int();
}
}
- out << "}" << endl;
+ out << "}" << '\n';
- out << indent() << "for _, src := range " << src << " {" << endl;
+ out << indent() << "for _, src := range " << src << " {" << '\n';
indent_up();
- out << indent() << "if " << context.tgt << " == src {" << endl;
+ out << indent() << "if " << context.tgt << " == src {" << '\n';
indent_up();
- out << indent() << exist << " = true" << endl;
- out << indent() << "break" << endl;
+ out << indent() << exist << " = true" << '\n';
+ out << indent() << "break" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "if " << exist << " == false {" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "if " << exist << " == false {" << '\n';
} else {
out << indent() << "if " << context.tgt << " != ";
if (values[0]->is_field_reference()) {
@@ -531,15 +531,15 @@
} else {
out << values[0]->get_int();
}
- out << "{" << endl;
+ out << "{" << '\n';
}
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.in\", \""
<< context.field_symbol << "\", \"" << context.field_symbol
- << " not valid, rule vt.in check failed\")" << endl;
+ << " not valid, rule vt.in check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else if (key == "vt.not_in") {
if (values.size() > 1) {
std::string src = GenID("_src");
@@ -584,11 +584,11 @@
out << (*it)->get_int();
}
}
- out << "}" << endl;
+ out << "}" << '\n';
- out << indent() << "for _, src := range " << src << " {" << endl;
+ out << indent() << "for _, src := range " << src << " {" << '\n';
indent_up();
- out << indent() << "if " << context.tgt << " == src {" << endl;
+ out << indent() << "if " << context.tgt << " == src {" << '\n';
} else {
out << indent() << "if " << context.tgt << " == ";
if (values[0]->is_field_reference()) {
@@ -608,18 +608,18 @@
} else {
out << values[0]->get_int();
}
- out << "{" << endl;
+ out << "{" << '\n';
}
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"vt.not_in\", \""
<< context.field_symbol << "\", \"" << context.field_symbol
- << " not valid, rule vt.not_in check failed\")" << endl;
+ << " not valid, rule vt.not_in check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (values.size() > 1) {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
}
@@ -635,7 +635,7 @@
if (type->is_binary()) {
target = GenID("_tgt");
out << indent() << target << " := "
- << "string(" << context.tgt << ")" << endl;
+ << "string(" << context.tgt << ")" << '\n';
}
for (auto it = context.rules.begin(); it != context.rules.end(); it++) {
const std::vector<validation_value*>& values = (*it)->get_values();
@@ -729,14 +729,14 @@
}
out << ")";
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \""
<< context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key
- << " check failed\")" << endl;
+ << " check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
@@ -764,19 +764,19 @@
} else {
out << values[0]->get_int();
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \""
<< context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key
- << " check failed\")" << endl;
+ << " check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else if (key == "vt.elem") {
- out << indent() << "for i := 0; i < len(" << context.tgt << ");i++ {" << endl;
+ out << indent() << "for i := 0; i < len(" << context.tgt << ");i++ {" << '\n';
indent_up();
std::string src = GenID("_elem");
- out << indent() << src << " := " << context.tgt << "[i]" << endl;
+ out << indent() << src << " := " << context.tgt << "[i]" << '\n';
t_type* elem_type;
if (context.type->is_list()) {
elem_type = ((t_list*)context.type)->get_elem_type();
@@ -791,7 +791,7 @@
std::vector<validation_rule*>{(*it)->get_inner()}};
generate_field_validator(out, ctx);
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
}
@@ -815,17 +815,17 @@
} else {
out << values[0]->get_int();
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
out << indent()
<< "return thrift.NewValidationException(thrift.VALIDATION_FAILED, \"" + key + "\", \""
<< context.field_symbol << "\", \"" << context.field_symbol << " not valid, rule " << key
- << " check failed\")" << endl;
+ << " check failed\")" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else if (key == "vt.key") {
std::string src = GenID("_key");
- out << indent() << "for " << src << " := range " << context.tgt << " {" << endl;
+ out << indent() << "for " << src << " := range " << context.tgt << " {" << '\n';
indent_up();
generator_context ctx{context.field_symbol + ".key",
"",
@@ -835,10 +835,10 @@
std::vector<validation_rule*>{(*it)->get_inner()}};
generate_field_validator(out, ctx);
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else if (key == "vt.value") {
std::string src = GenID("_value");
- out << indent() << "for _, " << src << " := range " << context.tgt << " {" << endl;
+ out << indent() << "for _, " << src << " := range " << context.tgt << " {" << '\n';
indent_up();
generator_context ctx{context.field_symbol + ".value",
"",
@@ -848,7 +848,7 @@
std::vector<validation_rule*>{(*it)->get_inner()}};
generate_field_validator(out, ctx);
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
}
@@ -875,31 +875,31 @@
}
if (generate_valid) {
if (last_valid_rule == nullptr) {
- out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << endl;
+ out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << '\n';
indent_up();
- out << indent() << "return err" << endl;
+ out << indent() << "return err" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else {
const std::vector<validation_value*>& values = last_valid_rule->get_values();
if (!values[0]->get_bool()) {
- out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << endl;
+ out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << '\n';
indent_up();
- out << indent() << "return err" << endl;
+ out << indent() << "return err" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else if (values[0]->is_field_reference()) {
out << indent() << "if !";
out << get_field_reference_name(values[0]->get_field_reference());
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
- out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << endl;
+ out << indent() << "if err := " << context.tgt << ".Validate(); err != nil {" << '\n';
indent_up();
- out << indent() << "return err" << endl;
+ out << indent() << "return err" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
index da25338..b5eb603 100644
--- a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
@@ -39,8 +39,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/* forward declarations */
string initial_caps_to_underscores(string name);
string underscores_to_initial_caps(string name);
@@ -241,18 +239,18 @@
f_types_impl_ << autogen_comment();
/* include inclusion guard */
- f_types_ << "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << "#define "
- << this->nspace_uc << program_name_uc << "_TYPES_H" << endl << endl;
+ f_types_ << "#ifndef " << this->nspace_uc << program_name_uc << "_TYPES_H" << '\n' << "#define "
+ << this->nspace_uc << program_name_uc << "_TYPES_H" << '\n' << '\n';
/* include base types */
- f_types_ << "/* base includes */" << endl << "#include <glib-object.h>" << endl
- << "#include <thrift/c_glib/thrift_struct.h>" << endl
- << "#include <thrift/c_glib/protocol/thrift_protocol.h>" << endl;
+ f_types_ << "/* base includes */" << '\n' << "#include <glib-object.h>" << '\n'
+ << "#include <thrift/c_glib/thrift_struct.h>" << '\n'
+ << "#include <thrift/c_glib/protocol/thrift_protocol.h>" << '\n';
/* include other thrift includes */
const vector<t_program*>& includes = program_->get_includes();
if (!includes.empty()) {
- f_types_ << "/* other thrift includes */" << endl;
+ f_types_ << "/* other thrift includes */" << '\n';
for (auto include : includes) {
const std::string& include_nspace = include->get_namespace("c_glib");
@@ -260,32 +258,32 @@
include_nspace.empty() ? "" : initial_caps_to_underscores(include_nspace) + "_";
f_types_ << "#include \"" << include_nspace_prefix
- << initial_caps_to_underscores(include->get_name()) << "_types.h\"" << endl;
+ << initial_caps_to_underscores(include->get_name()) << "_types.h\"" << '\n';
}
- f_types_ << endl;
+ f_types_ << '\n';
}
/* include custom headers */
const vector<string>& c_includes = program_->get_c_includes();
- f_types_ << "/* custom thrift includes */" << endl;
+ f_types_ << "/* custom thrift includes */" << '\n';
for (const auto & c_include : c_includes) {
if (c_include[0] == '<') {
- f_types_ << "#include " << c_include << endl;
+ f_types_ << "#include " << c_include << '\n';
} else {
- f_types_ << "#include \"" << c_include << "\"" << endl;
+ f_types_ << "#include \"" << c_include << "\"" << '\n';
}
}
- f_types_ << endl;
+ f_types_ << '\n';
/* include math.h (for "INFINITY") in the implementation file, in case we
encounter a struct with a member of type double */
- f_types_impl_ << endl << "#include <math.h>" << endl;
+ f_types_impl_ << '\n' << "#include <math.h>" << '\n';
// include the types file
- f_types_impl_ << endl << "#include \"" << this->nspace_lc << program_name_u << "_types.h\""
- << endl << "#include <thrift/c_glib/thrift.h>" << endl << endl;
+ f_types_impl_ << '\n' << "#include \"" << this->nspace_lc << program_name_u << "_types.h\""
+ << '\n' << "#include <thrift/c_glib/thrift.h>" << '\n' << '\n';
- f_types_ << "/* begin types */" << endl << endl;
+ f_types_ << "/* begin types */" << '\n' << '\n';
}
/**
@@ -295,7 +293,7 @@
string program_name_uc = to_upper_case(initial_caps_to_underscores(program_name_));
/* end the header inclusion guard */
- f_types_ << "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << endl;
+ f_types_ << "#endif /* " << this->nspace_uc << program_name_uc << "_TYPES_H */" << '\n';
/* close output file */
f_types_.close();
@@ -313,7 +311,7 @@
*/
void t_c_glib_generator::generate_typedef(t_typedef* ttypedef) {
f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << this->nspace
- << ttypedef->get_symbolic() << ";" << endl << endl;
+ << ttypedef->get_symbolic() << ";" << '\n' << '\n';
}
/**
@@ -336,7 +334,7 @@
string name = tenum->get_name();
string name_uc = to_upper_case(initial_caps_to_underscores(name));
- f_types_ << indent() << "enum _" << this->nspace << name << " {" << endl;
+ f_types_ << indent() << "enum _" << this->nspace << name << " {" << '\n';
indent_up();
@@ -349,7 +347,7 @@
if (first) {
first = false;
} else {
- f_types_ << "," << endl;
+ f_types_ << "," << '\n';
}
f_types_ << indent() << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name();
@@ -357,19 +355,19 @@
}
indent_down();
- f_types_ << endl << "};" << endl << "typedef enum _" << this->nspace << name << " "
- << this->nspace << name << ";" << endl << endl;
+ f_types_ << '\n' << "};" << '\n' << "typedef enum _" << this->nspace << name << " "
+ << this->nspace << name << ";" << '\n' << '\n';
- f_types_ << "/* return the name of the constant */" << endl;
- f_types_ << "const char *" << endl;
- f_types_ << "toString_" << name << "(int value); " << endl << endl;
+ f_types_ << "/* return the name of the constant */" << '\n';
+ f_types_ << "const char *" << '\n';
+ f_types_ << "toString_" << name << "(int value); " << '\n' << '\n';
;
- f_types_impl_ << "/* return the name of the constant */" << endl;
- f_types_impl_ << "const char *" << endl;
- f_types_impl_ << "toString_" << name << "(int value) " << endl;
- f_types_impl_ << "{" << endl;
- f_types_impl_ << " static __thread char buf[16] = {0};" << endl;
- f_types_impl_ << " switch(value) {" << endl;
+ f_types_impl_ << "/* return the name of the constant */" << '\n';
+ f_types_impl_ << "const char *" << '\n';
+ f_types_impl_ << "toString_" << name << "(int value) " << '\n';
+ f_types_impl_ << "{" << '\n';
+ f_types_impl_ << " static __thread char buf[16] = {0};" << '\n';
+ f_types_impl_ << " switch(value) {" << '\n';
std::set<int> done;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
@@ -379,20 +377,20 @@
f_types_impl_ << " case " << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
<< ":"
<< "return \"" << this->nspace_uc << name_uc << "_" << (*c_iter)->get_name()
- << "\";" << endl;
+ << "\";" << '\n';
}
}
- f_types_impl_ << " default: g_snprintf(buf, 16, \"%d\", value); return buf;" << endl;
- f_types_impl_ << " }" << endl;
- f_types_impl_ << "}" << endl << endl;
+ f_types_impl_ << " default: g_snprintf(buf, 16, \"%d\", value); return buf;" << '\n';
+ f_types_impl_ << " }" << '\n';
+ f_types_impl_ << "}" << '\n' << '\n';
}
/**
* Generates Thrift constants in C code.
*/
void t_c_glib_generator::generate_consts(vector<t_const*> consts) {
- f_types_ << "/* constants */" << endl;
- f_types_impl_ << "/* constants */" << endl;
+ f_types_ << "/* constants */" << '\n';
+ f_types_impl_ << "/* constants */" << '\n';
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -404,17 +402,17 @@
if (is_complex_type(type)) {
f_types_ << type_name(type) << indent() << this->nspace_lc << name_lc
- << "_constant();" << endl;
+ << "_constant();" << '\n';
}
f_types_ << indent() << "#define " << this->nspace_uc << name_uc << " "
- << constant_value(name_lc, type, value) << endl;
+ << constant_value(name_lc, type, value) << '\n';
generate_const_initializer(name_lc, type, value, true);
}
- f_types_ << endl;
- f_types_impl_ << endl;
+ f_types_ << '\n';
+ f_types_impl_ << '\n';
}
/**
@@ -439,7 +437,7 @@
* // ... additional GObject boilerplate ...
*/
void t_c_glib_generator::generate_struct(t_struct* tstruct) {
- f_types_ << "/* struct " << tstruct->get_name() << " */" << endl;
+ f_types_ << "/* struct " << tstruct->get_name() << " */" << '\n';
generate_object(tstruct);
}
@@ -463,21 +461,21 @@
f_header_ << autogen_comment();
// add an inclusion guard
- f_header_ << "#ifndef " << svcname_uc << "_H" << endl << "#define " << svcname_uc << "_H" << endl
- << endl;
+ f_header_ << "#ifndef " << svcname_uc << "_H" << '\n' << "#define " << svcname_uc << "_H" << '\n'
+ << '\n';
// add standard includes
- f_header_ << "#include <thrift/c_glib/processor/thrift_dispatch_processor.h>" << endl << endl;
- f_header_ << "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << endl;
+ f_header_ << "#include <thrift/c_glib/processor/thrift_dispatch_processor.h>" << '\n' << '\n';
+ f_header_ << "#include \"" << this->nspace_lc << program_name_lc << "_types.h\"" << '\n';
// if we are inheriting from another service, include its header
t_service* extends_service = tservice->get_extends();
if (extends_service != nullptr) {
f_header_ << "#include \"" << this->nspace_lc
<< to_lower_case(initial_caps_to_underscores(extends_service->get_name())) << ".h\""
- << endl;
+ << '\n';
}
- f_header_ << endl;
+ f_header_ << '\n';
// create the service implementation
string f_service_name = get_out_dir() + filename + ".c";
@@ -487,9 +485,9 @@
f_service_ << autogen_comment();
// include the headers
- f_service_ << "#include <string.h>" << endl << "#include <thrift/c_glib/thrift.h>" << endl
- << "#include <thrift/c_glib/thrift_application_exception.h>" << endl << "#include \""
- << filename << ".h\"" << endl << endl;
+ f_service_ << "#include <string.h>" << '\n' << "#include <thrift/c_glib/thrift.h>" << '\n'
+ << "#include <thrift/c_glib/thrift_application_exception.h>" << '\n' << "#include \""
+ << filename << ".h\"" << '\n' << '\n';
// generate the service-helper classes
generate_service_helpers(tservice);
@@ -501,7 +499,7 @@
generate_service_server(tservice);
// end the header inclusion guard
- f_header_ << "#endif /* " << svcname_uc << "_H */" << endl;
+ f_header_ << "#endif /* " << svcname_uc << "_H */" << '\n';
// close the files
f_service_.close();
@@ -519,27 +517,27 @@
generate_object(tstruct);
- f_types_ << "/* exception */" << endl
- << "typedef enum" << endl
- << "{" << endl;
+ f_types_ << "/* exception */" << '\n'
+ << "typedef enum" << '\n'
+ << "{" << '\n';
indent_up();
- f_types_ << indent() << this->nspace_uc << name_uc << "_ERROR_CODE" << endl;
+ f_types_ << indent() << this->nspace_uc << name_uc << "_ERROR_CODE" << '\n';
indent_down();
- f_types_ << "} " << this->nspace << name << "Error;" << endl
- << endl
+ f_types_ << "} " << this->nspace << name << "Error;" << '\n'
+ << '\n'
<< "GQuark " << this->nspace_lc << name_lc
- << "_error_quark (void);" << endl
+ << "_error_quark (void);" << '\n'
<< "#define " << this->nspace_uc << name_uc << "_ERROR ("
- << this->nspace_lc << name_lc << "_error_quark())" << endl
- << endl
- << endl;
+ << this->nspace_lc << name_lc << "_error_quark())" << '\n'
+ << '\n'
+ << '\n';
- f_types_impl_ << "/* define the GError domain for exceptions */" << endl << "#define "
+ f_types_impl_ << "/* define the GError domain for exceptions */" << '\n' << "#define "
<< this->nspace_uc << name_uc << "_ERROR_DOMAIN \"" << this->nspace_lc << name_lc
- << "_error_quark\"" << endl << "GQuark" << endl << this->nspace_lc << name_lc
- << "_error_quark (void)" << endl << "{" << endl
+ << "_error_quark\"" << '\n' << "GQuark" << '\n' << this->nspace_lc << name_lc
+ << "_error_quark (void)" << '\n' << "{" << '\n'
<< " return g_quark_from_static_string (" << this->nspace_uc << name_uc
- << "_ERROR_DOMAIN);" << endl << "}" << endl << endl;
+ << "_ERROR_DOMAIN);" << '\n' << "}" << '\n' << '\n';
}
/********************
@@ -983,12 +981,12 @@
ostringstream render;
if (is_numeric(etype)) {
render << " " << type_name(etype) << " *" << fname << " = "
- << "g_new (" << base_type_name(etype) << ", 1);" << endl
+ << "g_new (" << base_type_name(etype) << ", 1);" << '\n'
<< " *" << fname << " = " << constant_value(fname, (t_type*)etype, value) << ";"
- << endl;
+ << '\n';
} else {
render << " " << type_name(etype) << " " << fname << " = "
- << constant_value(fname, (t_type*)etype, value) << ";" << endl;
+ << constant_value(fname, (t_type*)etype, value) << ";" << '\n';
}
return render.str();
}
@@ -1037,22 +1035,22 @@
initializers << " constant->" << v_iter->first->get_string() << " = "
<< constant_value(name + "_constant_" + field_name,
field_type,
- v_iter->second) << ";" << endl
+ v_iter->second) << ";" << '\n'
<< " constant->__isset_" << v_iter->first->get_string()
- << " = TRUE;" << endl;
+ << " = TRUE;" << '\n';
}
// implement the initializer
f_types_impl_ << maybe_static << this->nspace << type->get_name() << " *"
- << endl
- << this->nspace_lc << name_lc << "_constant (void)" << endl;
+ << '\n'
+ << this->nspace_lc << name_lc << "_constant (void)" << '\n';
scope_up(f_types_impl_);
f_types_impl_ << indent() << "static " << this->nspace << type->get_name()
- << " *constant = NULL;" << endl
- << indent() << "if (constant == NULL)" << endl;
+ << " *constant = NULL;" << '\n'
+ << indent() << "if (constant == NULL)" << '\n';
scope_up(f_types_impl_);
f_types_impl_ << indent() << "constant = g_object_new (" << this->nspace_uc
- << "TYPE_" << type_uc << ", NULL);" << endl
+ << "TYPE_" << type_uc << ", NULL);" << '\n'
<< initializers.str();
scope_down(f_types_impl_);
@@ -1074,9 +1072,9 @@
field_name = tmp(field_name);
}
- f_types_impl_ << indent() << "return constant;" << endl;
+ f_types_impl_ << indent() << "return constant;" << '\n';
scope_down(f_types_impl_);
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
} else if (type->is_list()) {
string list_type = "GPtrArray *";
string free_func
@@ -1125,33 +1123,33 @@
if (list_variable) {
initializers << " " << type_name(etype) << " " << fname << " = "
<< constant_value(fname, (t_type*)etype, (*v_iter)) << ";"
- << endl;
+ << '\n';
appenders << " " << list_appender << "(constant, " << fname << ");"
- << endl;
+ << '\n';
} else {
appenders << " " << list_appender << "(constant, "
<< constant_value(fname, (t_type*)etype, (*v_iter)) << ");"
- << endl;
+ << '\n';
}
}
- f_types_impl_ << maybe_static << list_type << endl
- << this->nspace_lc << name_lc << "_constant (void)" << endl;
+ f_types_impl_ << maybe_static << list_type << '\n'
+ << this->nspace_lc << name_lc << "_constant (void)" << '\n';
scope_up(f_types_impl_);
f_types_impl_ << indent() << "static " << list_type << " constant = NULL;"
- << endl
- << indent() << "if (constant == NULL)" << endl;
+ << '\n'
+ << indent() << "if (constant == NULL)" << '\n';
scope_up(f_types_impl_);
if (!initializers.str().empty()) {
f_types_impl_ << initializers.str()
- << endl;
+ << '\n';
}
- f_types_impl_ << indent() << "constant = " << list_initializer << endl
+ f_types_impl_ << indent() << "constant = " << list_initializer << '\n'
<< appenders.str();
scope_down(f_types_impl_);
- f_types_impl_ << indent() << "return constant;" << endl;
+ f_types_impl_ << indent() << "return constant;" << '\n';
scope_down(f_types_impl_);
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
} else if (type->is_set()) {
t_type* etype = ((t_set*)type)->get_elem_type();
const vector<t_const_value*>& val = value->get_list();
@@ -1164,22 +1162,22 @@
string ptr = is_numeric(etype) ? "*" : "";
generate_const_initializer(fname, etype, (*v_iter));
initializers << constant_value_with_storage(fname, (t_type*)etype, *v_iter);
- appenders << " g_hash_table_insert (constant, " << fname << ", 0);" << endl;
+ appenders << " g_hash_table_insert (constant, " << fname << ", 0);" << '\n';
}
- f_types_impl_ << maybe_static << "GHashTable *" << endl
- << this->nspace_lc << name_lc << "_constant (void)" << endl;
+ f_types_impl_ << maybe_static << "GHashTable *" << '\n'
+ << this->nspace_lc << name_lc << "_constant (void)" << '\n';
scope_up(f_types_impl_);
- f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << endl
- << indent() << "if (constant == NULL)" << endl;
+ f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << '\n'
+ << indent() << "if (constant == NULL)" << '\n';
scope_up(f_types_impl_);
- f_types_impl_ << initializers.str() << endl
- << indent() << "constant = " << generate_new_hash_from_type(etype, nullptr) << endl
+ f_types_impl_ << initializers.str() << '\n'
+ << indent() << "constant = " << generate_new_hash_from_type(etype, nullptr) << '\n'
<< appenders.str();
scope_down(f_types_impl_);
- f_types_impl_ << indent() << "return constant;" << endl;
+ f_types_impl_ << indent() << "return constant;" << '\n';
scope_down(f_types_impl_);
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
@@ -1197,22 +1195,22 @@
initializers << constant_value_with_storage(kname, (t_type*)ktype, v_iter->first);
initializers << constant_value_with_storage(vname, (t_type*)vtype, v_iter->second);
- appenders << " g_hash_table_insert (constant, " << kname << ", " << vname << ");" << endl;
+ appenders << " g_hash_table_insert (constant, " << kname << ", " << vname << ");" << '\n';
}
- f_types_impl_ << maybe_static << "GHashTable *" << endl
- << this->nspace_lc << name_lc << "_constant (void)" << endl;
+ f_types_impl_ << maybe_static << "GHashTable *" << '\n'
+ << this->nspace_lc << name_lc << "_constant (void)" << '\n';
scope_up(f_types_impl_);
- f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << endl
- << indent() << "if (constant == NULL)" << endl;
+ f_types_impl_ << indent() << "static GHashTable *constant = NULL;" << '\n'
+ << indent() << "if (constant == NULL)" << '\n';
scope_up(f_types_impl_);
- f_types_impl_ << initializers.str() << endl
- << indent() << "constant = " << generate_new_hash_from_type(ktype, vtype) << endl
+ f_types_impl_ << initializers.str() << '\n'
+ << indent() << "constant = " << generate_new_hash_from_type(ktype, vtype) << '\n'
<< appenders.str();
scope_down(f_types_impl_);
- f_types_impl_ << indent() << "return constant;" << endl;
+ f_types_impl_ << indent() << "return constant;" << '\n';
scope_down(f_types_impl_);
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
}
}
@@ -1303,13 +1301,13 @@
string base_service_name_uc = to_upper_case(base_service_name_lc);
// Generate the client interface dummy object in the header.
- f_header_ << "/* " << service_name_ << " service interface */" << endl << "typedef struct _"
+ f_header_ << "/* " << service_name_ << " service interface */" << '\n' << "typedef struct _"
<< this->nspace << service_name_ << "If " << this->nspace << service_name_ << "If; "
- << " /* dummy object */" << endl << endl;
+ << " /* dummy object */" << '\n' << '\n';
// Generate the client interface object in the header.
- f_header_ << "struct _" << this->nspace << service_name_ << "IfInterface" << endl << "{" << endl
- << " GTypeInterface parent;" << endl << endl;
+ f_header_ << "struct _" << this->nspace << service_name_ << "IfInterface" << '\n' << "{" << '\n'
+ << " GTypeInterface parent;" << '\n' << '\n';
/* write out the functions for this interface */
indent_up();
@@ -1330,26 +1328,26 @@
+ (has_args ? "" : (", " + argument_list(arglist)))
+ (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
- indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" << endl;
+ indent(f_header_) << "gboolean (*" << funname << ") " << params << ";" << '\n';
}
indent_down();
- f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "IfInterface "
- << this->nspace << service_name_ << "IfInterface;" << endl << endl;
+ f_header_ << "};" << '\n' << "typedef struct _" << this->nspace << service_name_ << "IfInterface "
+ << this->nspace << service_name_ << "IfInterface;" << '\n' << '\n';
// generate all the interface boilerplate
- f_header_ << "GType " << this->nspace_lc << service_name_lc << "_if_get_type (void);" << endl
+ f_header_ << "GType " << this->nspace_lc << service_name_lc << "_if_get_type (void);" << '\n'
<< "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_IF "
- << "(" << this->nspace_lc << service_name_lc << "_if_get_type())" << endl << "#define "
+ << "(" << this->nspace_lc << service_name_lc << "_if_get_type())" << '\n' << "#define "
<< this->nspace_uc << service_name_uc << "_IF(obj) "
<< "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_IF, " << this->nspace << service_name_ << "If))" << endl
+ << service_name_uc << "_IF, " << this->nspace << service_name_ << "If))" << '\n'
<< "#define " << this->nspace_uc << "IS_" << service_name_uc << "_IF(obj) "
<< "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_IF))" << endl << "#define " << this->nspace_uc
+ << service_name_uc << "_IF))" << '\n' << "#define " << this->nspace_uc
<< service_name_uc << "_IF_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), "
<< this->nspace_uc << "TYPE_" << service_name_uc << "_IF, " << this->nspace
- << service_name_ << "IfInterface))" << endl << endl;
+ << service_name_ << "IfInterface))" << '\n' << '\n';
// write out all the interface function prototypes
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1368,50 +1366,50 @@
+ (has_xceptions ? "" : (", " + xception_list(xlist))) + ", GError **error)";
f_header_ << "gboolean " << this->nspace_lc << service_name_lc << "_if_" << funname << " "
- << params << ";" << endl;
+ << params << ";" << '\n';
}
- f_header_ << endl;
+ f_header_ << '\n';
// Generate the client object instance definition in the header.
- f_header_ << "/* " << service_name_ << " service client */" << endl << "struct _" << this->nspace
- << service_name_ << "Client" << endl << "{" << endl << " " << parent_class_name
- << " parent;" << endl;
+ f_header_ << "/* " << service_name_ << " service client */" << '\n' << "struct _" << this->nspace
+ << service_name_ << "Client" << '\n' << "{" << '\n' << " " << parent_class_name
+ << " parent;" << '\n';
if (!extends_service) {
// Define "input_protocol" and "output_protocol" properties only
// for base services; child service-client classes will inherit
// these
- f_header_ << endl << " ThriftProtocol *input_protocol;" << endl
- << " ThriftProtocol *output_protocol;" << endl;
+ f_header_ << '\n' << " ThriftProtocol *input_protocol;" << '\n'
+ << " ThriftProtocol *output_protocol;" << '\n';
}
- f_header_ << "};" << endl << "typedef struct _" << this->nspace << service_name_ << "Client "
- << this->nspace << service_name_ << "Client;" << endl << endl;
+ f_header_ << "};" << '\n' << "typedef struct _" << this->nspace << service_name_ << "Client "
+ << this->nspace << service_name_ << "Client;" << '\n' << '\n';
// Generate the class definition in the header.
- f_header_ << "struct _" << this->nspace << service_name_ << "ClientClass" << endl << "{" << endl
- << " " << parent_class_name << "Class parent;" << endl << "};" << endl
+ f_header_ << "struct _" << this->nspace << service_name_ << "ClientClass" << '\n' << "{" << '\n'
+ << " " << parent_class_name << "Class parent;" << '\n' << "};" << '\n'
<< "typedef struct _" << this->nspace << service_name_ << "ClientClass " << this->nspace
- << service_name_ << "ClientClass;" << endl << endl;
+ << service_name_ << "ClientClass;" << '\n' << '\n';
// Create all the GObject boilerplate
- f_header_ << "GType " << this->nspace_lc << service_name_lc << "_client_get_type (void);" << endl
+ f_header_ << "GType " << this->nspace_lc << service_name_lc << "_client_get_type (void);" << '\n'
<< "#define " << this->nspace_uc << "TYPE_" << service_name_uc << "_CLIENT "
- << "(" << this->nspace_lc << service_name_lc << "_client_get_type())" << endl
+ << "(" << this->nspace_lc << service_name_lc << "_client_get_type())" << '\n'
<< "#define " << this->nspace_uc << service_name_uc << "_CLIENT(obj) "
<< "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "Client))" << endl
+ << service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "Client))" << '\n'
<< "#define " << this->nspace_uc << service_name_uc << "_CLIENT_CLASS(c) "
<< "(G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
- << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))" << endl << "#define "
+ << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))" << '\n' << "#define "
<< this->nspace_uc << service_name_uc << "_IS_CLIENT(obj) "
<< "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_CLIENT))" << endl << "#define " << this->nspace_uc
+ << service_name_uc << "_CLIENT))" << '\n' << "#define " << this->nspace_uc
<< service_name_uc << "_IS_CLIENT_CLASS(c) "
<< "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
- << "_CLIENT))" << endl << "#define " << this->nspace_uc << service_name_uc
+ << "_CLIENT))" << '\n' << "#define " << this->nspace_uc << service_name_uc
<< "_CLIENT_GET_CLASS(obj) "
<< "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_"
<< service_name_uc << "_CLIENT, " << this->nspace << service_name_ << "ClientClass))"
- << endl << endl;
+ << '\n' << '\n';
/* write out the function prototypes */
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1422,12 +1420,12 @@
service_name_lc + string("_client_") + funname,
(*f_iter)->get_arglist(),
(*f_iter)->get_xceptions());
- indent(f_header_) << function_signature(&service_function) << ";" << endl;
+ indent(f_header_) << function_signature(&service_function) << ";" << '\n';
t_function send_function(g_type_void,
service_name_lc + string("_client_send_") + funname,
(*f_iter)->get_arglist());
- indent(f_header_) << function_signature(&send_function) << ";" << endl;
+ indent(f_header_) << function_signature(&send_function) << ";" << '\n';
// implement recv if not a oneway service
if (!(*f_iter)->is_oneway()) {
@@ -1436,19 +1434,19 @@
service_name_lc + string("_client_recv_") + funname,
&noargs,
(*f_iter)->get_xceptions());
- indent(f_header_) << function_signature(&recv_function) << ";" << endl;
+ indent(f_header_) << function_signature(&recv_function) << ";" << '\n';
}
}
/* write out the get/set function prototypes */
f_header_ << "void " + service_name_lc + "_client_set_property (GObject *object, guint "
"property_id, const GValue *value, GParamSpec *pspec);"
- << endl;
+ << '\n';
f_header_ << "void " + service_name_lc + "_client_get_property (GObject *object, guint "
"property_id, GValue *value, GParamSpec *pspec);"
- << endl;
+ << '\n';
- f_header_ << endl;
+ f_header_ << '\n';
// end of header code
// Generate interface method implementations
@@ -1483,76 +1481,76 @@
params_without_type += ", ";
}
- f_service_ << "gboolean" << endl << this->nspace_lc << service_name_lc << "_if_" << funname
- << " " << params << endl << "{" << endl << " return " << this->nspace_uc
+ f_service_ << "gboolean" << '\n' << this->nspace_lc << service_name_lc << "_if_" << funname
+ << " " << params << '\n' << "{" << '\n' << " return " << this->nspace_uc
<< service_name_uc << "_IF_GET_INTERFACE (iface)->" << funname << " ("
- << params_without_type << "error);" << endl << "}" << endl << endl;
+ << params_without_type << "error);" << '\n' << "}" << '\n' << '\n';
}
// Generate interface boilerplate
- f_service_ << "GType" << endl << this->nspace_lc << service_name_lc << "_if_get_type (void)"
- << endl << "{" << endl << " static GType type = 0;" << endl << " if (type == 0)"
- << endl << " {" << endl << " static const GTypeInfo type_info =" << endl << " {"
- << endl << " sizeof (" << this->nspace << service_name_ << "IfInterface)," << endl
- << " NULL, /* base_init */" << endl << " NULL, /* base_finalize */" << endl
- << " NULL, /* class_init */" << endl << " NULL, /* class_finalize */"
- << endl << " NULL, /* class_data */" << endl
- << " 0, /* instance_size */" << endl << " 0, /* n_preallocs */"
- << endl << " NULL, /* instance_init */" << endl
- << " NULL /* value_table */" << endl << " };" << endl
- << " type = g_type_register_static (G_TYPE_INTERFACE," << endl
+ f_service_ << "GType" << '\n' << this->nspace_lc << service_name_lc << "_if_get_type (void)"
+ << '\n' << "{" << '\n' << " static GType type = 0;" << '\n' << " if (type == 0)"
+ << '\n' << " {" << '\n' << " static const GTypeInfo type_info =" << '\n' << " {"
+ << '\n' << " sizeof (" << this->nspace << service_name_ << "IfInterface)," << '\n'
+ << " NULL, /* base_init */" << '\n' << " NULL, /* base_finalize */" << '\n'
+ << " NULL, /* class_init */" << '\n' << " NULL, /* class_finalize */"
+ << '\n' << " NULL, /* class_data */" << '\n'
+ << " 0, /* instance_size */" << '\n' << " 0, /* n_preallocs */"
+ << '\n' << " NULL, /* instance_init */" << '\n'
+ << " NULL /* value_table */" << '\n' << " };" << '\n'
+ << " type = g_type_register_static (G_TYPE_INTERFACE," << '\n'
<< " \"" << this->nspace << service_name_ << "If\","
- << endl << " &type_info, 0);" << endl << " }"
- << endl << " return type;" << endl << "}" << endl << endl;
+ << '\n' << " &type_info, 0);" << '\n' << " }"
+ << '\n' << " return type;" << '\n' << "}" << '\n' << '\n';
// Generate client boilerplate
- f_service_ << "static void " << endl << this->nspace_lc << service_name_lc
+ f_service_ << "static void " << '\n' << this->nspace_lc << service_name_lc
<< "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface);"
- << endl << endl << "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_
- << "Client, " << this->nspace_lc << service_name_lc << "_client," << endl
- << " " << parent_type_name << ", " << endl
+ << '\n' << '\n' << "G_DEFINE_TYPE_WITH_CODE (" << this->nspace << service_name_
+ << "Client, " << this->nspace_lc << service_name_lc << "_client," << '\n'
+ << " " << parent_type_name << ", " << '\n'
<< " G_IMPLEMENT_INTERFACE (" << this->nspace_uc << "TYPE_"
- << service_name_uc << "_IF," << endl
+ << service_name_uc << "_IF," << '\n'
<< " " << this->nspace_lc
- << service_name_lc << "_if_interface_init))" << endl << endl;
+ << service_name_lc << "_if_interface_init))" << '\n' << '\n';
// Generate property-related code only for base services---child
// service-client classes have only properties inherited from their
// parent class
if (!extends_service) {
// Generate client properties
- f_service_ << "enum _" << this->nspace << service_name_ << "ClientProperties" << endl << "{"
- << endl << " PROP_0," << endl << " PROP_" << this->nspace_uc << service_name_uc
- << "_CLIENT_INPUT_PROTOCOL," << endl << " PROP_" << this->nspace_uc
- << service_name_uc << "_CLIENT_OUTPUT_PROTOCOL" << endl << "};" << endl << endl;
+ f_service_ << "enum _" << this->nspace << service_name_ << "ClientProperties" << '\n' << "{"
+ << '\n' << " PROP_0," << '\n' << " PROP_" << this->nspace_uc << service_name_uc
+ << "_CLIENT_INPUT_PROTOCOL," << '\n' << " PROP_" << this->nspace_uc
+ << service_name_uc << "_CLIENT_OUTPUT_PROTOCOL" << '\n' << "};" << '\n' << '\n';
// generate property setter
- f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_set_property ("
+ f_service_ << "void" << '\n' << this->nspace_lc << service_name_lc << "_client_set_property ("
<< "GObject *object, guint property_id, const GValue *value, "
- << "GParamSpec *pspec)" << endl << "{" << endl << " " << this->nspace
+ << "GParamSpec *pspec)" << '\n' << "{" << '\n' << " " << this->nspace
<< service_name_ << "Client *client = " << this->nspace_uc << service_name_uc
- << "_CLIENT (object);" << endl << endl << " THRIFT_UNUSED_VAR (pspec);" << endl
- << endl << " switch (property_id)" << endl << " {" << endl << " case PROP_"
- << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl
- << " client->input_protocol = g_value_get_object (value);" << endl
- << " break;" << endl << " case PROP_" << this->nspace_uc << service_name_uc
- << "_CLIENT_OUTPUT_PROTOCOL:" << endl
- << " client->output_protocol = g_value_get_object (value);" << endl
- << " break;" << endl << " }" << endl << "}" << endl << endl;
+ << "_CLIENT (object);" << '\n' << '\n' << " THRIFT_UNUSED_VAR (pspec);" << '\n'
+ << '\n' << " switch (property_id)" << '\n' << " {" << '\n' << " case PROP_"
+ << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << '\n'
+ << " client->input_protocol = g_value_get_object (value);" << '\n'
+ << " break;" << '\n' << " case PROP_" << this->nspace_uc << service_name_uc
+ << "_CLIENT_OUTPUT_PROTOCOL:" << '\n'
+ << " client->output_protocol = g_value_get_object (value);" << '\n'
+ << " break;" << '\n' << " }" << '\n' << "}" << '\n' << '\n';
// generate property getter
- f_service_ << "void" << endl << this->nspace_lc << service_name_lc << "_client_get_property ("
+ f_service_ << "void" << '\n' << this->nspace_lc << service_name_lc << "_client_get_property ("
<< "GObject *object, guint property_id, GValue *value, "
- << "GParamSpec *pspec)" << endl << "{" << endl << " " << this->nspace
+ << "GParamSpec *pspec)" << '\n' << "{" << '\n' << " " << this->nspace
<< service_name_ << "Client *client = " << this->nspace_uc << service_name_uc
- << "_CLIENT (object);" << endl << endl << " THRIFT_UNUSED_VAR (pspec);" << endl
- << endl << " switch (property_id)" << endl << " {" << endl << " case PROP_"
- << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << endl
- << " g_value_set_object (value, client->input_protocol);" << endl
- << " break;" << endl << " case PROP_" << this->nspace_uc << service_name_uc
- << "_CLIENT_OUTPUT_PROTOCOL:" << endl
- << " g_value_set_object (value, client->output_protocol);" << endl
- << " break;" << endl << " }" << endl << "}" << endl << endl;
+ << "_CLIENT (object);" << '\n' << '\n' << " THRIFT_UNUSED_VAR (pspec);" << '\n'
+ << '\n' << " switch (property_id)" << '\n' << " {" << '\n' << " case PROP_"
+ << this->nspace_uc << service_name_uc << "_CLIENT_INPUT_PROTOCOL:" << '\n'
+ << " g_value_set_object (value, client->input_protocol);" << '\n'
+ << " break;" << '\n' << " case PROP_" << this->nspace_uc << service_name_uc
+ << "_CLIENT_OUTPUT_PROTOCOL:" << '\n'
+ << " g_value_set_object (value, client->output_protocol);" << '\n'
+ << " break;" << '\n' << " }" << '\n' << "}" << '\n' << '\n';
}
// Generate client method implementations
@@ -1569,31 +1567,31 @@
(*f_iter)->get_arglist());
// Open the send function
- indent(f_service_) << function_signature(&send_function) << endl;
+ indent(f_service_) << function_signature(&send_function) << '\n';
scope_up(f_service_);
string reqType = (*f_iter)->is_oneway() ? "T_ONEWAY" : "T_CALL";
// Serialize the request
- f_service_ << indent() << "gint32 cseqid = 0;" << endl << indent()
+ f_service_ << indent() << "gint32 cseqid = 0;" << '\n' << indent()
<< "ThriftProtocol * protocol = " << this->nspace_uc << base_service_name_uc
- << "_CLIENT (iface)->output_protocol;" << endl << endl << indent()
+ << "_CLIENT (iface)->output_protocol;" << '\n' << '\n' << indent()
<< "if (thrift_protocol_write_message_begin (protocol, \"" << name << "\", "
- << reqType << ", cseqid, error) < 0)" << endl << indent() << " return FALSE;"
- << endl << endl;
+ << reqType << ", cseqid, error) < 0)" << '\n' << indent() << " return FALSE;"
+ << '\n' << '\n';
generate_struct_writer(f_service_, arg_struct, "", "", false);
- f_service_ << indent() << "if (thrift_protocol_write_message_end (protocol, error) < 0)" << endl
- << indent() << " return FALSE;" << endl << indent()
- << "if (!thrift_transport_flush (protocol->transport, error))" << endl << indent()
- << " return FALSE;" << endl << indent()
- << "if (!thrift_transport_write_end (protocol->transport, error))" << endl
- << indent() << " return FALSE;" << endl << endl << indent() << "return TRUE;"
- << endl;
+ f_service_ << indent() << "if (thrift_protocol_write_message_end (protocol, error) < 0)" << '\n'
+ << indent() << " return FALSE;" << '\n' << indent()
+ << "if (!thrift_transport_flush (protocol->transport, error))" << '\n' << indent()
+ << " return FALSE;" << '\n' << indent()
+ << "if (!thrift_transport_write_end (protocol->transport, error))" << '\n'
+ << indent() << " return FALSE;" << '\n' << '\n' << indent() << "return TRUE;"
+ << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate recv function only if not an async function
if (!(*f_iter)->is_oneway()) {
@@ -1603,78 +1601,78 @@
&noargs,
(*f_iter)->get_xceptions());
// Open function
- indent(f_service_) << function_signature(&recv_function) << endl;
+ indent(f_service_) << function_signature(&recv_function) << '\n';
scope_up(f_service_);
- f_service_ << indent() << "gint32 rseqid;" << endl
- << indent() << "gchar * fname = NULL;" << endl
- << indent() << "ThriftMessageType mtype;" << endl
+ f_service_ << indent() << "gint32 rseqid;" << '\n'
+ << indent() << "gchar * fname = NULL;" << '\n'
+ << indent() << "ThriftMessageType mtype;" << '\n'
<< indent() << "ThriftProtocol * protocol = "
<< this->nspace_uc << base_service_name_uc
- << "_CLIENT (iface)->input_protocol;" << endl
- << indent() << "ThriftApplicationException *xception;" << endl
- << endl
+ << "_CLIENT (iface)->input_protocol;" << '\n'
+ << indent() << "ThriftApplicationException *xception;" << '\n'
+ << '\n'
<< indent() << "if (thrift_protocol_read_message_begin "
- "(protocol, &fname, &mtype, &rseqid, error) < 0) {" << endl;
+ "(protocol, &fname, &mtype, &rseqid, error) < 0) {" << '\n';
indent_up();
- f_service_ << indent() << "if (fname) g_free (fname);" << endl
- << indent() << "return FALSE;" << endl;
+ f_service_ << indent() << "if (fname) g_free (fname);" << '\n'
+ << indent() << "return FALSE;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl
- << endl
- << indent() << "if (mtype == T_EXCEPTION) {" << endl;
+ f_service_ << indent() << "}" << '\n'
+ << '\n'
+ << indent() << "if (mtype == T_EXCEPTION) {" << '\n';
indent_up();
- f_service_ << indent() << "if (fname) g_free (fname);" << endl
+ f_service_ << indent() << "if (fname) g_free (fname);" << '\n'
<< indent() << "xception = g_object_new "
- "(THRIFT_TYPE_APPLICATION_EXCEPTION, NULL);" << endl
+ "(THRIFT_TYPE_APPLICATION_EXCEPTION, NULL);" << '\n'
<< indent() << "thrift_struct_read (THRIFT_STRUCT (xception), "
- "protocol, NULL);" << endl
+ "protocol, NULL);" << '\n'
<< indent() << "thrift_protocol_read_message_end "
- "(protocol, NULL);" << endl
+ "(protocol, NULL);" << '\n'
<< indent() << "thrift_transport_read_end "
- "(protocol->transport, NULL);" << endl
+ "(protocol->transport, NULL);" << '\n'
<< indent() << "g_set_error (error, "
"THRIFT_APPLICATION_EXCEPTION_ERROR,xception->type, "
- "\"application error: %s\", xception->message);" << endl
- << indent() << "g_object_unref (xception);" << endl
- << indent() << "return FALSE;" << endl;
+ "\"application error: %s\", xception->message);" << '\n'
+ << indent() << "g_object_unref (xception);" << '\n'
+ << indent() << "return FALSE;" << '\n';
indent_down();
- f_service_ << indent() << "} else if (mtype != T_REPLY) {" << endl;
+ f_service_ << indent() << "} else if (mtype != T_REPLY) {" << '\n';
indent_up();
- f_service_ << indent() << "if (fname) g_free (fname);" << endl
+ f_service_ << indent() << "if (fname) g_free (fname);" << '\n'
<< indent() << "thrift_protocol_skip (protocol, T_STRUCT, "
- "NULL);" << endl
+ "NULL);" << '\n'
<< indent() << "thrift_protocol_read_message_end (protocol, "
- "NULL);" << endl
+ "NULL);" << '\n'
<< indent() << "thrift_transport_read_end ("
- "protocol->transport, NULL);" << endl
+ "protocol->transport, NULL);" << '\n'
<< indent() << "g_set_error (error, "
"THRIFT_APPLICATION_EXCEPTION_ERROR, "
"THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_MESSAGE_TYPE, "
"\"invalid message type %d, expected T_REPLY\", mtype);"
- << endl
- << indent() << "return FALSE;" << endl;
+ << '\n'
+ << indent() << "return FALSE;" << '\n';
indent_down();
f_service_ << indent() << "} else if (strncmp (fname, \"" << name
- << "\", " << name.length() << ") != 0) {" << endl;
+ << "\", " << name.length() << ") != 0) {" << '\n';
indent_up();
f_service_ << indent() << "thrift_protocol_skip (protocol, T_STRUCT, "
- "NULL);" << endl
+ "NULL);" << '\n'
<< indent() << "thrift_protocol_read_message_end (protocol,"
- "error);" << endl
+ "error);" << '\n'
<< indent() << "thrift_transport_read_end ("
- "protocol->transport, error);" << endl
+ "protocol->transport, error);" << '\n'
<< indent() << "g_set_error (error, "
"THRIFT_APPLICATION_EXCEPTION_ERROR, "
"THRIFT_APPLICATION_EXCEPTION_ERROR_WRONG_METHOD_NAME, "
"\"wrong method name %s, expected " << name
- << "\", fname);" << endl
- << indent() << "if (fname) g_free (fname);" << endl
- << indent() << "return FALSE;" << endl;
+ << "\", fname);" << '\n'
+ << indent() << "if (fname) g_free (fname);" << '\n'
+ << indent() << "return FALSE;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl
- << indent() << "if (fname) g_free (fname);" << endl
- << endl;
+ f_service_ << indent() << "}" << '\n'
+ << indent() << "if (fname) g_free (fname);" << '\n'
+ << '\n';
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -1699,25 +1697,25 @@
}
f_service_ << indent() << "if (thrift_protocol_read_message_end (protocol, error) < 0)"
- << endl << indent() << " return FALSE;" << endl << endl << indent()
- << "if (!thrift_transport_read_end (protocol->transport, error))" << endl
- << indent() << " return FALSE;" << endl << endl;
+ << '\n' << indent() << " return FALSE;" << '\n' << '\n' << indent()
+ << "if (!thrift_transport_read_end (protocol->transport, error))" << '\n'
+ << indent() << " return FALSE;" << '\n' << '\n';
// copy over any throw exceptions and return failure
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); x_iter++) {
- f_service_ << indent() << "if (*" << (*x_iter)->get_name() << " != NULL)" << endl
- << indent() << "{" << endl << indent() << " g_set_error (error, "
+ f_service_ << indent() << "if (*" << (*x_iter)->get_name() << " != NULL)" << '\n'
+ << indent() << "{" << '\n' << indent() << " g_set_error (error, "
<< this->nspace_uc
<< to_upper_case(initial_caps_to_underscores((*x_iter)->get_type()->get_name()))
<< "_ERROR, " << this->nspace_uc
<< to_upper_case(initial_caps_to_underscores((*x_iter)->get_type()->get_name()))
- << "_ERROR_CODE, \"" << (*x_iter)->get_type()->get_name() << "\");" << endl
- << indent() << " return FALSE;" << endl << indent() << "}" << endl;
+ << "_ERROR_CODE, \"" << (*x_iter)->get_type()->get_name() << "\");" << '\n'
+ << indent() << " return FALSE;" << '\n' << indent() << "}" << '\n';
}
// Close function
- indent(f_service_) << "return TRUE;" << endl;
+ indent(f_service_) << "return TRUE;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
// Open function
@@ -1725,7 +1723,7 @@
service_name_lc + string("_client_") + funname,
(*f_iter)->get_arglist(),
(*f_iter)->get_xceptions());
- indent(f_service_) << function_signature(&service_function) << endl;
+ indent(f_service_) << function_signature(&service_function) << '\n';
scope_up(f_service_);
// wrap each function
@@ -1738,7 +1736,7 @@
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << ", " << (*fld_iter)->get_name();
}
- f_service_ << ", error))" << endl << indent() << " return FALSE;" << endl;
+ f_service_ << ", error))" << '\n' << indent() << " return FALSE;" << '\n';
// if not oneway, implement recv
if (!(*f_iter)->is_oneway()) {
@@ -1752,20 +1750,20 @@
}
f_service_ << indent() << "if (!" << this->nspace_lc << service_name_lc << "_client_recv_"
- << funname << " (iface, " << ret << "error))" << endl << indent()
- << " return FALSE;" << endl;
+ << funname << " (iface, " << ret << "error))" << '\n' << indent()
+ << " return FALSE;" << '\n';
}
// return TRUE which means all functions were called OK
- indent(f_service_) << "return TRUE;" << endl;
+ indent(f_service_) << "return TRUE;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
// create the interface initializer
- f_service_ << "static void" << endl
+ f_service_ << "static void" << '\n'
<< this->nspace_lc << service_name_lc << "_if_interface_init ("
- << this->nspace << service_name_ << "IfInterface *iface)" << endl;
+ << this->nspace << service_name_ << "IfInterface *iface)" << '\n';
scope_up(f_service_);
if (functions.size() > 0) {
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1773,62 +1771,62 @@
string funname = initial_caps_to_underscores((*f_iter)->get_name());
f_service_ << indent() << "iface->" << funname << " = " << this->nspace_lc
- << service_name_lc << "_client_" << funname << ";" << endl;
+ << service_name_lc << "_client_" << funname << ";" << '\n';
}
}
else {
- f_service_ << indent() << "THRIFT_UNUSED_VAR (iface);" << endl;
+ f_service_ << indent() << "THRIFT_UNUSED_VAR (iface);" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// create the client instance initializer
- f_service_ << "static void" << endl
+ f_service_ << "static void" << '\n'
<< this->nspace_lc << service_name_lc << "_client_init ("
- << this->nspace << service_name_ << "Client *client)" << endl;
+ << this->nspace << service_name_ << "Client *client)" << '\n';
scope_up(f_service_);
if (!extends_service) {
- f_service_ << indent() << "client->input_protocol = NULL;" << endl
- << indent() << "client->output_protocol = NULL;" << endl;
+ f_service_ << indent() << "client->input_protocol = NULL;" << '\n'
+ << indent() << "client->output_protocol = NULL;" << '\n';
}
else {
- f_service_ << indent() << "THRIFT_UNUSED_VAR (client);" << endl;
+ f_service_ << indent() << "THRIFT_UNUSED_VAR (client);" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// create the client class initializer
- f_service_ << "static void" << endl << this->nspace_lc << service_name_lc
+ f_service_ << "static void" << '\n' << this->nspace_lc << service_name_lc
<< "_client_class_init (" << this->nspace << service_name_ << "ClientClass *cls)"
- << endl << "{" << endl;
+ << '\n' << "{" << '\n';
if (!extends_service) {
- f_service_ << " GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << endl
- << " GParamSpec *param_spec;" << endl << endl
+ f_service_ << " GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << '\n'
+ << " GParamSpec *param_spec;" << '\n' << '\n'
<< " gobject_class->set_property = " << this->nspace_lc << service_name_lc
- << "_client_set_property;" << endl
+ << "_client_set_property;" << '\n'
<< " gobject_class->get_property = " << this->nspace_lc << service_name_lc
- << "_client_get_property;" << endl << endl
- << " param_spec = g_param_spec_object (\"input_protocol\"," << endl
- << " \"input protocol (construct)\"," << endl
- << " \"Set the client input protocol\"," << endl
- << " THRIFT_TYPE_PROTOCOL," << endl
- << " G_PARAM_READWRITE);" << endl
- << " g_object_class_install_property (gobject_class," << endl
+ << "_client_get_property;" << '\n' << '\n'
+ << " param_spec = g_param_spec_object (\"input_protocol\"," << '\n'
+ << " \"input protocol (construct)\"," << '\n'
+ << " \"Set the client input protocol\"," << '\n'
+ << " THRIFT_TYPE_PROTOCOL," << '\n'
+ << " G_PARAM_READWRITE);" << '\n'
+ << " g_object_class_install_property (gobject_class," << '\n'
<< " PROP_" << this->nspace_uc << service_name_uc
- << "_CLIENT_INPUT_PROTOCOL, param_spec);" << endl << endl
- << " param_spec = g_param_spec_object (\"output_protocol\"," << endl
- << " \"output protocol (construct)\"," << endl
- << " \"Set the client output protocol\"," << endl
- << " THRIFT_TYPE_PROTOCOL," << endl
- << " G_PARAM_READWRITE);" << endl
- << " g_object_class_install_property (gobject_class," << endl
+ << "_CLIENT_INPUT_PROTOCOL, param_spec);" << '\n' << '\n'
+ << " param_spec = g_param_spec_object (\"output_protocol\"," << '\n'
+ << " \"output protocol (construct)\"," << '\n'
+ << " \"Set the client output protocol\"," << '\n'
+ << " THRIFT_TYPE_PROTOCOL," << '\n'
+ << " G_PARAM_READWRITE);" << '\n'
+ << " g_object_class_install_property (gobject_class," << '\n'
<< " PROP_" << this->nspace_uc << service_name_uc
- << "_CLIENT_OUTPUT_PROTOCOL, param_spec);" << endl;
+ << "_CLIENT_OUTPUT_PROTOCOL, param_spec);" << '\n';
}
else {
- f_service_ << " THRIFT_UNUSED_VAR (cls);" << endl;
+ f_service_ << " THRIFT_UNUSED_VAR (cls);" << '\n';
}
- f_service_ << "}" << endl << endl;
+ f_service_ << "}" << '\n' << '\n';
}
/**
@@ -1874,19 +1872,19 @@
// Generate the handler class' definition in the header file
// Generate the handler instance definition
- f_header_ << "/* " << service_name_ << " handler (abstract base class) */" << endl << "struct _"
- << class_name << endl << "{" << endl;
+ f_header_ << "/* " << service_name_ << " handler (abstract base class) */" << '\n' << "struct _"
+ << class_name << '\n' << "{" << '\n';
indent_up();
- f_header_ << indent() << parent_class_name << " parent;" << endl;
+ f_header_ << indent() << parent_class_name << " parent;" << '\n';
indent_down();
- f_header_ << "};" << endl << "typedef struct _" << class_name << " " << class_name << ";" << endl
- << endl;
+ f_header_ << "};" << '\n' << "typedef struct _" << class_name << " " << class_name << ";" << '\n'
+ << '\n';
// Generate the handler class definition, including its class members
// (methods)
- f_header_ << "struct _" << class_name << "Class" << endl << "{" << endl;
+ f_header_ << "struct _" << class_name << "Class" << '\n' << "{" << '\n';
indent_up();
- f_header_ << indent() << parent_class_name << "Class parent;" << endl << endl;
+ f_header_ << indent() << parent_class_name << "Class parent;" << '\n' << '\n';
for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
string method_name = initial_caps_to_underscores((*function_iter)->get_name());
@@ -1902,31 +1900,31 @@
+ (has_args ? "" : (", " + argument_list(arg_list)))
+ (has_xceptions ? "" : (", " + xception_list(x_list))) + ", GError **error)";
- indent(f_header_) << "gboolean (*" << method_name << ") " << params << ";" << endl;
+ indent(f_header_) << "gboolean (*" << method_name << ") " << params << ";" << '\n';
}
indent_down();
- f_header_ << "};" << endl << "typedef struct _" << class_name << "Class " << class_name
- << "Class;" << endl << endl;
+ f_header_ << "};" << '\n' << "typedef struct _" << class_name << "Class " << class_name
+ << "Class;" << '\n' << '\n';
// Generate the remaining header boilerplate
- f_header_ << "GType " << class_name_lc << "_get_type (void);" << endl << "#define "
+ f_header_ << "GType " << class_name_lc << "_get_type (void);" << '\n' << "#define "
<< this->nspace_uc << "TYPE_" << service_name_uc << "_HANDLER "
- << "(" << class_name_lc << "_get_type())" << endl << "#define " << class_name_uc
+ << "(" << class_name_lc << "_get_type())" << '\n' << "#define " << class_name_uc
<< "(obj) "
<< "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_HANDLER, " << class_name << "))" << endl << "#define "
+ << service_name_uc << "_HANDLER, " << class_name << "))" << '\n' << "#define "
<< this->nspace_uc << "IS_" << service_name_uc << "_HANDLER(obj) "
<< "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_HANDLER))" << endl << "#define " << class_name_uc
+ << service_name_uc << "_HANDLER))" << '\n' << "#define " << class_name_uc
<< "_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_HANDLER, " << class_name << "Class))" << endl << "#define "
+ << service_name_uc << "_HANDLER, " << class_name << "Class))" << '\n' << "#define "
<< this->nspace_uc << "IS_" << service_name_uc << "_HANDLER_CLASS(c) "
<< "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
- << "_HANDLER))" << endl << "#define " << this->nspace_uc << service_name_uc
+ << "_HANDLER))" << '\n' << "#define " << this->nspace_uc << service_name_uc
<< "_HANDLER_GET_CLASS(obj) "
<< "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_HANDLER, " << class_name << "Class))" << endl << endl;
+ << service_name_uc << "_HANDLER, " << class_name << "Class))" << '\n' << '\n';
// Generate the handler class' method definitions
for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
@@ -1943,25 +1941,25 @@
+ (has_args ? "" : (", " + argument_list(arg_list)))
+ (has_xceptions ? "" : (", " + xception_list(x_list))) + ", GError **error)";
- f_header_ << "gboolean " << class_name_lc << "_" << method_name << " " << params << ";" << endl;
+ f_header_ << "gboolean " << class_name_lc << "_" << method_name << " " << params << ";" << '\n';
}
- f_header_ << endl;
+ f_header_ << '\n';
// Generate the handler's implementation in the implementation file
// Generate the implementation boilerplate
- f_service_ << "static void" << endl << class_name_lc << "_" << service_name_lc
+ f_service_ << "static void" << '\n' << class_name_lc << "_" << service_name_lc
<< "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface);"
- << endl << endl;
+ << '\n' << '\n';
args_indent = string(25, ' ');
- f_service_ << "G_DEFINE_TYPE_WITH_CODE (" << class_name << ", " << endl << args_indent
- << class_name_lc << "," << endl << args_indent << parent_type_name << "," << endl
+ f_service_ << "G_DEFINE_TYPE_WITH_CODE (" << class_name << ", " << '\n' << args_indent
+ << class_name_lc << "," << '\n' << args_indent << parent_type_name << "," << '\n'
<< args_indent << "G_IMPLEMENT_INTERFACE (" << this->nspace_uc << "TYPE_"
- << service_name_uc << "_IF," << endl;
+ << service_name_uc << "_IF," << '\n';
args_indent += string(23, ' ');
f_service_ << args_indent << class_name_lc << "_" << service_name_lc << "_if_interface_init))"
- << endl << endl;
+ << '\n' << '\n';
// Generate the handler method implementations
for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
@@ -1982,10 +1980,10 @@
x_list,
(*function_iter)->is_oneway());
- indent(f_service_) << function_signature(&implementing_function) << endl;
+ indent(f_service_) << function_signature(&implementing_function) << '\n';
scope_up(f_service_);
f_service_ << indent() << "g_return_val_if_fail (" << this->nspace_uc << "IS_"
- << service_name_uc << "_HANDLER (iface), FALSE);" << endl << endl << indent()
+ << service_name_uc << "_HANDLER (iface), FALSE);" << '\n' << '\n' << indent()
<< "return " << class_name_uc << "_GET_CLASS (iface)"
<< "->" << method_name << " (iface, ";
@@ -1998,42 +1996,42 @@
for (field_iter = xceptions.begin(); field_iter != xceptions.end(); ++field_iter) {
f_service_ << (*field_iter)->get_name() << ", ";
}
- f_service_ << "error);" << endl;
+ f_service_ << "error);" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
// Generate the handler interface initializer
- f_service_ << "static void" << endl << class_name_lc << "_" << service_name_lc
+ f_service_ << "static void" << '\n' << class_name_lc << "_" << service_name_lc
<< "_if_interface_init (" << this->nspace << service_name_ << "IfInterface *iface)"
- << endl;
+ << '\n';
scope_up(f_service_);
if (functions.size() > 0) {
for (function_iter = functions.begin(); function_iter != functions.end(); ++function_iter) {
string method_name = initial_caps_to_underscores((*function_iter)->get_name());
f_service_ << indent() << "iface->" << method_name << " = " << class_name_lc << "_"
- << method_name << ";" << endl;
+ << method_name << ";" << '\n';
}
}
else {
- f_service_ << "THRIFT_UNUSED_VAR (iface);" << endl;
+ f_service_ << "THRIFT_UNUSED_VAR (iface);" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the handler instance initializer
- f_service_ << "static void" << endl << class_name_lc << "_init (" << class_name << " *self)"
- << endl;
+ f_service_ << "static void" << '\n' << class_name_lc << "_init (" << class_name << " *self)"
+ << '\n';
scope_up(f_service_);
- f_service_ << indent() << "THRIFT_UNUSED_VAR (self);" << endl;
+ f_service_ << indent() << "THRIFT_UNUSED_VAR (self);" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the handler class initializer
- f_service_ << "static void" << endl
+ f_service_ << "static void" << '\n'
<< class_name_lc << "_class_init (" << class_name << "Class *cls)"
- << endl;
+ << '\n';
scope_up(f_service_);
if (functions.size() > 0) {
for (function_iter = functions.begin();
@@ -2043,14 +2041,14 @@
string method_name = initial_caps_to_underscores(function_name);
// All methods are pure virtual and must be implemented by subclasses
- f_service_ << indent() << "cls->" << method_name << " = NULL;" << endl;
+ f_service_ << indent() << "cls->" << method_name << " = NULL;" << '\n';
}
}
else {
- f_service_ << indent() << "THRIFT_UNUSED_VAR (cls);" << endl;
+ f_service_ << indent() << "THRIFT_UNUSED_VAR (cls);" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
/**
@@ -2104,84 +2102,84 @@
// Generate the processor class' definition in the header file
// Generate the processor instance definition
- f_header_ << "/* " << service_name_ << " processor */" << endl << "struct _" << class_name << endl
- << "{" << endl;
+ f_header_ << "/* " << service_name_ << " processor */" << '\n' << "struct _" << class_name << '\n'
+ << "{" << '\n';
indent_up();
- f_header_ << indent() << parent_class_name << " parent;" << endl << endl << indent()
- << "/* protected */" << endl << indent()
- << this->nspace + service_name_ + "Handler *handler;" << endl << indent()
- << "GHashTable *process_map;" << endl;
+ f_header_ << indent() << parent_class_name << " parent;" << '\n' << '\n' << indent()
+ << "/* protected */" << '\n' << indent()
+ << this->nspace + service_name_ + "Handler *handler;" << '\n' << indent()
+ << "GHashTable *process_map;" << '\n';
indent_down();
- f_header_ << "};" << endl << "typedef struct _" << class_name << " " << class_name << ";" << endl
- << endl;
+ f_header_ << "};" << '\n' << "typedef struct _" << class_name << " " << class_name << ";" << '\n'
+ << '\n';
// Generate the processor class definition
- f_header_ << "struct _" << class_name << "Class" << endl << "{" << endl;
+ f_header_ << "struct _" << class_name << "Class" << '\n' << "{" << '\n';
indent_up();
- f_header_ << indent() << parent_class_name << "Class parent;" << endl << endl << indent()
- << "/* protected */" << endl << indent()
- << "gboolean (*dispatch_call) (ThriftDispatchProcessor *processor," << endl;
+ f_header_ << indent() << parent_class_name << "Class parent;" << '\n' << '\n' << indent()
+ << "/* protected */" << '\n' << indent()
+ << "gboolean (*dispatch_call) (ThriftDispatchProcessor *processor," << '\n';
args_indent = indent() + string(27, ' ');
- f_header_ << args_indent << "ThriftProtocol *in," << endl << args_indent << "ThriftProtocol *out,"
- << endl << args_indent << "gchar *fname," << endl << args_indent << "gint32 seqid,"
- << endl << args_indent << "GError **error);" << endl;
+ f_header_ << args_indent << "ThriftProtocol *in," << '\n' << args_indent << "ThriftProtocol *out,"
+ << '\n' << args_indent << "gchar *fname," << '\n' << args_indent << "gint32 seqid,"
+ << '\n' << args_indent << "GError **error);" << '\n';
indent_down();
- f_header_ << "};" << endl << "typedef struct _" << class_name << "Class " << class_name
- << "Class;" << endl << endl;
+ f_header_ << "};" << '\n' << "typedef struct _" << class_name << "Class " << class_name
+ << "Class;" << '\n' << '\n';
// Generate the remaining header boilerplate
- f_header_ << "GType " << class_name_lc << "_get_type (void);" << endl << "#define "
+ f_header_ << "GType " << class_name_lc << "_get_type (void);" << '\n' << "#define "
<< this->nspace_uc << "TYPE_" << service_name_uc << "_PROCESSOR "
- << "(" << class_name_lc << "_get_type())" << endl << "#define " << class_name_uc
+ << "(" << class_name_lc << "_get_type())" << '\n' << "#define " << class_name_uc
<< "(obj) "
<< "(G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_PROCESSOR, " << class_name << "))" << endl << "#define "
+ << service_name_uc << "_PROCESSOR, " << class_name << "))" << '\n' << "#define "
<< this->nspace_uc << "IS_" << service_name_uc << "_PROCESSOR(obj) "
<< "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_PROCESSOR))" << endl << "#define " << class_name_uc
+ << service_name_uc << "_PROCESSOR))" << '\n' << "#define " << class_name_uc
<< "_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << endl << "#define "
+ << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << '\n' << "#define "
<< this->nspace_uc << "IS_" << service_name_uc << "_PROCESSOR_CLASS(c) "
<< "(G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc << "TYPE_" << service_name_uc
- << "_PROCESSOR))" << endl << "#define " << this->nspace_uc << service_name_uc
+ << "_PROCESSOR))" << '\n' << "#define " << this->nspace_uc << service_name_uc
<< "_PROCESSOR_GET_CLASS(obj) "
<< "(G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_"
- << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << endl << endl;
+ << service_name_uc << "_PROCESSOR, " << class_name << "Class))" << '\n' << '\n';
// Generate the processor's implementation in the implementation file
// Generate the processor's properties enum
- f_service_ << "enum _" << class_name << "Properties" << endl << "{" << endl;
+ f_service_ << "enum _" << class_name << "Properties" << '\n' << "{" << '\n';
indent_up();
- f_service_ << indent() << "PROP_" << class_name_uc << "_0," << endl << indent() << "PROP_"
- << class_name_uc << "_HANDLER" << endl;
+ f_service_ << indent() << "PROP_" << class_name_uc << "_0," << '\n' << indent() << "PROP_"
+ << class_name_uc << "_HANDLER" << '\n';
indent_down();
- f_service_ << "};" << endl << endl;
+ f_service_ << "};" << '\n' << '\n';
// Generate the implementation boilerplate
args_indent = string(15, ' ');
- f_service_ << "G_DEFINE_TYPE (" << class_name << "," << endl << args_indent << class_name_lc
- << "," << endl << args_indent << parent_type_name << ")" << endl << endl;
+ f_service_ << "G_DEFINE_TYPE (" << class_name << "," << '\n' << args_indent << class_name_lc
+ << "," << '\n' << args_indent << parent_type_name << ")" << '\n' << '\n';
// Generate the processor's processing-function type
args_indent = string(process_function_type_name.length() + 23, ' ');
f_service_ << "typedef gboolean (* " << process_function_type_name << ") ("
- << class_name << " *, " << endl
- << args_indent << "gint32," << endl
- << args_indent << "ThriftProtocol *," << endl
- << args_indent << "ThriftProtocol *," << endl
- << args_indent << "GError **);" << endl
- << endl;
+ << class_name << " *, " << '\n'
+ << args_indent << "gint32," << '\n'
+ << args_indent << "ThriftProtocol *," << '\n'
+ << args_indent << "ThriftProtocol *," << '\n'
+ << args_indent << "GError **);" << '\n'
+ << '\n';
// Generate the processor's processing-function-definition type
- f_service_ << "typedef struct" << endl
- << "{" << endl;
+ f_service_ << "typedef struct" << '\n'
+ << "{" << '\n';
indent_up();
- f_service_ << indent() << "gchar *name;" << endl
- << indent() << process_function_type_name << " function;" << endl;
+ f_service_ << indent() << "gchar *name;" << '\n'
+ << indent() << process_function_type_name << " function;" << '\n';
indent_down();
- f_service_ << "} " << process_function_def_type_name << ";" << endl
- << endl;
+ f_service_ << "} " << process_function_def_type_name << ";" << '\n'
+ << '\n';
// Generate forward declarations of the processor's processing functions so we
// can refer to them in the processing-function-definition struct below and
@@ -2193,23 +2191,23 @@
+ initial_caps_to_underscores((*function_iter)->get_name());
args_indent = string(function_name.length() + 2, ' ');
- f_service_ << "static gboolean" << endl
+ f_service_ << "static gboolean" << '\n'
<< function_name << " ("
- << class_name << " *," << endl
- << args_indent << "gint32," << endl
- << args_indent << "ThriftProtocol *," << endl
- << args_indent << "ThriftProtocol *," << endl
- << args_indent << "GError **);" << endl;
+ << class_name << " *," << '\n'
+ << args_indent << "gint32," << '\n'
+ << args_indent << "ThriftProtocol *," << '\n'
+ << args_indent << "ThriftProtocol *," << '\n'
+ << args_indent << "GError **);" << '\n';
}
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the processor's processing-function definitions, if the service
// defines any methods
if (functions.size() > 0) {
f_service_ << indent() << "static " << process_function_def_type_name
- << endl
+ << '\n'
<< indent() << class_name_lc << "_process_function_defs["
- << functions.size() << "] = {" << endl;
+ << functions.size() << "] = {" << '\n';
indent_up();
for (function_iter = functions.begin();
function_iter != functions.end();
@@ -2218,17 +2216,17 @@
string process_function_name = class_name_lc + "_process_"
+ initial_caps_to_underscores(service_function_name);
- f_service_ << indent() << "{" << endl;
+ f_service_ << indent() << "{" << '\n';
indent_up();
- f_service_ << indent() << "\"" << service_function_name << "\"," << endl
- << indent() << process_function_name << endl;
+ f_service_ << indent() << "\"" << service_function_name << "\"," << '\n'
+ << indent() << process_function_name << '\n';
indent_down();
f_service_ << indent() << "}"
- << (function_iter == --functions.end() ? "" : ",") << endl;
+ << (function_iter == --functions.end() ? "" : ",") << '\n';
}
indent_down();
- f_service_ << indent() << "};" << endl
- << endl;
+ f_service_ << indent() << "};" << '\n'
+ << '\n';
}
// Generate the processor's processing functions
@@ -2262,76 +2260,76 @@
+ initial_caps_to_underscores(service_function_name);
args_indent = string(function_name.length() + 2, ' ');
- f_service_ << "static gboolean" << endl << function_name << " (" << class_name << " *self,"
- << endl << args_indent << "gint32 sequence_id," << endl << args_indent
- << "ThriftProtocol *input_protocol," << endl << args_indent
- << "ThriftProtocol *output_protocol," << endl << args_indent << "GError **error)"
- << endl;
+ f_service_ << "static gboolean" << '\n' << function_name << " (" << class_name << " *self,"
+ << '\n' << args_indent << "gint32 sequence_id," << '\n' << args_indent
+ << "ThriftProtocol *input_protocol," << '\n' << args_indent
+ << "ThriftProtocol *output_protocol," << '\n' << args_indent << "GError **error)"
+ << '\n';
scope_up(f_service_);
- f_service_ << indent() << "gboolean result = TRUE;" << endl
- << indent() << "ThriftTransport * transport;" << endl
- << indent() << "ThriftApplicationException *xception;" << endl
- << indent() << args_class_name + " * args =" << endl;
+ f_service_ << indent() << "gboolean result = TRUE;" << '\n'
+ << indent() << "ThriftTransport * transport;" << '\n'
+ << indent() << "ThriftApplicationException *xception;" << '\n'
+ << indent() << args_class_name + " * args =" << '\n';
indent_up();
- f_service_ << indent() << "g_object_new (" << args_class_type << ", NULL);" << endl << endl;
+ f_service_ << indent() << "g_object_new (" << args_class_type << ", NULL);" << '\n' << '\n';
indent_down();
if ((*function_iter)->is_oneway()) {
- f_service_ << indent() << "THRIFT_UNUSED_VAR (sequence_id);" << endl << indent()
- << "THRIFT_UNUSED_VAR (output_protocol);" << endl << endl;
+ f_service_ << indent() << "THRIFT_UNUSED_VAR (sequence_id);" << '\n' << indent()
+ << "THRIFT_UNUSED_VAR (output_protocol);" << '\n' << '\n';
}
f_service_ << indent() << "g_object_get (input_protocol, \"transport\", "
- << "&transport, NULL);" << endl << endl;
+ << "&transport, NULL);" << '\n' << '\n';
// Read the method's arguments from the caller
f_service_ << indent() << "if ((thrift_struct_read (THRIFT_STRUCT (args), "
- << "input_protocol, error) != -1) &&" << endl << indent()
+ << "input_protocol, error) != -1) &&" << '\n' << indent()
<< " (thrift_protocol_read_message_end (input_protocol, "
- << "error) != -1) &&" << endl << indent()
- << " (thrift_transport_read_end (transport, error) != FALSE))" << endl;
+ << "error) != -1) &&" << '\n' << indent()
+ << " (thrift_transport_read_end (transport, error) != FALSE))" << '\n';
scope_up(f_service_);
for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) {
f_service_ << indent() << property_type_name((*arg_iter)->get_type()) << " "
- << (*arg_iter)->get_name() << ";" << endl;
+ << (*arg_iter)->get_name() << ";" << '\n';
}
for (xception_iter = xceptions.begin(); xception_iter != xceptions.end(); ++xception_iter) {
f_service_ << indent() << type_name((*xception_iter)->get_type()) << " "
- << initial_caps_to_underscores((*xception_iter)->get_name()) << " = NULL;" << endl;
+ << initial_caps_to_underscores((*xception_iter)->get_name()) << " = NULL;" << '\n';
}
if (has_return_value) {
- f_service_ << indent() << property_type_name(return_type) << " return_value;" << endl;
+ f_service_ << indent() << property_type_name(return_type) << " return_value;" << '\n';
}
if (!(*function_iter)->is_oneway()) {
- f_service_ << indent() << result_class_name << " * result_struct;" << endl;
+ f_service_ << indent() << result_class_name << " * result_struct;" << '\n';
}
- f_service_ << endl;
+ f_service_ << '\n';
if (args.size() > 0) {
- f_service_ << indent() << "g_object_get (args," << endl;
+ f_service_ << indent() << "g_object_get (args," << '\n';
args_indent = indent() + string(14, ' ');
for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) {
string arg_name = (*arg_iter)->get_name();
- f_service_ << args_indent << "\"" << arg_name << "\", &" << arg_name << "," << endl;
+ f_service_ << args_indent << "\"" << arg_name << "\", &" << arg_name << "," << '\n';
}
- f_service_ << args_indent << "NULL);" << endl << endl;
+ f_service_ << args_indent << "NULL);" << '\n' << '\n';
}
if (!(*function_iter)->is_oneway()) {
- f_service_ << indent() << "g_object_unref (transport);" << endl << indent()
+ f_service_ << indent() << "g_object_unref (transport);" << '\n' << indent()
<< "g_object_get (output_protocol, \"transport\", "
- << "&transport, NULL);" << endl << endl << indent()
- << "result_struct = g_object_new (" << result_class_type << ", NULL);" << endl;
+ << "&transport, NULL);" << '\n' << '\n' << indent()
+ << "result_struct = g_object_new (" << result_class_type << ", NULL);" << '\n';
if (has_return_value) {
f_service_ << indent() << "g_object_get (result_struct, "
- "\"success\", &return_value, NULL);" << endl;
+ "\"success\", &return_value, NULL);" << '\n';
}
- f_service_ << endl;
+ f_service_ << '\n';
}
// Pass the arguments to the corresponding method in the handler
f_service_ << indent() << "if (" << handler_function_name << " (" << this->nspace_uc
- << service_name_uc << "_IF (self->handler)," << endl;
+ << service_name_uc << "_IF (self->handler)," << '\n';
args_indent = indent() + string(handler_function_name.length() + 6, ' ');
if (has_return_value) {
string return_type_name = type_name(return_type);
@@ -2351,16 +2349,16 @@
f_service_ << "(" << return_type_name << ")";
}
- f_service_ << "&return_value," << endl;
+ f_service_ << "&return_value," << '\n';
}
for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) {
- f_service_ << args_indent << (*arg_iter)->get_name() << "," << endl;
+ f_service_ << args_indent << (*arg_iter)->get_name() << "," << '\n';
}
for (xception_iter = xceptions.begin(); xception_iter != xceptions.end(); ++xception_iter) {
f_service_ << args_indent << "&" << initial_caps_to_underscores((*xception_iter)->get_name())
- << "," << endl;
+ << "," << '\n';
}
- f_service_ << args_indent << "error) == TRUE)" << endl;
+ f_service_ << args_indent << "error) == TRUE)" << '\n';
scope_up(f_service_);
// The handler reported success; return the result, if any, to the caller
@@ -2373,24 +2371,24 @@
<< "(" << type_name(return_type) << ")";
}
f_service_ << "return_value, "
- << "NULL);" << endl;
- f_service_ << endl;
+ << "NULL);" << '\n';
+ f_service_ << '\n';
}
- f_service_ << indent() << "result =" << endl;
+ f_service_ << indent() << "result =" << '\n';
indent_up();
- f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << endl;
+ f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << '\n';
args_indent = indent() + string(39, ' ');
- f_service_ << args_indent << "\"" << service_function_name << "\"," << endl << args_indent
- << "T_REPLY," << endl << args_indent << "sequence_id," << endl << args_indent
- << "error) != -1) &&" << endl << indent()
- << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << endl;
+ f_service_ << args_indent << "\"" << service_function_name << "\"," << '\n' << args_indent
+ << "T_REPLY," << '\n' << args_indent << "sequence_id," << '\n' << args_indent
+ << "error) != -1) &&" << '\n' << indent()
+ << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << '\n';
args_indent = indent() + string(23, ' ');
- f_service_ << args_indent << "output_protocol," << endl << args_indent << "error) != -1));"
- << endl;
+ f_service_ << args_indent << "output_protocol," << '\n' << args_indent << "error) != -1));"
+ << '\n';
indent_down();
}
scope_down(f_service_);
- f_service_ << indent() << "else" << endl;
+ f_service_ << indent() << "else" << '\n';
scope_up(f_service_);
// The handler reported failure; check to see if an application-defined
@@ -2399,28 +2397,28 @@
if (xceptions.size() > 0) {
for (xception_iter = xceptions.begin(); xception_iter != xceptions.end(); ++xception_iter) {
f_service_ << "if (" << initial_caps_to_underscores((*xception_iter)->get_name())
- << " != NULL)" << endl;
+ << " != NULL)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << "g_object_set (result_struct," << endl;
+ f_service_ << indent() << "g_object_set (result_struct," << '\n';
args_indent = indent() + string(14, ' ');
f_service_ << args_indent << "\"" << (*xception_iter)->get_name() << "\", "
- << (*xception_iter)->get_name() << "," << endl << args_indent << "NULL);" << endl
- << endl;
- f_service_ << indent() << "g_object_unref ("<< (*xception_iter)->get_name() <<");"<< endl;
- f_service_ << indent() << "result =" << endl;
+ << (*xception_iter)->get_name() << "," << '\n' << args_indent << "NULL);" << '\n'
+ << '\n';
+ f_service_ << indent() << "g_object_unref ("<< (*xception_iter)->get_name() <<");"<< '\n';
+ f_service_ << indent() << "result =" << '\n';
indent_up();
- f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << endl;
+ f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << '\n';
args_indent = indent() + string(39, ' ');
- f_service_ << args_indent << "\"" << service_function_name << "\"," << endl << args_indent
- << "T_REPLY," << endl << args_indent << "sequence_id," << endl << args_indent
- << "error) != -1) &&" << endl << indent()
- << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << endl;
+ f_service_ << args_indent << "\"" << service_function_name << "\"," << '\n' << args_indent
+ << "T_REPLY," << '\n' << args_indent << "sequence_id," << '\n' << args_indent
+ << "error) != -1) &&" << '\n' << indent()
+ << " (thrift_struct_write (THRIFT_STRUCT (result_struct)," << '\n';
args_indent = indent() + string(23, ' ');
- f_service_ << args_indent << "output_protocol," << endl << args_indent << "error) != -1));"
- << endl;
+ f_service_ << args_indent << "output_protocol," << '\n' << args_indent << "error) != -1));"
+ << '\n';
indent_down();
scope_down(f_service_);
- f_service_ << indent() << "else" << endl;
+ f_service_ << indent() << "else" << '\n';
}
scope_up(f_service_);
@@ -2430,41 +2428,41 @@
// If the handler reported failure but raised no application-defined
// exception, return a Thrift application exception with the information
// returned via GLib's own error-reporting mechanism
- f_service_ << "if (*error == NULL)" << endl;
+ f_service_ << "if (*error == NULL)" << '\n';
indent_up();
f_service_ << indent() << "g_warning (\"" << service_name_ << "."
- << (*function_iter)->get_name() << " implementation returned FALSE \"" << endl
- << indent() << string(11, ' ') << "\"but did not set an error\");" << endl << endl;
+ << (*function_iter)->get_name() << " implementation returned FALSE \"" << '\n'
+ << indent() << string(11, ' ') << "\"but did not set an error\");" << '\n' << '\n';
indent_down();
- f_service_ << indent() << "xception =" << endl;
+ f_service_ << indent() << "xception =" << '\n';
indent_up();
- f_service_ << indent() << "g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION," << endl;
+ f_service_ << indent() << "g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION," << '\n';
args_indent = indent() + string(14, ' ');
- f_service_ << args_indent << "\"type\", *error != NULL ? (*error)->code :" << endl
+ f_service_ << args_indent << "\"type\", *error != NULL ? (*error)->code :" << '\n'
<< args_indent << string(11, ' ') << "THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN,"
- << endl << args_indent << "\"message\", *error != NULL ? (*error)->message : NULL,"
- << endl << args_indent << "NULL);" << endl;
+ << '\n' << args_indent << "\"message\", *error != NULL ? (*error)->message : NULL,"
+ << '\n' << args_indent << "NULL);" << '\n';
indent_down();
- f_service_ << indent() << "g_clear_error (error);" << endl << endl << indent()
- << "result =" << endl;
+ f_service_ << indent() << "g_clear_error (error);" << '\n' << '\n' << indent()
+ << "result =" << '\n';
indent_up();
- f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << endl;
+ f_service_ << indent() << "((thrift_protocol_write_message_begin (output_protocol," << '\n';
args_indent = indent() + string(39, ' ');
- f_service_ << args_indent << "\"" << service_function_name << "\"," << endl << args_indent
- << "T_EXCEPTION," << endl << args_indent << "sequence_id," << endl << args_indent
- << "error) != -1) &&" << endl << indent()
- << " (thrift_struct_write (THRIFT_STRUCT (xception)," << endl;
+ f_service_ << args_indent << "\"" << service_function_name << "\"," << '\n' << args_indent
+ << "T_EXCEPTION," << '\n' << args_indent << "sequence_id," << '\n' << args_indent
+ << "error) != -1) &&" << '\n' << indent()
+ << " (thrift_struct_write (THRIFT_STRUCT (xception)," << '\n';
args_indent = indent() + string(23, ' ');
- f_service_ << args_indent << "output_protocol," << endl << args_indent << "error) != -1));"
- << endl;
+ f_service_ << args_indent << "output_protocol," << '\n' << args_indent << "error) != -1));"
+ << '\n';
indent_down();
- f_service_ << endl << indent() << "g_object_unref (xception);" << endl;
+ f_service_ << '\n' << indent() << "g_object_unref (xception);" << '\n';
if (xceptions.size() > 0) {
scope_down(f_service_);
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Dellocate or unref retrieved argument values as necessary
for (arg_iter = args.begin(); arg_iter != args.end(); ++arg_iter) {
@@ -2475,17 +2473,17 @@
t_base_type* base_type = ((t_base_type*)arg_type);
if (base_type->get_base() == t_base_type::TYPE_STRING) {
- f_service_ << indent() << "if (" << arg_name << " != NULL)" << endl;
+ f_service_ << indent() << "if (" << arg_name << " != NULL)" << '\n';
indent_up();
if (base_type->is_binary()) {
- f_service_ << indent() << "g_byte_array_unref (" << arg_name << ");" << endl;
+ f_service_ << indent() << "g_byte_array_unref (" << arg_name << ");" << '\n';
} else {
- f_service_ << indent() << "g_free (" << arg_name << ");" << endl;
+ f_service_ << indent() << "g_free (" << arg_name << ");" << '\n';
}
indent_down();
}
} else if (arg_type->is_container()) {
- f_service_ << indent() << "if (" << arg_name << " != NULL)" << endl;
+ f_service_ << indent() << "if (" << arg_name << " != NULL)" << '\n';
indent_up();
if (arg_type->is_list()) {
@@ -2497,16 +2495,16 @@
} else {
f_service_ << "g_ptr_array_unref";
}
- f_service_ << " (" << arg_name << ");" << endl;
+ f_service_ << " (" << arg_name << ");" << '\n';
} else if (arg_type->is_map() || arg_type->is_set()) {
- f_service_ << indent() << "g_hash_table_unref (" << arg_name << ");" << endl;
+ f_service_ << indent() << "g_hash_table_unref (" << arg_name << ");" << '\n';
}
indent_down();
} else if (arg_type->is_struct()) {
- f_service_ << indent() << "if (" << arg_name << " != NULL)" << endl;
+ f_service_ << indent() << "if (" << arg_name << " != NULL)" << '\n';
indent_up();
- f_service_ << indent() << "g_object_unref (" << arg_name << ");" << endl;
+ f_service_ << indent() << "g_object_unref (" << arg_name << ");" << '\n';
indent_down();
}
}
@@ -2518,17 +2516,17 @@
if (return_type->is_base_type()) {
t_base_type* base_type = ((t_base_type*)return_type);
if (base_type->get_base() == t_base_type::TYPE_STRING) {
- f_service_ << indent() << "if (return_value != NULL)" << endl;
+ f_service_ << indent() << "if (return_value != NULL)" << '\n';
indent_up();
if (base_type->is_binary()) {
- f_service_ << indent() << "g_byte_array_unref (return_value);" << endl;
+ f_service_ << indent() << "g_byte_array_unref (return_value);" << '\n';
} else {
- f_service_ << indent() << "g_free (return_value);" << endl;
+ f_service_ << indent() << "g_free (return_value);" << '\n';
}
indent_down();
}
} else if (return_type->is_container()) {
- f_service_ << indent() << "if (return_value != NULL)" << endl;
+ f_service_ << indent() << "if (return_value != NULL)" << '\n';
indent_up();
if (return_type->is_list()) {
@@ -2540,81 +2538,81 @@
} else {
f_service_ << "g_ptr_array_unref";
}
- f_service_ << " (return_value);" << endl;
+ f_service_ << " (return_value);" << '\n';
} else if (return_type->is_map() || return_type->is_set()) {
- f_service_ << indent() << "g_hash_table_unref (return_value);" << endl;
+ f_service_ << indent() << "g_hash_table_unref (return_value);" << '\n';
}
indent_down();
} else if (return_type->is_struct()) {
- f_service_ << indent() << "if (return_value != NULL)" << endl;
+ f_service_ << indent() << "if (return_value != NULL)" << '\n';
indent_up();
- f_service_ << indent() << "g_object_unref (return_value);" << endl;
+ f_service_ << indent() << "g_object_unref (return_value);" << '\n';
indent_down();
}
}
- f_service_ << indent() << "g_object_unref (result_struct);" << endl << endl << indent()
- << "if (result == TRUE)" << endl;
+ f_service_ << indent() << "g_object_unref (result_struct);" << '\n' << '\n' << indent()
+ << "if (result == TRUE)" << '\n';
indent_up();
- f_service_ << indent() << "result =" << endl;
+ f_service_ << indent() << "result =" << '\n';
indent_up();
f_service_ << indent() << "((thrift_protocol_write_message_end "
- << "(output_protocol, error) != -1) &&" << endl << indent()
+ << "(output_protocol, error) != -1) &&" << '\n' << indent()
<< " (thrift_transport_write_end (transport, error) "
- << "!= FALSE) &&" << endl << indent()
+ << "!= FALSE) &&" << '\n' << indent()
<< " (thrift_transport_flush (transport, error) "
- << "!= FALSE));" << endl;
+ << "!= FALSE));" << '\n';
indent_down();
indent_down();
}
scope_down(f_service_);
- f_service_ << indent() << "else" << endl;
+ f_service_ << indent() << "else" << '\n';
indent_up();
- f_service_ << indent() << "result = FALSE;" << endl;
+ f_service_ << indent() << "result = FALSE;" << '\n';
indent_down();
- f_service_ << endl << indent() << "g_object_unref (transport);" << endl << indent()
- << "g_object_unref (args);" << endl << endl << indent() << "return result;" << endl;
+ f_service_ << '\n' << indent() << "g_object_unref (transport);" << '\n' << indent()
+ << "g_object_unref (args);" << '\n' << '\n' << indent() << "return result;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
// Generate the processor's dispatch_call implementation
function_name = class_name_lc + "_dispatch_call";
args_indent = indent() + string(function_name.length() + 2, ' ');
- f_service_ << "static gboolean" << endl << function_name
- << " (ThriftDispatchProcessor *dispatch_processor," << endl << args_indent
- << "ThriftProtocol *input_protocol," << endl << args_indent
- << "ThriftProtocol *output_protocol," << endl << args_indent << "gchar *method_name,"
- << endl << args_indent << "gint32 sequence_id," << endl << args_indent
- << "GError **error)" << endl;
+ f_service_ << "static gboolean" << '\n' << function_name
+ << " (ThriftDispatchProcessor *dispatch_processor," << '\n' << args_indent
+ << "ThriftProtocol *input_protocol," << '\n' << args_indent
+ << "ThriftProtocol *output_protocol," << '\n' << args_indent << "gchar *method_name,"
+ << '\n' << args_indent << "gint32 sequence_id," << '\n' << args_indent
+ << "GError **error)" << '\n';
scope_up(f_service_);
f_service_ << indent() << class_name_lc << "_process_function_def *"
- << "process_function_def;" << endl;
- f_service_ << indent() << "gboolean dispatch_result = FALSE;" << endl << endl << indent()
- << class_name << " *self = " << class_name_uc << " (dispatch_processor);" << endl;
+ << "process_function_def;" << '\n';
+ f_service_ << indent() << "gboolean dispatch_result = FALSE;" << '\n' << '\n' << indent()
+ << class_name << " *self = " << class_name_uc << " (dispatch_processor);" << '\n';
f_service_ << indent() << parent_class_name << "Class "
- "*parent_class =" << endl;
+ "*parent_class =" << '\n';
indent_up();
f_service_ << indent() << "g_type_class_peek_parent (" << class_name_uc << "_GET_CLASS (self));"
- << endl;
+ << '\n';
indent_down();
- f_service_ << endl
+ f_service_ << '\n'
<< indent() << "process_function_def = "
- << "g_hash_table_lookup (self->process_map, method_name);" << endl
- << indent() << "if (process_function_def != NULL)" << endl;
+ << "g_hash_table_lookup (self->process_map, method_name);" << '\n'
+ << indent() << "if (process_function_def != NULL)" << '\n';
scope_up(f_service_);
args_indent = indent() + string(53, ' ');
- f_service_ << indent() << "g_free (method_name);" << endl
+ f_service_ << indent() << "g_free (method_name);" << '\n'
<< indent() << "dispatch_result = "
- << "(*process_function_def->function) (self," << endl
- << args_indent << "sequence_id," << endl
- << args_indent << "input_protocol," << endl
- << args_indent << "output_protocol," << endl
- << args_indent << "error);" << endl;
+ << "(*process_function_def->function) (self," << '\n'
+ << args_indent << "sequence_id," << '\n'
+ << args_indent << "input_protocol," << '\n'
+ << args_indent << "output_protocol," << '\n'
+ << args_indent << "error);" << '\n';
scope_down(f_service_);
- f_service_ << indent() << "else" << endl;
+ f_service_ << indent() << "else" << '\n';
scope_up(f_service_);
// Method name not recognized; chain up to our parent processor---note the
@@ -2622,160 +2620,160 @@
// will return an application exception to the caller if no class in the
// hierarchy recognizes the method name
f_service_ << indent() << "dispatch_result = parent_class->dispatch_call "
- "(dispatch_processor," << endl;
+ "(dispatch_processor," << '\n';
args_indent = indent() + string(47, ' ');
- f_service_ << args_indent << "input_protocol," << endl << args_indent << "output_protocol,"
- << endl << args_indent << "method_name," << endl << args_indent << "sequence_id,"
- << endl << args_indent << "error);" << endl;
+ f_service_ << args_indent << "input_protocol," << '\n' << args_indent << "output_protocol,"
+ << '\n' << args_indent << "method_name," << '\n' << args_indent << "sequence_id,"
+ << '\n' << args_indent << "error);" << '\n';
scope_down(f_service_);
- f_service_ << endl << indent() << "return dispatch_result;" << endl;
+ f_service_ << '\n' << indent() << "return dispatch_result;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the processor's property setter
function_name = class_name_lc + "_set_property";
args_indent = string(function_name.length() + 2, ' ');
- f_service_ << "static void" << endl << function_name << " (GObject *object," << endl
- << args_indent << "guint property_id," << endl << args_indent << "const GValue *value,"
- << endl << args_indent << "GParamSpec *pspec)" << endl;
+ f_service_ << "static void" << '\n' << function_name << " (GObject *object," << '\n'
+ << args_indent << "guint property_id," << '\n' << args_indent << "const GValue *value,"
+ << '\n' << args_indent << "GParamSpec *pspec)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl
- << endl << indent() << "switch (property_id)" << endl;
+ f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n'
+ << '\n' << indent() << "switch (property_id)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << endl;
+ f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << '\n';
indent_up();
- f_service_ << indent() << "if (self->handler != NULL)" << endl;
+ f_service_ << indent() << "if (self->handler != NULL)" << '\n';
indent_up();
- f_service_ << indent() << "g_object_unref (self->handler);" << endl;
+ f_service_ << indent() << "g_object_unref (self->handler);" << '\n';
indent_down();
- f_service_ << indent() << "self->handler = g_value_get_object (value);" << endl << indent()
- << "g_object_ref (self->handler);" << endl;
+ f_service_ << indent() << "self->handler = g_value_get_object (value);" << '\n' << indent()
+ << "g_object_ref (self->handler);" << '\n';
if (extends_service) {
// Chain up to set the handler in every superclass as well
- f_service_ << endl << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)->"
- << endl;
+ f_service_ << '\n' << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)->"
+ << '\n';
indent_up();
- f_service_ << indent() << "set_property (object, property_id, value, pspec);" << endl;
+ f_service_ << indent() << "set_property (object, property_id, value, pspec);" << '\n';
indent_down();
}
- f_service_ << indent() << "break;" << endl;
+ f_service_ << indent() << "break;" << '\n';
indent_down();
- f_service_ << indent() << "default:" << endl;
+ f_service_ << indent() << "default:" << '\n';
indent_up();
f_service_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);"
- << endl << indent() << "break;" << endl;
+ << '\n' << indent() << "break;" << '\n';
indent_down();
scope_down(f_service_);
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate processor's property getter
function_name = class_name_lc + "_get_property";
args_indent = string(function_name.length() + 2, ' ');
- f_service_ << "static void" << endl << function_name << " (GObject *object," << endl
- << args_indent << "guint property_id," << endl << args_indent << "GValue *value,"
- << endl << args_indent << "GParamSpec *pspec)" << endl;
+ f_service_ << "static void" << '\n' << function_name << " (GObject *object," << '\n'
+ << args_indent << "guint property_id," << '\n' << args_indent << "GValue *value,"
+ << '\n' << args_indent << "GParamSpec *pspec)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl
- << endl << indent() << "switch (property_id)" << endl;
+ f_service_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n'
+ << '\n' << indent() << "switch (property_id)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << endl;
+ f_service_ << indent() << "case PROP_" << class_name_uc << "_HANDLER:" << '\n';
indent_up();
- f_service_ << indent() << "g_value_set_object (value, self->handler);" << endl << indent()
- << "break;" << endl;
+ f_service_ << indent() << "g_value_set_object (value, self->handler);" << '\n' << indent()
+ << "break;" << '\n';
indent_down();
- f_service_ << indent() << "default:" << endl;
+ f_service_ << indent() << "default:" << '\n';
indent_up();
f_service_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);"
- << endl << indent() << "break;" << endl;
+ << '\n' << indent() << "break;" << '\n';
indent_down();
scope_down(f_service_);
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generator the processor's dispose function
- f_service_ << "static void" << endl << class_name_lc << "_dispose (GObject *gobject)" << endl;
+ f_service_ << "static void" << '\n' << class_name_lc << "_dispose (GObject *gobject)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << class_name << " *self = " << class_name_uc << " (gobject);" << endl
- << endl << indent() << "if (self->handler != NULL)" << endl;
+ f_service_ << indent() << class_name << " *self = " << class_name_uc << " (gobject);" << '\n'
+ << '\n' << indent() << "if (self->handler != NULL)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << "g_object_unref (self->handler);" << endl << indent()
- << "self->handler = NULL;" << endl;
+ f_service_ << indent() << "g_object_unref (self->handler);" << '\n' << indent()
+ << "self->handler = NULL;" << '\n';
scope_down(f_service_);
- f_service_ << endl << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)"
+ f_service_ << '\n' << indent() << "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)"
"->dispose (gobject);"
- << endl;
+ << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate processor finalize function
- f_service_ << "static void" << endl << class_name_lc << "_finalize (GObject *gobject)" << endl;
+ f_service_ << "static void" << '\n' << class_name_lc << "_finalize (GObject *gobject)" << '\n';
scope_up(f_service_);
f_service_ << indent() << this->nspace << service_name_ << "Processor *self = " << this->nspace_uc
- << service_name_uc << "_PROCESSOR (gobject);" << endl << endl << indent()
- << "thrift_safe_hash_table_destroy (self->process_map);" << endl << endl << indent()
+ << service_name_uc << "_PROCESSOR (gobject);" << '\n' << '\n' << indent()
+ << "thrift_safe_hash_table_destroy (self->process_map);" << '\n' << '\n' << indent()
<< "G_OBJECT_CLASS (" << class_name_lc << "_parent_class)"
- "->finalize (gobject);" << endl;
+ "->finalize (gobject);" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate processor instance initializer
- f_service_ << "static void" << endl << class_name_lc << "_init (" << class_name << " *self)"
- << endl;
+ f_service_ << "static void" << '\n' << class_name_lc << "_init (" << class_name << " *self)"
+ << '\n';
scope_up(f_service_);
if (functions.size() > 0) {
- f_service_ << indent() << "guint index;" << endl
- << endl;
+ f_service_ << indent() << "guint index;" << '\n'
+ << '\n';
}
- f_service_ << indent() << "self->handler = NULL;" << endl << indent()
+ f_service_ << indent() << "self->handler = NULL;" << '\n' << indent()
<< "self->process_map = "
- "g_hash_table_new (g_str_hash, g_str_equal);" << endl;
+ "g_hash_table_new (g_str_hash, g_str_equal);" << '\n';
if (functions.size() > 0) {
args_indent = string(21, ' ');
- f_service_ << endl
+ f_service_ << '\n'
<< indent() << "for (index = 0; index < "
- << functions.size() << "; index += 1)" << endl;
+ << functions.size() << "; index += 1)" << '\n';
indent_up();
- f_service_ << indent() << "g_hash_table_insert (self->process_map," << endl
+ f_service_ << indent() << "g_hash_table_insert (self->process_map," << '\n'
<< indent() << args_indent
- << class_name_lc << "_process_function_defs[index].name," << endl
+ << class_name_lc << "_process_function_defs[index].name," << '\n'
<< indent() << args_indent
<< "&" << class_name_lc << "_process_function_defs[index]" << ");"
- << endl;
+ << '\n';
indent_down();
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate processor class initializer
- f_service_ << "static void" << endl << class_name_lc << "_class_init (" << class_name
- << "Class *cls)" << endl;
+ f_service_ << "static void" << '\n' << class_name_lc << "_class_init (" << class_name
+ << "Class *cls)" << '\n';
scope_up(f_service_);
- f_service_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << endl
- << indent() << "ThriftDispatchProcessorClass *dispatch_processor_class =" << endl;
+ f_service_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << '\n'
+ << indent() << "ThriftDispatchProcessorClass *dispatch_processor_class =" << '\n';
indent_up();
- f_service_ << indent() << "THRIFT_DISPATCH_PROCESSOR_CLASS (cls);" << endl;
+ f_service_ << indent() << "THRIFT_DISPATCH_PROCESSOR_CLASS (cls);" << '\n';
indent_down();
- f_service_ << indent() << "GParamSpec *param_spec;" << endl << endl << indent()
- << "gobject_class->dispose = " << class_name_lc << "_dispose;" << endl << indent()
- << "gobject_class->finalize = " << class_name_lc << "_finalize;" << endl << indent()
- << "gobject_class->set_property = " << class_name_lc << "_set_property;" << endl
+ f_service_ << indent() << "GParamSpec *param_spec;" << '\n' << '\n' << indent()
+ << "gobject_class->dispose = " << class_name_lc << "_dispose;" << '\n' << indent()
+ << "gobject_class->finalize = " << class_name_lc << "_finalize;" << '\n' << indent()
+ << "gobject_class->set_property = " << class_name_lc << "_set_property;" << '\n'
<< indent() << "gobject_class->get_property = " << class_name_lc << "_get_property;"
- << endl << endl << indent()
+ << '\n' << '\n' << indent()
<< "dispatch_processor_class->dispatch_call = " << class_name_lc << "_dispatch_call;"
- << endl << indent() << "cls->dispatch_call = " << class_name_lc << "_dispatch_call;"
- << endl << endl << indent() << "param_spec = g_param_spec_object (\"handler\","
- << endl;
+ << '\n' << indent() << "cls->dispatch_call = " << class_name_lc << "_dispatch_call;"
+ << '\n' << '\n' << indent() << "param_spec = g_param_spec_object (\"handler\","
+ << '\n';
args_indent = indent() + string(34, ' ');
- f_service_ << args_indent << "\"Service handler implementation\"," << endl << args_indent
- << "\"The service handler implementation \"" << endl << args_indent
- << "\"to which method calls are dispatched.\"," << endl << args_indent
- << this->nspace_uc + "TYPE_" + service_name_uc + "_HANDLER," << endl << args_indent
- << "G_PARAM_READWRITE);" << endl;
- f_service_ << indent() << "g_object_class_install_property (gobject_class," << endl;
+ f_service_ << args_indent << "\"Service handler implementation\"," << '\n' << args_indent
+ << "\"The service handler implementation \"" << '\n' << args_indent
+ << "\"to which method calls are dispatched.\"," << '\n' << args_indent
+ << this->nspace_uc + "TYPE_" + service_name_uc + "_HANDLER," << '\n' << args_indent
+ << "G_PARAM_READWRITE);" << '\n';
+ f_service_ << indent() << "g_object_class_install_property (gobject_class," << '\n';
args_indent = indent() + string(33, ' ');
- f_service_ << args_indent << "PROP_" << class_name_uc << "_HANDLER," << endl << args_indent
- << "param_spec);" << endl;
+ f_service_ << args_indent << "PROP_" << class_name_uc << "_HANDLER," << '\n' << args_indent
+ << "param_spec);" << '\n';
scope_down(f_service_);
}
@@ -2807,60 +2805,60 @@
string args_indent;
// write the instance definition
- f_types_ << "struct _" << this->nspace << name << endl << "{ " << endl
- << " ThriftStruct parent; " << endl << endl << " /* public */" << endl;
+ f_types_ << "struct _" << this->nspace << name << '\n' << "{ " << '\n'
+ << " ThriftStruct parent; " << '\n' << '\n' << " /* public */" << '\n';
// for each field, add a member variable
vector<t_field*>::const_iterator m_iter;
const vector<t_field*>& members = tstruct->get_members();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- f_types_ << " " << type_name(t) << " " << (*m_iter)->get_name() << ";" << endl;
+ f_types_ << " " << type_name(t) << " " << (*m_iter)->get_name() << ";" << '\n';
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
- f_types_ << " gboolean __isset_" << (*m_iter)->get_name() << ";" << endl;
+ f_types_ << " gboolean __isset_" << (*m_iter)->get_name() << ";" << '\n';
}
}
// close the structure definition and create a typedef
- f_types_ << "};" << endl << "typedef struct _" << this->nspace << name << " " << this->nspace
- << name << ";" << endl << endl;
+ f_types_ << "};" << '\n' << "typedef struct _" << this->nspace << name << " " << this->nspace
+ << name << ";" << '\n' << '\n';
// write the class definition
- f_types_ << "struct _" << this->nspace << name << "Class" << endl << "{" << endl
- << " ThriftStructClass parent;" << endl << "};" << endl << "typedef struct _"
- << this->nspace << name << "Class " << this->nspace << name << "Class;" << endl << endl;
+ f_types_ << "struct _" << this->nspace << name << "Class" << '\n' << "{" << '\n'
+ << " ThriftStructClass parent;" << '\n' << "};" << '\n' << "typedef struct _"
+ << this->nspace << name << "Class " << this->nspace << name << "Class;" << '\n' << '\n';
// write the standard GObject boilerplate
- f_types_ << "GType " << this->nspace_lc << name_u << "_get_type (void);" << endl << "#define "
+ f_types_ << "GType " << this->nspace_lc << name_u << "_get_type (void);" << '\n' << "#define "
<< this->nspace_uc << "TYPE_" << name_uc << " (" << this->nspace_lc << name_u
- << "_get_type())" << endl << "#define " << this->nspace_uc << name_uc
+ << "_get_type())" << '\n' << "#define " << this->nspace_uc << name_uc
<< "(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), " << this->nspace_uc << "TYPE_" << name_uc
- << ", " << this->nspace << name << "))" << endl << "#define " << this->nspace_uc
+ << ", " << this->nspace << name << "))" << '\n' << "#define " << this->nspace_uc
<< name_uc << "_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), " << this->nspace_uc << "_TYPE_"
- << name_uc << ", " << this->nspace << name << "Class))" << endl << "#define "
+ << name_uc << ", " << this->nspace << name << "Class))" << '\n' << "#define "
<< this->nspace_uc << "IS_" << name_uc << "(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), "
- << this->nspace_uc << "TYPE_" << name_uc << "))" << endl << "#define " << this->nspace_uc
+ << this->nspace_uc << "TYPE_" << name_uc << "))" << '\n' << "#define " << this->nspace_uc
<< "IS_" << name_uc << "_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), " << this->nspace_uc
- << "TYPE_" << name_uc << "))" << endl << "#define " << this->nspace_uc << name_uc
+ << "TYPE_" << name_uc << "))" << '\n' << "#define " << this->nspace_uc << name_uc
<< "_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), " << this->nspace_uc << "TYPE_"
- << name_uc << ", " << this->nspace << name << "Class))" << endl << endl;
+ << name_uc << ", " << this->nspace << name << "Class))" << '\n' << '\n';
// start writing the object implementation .c file
// generate properties enum
if (members.size() > 0) {
- f_types_impl_ << "enum _" << class_name << "Properties" << endl << "{" << endl;
+ f_types_impl_ << "enum _" << class_name << "Properties" << '\n' << "{" << '\n';
indent_up();
f_types_impl_ << indent() << "PROP_" << class_name_uc << "_0";
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string member_name_uc
= to_upper_case(to_lower_case(initial_caps_to_underscores((*m_iter)->get_name())));
- f_types_impl_ << "," << endl << indent() << "PROP_" << class_name_uc << "_" << member_name_uc;
+ f_types_impl_ << "," << '\n' << indent() << "PROP_" << class_name_uc << "_" << member_name_uc;
}
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
indent_down();
- f_types_impl_ << "};" << endl << endl;
+ f_types_impl_ << "};" << '\n' << '\n';
}
// generate struct I/O methods
@@ -2874,12 +2872,12 @@
// generate property setter
function_name = class_name_lc + "_set_property";
args_indent = string(function_name.length() + 2, ' ');
- f_types_impl_ << "static void" << endl << function_name << " (GObject *object," << endl
- << args_indent << "guint property_id," << endl << args_indent
- << "const GValue *value," << endl << args_indent << "GParamSpec *pspec)" << endl;
+ f_types_impl_ << "static void" << '\n' << function_name << " (GObject *object," << '\n'
+ << args_indent << "guint property_id," << '\n' << args_indent
+ << "const GValue *value," << '\n' << args_indent << "GParamSpec *pspec)" << '\n';
scope_up(f_types_impl_);
- f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl
- << endl << indent() << "switch (property_id)" << endl;
+ f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n'
+ << '\n' << indent() << "switch (property_id)" << '\n';
scope_up(f_types_impl_);
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* member = (*m_iter);
@@ -2890,7 +2888,7 @@
string property_identifier = "PROP_" + class_name_uc + "_" + member_name_uc;
- f_types_impl_ << indent() << "case " << property_identifier + ":" << endl;
+ f_types_impl_ << indent() << "case " << property_identifier + ":" << '\n';
indent_up();
if (member_type->is_base_type()) {
@@ -2900,7 +2898,7 @@
if (base_type->get_base() == t_base_type::TYPE_STRING) {
string release_function_name;
- f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << endl;
+ f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << '\n';
indent_up();
if (base_type->is_binary()) {
@@ -2912,7 +2910,7 @@
}
f_types_impl_ << indent() << release_function_name << " (self->" << member_name << ");"
- << endl;
+ << '\n';
indent_down();
} else {
switch (base_type->get_base()) {
@@ -2944,10 +2942,10 @@
}
f_types_impl_ << indent() << "self->" << member_name << " = " << assign_function_name
- << " (value);" << endl;
+ << " (value);" << '\n';
} else if (member_type->is_enum()) {
f_types_impl_ << indent() << "self->" << member_name << " = g_value_get_int (value);"
- << endl;
+ << '\n';
} else if (member_type->is_container()) {
string release_function_name;
string assign_function_name;
@@ -2969,47 +2967,47 @@
assign_function_name = "g_value_dup_boxed";
}
- f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << endl;
+ f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << '\n';
indent_up();
f_types_impl_ << indent() << release_function_name << " (self->" << member_name << ");"
- << endl;
+ << '\n';
indent_down();
f_types_impl_ << indent() << "self->" << member_name << " = " << assign_function_name
- << " (value);" << endl;
+ << " (value);" << '\n';
} else if (member_type->is_struct() || member_type->is_xception()) {
- f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << endl;
+ f_types_impl_ << indent() << "if (self->" << member_name << " != NULL)" << '\n';
indent_up();
- f_types_impl_ << indent() << "g_object_unref (self->" << member_name << ");" << endl;
+ f_types_impl_ << indent() << "g_object_unref (self->" << member_name << ");" << '\n';
indent_down();
f_types_impl_ << indent() << "self->" << member_name << " = g_value_dup_object (value);"
- << endl;
+ << '\n';
}
if (member->get_req() != t_field::T_REQUIRED) {
- f_types_impl_ << indent() << "self->__isset_" << member_name << " = TRUE;" << endl;
+ f_types_impl_ << indent() << "self->__isset_" << member_name << " = TRUE;" << '\n';
}
- f_types_impl_ << indent() << "break;" << endl << endl;
+ f_types_impl_ << indent() << "break;" << '\n' << '\n';
indent_down();
}
- f_types_impl_ << indent() << "default:" << endl;
+ f_types_impl_ << indent() << "default:" << '\n';
indent_up();
f_types_impl_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);"
- << endl << indent() << "break;" << endl;
+ << '\n' << indent() << "break;" << '\n';
indent_down();
scope_down(f_types_impl_);
scope_down(f_types_impl_);
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
// generate property getter
function_name = class_name_lc + "_get_property";
args_indent = string(function_name.length() + 2, ' ');
- f_types_impl_ << "static void" << endl << function_name << " (GObject *object," << endl
- << args_indent << "guint property_id," << endl << args_indent << "GValue *value,"
- << endl << args_indent << "GParamSpec *pspec)" << endl;
+ f_types_impl_ << "static void" << '\n' << function_name << " (GObject *object," << '\n'
+ << args_indent << "guint property_id," << '\n' << args_indent << "GValue *value,"
+ << '\n' << args_indent << "GParamSpec *pspec)" << '\n';
scope_up(f_types_impl_);
- f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << endl
- << endl << indent() << "switch (property_id)" << endl;
+ f_types_impl_ << indent() << class_name << " *self = " << class_name_uc << " (object);" << '\n'
+ << '\n' << indent() << "switch (property_id)" << '\n';
scope_up(f_types_impl_);
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* member = (*m_iter);
@@ -3070,26 +3068,26 @@
"unrecognized type for struct member \"" + member_name + "\"";
}
- f_types_impl_ << indent() << "case " << property_identifier + ":" << endl;
+ f_types_impl_ << indent() << "case " << property_identifier + ":" << '\n';
indent_up();
f_types_impl_ << indent() << setter_function_name << " (value, self->" << member_name << ");"
- << endl << indent() << "break;" << endl << endl;
+ << '\n' << indent() << "break;" << '\n' << '\n';
indent_down();
}
- f_types_impl_ << indent() << "default:" << endl;
+ f_types_impl_ << indent() << "default:" << '\n';
indent_up();
f_types_impl_ << indent() << "G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);"
- << endl << indent() << "break;" << endl;
+ << '\n' << indent() << "break;" << '\n';
indent_down();
scope_down(f_types_impl_);
scope_down(f_types_impl_);
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
}
// generate the instance init function
- f_types_impl_ << "static void " << endl << this->nspace_lc << name_u << "_instance_init ("
- << this->nspace << name << " * object)" << endl << "{" << endl;
+ f_types_impl_ << "static void " << '\n' << this->nspace_lc << name_u << "_instance_init ("
+ << this->nspace << name << " * object)" << '\n' << "{" << '\n';
indent_up();
// generate default-value structures for container-type members
@@ -3109,9 +3107,9 @@
// Generate an array with the list literal
indent(f_types_impl_) << "static " << type_name(elem_type, false, true) << " __default_"
- << member_name << "[" << list.size() << "] = " << endl;
+ << member_name << "[" << list.size() << "] = " << '\n';
indent_up();
- f_types_impl_ << indent() << constant_literal(member_type, member_value) << ";" << endl;
+ f_types_impl_ << indent() << constant_literal(member_type, member_value) << ";" << '\n';
indent_down();
constant_declaration_output = true;
@@ -3129,15 +3127,15 @@
}
if (constant_declaration_output) {
if (string_list_constant_output) {
- indent(f_types_impl_) << "unsigned int list_index;" << endl;
+ indent(f_types_impl_) << "unsigned int list_index;" << '\n';
}
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
}
// satisfy compilers with -Wall turned on
- indent(f_types_impl_) << "/* satisfy -Wall */" << endl << indent()
- << "THRIFT_UNUSED_VAR (object);" << endl;
+ indent(f_types_impl_) << "/* satisfy -Wall */" << '\n' << indent()
+ << "THRIFT_UNUSED_VAR (object);" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* member_type = (*m_iter)->get_type();
@@ -3153,7 +3151,7 @@
} else {
dval += t->is_string() ? "NULL" : "0";
}
- indent(f_types_impl_) << "object->" << (*m_iter)->get_name() << dval << ";" << endl;
+ indent(f_types_impl_) << "object->" << (*m_iter)->get_name() << dval << ";" << '\n';
} else if (t->is_struct()) {
string name = (*m_iter)->get_name();
t_program* type_program = member_type->get_program();
@@ -3163,10 +3161,10 @@
string type_name_uc = to_upper_case(initial_caps_to_underscores(member_type->get_name()));
indent(f_types_impl_) << "object->" << name << " = g_object_new ("
<< to_upper_case(type_nspace_prefix) << "TYPE_" << type_name_uc
- << ", NULL);" << endl;
+ << ", NULL);" << '\n';
} else if (t->is_xception()) {
string name = (*m_iter)->get_name();
- indent(f_types_impl_) << "object->" << name << " = NULL;" << endl;
+ indent(f_types_impl_) << "object->" << name << " = NULL;" << '\n';
} else if (t->is_container()) {
string name = (*m_iter)->get_name();
string init_function;
@@ -3184,7 +3182,7 @@
init_function = generate_new_array_from_type(etype);
}
- indent(f_types_impl_) << "object->" << name << " = " << init_function << endl;
+ indent(f_types_impl_) << "object->" << name << " = " << init_function << '\n';
// Pre-populate the container with the specified default values, if any
if ((*m_iter)->get_value()) {
@@ -3196,17 +3194,17 @@
if (is_numeric(etype)) {
indent(f_types_impl_) <<
"g_array_append_vals (object->" << name << ", &__default_" <<
- name << ", " << list.size() << ");" << endl;
+ name << ", " << list.size() << ");" << '\n';
}
else {
indent(f_types_impl_) <<
"for (list_index = 0; list_index < " << list.size() << "; " <<
- "list_index += 1)" << endl;
+ "list_index += 1)" << '\n';
indent_up();
indent(f_types_impl_) <<
- "g_ptr_array_add (object->" << name << "," << endl <<
+ "g_ptr_array_add (object->" << name << "," << '\n' <<
indent() << string(17, ' ') << "g_strdup (__default_" <<
- name << "[list_index]));" << endl;
+ name << "[list_index]));" << '\n';
indent_down();
}
}
@@ -3217,36 +3215,36 @@
/* if not required, initialize the __isset variable */
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
- indent(f_types_impl_) << "object->__isset_" << (*m_iter)->get_name() << " = FALSE;" << endl;
+ indent(f_types_impl_) << "object->__isset_" << (*m_iter)->get_name() << " = FALSE;" << '\n';
}
}
indent_down();
- f_types_impl_ << "}" << endl << endl;
+ f_types_impl_ << "}" << '\n' << '\n';
/* create the destructor */
- f_types_impl_ << "static void " << endl << this->nspace_lc << name_u
- << "_finalize (GObject *object)" << endl << "{" << endl;
+ f_types_impl_ << "static void " << '\n' << this->nspace_lc << name_u
+ << "_finalize (GObject *object)" << '\n' << "{" << '\n';
indent_up();
f_types_impl_ << indent() << this->nspace << name << " *tobject = " << this->nspace_uc << name_uc
- << " (object);" << endl << endl;
+ << " (object);" << '\n' << '\n';
- f_types_impl_ << indent() << "/* satisfy -Wall in case we don't use tobject */" << endl
- << indent() << "THRIFT_UNUSED_VAR (tobject);" << endl;
+ f_types_impl_ << indent() << "/* satisfy -Wall in case we don't use tobject */" << '\n'
+ << indent() << "THRIFT_UNUSED_VAR (tobject);" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
if (t->is_container()) {
string name = (*m_iter)->get_name();
if (t->is_map() || t->is_set()) {
- f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl;
- f_types_impl_ << indent() << "{" << endl;
+ f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n';
+ f_types_impl_ << indent() << "{" << '\n';
indent_up();
- f_types_impl_ << indent() << "g_hash_table_destroy (tobject->" << name << ");" << endl;
- f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl;
+ f_types_impl_ << indent() << "g_hash_table_destroy (tobject->" << name << ");" << '\n';
+ f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n';
indent_down();
- f_types_impl_ << indent() << "}" << endl;
+ f_types_impl_ << indent() << "}" << '\n';
} else if (t->is_list()) {
t_type* etype = ((t_list*)t)->get_elem_type();
string destructor_function = "g_ptr_array_unref";
@@ -3273,59 +3271,59 @@
destructor_function = "g_array_unref";
}
- f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl;
- f_types_impl_ << indent() << "{" << endl;
+ f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n';
+ f_types_impl_ << indent() << "{" << '\n';
indent_up();
- f_types_impl_ << indent() << destructor_function << " (tobject->" << name << ");" << endl;
- f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl;
+ f_types_impl_ << indent() << destructor_function << " (tobject->" << name << ");" << '\n';
+ f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n';
indent_down();
- f_types_impl_ << indent() << "}" << endl;
+ f_types_impl_ << indent() << "}" << '\n';
}
} else if (t->is_struct() || t->is_xception()) {
string name = (*m_iter)->get_name();
// TODO: g_clear_object needs glib >= 2.28
- // f_types_impl_ << indent() << "g_clear_object (&(tobject->" << name << "));" << endl;
+ // f_types_impl_ << indent() << "g_clear_object (&(tobject->" << name << "));" << '\n';
// does g_object_unref the trick?
- f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl;
- f_types_impl_ << indent() << "{" << endl;
+ f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n';
+ f_types_impl_ << indent() << "{" << '\n';
indent_up();
- f_types_impl_ << indent() << "g_object_unref(tobject->" << name << ");" << endl;
- f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl;
+ f_types_impl_ << indent() << "g_object_unref(tobject->" << name << ");" << '\n';
+ f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n';
indent_down();
- f_types_impl_ << indent() << "}" << endl;
+ f_types_impl_ << indent() << "}" << '\n';
} else if (t->is_string()) {
string name = (*m_iter)->get_name();
- f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << endl;
- f_types_impl_ << indent() << "{" << endl;
+ f_types_impl_ << indent() << "if (tobject->" << name << " != NULL)" << '\n';
+ f_types_impl_ << indent() << "{" << '\n';
indent_up();
f_types_impl_ << indent() << generate_free_func_from_type(t) << "(tobject->" << name << ");"
- << endl;
- f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << endl;
+ << '\n';
+ f_types_impl_ << indent() << "tobject->" << name << " = NULL;" << '\n';
indent_down();
- f_types_impl_ << indent() << "}" << endl;
+ f_types_impl_ << indent() << "}" << '\n';
}
}
indent_down();
- f_types_impl_ << "}" << endl << endl;
+ f_types_impl_ << "}" << '\n' << '\n';
// generate the class init function
- f_types_impl_ << "static void" << endl << class_name_lc << "_class_init (" << class_name
- << "Class * cls)" << endl;
+ f_types_impl_ << "static void" << '\n' << class_name_lc << "_class_init (" << class_name
+ << "Class * cls)" << '\n';
scope_up(f_types_impl_);
- f_types_impl_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << endl
+ f_types_impl_ << indent() << "GObjectClass *gobject_class = G_OBJECT_CLASS (cls);" << '\n'
<< indent() << "ThriftStructClass *struct_class = "
- << "THRIFT_STRUCT_CLASS (cls);" << endl << endl << indent()
- << "struct_class->read = " << class_name_lc << "_read;" << endl << indent()
- << "struct_class->write = " << class_name_lc << "_write;" << endl << endl
+ << "THRIFT_STRUCT_CLASS (cls);" << '\n' << '\n' << indent()
+ << "struct_class->read = " << class_name_lc << "_read;" << '\n' << indent()
+ << "struct_class->write = " << class_name_lc << "_write;" << '\n' << '\n'
<< indent() << "gobject_class->finalize = " << class_name_lc << "_finalize;"
- << endl;
+ << '\n';
if (members.size() > 0) {
f_types_impl_ << indent() << "gobject_class->get_property = " << class_name_lc
- << "_get_property;" << endl << indent()
- << "gobject_class->set_property = " << class_name_lc << "_set_property;" << endl;
+ << "_get_property;" << '\n' << indent()
+ << "gobject_class->set_property = " << class_name_lc << "_set_property;" << '\n';
// install a property for each member
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -3338,11 +3336,11 @@
string property_identifier = "PROP_" + class_name_uc + "_" + member_name_uc;
- f_types_impl_ << endl << indent() << "g_object_class_install_property" << endl;
+ f_types_impl_ << '\n' << indent() << "g_object_class_install_property" << '\n';
indent_up();
args_indent = indent() + ' ';
- f_types_impl_ << indent() << "(gobject_class," << endl << args_indent << property_identifier
- << "," << endl << args_indent;
+ f_types_impl_ << indent() << "(gobject_class," << '\n' << args_indent << property_identifier
+ << "," << '\n' << args_indent;
if (member_type->is_base_type()) {
t_base_type::t_base base_type = ((t_base_type*)member_type)->get_base();
@@ -3350,27 +3348,27 @@
if (base_type == t_base_type::TYPE_STRING) {
if (((t_base_type*)member_type)->is_binary()) {
args_indent += string(20, ' ');
- f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << endl << args_indent
- << "NULL," << endl << args_indent << "NULL," << endl << args_indent
- << "G_TYPE_BYTE_ARRAY," << endl << args_indent << "G_PARAM_READWRITE));"
- << endl;
+ f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << '\n' << args_indent
+ << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent
+ << "G_TYPE_BYTE_ARRAY," << '\n' << args_indent << "G_PARAM_READWRITE));"
+ << '\n';
} else {
args_indent += string(21, ' ');
- f_types_impl_ << "g_param_spec_string (\"" << member_name << "\"," << endl
- << args_indent << "NULL," << endl << args_indent << "NULL," << endl
+ f_types_impl_ << "g_param_spec_string (\"" << member_name << "\"," << '\n'
+ << args_indent << "NULL," << '\n' << args_indent << "NULL," << '\n'
<< args_indent
<< ((member_value != NULL) ? "\"" + member_value->get_string() + "\""
- : "NULL") << "," << endl << args_indent
- << "G_PARAM_READWRITE));" << endl;
+ : "NULL") << "," << '\n' << args_indent
+ << "G_PARAM_READWRITE));" << '\n';
}
} else if (base_type == t_base_type::TYPE_BOOL) {
args_indent += string(22, ' ');
- f_types_impl_ << "g_param_spec_boolean (\"" << member_name << "\"," << endl << args_indent
- << "NULL," << endl << args_indent << "NULL," << endl << args_indent
+ f_types_impl_ << "g_param_spec_boolean (\"" << member_name << "\"," << '\n' << args_indent
+ << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent
<< (((member_value != NULL) && (member_value->get_integer() != 0))
? "TRUE"
- : "FALSE") << "," << endl << args_indent << "G_PARAM_READWRITE));"
- << endl;
+ : "FALSE") << "," << '\n' << args_indent << "G_PARAM_READWRITE));"
+ << '\n';
} else if ((base_type == t_base_type::TYPE_I8) || (base_type == t_base_type::TYPE_I16)
|| (base_type == t_base_type::TYPE_I32) || (base_type == t_base_type::TYPE_I64)
|| (base_type == t_base_type::TYPE_DOUBLE)) {
@@ -3423,11 +3421,11 @@
}
args_indent += string(param_spec_function_name.length() + 2, ' ');
- f_types_impl_ << param_spec_function_name << " (\"" << member_name << "\"," << endl
- << args_indent << "NULL," << endl << args_indent << "NULL," << endl
- << args_indent << min_value << "," << endl << args_indent << max_value
- << "," << endl << args_indent << default_value.str() << "," << endl
- << args_indent << "G_PARAM_READWRITE));" << endl;
+ f_types_impl_ << param_spec_function_name << " (\"" << member_name << "\"," << '\n'
+ << args_indent << "NULL," << '\n' << args_indent << "NULL," << '\n'
+ << args_indent << min_value << "," << '\n' << args_indent << max_value
+ << "," << '\n' << args_indent << default_value.str() << "," << '\n'
+ << args_indent << "G_PARAM_READWRITE));" << '\n';
}
indent_down();
@@ -3438,11 +3436,11 @@
int max_value = (enum_max_value != nullptr) ? enum_max_value->get_value() : 0;
args_indent += string(18, ' ');
- f_types_impl_ << "g_param_spec_int (\"" << member_name << "\"," << endl << args_indent
- << "NULL," << endl << args_indent << "NULL," << endl << args_indent
- << min_value << "," << endl << args_indent << max_value << "," << endl
- << args_indent << min_value << "," << endl << args_indent
- << "G_PARAM_READWRITE));" << endl;
+ f_types_impl_ << "g_param_spec_int (\"" << member_name << "\"," << '\n' << args_indent
+ << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent
+ << min_value << "," << '\n' << args_indent << max_value << "," << '\n'
+ << args_indent << min_value << "," << '\n' << args_indent
+ << "G_PARAM_READWRITE));" << '\n';
indent_down();
} else if (member_type->is_struct() || member_type->is_xception()) {
t_program* type_program = member_type->get_program();
@@ -3454,9 +3452,9 @@
+ to_upper_case(initial_caps_to_underscores(member_type->get_name()));
args_indent += string(20, ' ');
- f_types_impl_ << "g_param_spec_object (\"" << member_name << "\"," << endl << args_indent
- << "NULL," << endl << args_indent << "NULL," << endl << args_indent
- << param_type << "," << endl << args_indent << "G_PARAM_READWRITE));" << endl;
+ f_types_impl_ << "g_param_spec_object (\"" << member_name << "\"," << '\n' << args_indent
+ << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent
+ << param_type << "," << '\n' << args_indent << "G_PARAM_READWRITE));" << '\n';
indent_down();
} else if (member_type->is_list()) {
t_type* elem_type = ((t_list*)member_type)->get_elem_type();
@@ -3469,38 +3467,38 @@
}
args_indent += string(20, ' ');
- f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << endl << args_indent
- << "NULL," << endl << args_indent << "NULL," << endl << args_indent
- << param_type << "," << endl << args_indent << "G_PARAM_READWRITE));" << endl;
+ f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << '\n' << args_indent
+ << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent
+ << param_type << "," << '\n' << args_indent << "G_PARAM_READWRITE));" << '\n';
indent_down();
} else if (member_type->is_set() || member_type->is_map()) {
args_indent += string(20, ' ');
- f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << endl << args_indent
- << "NULL," << endl << args_indent << "NULL," << endl << args_indent
- << "G_TYPE_HASH_TABLE," << endl << args_indent << "G_PARAM_READWRITE));"
- << endl;
+ f_types_impl_ << "g_param_spec_boxed (\"" << member_name << "\"," << '\n' << args_indent
+ << "NULL," << '\n' << args_indent << "NULL," << '\n' << args_indent
+ << "G_TYPE_HASH_TABLE," << '\n' << args_indent << "G_PARAM_READWRITE));"
+ << '\n';
indent_down();
}
}
}
scope_down(f_types_impl_);
- f_types_impl_ << endl;
+ f_types_impl_ << '\n';
- f_types_impl_ << "GType" << endl << this->nspace_lc << name_u << "_get_type (void)" << endl << "{"
- << endl << " static GType type = 0;" << endl << endl << " if (type == 0) " << endl
- << " {" << endl << " static const GTypeInfo type_info = " << endl << " {"
- << endl << " sizeof (" << this->nspace << name << "Class)," << endl
- << " NULL, /* base_init */" << endl << " NULL, /* base_finalize */"
- << endl << " (GClassInitFunc) " << this->nspace_lc << name_u << "_class_init,"
- << endl << " NULL, /* class_finalize */" << endl
- << " NULL, /* class_data */" << endl << " sizeof (" << this->nspace
- << name << ")," << endl << " 0, /* n_preallocs */" << endl
+ f_types_impl_ << "GType" << '\n' << this->nspace_lc << name_u << "_get_type (void)" << '\n' << "{"
+ << '\n' << " static GType type = 0;" << '\n' << '\n' << " if (type == 0) " << '\n'
+ << " {" << '\n' << " static const GTypeInfo type_info = " << '\n' << " {"
+ << '\n' << " sizeof (" << this->nspace << name << "Class)," << '\n'
+ << " NULL, /* base_init */" << '\n' << " NULL, /* base_finalize */"
+ << '\n' << " (GClassInitFunc) " << this->nspace_lc << name_u << "_class_init,"
+ << '\n' << " NULL, /* class_finalize */" << '\n'
+ << " NULL, /* class_data */" << '\n' << " sizeof (" << this->nspace
+ << name << ")," << '\n' << " 0, /* n_preallocs */" << '\n'
<< " (GInstanceInitFunc) " << this->nspace_lc << name_u << "_instance_init,"
- << endl << " NULL, /* value_table */" << endl << " };" << endl << endl
- << " type = g_type_register_static (THRIFT_TYPE_STRUCT, " << endl
+ << '\n' << " NULL, /* value_table */" << '\n' << " };" << '\n' << '\n'
+ << " type = g_type_register_static (THRIFT_TYPE_STRUCT, " << '\n'
<< " \"" << this->nspace << name << "Type\","
- << endl << " &type_info, 0);" << endl << " }"
- << endl << endl << " return type;" << endl << "}" << endl << endl;
+ << '\n' << " &type_info, 0);" << '\n' << " }"
+ << '\n' << '\n' << " return type;" << '\n' << "}" << '\n' << '\n';
}
/**
@@ -3521,59 +3519,59 @@
if (is_function) {
error_ret = -1;
- indent(out) << "static gint32" << endl << this->nspace_lc << name_u
+ indent(out) << "static gint32" << '\n' << this->nspace_lc << name_u
<< "_write (ThriftStruct *object, ThriftProtocol *protocol, GError **error)"
- << endl;
+ << '\n';
}
- indent(out) << "{" << endl;
+ indent(out) << "{" << '\n';
indent_up();
- out << indent() << "gint32 ret;" << endl << indent() << "gint32 xfer = 0;" << endl << endl;
+ out << indent() << "gint32 ret;" << '\n' << indent() << "gint32 xfer = 0;" << '\n' << '\n';
- indent(out) << this_get << endl;
+ indent(out) << this_get << '\n';
// satisfy -Wall in the case of an empty struct
if (!this_get.empty()) {
- indent(out) << "THRIFT_UNUSED_VAR (this_object);" << endl;
+ indent(out) << "THRIFT_UNUSED_VAR (this_object);" << '\n';
}
out << indent() << "if ((ret = thrift_protocol_write_struct_begin (protocol, \"" << name
- << "\", error)) < 0)" << endl << indent() << " return " << error_ret << ";" << endl
- << indent() << "xfer += ret;" << endl;
+ << "\", error)) < 0)" << '\n' << indent() << " return " << error_ret << ";" << '\n'
+ << indent() << "xfer += ret;" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_OPTIONAL) {
- indent(out) << "if (this_object->__isset_" << (*f_iter)->get_name() << " == TRUE) {" << endl;
+ indent(out) << "if (this_object->__isset_" << (*f_iter)->get_name() << " == TRUE) {" << '\n';
indent_up();
}
out << indent() << "if ((ret = thrift_protocol_write_field_begin (protocol, "
<< "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", "
- << (*f_iter)->get_key() << ", error)) < 0)" << endl << indent() << " return " << error_ret
- << ";" << endl << indent() << "xfer += ret;" << endl;
+ << (*f_iter)->get_key() << ", error)) < 0)" << '\n' << indent() << " return " << error_ret
+ << ";" << '\n' << indent() << "xfer += ret;" << '\n';
generate_serialize_field(out, *f_iter, this_name, "", error_ret);
- out << indent() << "if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)" << endl
- << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;"
- << endl;
+ out << indent() << "if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;"
+ << '\n';
if ((*f_iter)->get_req() == t_field::T_OPTIONAL) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
// write the struct map
- out << indent() << "if ((ret = thrift_protocol_write_field_stop (protocol, error)) < 0)" << endl
- << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl
- << indent() << "if ((ret = thrift_protocol_write_struct_end (protocol, error)) < 0)" << endl
- << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl
- << endl;
+ out << indent() << "if ((ret = thrift_protocol_write_field_stop (protocol, error)) < 0)" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n'
+ << indent() << "if ((ret = thrift_protocol_write_struct_end (protocol, error)) < 0)" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n'
+ << '\n';
if (is_function) {
- indent(out) << "return xfer;" << endl;
+ indent(out) << "return xfer;" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -3593,127 +3591,127 @@
if (is_function) {
error_ret = -1;
- indent(out) << "/* reads a " << name_u << " object */" << endl << "static gint32" << endl
+ indent(out) << "/* reads a " << name_u << " object */" << '\n' << "static gint32" << '\n'
<< this->nspace_lc << name_u
- << "_read (ThriftStruct *object, ThriftProtocol *protocol, GError **error)" << endl;
+ << "_read (ThriftStruct *object, ThriftProtocol *protocol, GError **error)" << '\n';
}
- indent(out) << "{" << endl;
+ indent(out) << "{" << '\n';
indent_up();
// declare stack temp variables
- out << indent() << "gint32 ret;" << endl << indent() << "gint32 xfer = 0;" << endl << indent()
- << "gchar *name = NULL;" << endl << indent() << "ThriftType ftype;" << endl << indent()
- << "gint16 fid;" << endl << indent() << "guint32 len = 0;" << endl << indent()
- << "gpointer data = NULL;" << endl << indent() << this_get << endl;
+ out << indent() << "gint32 ret;" << '\n' << indent() << "gint32 xfer = 0;" << '\n' << indent()
+ << "gchar *name = NULL;" << '\n' << indent() << "ThriftType ftype;" << '\n' << indent()
+ << "gint16 fid;" << '\n' << indent() << "guint32 len = 0;" << '\n' << indent()
+ << "gpointer data = NULL;" << '\n' << indent() << this_get << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
- indent(out) << "gboolean isset_" << (*f_iter)->get_name() << " = FALSE;" << endl;
+ indent(out) << "gboolean isset_" << (*f_iter)->get_name() << " = FALSE;" << '\n';
}
}
- out << endl;
+ out << '\n';
// satisfy -Wall in case we don't use some variables
- out << indent() << "/* satisfy -Wall in case these aren't used */" << endl << indent()
- << "THRIFT_UNUSED_VAR (len);" << endl << indent() << "THRIFT_UNUSED_VAR (data);" << endl;
+ out << indent() << "/* satisfy -Wall in case these aren't used */" << '\n' << indent()
+ << "THRIFT_UNUSED_VAR (len);" << '\n' << indent() << "THRIFT_UNUSED_VAR (data);" << '\n';
if (!this_get.empty()) {
- out << indent() << "THRIFT_UNUSED_VAR (this_object);" << endl;
+ out << indent() << "THRIFT_UNUSED_VAR (this_object);" << '\n';
}
- out << endl;
+ out << '\n';
// read the beginning of the structure marker
- out << indent() << "/* read the struct begin marker */" << endl << indent()
- << "if ((ret = thrift_protocol_read_struct_begin (protocol, &name, error)) < 0)" << endl
- << indent() << "{" << endl << indent() << " if (name) g_free (name);" << endl << indent()
- << " return " << error_ret << ";" << endl << indent() << "}" << endl << indent()
- << "xfer += ret;" << endl << indent() << "if (name) g_free (name);" << endl << indent()
- << "name = NULL;" << endl << endl;
+ out << indent() << "/* read the struct begin marker */" << '\n' << indent()
+ << "if ((ret = thrift_protocol_read_struct_begin (protocol, &name, error)) < 0)" << '\n'
+ << indent() << "{" << '\n' << indent() << " if (name) g_free (name);" << '\n' << indent()
+ << " return " << error_ret << ";" << '\n' << indent() << "}" << '\n' << indent()
+ << "xfer += ret;" << '\n' << indent() << "if (name) g_free (name);" << '\n' << indent()
+ << "name = NULL;" << '\n' << '\n';
// read the struct fields
- out << indent() << "/* read the struct fields */" << endl << indent() << "while (1)" << endl;
+ out << indent() << "/* read the struct fields */" << '\n' << indent() << "while (1)" << '\n';
scope_up(out);
// read beginning field marker
- out << indent() << "/* read the beginning of a field */" << endl << indent()
+ out << indent() << "/* read the beginning of a field */" << '\n' << indent()
<< "if ((ret = thrift_protocol_read_field_begin (protocol, &name, &ftype, &fid, error)) < 0)"
- << endl << indent() << "{" << endl << indent() << " if (name) g_free (name);" << endl
- << indent() << " return " << error_ret << ";" << endl << indent() << "}" << endl << indent()
- << "xfer += ret;" << endl << indent() << "if (name) g_free (name);" << endl << indent()
- << "name = NULL;" << endl << endl;
+ << '\n' << indent() << "{" << '\n' << indent() << " if (name) g_free (name);" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n' << indent() << "}" << '\n' << indent()
+ << "xfer += ret;" << '\n' << indent() << "if (name) g_free (name);" << '\n' << indent()
+ << "name = NULL;" << '\n' << '\n';
// check for field STOP marker
- out << indent() << "/* break if we get a STOP field */" << endl << indent()
- << "if (ftype == T_STOP)" << endl << indent() << "{" << endl << indent() << " break;" << endl
- << indent() << "}" << endl << endl;
+ out << indent() << "/* break if we get a STOP field */" << '\n' << indent()
+ << "if (ftype == T_STOP)" << '\n' << indent() << "{" << '\n' << indent() << " break;" << '\n'
+ << indent() << "}" << '\n' << '\n';
// switch depending on the field type
- indent(out) << "switch (fid)" << endl;
+ indent(out) << "switch (fid)" << '\n';
// start switch
scope_up(out);
// generate deserialization code for known types
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
+ indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ")" << endl;
- indent(out) << "{" << endl;
+ indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ")" << '\n';
+ indent(out) << "{" << '\n';
indent_up();
// generate deserialize field
generate_deserialize_field(out, *f_iter, this_name, "", error_ret, false);
indent_down();
- out << indent() << "} else {" << endl << indent()
- << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << endl << indent()
- << " return " << error_ret << ";" << endl << indent() << " xfer += ret;" << endl
- << indent() << "}" << endl << indent() << "break;" << endl;
+ out << indent() << "} else {" << '\n' << indent()
+ << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << '\n' << indent()
+ << " return " << error_ret << ";" << '\n' << indent() << " xfer += ret;" << '\n'
+ << indent() << "}" << '\n' << indent() << "break;" << '\n';
indent_down();
}
// create the default case
- out << indent() << "default:" << endl << indent()
- << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << endl << indent()
- << " return " << error_ret << ";" << endl << indent() << " xfer += ret;" << endl
- << indent() << " break;" << endl;
+ out << indent() << "default:" << '\n' << indent()
+ << " if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0)" << '\n' << indent()
+ << " return " << error_ret << ";" << '\n' << indent() << " xfer += ret;" << '\n'
+ << indent() << " break;" << '\n';
// end switch
scope_down(out);
// read field end marker
- out << indent() << "if ((ret = thrift_protocol_read_field_end (protocol, error)) < 0)" << endl
- << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl;
+ out << indent() << "if ((ret = thrift_protocol_read_field_end (protocol, error)) < 0)" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n';
// end while loop
scope_down(out);
- out << endl;
+ out << '\n';
// read the end of the structure
- out << indent() << "if ((ret = thrift_protocol_read_struct_end (protocol, error)) < 0)" << endl
- << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl
- << endl;
+ out << indent() << "if ((ret = thrift_protocol_read_struct_end (protocol, error)) < 0)" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n'
+ << '\n';
// if a required field is missing, throw an error
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
- out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << endl << indent() << "{"
- << endl << indent() << " g_set_error (error, THRIFT_PROTOCOL_ERROR," << endl << indent()
- << " THRIFT_PROTOCOL_ERROR_INVALID_DATA," << endl << indent()
- << " \"missing field\");" << endl << indent() << " return -1;" << endl
- << indent() << "}" << endl << endl;
+ out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << '\n' << indent() << "{"
+ << '\n' << indent() << " g_set_error (error, THRIFT_PROTOCOL_ERROR," << '\n' << indent()
+ << " THRIFT_PROTOCOL_ERROR_INVALID_DATA," << '\n' << indent()
+ << " \"missing field\");" << '\n' << indent() << " return -1;" << '\n'
+ << indent() << "}" << '\n' << '\n';
}
}
if (is_function) {
- indent(out) << "return xfer;" << endl;
+ indent(out) << "return xfer;" << '\n';
}
// end the function/structure
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
void t_c_glib_generator::generate_serialize_field(ostream& out,
@@ -3773,9 +3771,9 @@
} else {
out << "i32 (protocol, (gint32) " << name;
}
- out << ", error)) < 0)" << endl
- << indent() << " return " << error_ret << ";" << endl
- << indent() << "xfer += ret;" << endl << endl;
+ out << ", error)) < 0)" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n'
+ << indent() << "xfer += ret;" << '\n' << '\n';
} else {
throw std::logic_error("DO NOT KNOW HOW TO SERIALIZE FIELD '" + name + "' TYPE '"
+ type_name(type));
@@ -3788,8 +3786,8 @@
int error_ret) {
(void)tstruct;
out << indent() << "if ((ret = thrift_struct_write (THRIFT_STRUCT (" << prefix
- << "), protocol, error)) < 0)" << endl << indent() << " return " << error_ret << ";" << endl
- << indent() << "xfer += ret;" << endl << endl;
+ << "), protocol, error)) < 0)" << '\n' << indent() << " return " << error_ret << ";" << '\n'
+ << indent() << "xfer += ret;" << '\n' << '\n';
}
void t_c_glib_generator::generate_serialize_container(ostream& out,
@@ -3826,39 +3824,39 @@
* This is because we may exit early before we get a chance to free the
* GList.
*/
- out << indent() << "GList *key_list = NULL, *iter = NULL;" << endl
- << indent() << tkey_name << tkey_ptr << "* keys;" << endl
- << indent() << "int i = 0, key_count;" << endl
- << endl
+ out << indent() << "GList *key_list = NULL, *iter = NULL;" << '\n'
+ << indent() << tkey_name << tkey_ptr << "* keys;" << '\n'
+ << indent() << "int i = 0, key_count;" << '\n'
+ << '\n'
<< indent() << "if ((ret = thrift_protocol_write_map_begin (protocol, "
<< type_to_enum(tkey) << ", " << type_to_enum(tval) << ", " << prefix << " ? "
<< "(gint32) g_hash_table_size ((GHashTable *) " << prefix << ") : 0"
- << ", error)) < 0)" << endl;
+ << ", error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl
- << indent() << "if (" << prefix << ")" << endl
+ out << indent() << "xfer += ret;" << '\n'
+ << indent() << "if (" << prefix << ")" << '\n'
<< indent() << " g_hash_table_foreach ((GHashTable *) " << prefix
- << ", thrift_hash_table_get_keys, &key_list);" << endl
- << indent() << "key_count = g_list_length (key_list);" << endl
+ << ", thrift_hash_table_get_keys, &key_list);" << '\n'
+ << indent() << "key_count = g_list_length (key_list);" << '\n'
<< indent() << "keys = g_newa (" << tkey_name << tkey_ptr
- << ", key_count);" << endl
+ << ", key_count);" << '\n'
<< indent() << "for (iter = g_list_first (key_list); iter; "
- "iter = iter->next)" << endl;
+ "iter = iter->next)" << '\n';
indent_up();
out << indent() << "keys[i++] = (" << tkey_name << tkey_ptr
- << ") iter->data;" << endl;
+ << ") iter->data;" << '\n';
indent_down();
- out << indent() << "g_list_free (key_list);" << endl
- << endl
- << indent() << "for (i = 0; i < key_count; ++i)" << endl;
+ out << indent() << "g_list_free (key_list);" << '\n'
+ << '\n'
+ << indent() << "for (i = 0; i < key_count; ++i)" << '\n';
scope_up(out);
- out << indent() << keyname << " = keys[i];" << endl
+ out << indent() << keyname << " = keys[i];" << '\n'
<< indent() << valname << " = (" << tval_name << tval_ptr
<< ") g_hash_table_lookup (((GHashTable *) " << prefix
- << "), (gpointer) " << keyname << ");" << endl
- << endl;
+ << "), (gpointer) " << keyname << ");" << '\n'
+ << '\n';
generate_serialize_map_element(out,
(t_map*)ttype,
tkey_ptr + " " + keyname,
@@ -3866,84 +3864,84 @@
error_ret);
scope_down(out);
out << indent() << "if ((ret = thrift_protocol_write_map_end (protocol, "
- "error)) < 0)" << endl;
+ "error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl;
+ out << indent() << "xfer += ret;" << '\n';
} else if (ttype->is_set()) {
t_type* telem = ((t_set*)ttype)->get_elem_type();
string telem_name = type_name(telem);
string telem_ptr = telem->is_string() || !telem->is_base_type() ? "" : "*";
- out << indent() << "GList *key_list = NULL, *iter = NULL;" << endl
- << indent() << telem_name << telem_ptr << "* keys;" << endl
- << indent() << "int i = 0, key_count;" << endl
- << indent() << telem_name << telem_ptr << " elem;" << endl
- << indent() << "gpointer value;" << endl
- << indent() << "THRIFT_UNUSED_VAR (value);" << endl
- << endl
+ out << indent() << "GList *key_list = NULL, *iter = NULL;" << '\n'
+ << indent() << telem_name << telem_ptr << "* keys;" << '\n'
+ << indent() << "int i = 0, key_count;" << '\n'
+ << indent() << telem_name << telem_ptr << " elem;" << '\n'
+ << indent() << "gpointer value;" << '\n'
+ << indent() << "THRIFT_UNUSED_VAR (value);" << '\n'
+ << '\n'
<< indent() << "if ((ret = thrift_protocol_write_set_begin (protocol, "
<< type_to_enum(telem) << ", " << prefix << " ? "
<< "(gint32) g_hash_table_size ((GHashTable *) " << prefix << ") : 0"
- << ", error)) < 0)" << endl;
+ << ", error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl
- << indent() << "if (" << prefix << ")" << endl
+ out << indent() << "xfer += ret;" << '\n'
+ << indent() << "if (" << prefix << ")" << '\n'
<< indent() << " g_hash_table_foreach ((GHashTable *) " << prefix
- << ", thrift_hash_table_get_keys, &key_list);" << endl
- << indent() << "key_count = g_list_length (key_list);" << endl
+ << ", thrift_hash_table_get_keys, &key_list);" << '\n'
+ << indent() << "key_count = g_list_length (key_list);" << '\n'
<< indent() << "keys = g_newa (" << telem_name << telem_ptr
- << ", key_count);" << endl
+ << ", key_count);" << '\n'
<< indent() << "for (iter = g_list_first (key_list); iter; "
- "iter = iter->next)" << endl;
+ "iter = iter->next)" << '\n';
indent_up();
out << indent() << "keys[i++] = (" << telem_name << telem_ptr
- << ") iter->data;" << endl;
+ << ") iter->data;" << '\n';
indent_down();
- out << indent() << "g_list_free (key_list);" << endl
- << endl
- << indent() << "for (i = 0; i < key_count; ++i)" << endl;
+ out << indent() << "g_list_free (key_list);" << '\n'
+ << '\n'
+ << indent() << "for (i = 0; i < key_count; ++i)" << '\n';
scope_up(out);
- out << indent() << "elem = keys[i];" << endl
+ out << indent() << "elem = keys[i];" << '\n'
<< indent() << "value = (gpointer) g_hash_table_lookup "
- "(((GHashTable *) " << prefix << "), (gpointer) elem);" << endl
- << endl;
+ "(((GHashTable *) " << prefix << "), (gpointer) elem);" << '\n'
+ << '\n';
generate_serialize_set_element(out,
(t_set*)ttype,
telem_ptr + "elem",
error_ret);
scope_down(out);
out << indent() << "if ((ret = thrift_protocol_write_set_end (protocol, "
- "error)) < 0)" << endl;
+ "error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl;
+ out << indent() << "xfer += ret;" << '\n';
} else if (ttype->is_list()) {
string length = "(" + prefix + " ? " + prefix + "->len : 0)";
string i = tmp("i");
- out << indent() << "guint " << i << ";" << endl
- << endl
+ out << indent() << "guint " << i << ";" << '\n'
+ << '\n'
<< indent() << "if ((ret = thrift_protocol_write_list_begin (protocol, "
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", (gint32) "
- << length << ", error)) < 0)" << endl;
+ << length << ", error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl
+ out << indent() << "xfer += ret;" << '\n'
<< indent() << "for (" << i << " = 0; " << i << " < " << length << "; "
- << i << "++)" << endl;
+ << i << "++)" << '\n';
scope_up(out);
generate_serialize_list_element(out, (t_list*)ttype, prefix, i, error_ret);
scope_down(out);
out << indent() << "if ((ret = thrift_protocol_write_list_end (protocol, "
- "error)) < 0)" << endl;
+ "error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl;
+ out << indent() << "xfer += ret;" << '\n';
}
scope_down(out);
@@ -4023,11 +4021,11 @@
} else if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
if (tbase == t_base_type::TYPE_STRING) {
- indent(out) << "if (" << name << " != NULL)" << endl << indent() << "{" << endl;
+ indent(out) << "if (" << name << " != NULL)" << '\n' << indent() << "{" << '\n';
indent_up();
- indent(out) << "g_free(" << name << ");" << endl << indent() << name << " = NULL;" << endl;
+ indent(out) << "g_free(" << name << ");" << '\n' << indent() << name << " = NULL;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
indent(out) << "if ((ret = thrift_protocol_read_";
@@ -4063,22 +4061,22 @@
default:
throw "compiler error: no C reader for base type " + t_base_type::t_base_name(tbase) + name;
}
- out << ", error)) < 0)" << endl;
- out << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;"
- << endl;
+ out << ", error)) < 0)" << '\n';
+ out << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;"
+ << '\n';
// load the byte array with the data
if (tbase == t_base_type::TYPE_STRING && type->is_binary()) {
- indent(out) << name << " = g_byte_array_new();" << endl;
- indent(out) << "g_byte_array_append (" << name << ", (guint8 *) data, (guint) len);" << endl;
- indent(out) << "g_free (data);" << endl;
+ indent(out) << name << " = g_byte_array_new();" << '\n';
+ indent(out) << "g_byte_array_append (" << name << ", (guint8 *) data, (guint) len);" << '\n';
+ indent(out) << "g_free (data);" << '\n';
}
} else if (type->is_enum()) {
string t = tmp("ecast");
- out << indent() << "gint32 " << t << ";" << endl << indent()
- << "if ((ret = thrift_protocol_read_i32 (protocol, &" << t << ", error)) < 0)" << endl
- << indent() << " return " << error_ret << ";" << endl << indent() << "xfer += ret;" << endl
- << indent() << name << " = (" << type_name(type) << ")" << t << ";" << endl;
+ out << indent() << "gint32 " << t << ";" << '\n' << indent()
+ << "if ((ret = thrift_protocol_read_i32 (protocol, &" << t << ", error)) < 0)" << '\n'
+ << indent() << " return " << error_ret << ";" << '\n' << indent() << "xfer += ret;" << '\n'
+ << indent() << name << " = (" << type_name(type) << ")" << t << ";" << '\n';
} else {
throw std::logic_error("DO NOT KNOW HOW TO SERIALIZE FIELD '" + tfield->get_name() + "' TYPE '"
+ type_name(type));
@@ -4088,9 +4086,9 @@
// set the isset variable. if the type is required, then set the
// local variable indicating the value was set, so that we can do // validation later.
if (prefix != "" && tfield->get_req() != t_field::T_REQUIRED) {
- indent(out) << prefix << "__isset_" << tfield->get_name() << suffix << " = TRUE;" << endl;
+ indent(out) << prefix << "__isset_" << tfield->get_name() << suffix << " = TRUE;" << '\n';
} else if (prefix != "" && tfield->get_req() == t_field::T_REQUIRED) {
- indent(out) << "isset_" << tfield->get_name() << " = TRUE;" << endl;
+ indent(out) << "isset_" << tfield->get_name() << " = TRUE;" << '\n';
}
}
@@ -4101,30 +4099,30 @@
bool allocate) {
string name_uc = to_upper_case(initial_caps_to_underscores(tstruct->get_name()));
if (tstruct->is_xception()) {
- out << indent() << "/* This struct is an exception */" << endl;
+ out << indent() << "/* This struct is an exception */" << '\n';
allocate = true;
}
if (allocate) {
- out << indent() << "if ( " << prefix << " != NULL)" << endl << indent() << "{" << endl;
+ out << indent() << "if ( " << prefix << " != NULL)" << '\n' << indent() << "{" << '\n';
indent_up();
- out << indent() << "g_object_unref (" << prefix << ");" << endl;
+ out << indent() << "g_object_unref (" << prefix << ");" << '\n';
indent_down();
- out << indent() << "}" << endl << indent() << prefix << " = g_object_new (" << this->nspace_uc
- << "TYPE_" << name_uc << ", NULL);" << endl;
+ out << indent() << "}" << '\n' << indent() << prefix << " = g_object_new (" << this->nspace_uc
+ << "TYPE_" << name_uc << ", NULL);" << '\n';
}
out << indent() << "if ((ret = thrift_struct_read (THRIFT_STRUCT (" << prefix
- << "), protocol, error)) < 0)" << endl << indent() << "{" << endl;
+ << "), protocol, error)) < 0)" << '\n' << indent() << "{" << '\n';
indent_up();
if (allocate) {
- indent(out) << "g_object_unref (" << prefix << ");" << endl;
+ indent(out) << "g_object_unref (" << prefix << ");" << '\n';
if (tstruct->is_xception()) {
- indent(out) << prefix << " = NULL;" << endl;
+ indent(out) << prefix << " = NULL;" << '\n';
}
}
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "}" << endl << indent() << "xfer += ret;" << endl;
+ out << indent() << "}" << '\n' << indent() << "xfer += ret;" << '\n';
}
void t_c_glib_generator::generate_deserialize_container(ostream& out,
@@ -4134,80 +4132,80 @@
scope_up(out);
if (ttype->is_map()) {
- out << indent() << "guint32 size;" << endl
- << indent() << "guint32 i;" << endl
- << indent() << "ThriftType key_type;" << endl
- << indent() << "ThriftType value_type;" << endl
- << endl
- << indent() << "/* read the map begin marker */" << endl
+ out << indent() << "guint32 size;" << '\n'
+ << indent() << "guint32 i;" << '\n'
+ << indent() << "ThriftType key_type;" << '\n'
+ << indent() << "ThriftType value_type;" << '\n'
+ << '\n'
+ << indent() << "/* read the map begin marker */" << '\n'
<< indent() << "if ((ret = thrift_protocol_read_map_begin (protocol, "
- "&key_type, &value_type, &size, error)) < 0)" << endl;
+ "&key_type, &value_type, &size, error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl
- << endl;
+ out << indent() << "xfer += ret;" << '\n'
+ << '\n';
// iterate over map elements
- out << indent() << "/* iterate through each of the map's fields */" << endl
- << indent() << "for (i = 0; i < size; i++)" << endl;
+ out << indent() << "/* iterate through each of the map's fields */" << '\n'
+ << indent() << "for (i = 0; i < size; i++)" << '\n';
scope_up(out);
generate_deserialize_map_element(out, (t_map*)ttype, prefix, error_ret);
scope_down(out);
- out << endl;
+ out << '\n';
// read map end
- out << indent() << "/* read the map end marker */" << endl
+ out << indent() << "/* read the map end marker */" << '\n'
<< indent() << "if ((ret = thrift_protocol_read_map_end (protocol, "
- "error)) < 0)" << endl;
+ "error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl;
+ out << indent() << "xfer += ret;" << '\n';
} else if (ttype->is_set()) {
- out << indent() << "guint32 size;" << endl
- << indent() << "guint32 i;" << endl
- << indent() << "ThriftType element_type;" << endl
- << endl
+ out << indent() << "guint32 size;" << '\n'
+ << indent() << "guint32 i;" << '\n'
+ << indent() << "ThriftType element_type;" << '\n'
+ << '\n'
<< indent() << "if ((ret = thrift_protocol_read_set_begin (protocol, "
- "&element_type, &size, error)) < 0)" << endl;
+ "&element_type, &size, error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl
- << endl;
+ out << indent() << "xfer += ret;" << '\n'
+ << '\n';
// iterate over the elements
- out << indent() << "/* iterate through the set elements */" << endl
- << indent() << "for (i = 0; i < size; ++i)" << endl;
+ out << indent() << "/* iterate through the set elements */" << '\n'
+ << indent() << "for (i = 0; i < size; ++i)" << '\n';
scope_up(out);
generate_deserialize_set_element(out, (t_set*)ttype, prefix, error_ret);
scope_down(out);
// read set end
out << indent() << "if ((ret = thrift_protocol_read_set_end (protocol, "
- "error)) < 0)" << endl;
+ "error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl
- << endl;
+ out << indent() << "xfer += ret;" << '\n'
+ << '\n';
} else if (ttype->is_list()) {
- out << indent() << "guint32 size;" << endl
- << indent() << "guint32 i;" << endl
- << indent() << "ThriftType element_type;" << endl
- << endl
+ out << indent() << "guint32 size;" << '\n'
+ << indent() << "guint32 i;" << '\n'
+ << indent() << "ThriftType element_type;" << '\n'
+ << '\n'
<< indent() << "if ((ret = thrift_protocol_read_list_begin (protocol, "
- "&element_type,&size, error)) < 0)" << endl;
+ "&element_type,&size, error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl
- << endl;
+ out << indent() << "xfer += ret;" << '\n'
+ << '\n';
// iterate over the elements
- out << indent() << "/* iterate through list elements */" << endl
- << indent() << "for (i = 0; i < size; i++)" << endl;
+ out << indent() << "/* iterate through list elements */" << '\n'
+ << indent() << "for (i = 0; i < size; i++)" << '\n';
scope_up(out);
generate_deserialize_list_element(out,
(t_list*)ttype,
@@ -4218,11 +4216,11 @@
// read list end
out << indent() << "if ((ret = thrift_protocol_read_list_end (protocol, "
- "error)) < 0)" << endl;
+ "error)) < 0)" << '\n';
indent_up();
- out << indent() << "return " << error_ret << ";" << endl;
+ out << indent() << "return " << error_ret << ";" << '\n';
indent_down();
- out << indent() << "xfer += ret;" << endl;
+ out << indent() << "xfer += ret;" << '\n';
}
scope_down(out);
@@ -4239,16 +4237,16 @@
if (ttype->is_map()) {
t_map* tmap = (t_map*)ttype;
out << indent() << tname << ptr << " " << name << " = "
- << generate_new_hash_from_type(tmap->get_key_type(), tmap->get_val_type()) << endl;
+ << generate_new_hash_from_type(tmap->get_key_type(), tmap->get_val_type()) << '\n';
} else if (ttype->is_list()) {
t_list* tlist = (t_list*)ttype;
out << indent() << tname << ptr << " " << name << " = "
- << generate_new_array_from_type(tlist->get_elem_type()) << endl;
+ << generate_new_array_from_type(tlist->get_elem_type()) << '\n';
} else if (for_hash_table && ttype->is_enum()) {
- out << indent() << tname << " " << name << ";" << endl;
+ out << indent() << tname << " " << name << ";" << '\n';
} else {
out << indent() << tname << ptr << " " << name
- << (ptr != "" ? " = g_new (" + tname + ", 1)" : " = NULL") << ";" << endl;
+ << (ptr != "" ? " = g_new (" + tname + ", 1)" : " = NULL") << ";" << '\n';
}
}
@@ -4259,7 +4257,7 @@
ttype = get_true_type(ttype);
string ptr = ttype->is_string() || !ttype->is_base_type() ? " " : "* ";
string init_val = ttype->is_enum() ? "" : " = NULL";
- out << indent() << tname << ptr << name << init_val << ";" << endl;
+ out << indent() << tname << ptr << name << init_val << ";" << '\n';
}
void t_c_glib_generator::generate_deserialize_map_element(ostream& out,
@@ -4289,10 +4287,10 @@
t_field fval(tval, tval_ptr + valname);
generate_deserialize_field(out, &fval, "", "", error_ret);
- indent(out) << "if (" << prefix << " && " << keyname << ")" << endl;
+ indent(out) << "if (" << prefix << " && " << keyname << ")" << '\n';
indent_up();
indent(out) << "g_hash_table_insert ((GHashTable *)" << prefix << ", (gpointer) " << keyname
- << ", (gpointer) " << valname << ");" << endl;
+ << ", (gpointer) " << valname << ");" << '\n';
indent_down();
}
@@ -4309,10 +4307,10 @@
t_field felem(telem, telem_ptr + elem);
generate_deserialize_field(out, &felem, "", "", error_ret);
- indent(out) << "if (" << prefix << " && " << elem << ")" << endl;
+ indent(out) << "if (" << prefix << " && " << elem << ")" << '\n';
indent_up();
indent(out) << "g_hash_table_insert ((GHashTable *) " << prefix << ", (gpointer) " << elem
- << ", (gpointer) " << elem << ");" << endl;
+ << ", (gpointer) " << elem << ");" << '\n';
indent_down();
}
@@ -4334,10 +4332,10 @@
if (ttype->is_void()) {
throw std::runtime_error("compiler error: list element type cannot be void");
} else if (is_numeric(ttype)) {
- indent(out) << "g_array_append_vals (" << prefix << ", " << elem << ", 1);" << endl;
- indent(out) << "g_free (" << elem << ");" << endl;
+ indent(out) << "g_array_append_vals (" << prefix << ", " << elem << ", 1);" << '\n';
+ indent(out) << "g_free (" << elem << ");" << '\n';
} else {
- indent(out) << "g_ptr_array_add (" << prefix << ", " << elem << ");" << endl;
+ indent(out) << "g_ptr_array_add (" << prefix << ", " << elem << ");" << '\n';
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_cl_generator.cc b/compiler/cpp/src/thrift/generate/t_cl_generator.cc
index e0dcc46..dccecdc 100644
--- a/compiler/cpp/src/thrift/generate/t_cl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_cl_generator.cc
@@ -130,9 +130,9 @@
string f_vars_name = program_dir + "/" + program_name_ + "-vars.lisp";
f_types_.open(f_types_name);
- f_types_ << cl_autogen_comment() << endl;
+ f_types_ << cl_autogen_comment() << '\n';
f_vars_.open(f_vars_name);
- f_vars_ << cl_autogen_comment() << endl;
+ f_vars_ << cl_autogen_comment() << '\n';
package_def(f_types_);
package_in(f_types_);
@@ -141,7 +141,7 @@
if (!no_asd) {
string f_asd_name = program_dir + "/" + system_prefix + program_name_ + ".asd";
f_asd_.open(f_asd_name);
- f_asd_ << cl_autogen_comment() << endl;
+ f_asd_ << cl_autogen_comment() << '\n';
asdf_def(f_asd_);
}
}
@@ -197,13 +197,13 @@
}
void t_cl_generator::asdf_def(std::ostream &out) {
- out << "(asdf:defsystem #:" << system_prefix << program_name_ << endl;
+ out << "(asdf:defsystem #:" << system_prefix << program_name_ << '\n';
indent_up();
out << indent() << render_includes()
- << indent() << ":serial t" << endl
+ << indent() << ":serial t" << '\n'
<< indent() << ":components ("
<< "(:file \"" << program_name_ << "-types\") "
- << "(:file \"" << program_name_ << "-vars\")))" << endl;
+ << "(:file \"" << program_name_ << "-vars\")))" << '\n';
indent_down();
}
@@ -221,11 +221,11 @@
}
out << ")";
}
- out << ")" << endl << endl;
+ out << ")" << '\n' << '\n';
}
void t_cl_generator::package_in(std::ostream &out) {
- out << "(cl:in-package :" << package() << ")" << endl << endl;
+ out << "(cl:in-package :" << package() << ")" << '\n' << '\n';
}
/**
@@ -238,7 +238,7 @@
}
void t_cl_generator::generate_enum(t_enum* tenum) {
- f_types_ << "(thrift:def-enum " << prefix(tenum->get_name()) << endl;
+ f_types_ << "(thrift:def-enum " << prefix(tenum->get_name()) << '\n';
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
@@ -249,12 +249,12 @@
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
value = (*c_iter)->get_value();
- if(c_iter != constants.begin()) f_types_ << endl << indent() << " ";
+ if(c_iter != constants.begin()) f_types_ << '\n' << indent() << " ";
f_types_ << "(\"" << (*c_iter)->get_name() << "\" . " << value << ")";
}
indent_down();
- f_types_ << "))" << endl << endl;
+ f_types_ << "))" << '\n' << '\n';
}
/**
@@ -266,7 +266,7 @@
t_const_value* value = tconst->get_value();
f_vars_ << "(thrift:def-constant " << prefix(name) << " " << render_const_value(type, value) << ")"
- << endl << endl;
+ << '\n' << '\n';
}
/**
@@ -306,7 +306,7 @@
indent(out) << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
out << (type->is_struct() ? "(make-instance '" : "(make-exception '") <<
- lowercase(type->get_name()) << " " << endl;
+ lowercase(type->get_name()) << " " << '\n';
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
@@ -326,7 +326,7 @@
}
out << indent() << ":" << v_iter->first->get_string() << " " <<
- render_const_value(field_type, v_iter->second) << endl;
+ render_const_value(field_type, v_iter->second) << '\n';
}
out << indent() << ")";
@@ -340,7 +340,7 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- out << endl << indent()
+ out << '\n' << indent()
<< "(cl:cons " << render_const_value(ktype, v_iter->first) << " "
<< render_const_value(vtype, v_iter->second) << ")";
}
@@ -354,16 +354,16 @@
etype = ((t_set*)type)->get_elem_type();
}
if (type->is_set()) {
- out << "(thrift:set" << endl;
+ out << "(thrift:set" << '\n';
} else {
- out << "(thrift:list" << endl;
+ out << "(thrift:list" << '\n';
}
indent_up();
indent_up();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- out << indent() << render_const_value(etype, *v_iter) << endl;
+ out << indent() << render_const_value(etype, *v_iter) << '\n';
}
out << indent() << ")";
indent_down();
@@ -394,7 +394,7 @@
t_type* type = (*m_iter)->get_type();
if (m_iter != members.begin()) {
- out << endl << indent() << " ";
+ out << '\n' << indent() << " ";
}
out << "(" << prefix((*m_iter)->get_name()) << " " <<
( (nullptr != value) ? render_const_value(type, value) : "nil" ) <<
@@ -421,16 +421,16 @@
void t_cl_generator::generate_cl_struct(std::ostream& out, t_struct* tstruct, bool is_exception = false) {
std::string name = type_name(tstruct);
out << (is_exception ? "(thrift:def-exception " : "(thrift:def-struct ") <<
- prefix(name) << endl;
+ prefix(name) << '\n';
indent_up();
if ( tstruct->has_doc() ) {
out << indent() ;
- out << "\"" << cl_docstring(tstruct->get_doc()) << "\"" << endl;
+ out << "\"" << cl_docstring(tstruct->get_doc()) << "\"" << '\n';
}
out << indent() ;
generate_cl_struct_internal(out, tstruct, is_exception);
indent_down();
- out << ")" << endl << endl;
+ out << ")" << '\n' << '\n';
}
void t_cl_generator::generate_exception_sig(std::ostream& out, t_function* f) {
@@ -454,7 +454,7 @@
indent_up();
if ( tservice->has_doc()) {
- f_types_ << endl << indent()
+ f_types_ << '\n' << indent()
<< "(:documentation \"" << cl_docstring(tservice->get_doc()) << "\")";
}
@@ -465,23 +465,23 @@
t_struct* exceptions = function->get_xceptions();
const vector<t_field*>& xmembers = exceptions->get_members();
- f_types_ << endl << indent() << "(:method " << prefix(fname);
+ f_types_ << '\n' << indent() << "(:method " << prefix(fname);
f_types_ << " (" << signature << " " << typespec((*f_iter)->get_returntype()) << ")";
if (xmembers.size() > 0) {
- f_types_ << endl << indent() << " :exceptions " ;
+ f_types_ << '\n' << indent() << " :exceptions " ;
generate_exception_sig(f_types_, function);
}
if ( (*f_iter)->is_oneway() ) {
- f_types_ << endl << indent() << " :oneway t";
+ f_types_ << '\n' << indent() << " :oneway t";
}
if ( (*f_iter)->has_doc() ) {
- f_types_ << endl << indent() << " :documentation \""
+ f_types_ << '\n' << indent() << " :documentation \""
<< cl_docstring((*f_iter)->get_doc()) << "\"";
}
f_types_ << ")";
}
- f_types_ << ")" << endl << endl;
+ f_types_ << ")" << '\n' << '\n';
indent_down();
}
diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc
index e21252e..dc74a92 100644
--- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc
@@ -42,8 +42,6 @@
using std::string;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* C++ code generator. This is legitimacy incarnate.
*
@@ -438,69 +436,69 @@
f_types_tcc_ << autogen_comment();
// Start ifndef
- f_types_ << "#ifndef " << program_name_ << "_TYPES_H" << endl << "#define " << program_name_
- << "_TYPES_H" << endl << endl;
- f_types_tcc_ << "#ifndef " << program_name_ << "_TYPES_TCC" << endl << "#define " << program_name_
- << "_TYPES_TCC" << endl << endl;
+ f_types_ << "#ifndef " << program_name_ << "_TYPES_H" << '\n' << "#define " << program_name_
+ << "_TYPES_H" << '\n' << '\n';
+ f_types_tcc_ << "#ifndef " << program_name_ << "_TYPES_TCC" << '\n' << "#define " << program_name_
+ << "_TYPES_TCC" << '\n' << '\n';
// Include base types
- f_types_ << "#include <iosfwd>" << endl
- << endl
- << "#include <thrift/Thrift.h>" << endl
- << "#include <thrift/TApplicationException.h>" << endl
- << "#include <thrift/TBase.h>" << endl
- << "#include <thrift/protocol/TProtocol.h>" << endl
- << "#include <thrift/transport/TTransport.h>" << endl
- << endl;
+ f_types_ << "#include <iosfwd>" << '\n'
+ << '\n'
+ << "#include <thrift/Thrift.h>" << '\n'
+ << "#include <thrift/TApplicationException.h>" << '\n'
+ << "#include <thrift/TBase.h>" << '\n'
+ << "#include <thrift/protocol/TProtocol.h>" << '\n'
+ << "#include <thrift/transport/TTransport.h>" << '\n'
+ << '\n';
// Include C++xx compatibility header
- f_types_ << "#include <functional>" << endl;
- f_types_ << "#include <memory>" << endl;
+ f_types_ << "#include <functional>" << '\n';
+ f_types_ << "#include <memory>" << '\n';
// Include other Thrift includes
const vector<t_program*>& includes = program_->get_includes();
for (auto include : includes) {
f_types_ << "#include \"" << get_include_prefix(*include) << include->get_name()
- << "_types.h\"" << endl;
+ << "_types.h\"" << '\n';
// XXX(simpkins): If gen_templates_ is enabled, we currently assume all
// included files were also generated with templates enabled.
f_types_tcc_ << "#include \"" << get_include_prefix(*include) << include->get_name()
- << "_types.tcc\"" << endl;
+ << "_types.tcc\"" << '\n';
}
- f_types_ << endl;
+ f_types_ << '\n';
// Include custom headers
const vector<string>& cpp_includes = program_->get_cpp_includes();
for (const auto & cpp_include : cpp_includes) {
if (cpp_include[0] == '<') {
- f_types_ << "#include " << cpp_include << endl;
+ f_types_ << "#include " << cpp_include << '\n';
} else {
- f_types_ << "#include \"" << cpp_include << "\"" << endl;
+ f_types_ << "#include \"" << cpp_include << "\"" << '\n';
}
}
- f_types_ << endl;
+ f_types_ << '\n';
// Include the types file
f_types_impl_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
- << "_types.h\"" << endl << endl;
+ << "_types.h\"" << '\n' << '\n';
f_types_tcc_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
- << "_types.h\"" << endl << endl;
+ << "_types.h\"" << '\n' << '\n';
// The swap() code needs <algorithm> for std::swap()
- f_types_impl_ << "#include <algorithm>" << endl;
+ f_types_impl_ << "#include <algorithm>" << '\n';
// for operator<<
- f_types_impl_ << "#include <ostream>" << endl << endl;
- f_types_impl_ << "#include <thrift/TToString.h>" << endl << endl;
+ f_types_impl_ << "#include <ostream>" << '\n' << '\n';
+ f_types_impl_ << "#include <thrift/TToString.h>" << '\n' << '\n';
// Open namespace
ns_open_ = namespace_open(program_->get_namespace("cpp"));
ns_close_ = namespace_close(program_->get_namespace("cpp"));
- f_types_ << ns_open_ << endl << endl;
+ f_types_ << ns_open_ << '\n' << '\n';
- f_types_impl_ << ns_open_ << endl << endl;
+ f_types_impl_ << ns_open_ << '\n' << '\n';
- f_types_tcc_ << ns_open_ << endl << endl;
+ f_types_tcc_ << ns_open_ << '\n' << '\n';
}
/**
@@ -508,21 +506,21 @@
*/
void t_cpp_generator::close_generator() {
// Close namespace
- f_types_ << ns_close_ << endl << endl;
- f_types_impl_ << ns_close_ << endl;
- f_types_tcc_ << ns_close_ << endl << endl;
+ f_types_ << ns_close_ << '\n' << '\n';
+ f_types_impl_ << ns_close_ << '\n';
+ f_types_tcc_ << ns_close_ << '\n' << '\n';
// Include the types.tcc file from the types header file,
// so clients don't have to explicitly include the tcc file.
// TODO(simpkins): Make this a separate option.
if (gen_templates_) {
f_types_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
- << "_types.tcc\"" << endl << endl;
+ << "_types.tcc\"" << '\n' << '\n';
}
// Close ifndef
- f_types_ << "#endif" << endl;
- f_types_tcc_ << "#endif" << endl;
+ f_types_ << "#endif" << '\n';
+ f_types_tcc_ << "#endif" << '\n';
// Close output file
f_types_.close();
@@ -544,7 +542,7 @@
void t_cpp_generator::generate_typedef(t_typedef* ttypedef) {
generate_java_doc(f_types_, ttypedef);
f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " "
- << ttypedef->get_symbolic() << ";" << endl << endl;
+ << ttypedef->get_symbolic() << ";" << '\n' << '\n';
}
void t_cpp_generator::generate_enum_constant_list(std::ostream& f,
@@ -552,7 +550,7 @@
const char* prefix,
const char* suffix,
bool include_values) {
- f << " {" << endl;
+ f << " {" << '\n';
indent_up();
vector<t_enum_value*>::const_iterator c_iter;
@@ -561,7 +559,7 @@
if (first) {
first = false;
} else {
- f << "," << endl;
+ f << "," << '\n';
}
generate_java_doc(f, *c_iter);
indent(f) << prefix << (*c_iter)->get_name() << suffix;
@@ -570,9 +568,9 @@
}
}
- f << endl;
+ f << '\n';
indent_down();
- indent(f) << "};" << endl;
+ indent(f) << "};" << '\n';
}
/**
@@ -588,7 +586,7 @@
if (!gen_pure_enums_) {
enum_name = "type";
generate_java_doc(f_types_, tenum);
- f_types_ << indent() << "struct " << tenum->get_name() << " {" << endl;
+ f_types_ << indent() << "struct " << tenum->get_name() << " {" << '\n';
indent_up();
}
f_types_ << indent() << "enum " << enum_name;
@@ -597,10 +595,10 @@
if (!gen_pure_enums_) {
indent_down();
- f_types_ << "};" << endl;
+ f_types_ << "};" << '\n';
}
- f_types_ << endl;
+ f_types_ << '\n';
/**
Generate a character array of enum names for debugging purposes.
@@ -617,13 +615,13 @@
generate_enum_constant_list(f_types_impl_, constants, "\"", "\"", false);
f_types_ << indent() << "extern const std::map<int, const char*> _" << tenum->get_name()
- << "_VALUES_TO_NAMES;" << endl << endl;
+ << "_VALUES_TO_NAMES;" << '\n' << '\n';
f_types_impl_ << indent() << "const std::map<int, const char*> _" << tenum->get_name()
<< "_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(" << constants.size() << ", _k"
<< tenum->get_name() << "Values"
<< ", _k" << tenum->get_name() << "Names), "
- << "::apache::thrift::TEnumIterator(-1, nullptr, nullptr));" << endl << endl;
+ << "::apache::thrift::TEnumIterator(-1, nullptr, nullptr));" << '\n' << '\n';
generate_enum_ostream_operator_decl(f_types_, tenum);
generate_enum_ostream_operator(f_types_impl_, tenum);
@@ -642,8 +640,8 @@
} else {
out << tenum->get_name() << "::type&";
}
- out << " val);" << endl;
- out << endl;
+ out << " val);" << '\n';
+ out << '\n';
}
void t_cpp_generator::generate_enum_ostream_operator(std::ostream& out, t_enum* tenum) {
@@ -662,20 +660,20 @@
scope_up(out);
out << indent() << "std::map<int, const char*>::const_iterator it = _"
- << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << endl;
- out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << endl;
+ << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << '\n';
+ out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << '\n';
indent_up();
- out << indent() << "out << it->second;" << endl;
+ out << indent() << "out << it->second;" << '\n';
indent_down();
- out << indent() << "} else {" << endl;
+ out << indent() << "} else {" << '\n';
indent_up();
- out << indent() << "out << static_cast<int>(val);" << endl;
+ out << indent() << "out << static_cast<int>(val);" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
- out << indent() << "return out;" << endl;
+ out << indent() << "return out;" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
}
}
@@ -686,8 +684,8 @@
} else {
out << tenum->get_name() << "::type&";
}
- out << " val);" << endl;
- out << endl;
+ out << " val);" << '\n';
+ out << '\n';
}
void t_cpp_generator::generate_enum_to_string_helper_function(std::ostream& out, t_enum* tenum) {
@@ -702,19 +700,19 @@
scope_up(out);
out << indent() << "std::map<int, const char*>::const_iterator it = _"
- << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << endl;
- out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << endl;
+ << tenum->get_name() << "_VALUES_TO_NAMES.find(val);" << '\n';
+ out << indent() << "if (it != _" << tenum->get_name() << "_VALUES_TO_NAMES.end()) {" << '\n';
indent_up();
- out << indent() << "return std::string(it->second);" << endl;
+ out << indent() << "return std::string(it->second);" << '\n';
indent_down();
- out << indent() << "} else {" << endl;
+ out << indent() << "} else {" << '\n';
indent_up();
- out << indent() << "return std::to_string(static_cast<int>(val));" << endl;
+ out << indent() << "return std::to_string(static_cast<int>(val));" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
}
}
@@ -736,28 +734,28 @@
f_consts_impl << autogen_comment();
// Start ifndef
- f_consts << "#ifndef " << program_name_ << "_CONSTANTS_H" << endl << "#define " << program_name_
- << "_CONSTANTS_H" << endl << endl << "#include \"" << get_include_prefix(*get_program())
- << program_name_ << "_types.h\"" << endl << endl << ns_open_ << endl << endl;
+ f_consts << "#ifndef " << program_name_ << "_CONSTANTS_H" << '\n' << "#define " << program_name_
+ << "_CONSTANTS_H" << '\n' << '\n' << "#include \"" << get_include_prefix(*get_program())
+ << program_name_ << "_types.h\"" << '\n' << '\n' << ns_open_ << '\n' << '\n';
f_consts_impl << "#include \"" << get_include_prefix(*get_program()) << program_name_
- << "_constants.h\"" << endl << endl << ns_open_ << endl << endl;
+ << "_constants.h\"" << '\n' << '\n' << ns_open_ << '\n' << '\n';
- f_consts << "class " << program_name_ << "Constants {" << endl << " public:" << endl << " "
- << program_name_ << "Constants();" << endl << endl;
+ f_consts << "class " << program_name_ << "Constants {" << '\n' << " public:" << '\n' << " "
+ << program_name_ << "Constants();" << '\n' << '\n';
indent_up();
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
string name = (*c_iter)->get_name();
t_type* type = (*c_iter)->get_type();
- f_consts << indent() << type_name(type) << " " << name << ";" << endl;
+ f_consts << indent() << type_name(type) << " " << name << ";" << '\n';
}
indent_down();
- f_consts << "};" << endl;
+ f_consts << "};" << '\n';
f_consts_impl << "const " << program_name_ << "Constants g_" << program_name_ << "_constants;"
- << endl << endl << program_name_ << "Constants::" << program_name_
- << "Constants() {" << endl;
+ << '\n' << '\n' << program_name_ << "Constants::" << program_name_
+ << "Constants() {" << '\n';
indent_up();
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
print_const_value(f_consts_impl,
@@ -766,13 +764,13 @@
(*c_iter)->get_value());
}
indent_down();
- indent(f_consts_impl) << "}" << endl;
+ indent(f_consts_impl) << "}" << '\n';
- f_consts << endl << "extern const " << program_name_ << "Constants g_" << program_name_
- << "_constants;" << endl << endl << ns_close_ << endl << endl << "#endif" << endl;
+ f_consts << '\n' << "extern const " << program_name_ << "Constants g_" << program_name_
+ << "_constants;" << '\n' << '\n' << ns_close_ << '\n' << '\n' << "#endif" << '\n';
f_consts.close();
- f_consts_impl << endl << ns_close_ << endl << endl;
+ f_consts_impl << '\n' << ns_close_ << '\n' << '\n';
f_consts_impl.close();
}
}
@@ -789,11 +787,11 @@
type = get_true_type(type);
if (type->is_base_type()) {
string v2 = render_const_value(out, name, type, value);
- indent(out) << name << " = " << v2 << ";" << endl << endl;
+ indent(out) << name << " = " << v2 << ";" << '\n' << '\n';
} else if (type->is_enum()) {
indent(out) << name
<< " = static_cast<" << type_name(type) << '>'
- << '(' << value->get_integer() << ");" << endl << endl;
+ << '(' << value->get_integer() << ");" << '\n' << '\n';
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -813,12 +811,12 @@
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string item_val = render_const_value(out, name, field_type, v_iter->second);
- indent(out) << name << "." << v_iter->first->get_string() << " = " << item_val << ";" << endl;
+ indent(out) << name << "." << v_iter->first->get_string() << " = " << item_val << ";" << '\n';
if (is_nonrequired_field) {
- indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << endl;
+ indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << '\n';
}
}
- out << endl;
+ out << '\n';
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
@@ -827,27 +825,27 @@
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, name, ktype, v_iter->first);
string item_val = render_const_value(out, name, vtype, v_iter->second);
- indent(out) << name << ".insert(std::make_pair(" << key << ", " << item_val << "));" << endl;
+ indent(out) << name << ".insert(std::make_pair(" << key << ", " << item_val << "));" << '\n';
}
- out << endl;
+ out << '\n';
} else if (type->is_list()) {
t_type* etype = ((t_list*)type)->get_elem_type();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string item_val = render_const_value(out, name, etype, *v_iter);
- indent(out) << name << ".push_back(" << item_val << ");" << endl;
+ indent(out) << name << ".push_back(" << item_val << ");" << '\n';
}
- out << endl;
+ out << '\n';
} else if (type->is_set()) {
t_type* etype = ((t_set*)type)->get_elem_type();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string item_val = render_const_value(out, name, etype, *v_iter);
- indent(out) << name << ".insert(" << item_val << ");" << endl;
+ indent(out) << name << ".insert(" << item_val << ");" << '\n';
}
- out << endl;
+ out << '\n';
} else {
throw "INVALID TYPE IN print_const_value: " + type->get_name();
}
@@ -895,7 +893,7 @@
<< '(' << value->get_integer() << ')';
} else {
string t = tmp("tmp");
- indent(out) << type_name(type) << " " << t << ";" << endl;
+ indent(out) << type_name(type) << " " << t << ";" << '\n';
print_const_value(out, t, type, value);
render << t;
}
@@ -905,7 +903,7 @@
void t_cpp_generator::generate_forward_declaration(t_struct* tstruct) {
// Forward declare struct def
- f_types_ << indent() << "class " << tstruct->get_name() << ";" << endl << endl;
+ f_types_ << indent() << "class " << tstruct->get_name() << ";" << '\n' << '\n';
}
/**
@@ -953,25 +951,25 @@
out << indent() << "bool " << tstruct->get_name()
<< "::operator==(const " << tstruct->get_name() << " & "
- << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl;
+ << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << '\n';
scope_up(out);
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
// Most existing Thrift code does not use isset or optional/required,
// so we treat "default" fields as required.
if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
out << indent() << "if (!(" << (*m_iter)->get_name() << " == rhs."
- << (*m_iter)->get_name() << "))" << endl << indent() << " return false;" << endl;
+ << (*m_iter)->get_name() << "))" << '\n' << indent() << " return false;" << '\n';
} else {
out << indent() << "if (__isset." << (*m_iter)->get_name() << " != rhs.__isset."
- << (*m_iter)->get_name() << ")" << endl << indent() << " return false;" << endl
+ << (*m_iter)->get_name() << ")" << '\n' << indent() << " return false;" << '\n'
<< indent() << "else if (__isset." << (*m_iter)->get_name() << " && !("
- << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << endl
- << indent() << " return false;" << endl;
+ << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << '\n'
+ << indent() << " return false;" << '\n';
}
}
- indent(out) << "return true;" << endl;
+ indent(out) << "return true;" << '\n';
scope_down(out);
- out << "\n";
+ out << '\n';
}
bool t_cpp_generator::has_field_with_default_value(t_struct* tstruct)
@@ -1014,7 +1012,7 @@
// Default-initialize TException, if it is our base type
if (is_exception)
{
- out << "\n";
+ out << '\n';
indent(out) << " : ";
out << "TException()";
init_ctor = true;
@@ -1054,7 +1052,7 @@
// Start generating body
//
- out << " {" << endl;
+ out << " {" << '\n';
indent_up();
// TODO(dreiss): When everything else in Thrift is perfect,
// do more of these in the initializer list.
@@ -1111,14 +1109,14 @@
out << "noexcept ";
if (is_exception)
out << ": TException() ";
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
// eliminate compiler unused warning
if (members.empty())
- indent(out) << "(void) " << tmp_name << ";" << endl;
+ indent(out) << "(void) " << tmp_name << ";" << '\n';
vector<t_field*>::const_iterator f_iter;
bool has_nonrequired_fields = false;
@@ -1129,15 +1127,15 @@
<< maybeMove(
tmp_name + "." + (*f_iter)->get_name(),
is_move && is_complex_type((*f_iter)->get_type()))
- << ";" << endl;
+ << ";" << '\n';
}
if (has_nonrequired_fields) {
- indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << endl;
+ indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << '\n';
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_cpp_generator::generate_assignment_operator(ostream& out, t_struct* tstruct) {
@@ -1161,14 +1159,14 @@
out << tmp_name << ") ";
if(is_move || is_struct_storage_not_throwing(tstruct))
out << "noexcept ";
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
// eliminate compiler unused warning
if (members.empty())
- indent(out) << "(void) " << tmp_name << ";" << endl;
+ indent(out) << "(void) " << tmp_name << ";" << '\n';
vector<t_field*>::const_iterator f_iter;
bool has_nonrequired_fields = false;
@@ -1179,15 +1177,15 @@
<< maybeMove(
tmp_name + "." + (*f_iter)->get_name(),
is_move && is_complex_type((*f_iter)->get_type()))
- << ";" << endl;
+ << ";" << '\n';
}
if (has_nonrequired_fields) {
- indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << endl;
+ indent(out) << "__isset = " << maybeMove(tmp_name + ".__isset", false) << ";" << '\n';
}
- indent(out) << "return *this;" << endl;
+ indent(out) << "return *this;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
/**
@@ -1230,7 +1228,7 @@
if (has_nonrequired_fields && (!pointers || read)) {
- out << indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << endl;
+ out << indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << '\n';
indent_up();
indent(out) << "_" << tstruct->get_name() << "__isset() ";
@@ -1247,58 +1245,58 @@
out << ", " << (*m_iter)->get_name() << "(" << isSet << ")";
}
}
- out << " {}" << endl;
+ out << " {}" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
- indent(out) << "bool " << (*m_iter)->get_name() << " :1;" << endl;
+ indent(out) << "bool " << (*m_iter)->get_name() << " :1;" << '\n';
}
}
indent_down();
- indent(out) << "} _" << tstruct->get_name() << "__isset;" << endl;
+ indent(out) << "} _" << tstruct->get_name() << "__isset;" << '\n';
}
- out << endl;
+ out << '\n';
generate_java_doc(out, tstruct);
// Open struct def
- out << indent() << "class " << tstruct->get_name() << extends << " {" << endl << indent()
- << " public:" << endl << endl;
+ out << indent() << "class " << tstruct->get_name() << extends << " {" << '\n' << indent()
+ << " public:" << '\n' << '\n';
indent_up();
if (!pointers) {
bool ok_noexcept = is_struct_storage_not_throwing(tstruct);
// Copy constructor
indent(out) << tstruct->get_name() << "(const " << tstruct->get_name() << "&)"
- << (ok_noexcept? " noexcept" : "") << ';' << endl;
+ << (ok_noexcept? " noexcept" : "") << ';' << '\n';
// Move constructor
if (gen_moveable_) {
indent(out) << tstruct->get_name() << "(" << tstruct->get_name() << "&&) noexcept;"
- << endl;
+ << '\n';
}
// Assignment Operator
indent(out) << tstruct->get_name() << "& operator=(const " << tstruct->get_name() << "&)"
- << (ok_noexcept? " noexcept" : "") << ';' << endl;
+ << (ok_noexcept? " noexcept" : "") << ';' << '\n';
// Move assignment operator
if (gen_moveable_) {
indent(out) << tstruct->get_name() << "& operator=(" << tstruct->get_name() << "&&) noexcept;"
- << endl;
+ << '\n';
}
bool has_default_value = has_field_with_default_value(tstruct);
// Default constructor
std::string clsname_ctor = tstruct->get_name() + "()";
- indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept") << ";" << endl;
+ indent(out) << clsname_ctor << (has_default_value ? "" : " noexcept") << ";" << '\n';
}
if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
- out << endl << indent() << "virtual ~" << tstruct->get_name() << "() noexcept;" << endl;
+ out << '\n' << indent() << "virtual ~" << tstruct->get_name() << "() noexcept;" << '\n';
}
// Declare all fields
@@ -1307,12 +1305,12 @@
indent(out) << declare_field(*m_iter,
false,
(pointers && !(*m_iter)->get_type()->is_xception()),
- !read) << endl;
+ !read) << '\n';
}
// Add the __isset data member if we need it, using the definition from above
if (has_nonrequired_fields && (!pointers || read)) {
- out << endl << indent() << "_" << tstruct->get_name() << "__isset __isset;" << endl;
+ out << '\n' << indent() << "_" << tstruct->get_name() << "__isset __isset;" << '\n';
}
// Create a setter function for each field
@@ -1321,87 +1319,87 @@
continue;
}
if (is_reference((*m_iter))) {
- out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "(::std::shared_ptr<"
+ out << '\n' << indent() << "void __set_" << (*m_iter)->get_name() << "(::std::shared_ptr<"
<< type_name((*m_iter)->get_type(), false, false) << ">";
- out << " val);" << endl;
+ out << " val);" << '\n';
} else {
- out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "("
+ out << '\n' << indent() << "void __set_" << (*m_iter)->get_name() << "("
<< type_name((*m_iter)->get_type(), false, true);
- out << " val);" << endl;
+ out << " val);" << '\n';
}
}
- out << endl;
+ out << '\n';
if (!pointers) {
// Should we generate default operators?
if (!gen_no_default_operators_) {
// Generate an equality testing operator.
out << indent() << "bool operator == (const " << tstruct->get_name() << " & "
- << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const;" << endl;
+ << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const;" << '\n';
out << indent() << "bool operator != (const " << tstruct->get_name() << " &rhs) const {"
- << endl << indent() << " return !(*this == rhs);" << endl << indent() << "}" << endl
- << endl;
+ << '\n' << indent() << " return !(*this == rhs);" << '\n' << indent() << "}" << '\n'
+ << '\n';
// Generate the declaration of a less-than operator. This must be
// implemented by the application developer if they wish to use it. (They
// will get a link error if they try to use it without an implementation.)
- out << indent() << "bool operator < (const " << tstruct->get_name() << " & ) const;" << endl
- << endl;
+ out << indent() << "bool operator < (const " << tstruct->get_name() << " & ) const;" << '\n'
+ << '\n';
}
}
if (read) {
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl << indent()
- << "uint32_t read(Protocol_* iprot);" << endl;
+ out << indent() << "template <class Protocol_>" << '\n' << indent()
+ << "uint32_t read(Protocol_* iprot);" << '\n';
} else {
out << indent() << "uint32_t read("
<< "::apache::thrift::protocol::TProtocol* iprot)";
if(!is_exception && !extends.empty())
out << " override";
- out << ';' << endl;
+ out << ';' << '\n';
}
}
if (write) {
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl << indent()
- << "uint32_t write(Protocol_* oprot) const;" << endl;
+ out << indent() << "template <class Protocol_>" << '\n' << indent()
+ << "uint32_t write(Protocol_* oprot) const;" << '\n';
} else {
out << indent() << "uint32_t write("
<< "::apache::thrift::protocol::TProtocol* oprot) const";
if(!is_exception && !extends.empty())
out << " override";
- out << ';' << endl;
+ out << ';' << '\n';
}
}
- out << endl;
+ out << '\n';
if (is_user_struct && !has_custom_ostream(tstruct)) {
out << indent() << "virtual ";
generate_struct_print_method_decl(out, nullptr);
- out << ";" << endl;
+ out << ";" << '\n';
}
// std::exception::what()
if (is_exception) {
- out << indent() << "mutable std::string thriftTExceptionMessageHolder_;" << endl;
+ out << indent() << "mutable std::string thriftTExceptionMessageHolder_;" << '\n';
out << indent();
generate_exception_what_method_decl(out, tstruct, false);
- out << ";" << endl;
+ out << ";" << '\n';
}
indent_down();
- indent(out) << "};" << endl << endl;
+ indent(out) << "};" << '\n' << '\n';
if (swap) {
// Generate a namespace-scope swap() function
if (tstruct->get_name() == "a" || tstruct->get_name() == "b") {
out << indent() << "void swap(" << tstruct->get_name() << " &a1, " << tstruct->get_name()
- << " &a2);" << endl << endl;
+ << " &a2);" << '\n' << '\n';
} else {
out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name()
- << " &b);" << endl << endl;
+ << " &b);" << '\n' << '\n';
}
}
@@ -1422,12 +1420,12 @@
// Destructor
if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
- force_cpp_out << endl << indent() << tstruct->get_name() << "::~" << tstruct->get_name()
- << "() noexcept {" << endl;
+ force_cpp_out << '\n' << indent() << tstruct->get_name() << "::~" << tstruct->get_name()
+ << "() noexcept {" << '\n';
indent_up();
indent_down();
- force_cpp_out << indent() << "}" << endl << endl;
+ force_cpp_out << indent() << "}" << '\n' << '\n';
}
if (!pointers)
@@ -1442,32 +1440,32 @@
if (setters) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (is_reference((*m_iter))) {
- out << endl << indent() << "void " << tstruct->get_name() << "::__set_"
+ out << '\n' << indent() << "void " << tstruct->get_name() << "::__set_"
<< (*m_iter)->get_name() << "(::std::shared_ptr<"
<< type_name((*m_iter)->get_type(), false, false) << ">";
- out << " val) {" << endl;
+ out << " val) {" << '\n';
} else {
- out << endl << indent() << "void " << tstruct->get_name() << "::__set_"
+ out << '\n' << indent() << "void " << tstruct->get_name() << "::__set_"
<< (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type(), false, true);
- out << " val) {" << endl;
+ out << " val) {" << '\n';
}
indent_up();
- out << indent() << "this->" << (*m_iter)->get_name() << " = val;" << endl;
+ out << indent() << "this->" << (*m_iter)->get_name() << " = val;" << '\n';
indent_down();
// assume all fields are required except optional fields.
// for optional fields change __isset.name to true
bool is_optional = (*m_iter)->get_req() == t_field::T_OPTIONAL;
if (is_optional) {
- out << indent() << indent() << "__isset." << (*m_iter)->get_name() << " = true;" << endl;
+ out << indent() << indent() << "__isset." << (*m_iter)->get_name() << " = true;" << '\n';
}
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
if (is_user_struct) {
generate_struct_ostream_operator(out, tstruct);
}
- out << endl;
+ out << '\n';
}
/**
@@ -1478,11 +1476,11 @@
*/
void t_cpp_generator::generate_struct_reader(ostream& out, t_struct* tstruct, bool pointers) {
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl << indent() << "uint32_t "
- << tstruct->get_name() << "::read(Protocol_* iprot) {" << endl;
+ out << indent() << "template <class Protocol_>" << '\n' << indent() << "uint32_t "
+ << tstruct->get_name() << "::read(Protocol_* iprot) {" << '\n';
} else {
indent(out) << "uint32_t " << tstruct->get_name()
- << "::read(::apache::thrift::protocol::TProtocol* iprot) {" << endl;
+ << "::read(::apache::thrift::protocol::TProtocol* iprot) {" << '\n';
}
indent_up();
@@ -1490,49 +1488,49 @@
vector<t_field*>::const_iterator f_iter;
// Declare stack tmp variables
- out << endl
- << indent() << "::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);" << endl
- << indent() << "uint32_t xfer = 0;" << endl
- << indent() << "std::string fname;" << endl
- << indent() << "::apache::thrift::protocol::TType ftype;" << endl
- << indent() << "int16_t fid;" << endl
- << endl
- << indent() << "xfer += iprot->readStructBegin(fname);" << endl
- << endl
- << indent() << "using ::apache::thrift::protocol::TProtocolException;" << endl
- << endl;
+ out << '\n'
+ << indent() << "::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);" << '\n'
+ << indent() << "uint32_t xfer = 0;" << '\n'
+ << indent() << "std::string fname;" << '\n'
+ << indent() << "::apache::thrift::protocol::TType ftype;" << '\n'
+ << indent() << "int16_t fid;" << '\n'
+ << '\n'
+ << indent() << "xfer += iprot->readStructBegin(fname);" << '\n'
+ << '\n'
+ << indent() << "using ::apache::thrift::protocol::TProtocolException;" << '\n'
+ << '\n';
// Required variables aren't in __isset, so we need tmp vars to check them.
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED)
- indent(out) << "bool isset_" << (*f_iter)->get_name() << " = false;" << endl;
+ indent(out) << "bool isset_" << (*f_iter)->get_name() << " = false;" << '\n';
}
- out << endl;
+ out << '\n';
// Loop over reading in fields
- indent(out) << "while (true)" << endl;
+ indent(out) << "while (true)" << '\n';
scope_up(out);
// Read beginning field marker
- indent(out) << "xfer += iprot->readFieldBegin(fname, ftype, fid);" << endl;
+ indent(out) << "xfer += iprot->readFieldBegin(fname, ftype, fid);" << '\n';
// Check for field STOP marker
- out << indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << endl << indent()
- << " break;" << endl << indent() << "}" << endl;
+ out << indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << '\n' << indent()
+ << " break;" << '\n' << indent() << "}" << '\n';
if (fields.empty()) {
- out << indent() << "xfer += iprot->skip(ftype);" << endl;
+ out << indent() << "xfer += iprot->skip(ftype);" << '\n';
} else {
// Switch statement on the field we are reading
- indent(out) << "switch (fid)" << endl;
+ indent(out) << "switch (fid)" << '\n';
scope_up(out);
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
+ indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+ indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n';
indent_up();
const char* isset_prefix = ((*f_iter)->get_req() != t_field::T_REQUIRED) ? "this->__isset."
@@ -1544,8 +1542,8 @@
// TODO(dreiss): Generate this code and "if" it out to make it easier
// for people recompiling thrift to include it.
out <<
- indent() << "if (" << isset_prefix << (*f_iter)->get_name() << ")" << endl <<
- indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
+ indent() << "if (" << isset_prefix << (*f_iter)->get_name() << ")" << '\n' <<
+ indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n';
#endif
if (pointers && !(*f_iter)->get_type()->is_xception()) {
@@ -1553,44 +1551,44 @@
} else {
generate_deserialize_field(out, *f_iter, "this->");
}
- out << indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << endl;
+ out << indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << '\n';
indent_down();
- out << indent() << "} else {" << endl << indent() << " xfer += iprot->skip(ftype);" << endl
+ out << indent() << "} else {" << '\n' << indent() << " xfer += iprot->skip(ftype);" << '\n'
<<
// TODO(dreiss): Make this an option when thrift structs
// have a common base class.
- // indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl <<
- indent() << "}" << endl << indent() << "break;" << endl;
+ // indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n' <<
+ indent() << "}" << '\n' << indent() << "break;" << '\n';
indent_down();
}
// In the default case we skip the field
- out << indent() << "default:" << endl << indent() << " xfer += iprot->skip(ftype);" << endl
- << indent() << " break;" << endl;
+ out << indent() << "default:" << '\n' << indent() << " xfer += iprot->skip(ftype);" << '\n'
+ << indent() << " break;" << '\n';
scope_down(out);
} //!fields.empty()
// Read field end marker
- indent(out) << "xfer += iprot->readFieldEnd();" << endl;
+ indent(out) << "xfer += iprot->readFieldEnd();" << '\n';
scope_down(out);
- out << endl << indent() << "xfer += iprot->readStructEnd();" << endl;
+ out << '\n' << indent() << "xfer += iprot->readStructEnd();" << '\n';
// Throw if any required fields are missing.
// We do this after reading the struct end so that
// there might possibly be a chance of continuing.
- out << endl;
+ out << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED)
- out << indent() << "if (!isset_" << (*f_iter)->get_name() << ')' << endl << indent()
- << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
+ out << indent() << "if (!isset_" << (*f_iter)->get_name() << ')' << '\n' << indent()
+ << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n';
}
- indent(out) << "return xfer;" << endl;
+ indent(out) << "return xfer;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1605,33 +1603,33 @@
vector<t_field*>::const_iterator f_iter;
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl << indent() << "uint32_t "
- << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl;
+ out << indent() << "template <class Protocol_>" << '\n' << indent() << "uint32_t "
+ << tstruct->get_name() << "::write(Protocol_* oprot) const {" << '\n';
} else {
indent(out) << "uint32_t " << tstruct->get_name()
- << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
+ << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << '\n';
}
indent_up();
- out << indent() << "uint32_t xfer = 0;" << endl;
+ out << indent() << "uint32_t xfer = 0;" << '\n';
- indent(out) << "::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);" << endl;
- indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
+ indent(out) << "::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);" << '\n';
+ indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool check_if_set = (*f_iter)->get_req() == t_field::T_OPTIONAL
|| (*f_iter)->get_type()->is_xception();
if (check_if_set) {
- out << endl << indent() << "if (this->__isset." << (*f_iter)->get_name() << ") {" << endl;
+ out << '\n' << indent() << "if (this->__isset." << (*f_iter)->get_name() << ") {" << '\n';
indent_up();
} else {
- out << endl;
+ out << '\n';
}
// Write field header
out << indent() << "xfer += oprot->writeFieldBegin("
<< "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", "
- << (*f_iter)->get_key() << ");" << endl;
+ << (*f_iter)->get_key() << ");" << '\n';
// Write field contents
if (pointers && !(*f_iter)->get_type()->is_xception()) {
generate_serialize_field(out, *f_iter, "(*(this->", "))");
@@ -1639,22 +1637,22 @@
generate_serialize_field(out, *f_iter, "this->");
}
// Write field closer
- indent(out) << "xfer += oprot->writeFieldEnd();" << endl;
+ indent(out) << "xfer += oprot->writeFieldEnd();" << '\n';
if (check_if_set) {
indent_down();
indent(out) << '}';
}
}
- out << endl;
+ out << '\n';
// Write the struct map
- out << indent() << "xfer += oprot->writeFieldStop();" << endl << indent()
- << "xfer += oprot->writeStructEnd();" << endl << indent()
- << "return xfer;" << endl;
+ out << indent() << "xfer += oprot->writeFieldStop();" << '\n' << indent()
+ << "xfer += oprot->writeStructEnd();" << '\n' << indent()
+ << "return xfer;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1673,35 +1671,35 @@
vector<t_field*>::const_iterator f_iter;
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl << indent() << "uint32_t "
- << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl;
+ out << indent() << "template <class Protocol_>" << '\n' << indent() << "uint32_t "
+ << tstruct->get_name() << "::write(Protocol_* oprot) const {" << '\n';
} else {
indent(out) << "uint32_t " << tstruct->get_name()
- << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
+ << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << '\n';
}
indent_up();
- out << endl << indent() << "uint32_t xfer = 0;" << endl << endl;
+ out << '\n' << indent() << "uint32_t xfer = 0;" << '\n' << '\n';
- indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
+ indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << '\n';
bool first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (first) {
first = false;
- out << endl << indent() << "if ";
+ out << '\n' << indent() << "if ";
} else {
out << " else if ";
}
- out << "(this->__isset." << (*f_iter)->get_name() << ") {" << endl;
+ out << "(this->__isset." << (*f_iter)->get_name() << ") {" << '\n';
indent_up();
// Write field header
out << indent() << "xfer += oprot->writeFieldBegin("
<< "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", "
- << (*f_iter)->get_key() << ");" << endl;
+ << (*f_iter)->get_key() << ");" << '\n';
// Write field contents
if (pointers) {
generate_serialize_field(out, *f_iter, "(*(this->", "))");
@@ -1709,18 +1707,18 @@
generate_serialize_field(out, *f_iter, "this->");
}
// Write field closer
- indent(out) << "xfer += oprot->writeFieldEnd();" << endl;
+ indent(out) << "xfer += oprot->writeFieldEnd();" << '\n';
indent_down();
indent(out) << "}";
}
// Write the struct map
- out << endl << indent() << "xfer += oprot->writeFieldStop();" << endl << indent()
- << "xfer += oprot->writeStructEnd();" << endl << indent() << "return xfer;" << endl;
+ out << '\n' << indent() << "xfer += oprot->writeFieldStop();" << '\n' << indent()
+ << "xfer += oprot->writeStructEnd();" << '\n' << indent() << "return xfer;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1732,10 +1730,10 @@
void t_cpp_generator::generate_struct_swap(ostream& out, t_struct* tstruct) {
if (tstruct->get_name() == "a" || tstruct->get_name() == "b") {
out << indent() << "void swap(" << tstruct->get_name() << " &a1, " << tstruct->get_name()
- << " &a2) {" << endl;
+ << " &a2) {" << '\n';
} else {
out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name()
- << " &b) {" << endl;
+ << " &b) {" << '\n';
}
indent_up();
@@ -1743,7 +1741,7 @@
// Let argument-dependent name lookup find the correct swap() function to
// use based on the argument types. If none is found in the arguments'
// namespaces, fall back to ::std::swap().
- out << indent() << "using ::std::swap;" << endl;
+ out << indent() << "using ::std::swap;" << '\n';
bool has_nonrequired_fields = false;
const vector<t_field*>& fields = tstruct->get_members();
@@ -1754,41 +1752,41 @@
if (tstruct->get_name() == "a" || tstruct->get_name() == "b") {
out << indent() << "swap(a1." << tfield->get_name() << ", a2." << tfield->get_name() << ");"
- << endl;
+ << '\n';
} else {
out << indent() << "swap(a." << tfield->get_name() << ", b." << tfield->get_name() << ");"
- << endl;
+ << '\n';
}
}
if (has_nonrequired_fields) {
if (tstruct->get_name() == "a" || tstruct->get_name() == "b") {
- out << indent() << "swap(a1.__isset, a2.__isset);" << endl;
+ out << indent() << "swap(a1.__isset, a2.__isset);" << '\n';
} else {
- out << indent() << "swap(a.__isset, b.__isset);" << endl;
+ out << indent() << "swap(a.__isset, b.__isset);" << '\n';
}
}
// handle empty structs
if (fields.size() == 0) {
if (tstruct->get_name() == "a" || tstruct->get_name() == "b") {
- out << indent() << "(void) a1;" << endl;
- out << indent() << "(void) a2;" << endl;
+ out << indent() << "(void) a1;" << '\n';
+ out << indent() << "(void) a2;" << '\n';
} else {
- out << indent() << "(void) a;" << endl;
- out << indent() << "(void) b;" << endl;
+ out << indent() << "(void) a;" << '\n';
+ out << indent() << "(void) b;" << '\n';
}
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_cpp_generator::generate_struct_ostream_operator_decl(std::ostream& out, t_struct* tstruct) {
out << "std::ostream& operator<<(std::ostream& out, const "
<< tstruct->get_name()
- << "& obj);" << endl;
- out << endl;
+ << "& obj);" << '\n';
+ out << '\n';
}
void t_cpp_generator::generate_struct_ostream_operator(std::ostream& out, t_struct* tstruct) {
@@ -1796,12 +1794,12 @@
// thrift defines this behavior
out << "std::ostream& operator<<(std::ostream& out, const "
<< tstruct->get_name()
- << "& obj)" << endl;
+ << "& obj)" << '\n';
scope_up(out);
- out << indent() << "obj.printTo(out);" << endl
- << indent() << "return out;" << endl;
+ out << indent() << "obj.printTo(out);" << '\n'
+ << indent() << "return out;" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
}
}
@@ -1866,7 +1864,7 @@
}
generate_field(out, *it);
- out << ";" << endl;
+ out << ";" << '\n';
}
}
}
@@ -1877,17 +1875,17 @@
void t_cpp_generator::generate_struct_print_method(std::ostream& out, t_struct* tstruct) {
out << indent();
generate_struct_print_method_decl(out, tstruct);
- out << " {" << endl;
+ out << " {" << '\n';
indent_up();
- out << indent() << "using ::apache::thrift::to_string;" << endl;
- out << indent() << "out << \"" << tstruct->get_name() << "(\";" << endl;
+ out << indent() << "using ::apache::thrift::to_string;" << '\n';
+ out << indent() << "out << \"" << tstruct->get_name() << "(\";" << '\n';
struct_ostream_operator_generator::generate_fields(out, tstruct->get_members(), indent());
- out << indent() << "out << \")\";" << endl;
+ out << indent() << "out << \")\";" << '\n';
indent_down();
- out << "}" << endl << endl;
+ out << "}" << '\n' << '\n';
}
/**
@@ -1896,29 +1894,29 @@
void t_cpp_generator::generate_exception_what_method(std::ostream& out, t_struct* tstruct) {
out << indent();
generate_exception_what_method_decl(out, tstruct, true);
- out << " {" << endl;
+ out << " {" << '\n';
indent_up();
- out << indent() << "try {" << endl;
+ out << indent() << "try {" << '\n';
indent_up();
- out << indent() << "std::stringstream ss;" << endl;
- out << indent() << "ss << \"TException - service has thrown: \" << *this;" << endl;
- out << indent() << "this->thriftTExceptionMessageHolder_ = ss.str();" << endl;
- out << indent() << "return this->thriftTExceptionMessageHolder_.c_str();" << endl;
+ out << indent() << "std::stringstream ss;" << '\n';
+ out << indent() << "ss << \"TException - service has thrown: \" << *this;" << '\n';
+ out << indent() << "this->thriftTExceptionMessageHolder_ = ss.str();" << '\n';
+ out << indent() << "return this->thriftTExceptionMessageHolder_.c_str();" << '\n';
indent_down();
- out << indent() << "} catch (const std::exception&) {" << endl;
+ out << indent() << "} catch (const std::exception&) {" << '\n';
indent_up();
out << indent() << "return \"TException - service has thrown: " << tstruct->get_name() << "\";"
- << endl;
+ << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << "}" << endl << endl;
+ out << "}" << '\n' << '\n';
}
/**
@@ -1938,30 +1936,30 @@
// Print header file includes
f_header_ << autogen_comment();
- f_header_ << "#ifndef " << svcname << "_H" << endl << "#define " << svcname << "_H" << endl
- << endl;
+ f_header_ << "#ifndef " << svcname << "_H" << '\n' << "#define " << svcname << "_H" << '\n'
+ << '\n';
if (gen_cob_style_) {
- f_header_ << "#include <thrift/transport/TBufferTransports.h>" << endl // TMemoryBuffer
- << "#include <functional>" << endl
- << "namespace apache { namespace thrift { namespace async {" << endl
- << "class TAsyncChannel;" << endl << "}}}" << endl;
+ f_header_ << "#include <thrift/transport/TBufferTransports.h>" << '\n' // TMemoryBuffer
+ << "#include <functional>" << '\n'
+ << "namespace apache { namespace thrift { namespace async {" << '\n'
+ << "class TAsyncChannel;" << '\n' << "}}}" << '\n';
}
- f_header_ << "#include <thrift/TDispatchProcessor.h>" << endl;
+ f_header_ << "#include <thrift/TDispatchProcessor.h>" << '\n';
if (gen_cob_style_) {
- f_header_ << "#include <thrift/async/TAsyncDispatchProcessor.h>" << endl;
+ f_header_ << "#include <thrift/async/TAsyncDispatchProcessor.h>" << '\n';
}
- f_header_ << "#include <thrift/async/TConcurrentClientSyncInfo.h>" << endl;
- f_header_ << "#include <memory>" << endl;
+ f_header_ << "#include <thrift/async/TConcurrentClientSyncInfo.h>" << '\n';
+ f_header_ << "#include <memory>" << '\n';
f_header_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ << "_types.h\""
- << endl;
+ << '\n';
t_service* extends_service = tservice->get_extends();
if (extends_service != nullptr) {
f_header_ << "#include \"" << get_include_prefix(*(extends_service->get_program()))
- << extends_service->get_name() << ".h\"" << endl;
+ << extends_service->get_name() << ".h\"" << '\n';
}
- f_header_ << endl << ns_open_ << endl << endl;
+ f_header_ << '\n' << ns_open_ << '\n' << '\n';
f_header_ << "#ifdef _MSC_VER\n"
" #pragma warning( push )\n"
@@ -1972,30 +1970,30 @@
string f_service_name = get_out_dir() + svcname + ".cpp";
f_service_.open(f_service_name.c_str());
f_service_ << autogen_comment();
- f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl;
+ f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << '\n';
if (gen_cob_style_) {
- f_service_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl;
+ f_service_ << "#include \"thrift/async/TAsyncChannel.h\"" << '\n';
}
if (gen_templates_) {
f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\""
- << endl;
+ << '\n';
string f_service_tcc_name = get_out_dir() + svcname + ".tcc";
f_service_tcc_.open(f_service_tcc_name.c_str());
f_service_tcc_ << autogen_comment();
f_service_tcc_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\""
- << endl;
+ << '\n';
- f_service_tcc_ << "#ifndef " << svcname << "_TCC" << endl << "#define " << svcname << "_TCC"
- << endl << endl;
+ f_service_tcc_ << "#ifndef " << svcname << "_TCC" << '\n' << "#define " << svcname << "_TCC"
+ << '\n' << '\n';
if (gen_cob_style_) {
- f_service_tcc_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl;
+ f_service_tcc_ << "#include \"thrift/async/TAsyncChannel.h\"" << '\n';
}
}
- f_service_ << endl << ns_open_ << endl << endl;
- f_service_tcc_ << endl << ns_open_ << endl << endl;
+ f_service_ << '\n' << ns_open_ << '\n' << '\n';
+ f_service_tcc_ << '\n' << ns_open_ << '\n' << '\n';
// Generate all the components
generate_service_interface(tservice, "");
@@ -2032,19 +2030,19 @@
"#endif\n\n";
// Close the namespace
- f_service_ << ns_close_ << endl << endl;
- f_service_tcc_ << ns_close_ << endl << endl;
- f_header_ << ns_close_ << endl << endl;
+ f_service_ << ns_close_ << '\n' << '\n';
+ f_service_tcc_ << ns_close_ << '\n' << '\n';
+ f_header_ << ns_close_ << '\n' << '\n';
// TODO(simpkins): Make this a separate option
if (gen_templates_) {
- f_header_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\"" << endl
+ f_header_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\"" << '\n'
<< "#include \"" << get_include_prefix(*get_program()) << program_name_
- << "_types.tcc\"" << endl << endl;
+ << "_types.tcc\"" << '\n' << '\n';
}
- f_header_ << "#endif" << endl;
- f_service_tcc_ << "#endif" << endl;
+ f_header_ << "#endif" << '\n';
+ f_service_tcc_ << "#endif" << '\n';
// Close the files
f_service_tcc_.close();
@@ -2098,9 +2096,9 @@
if (gen_templates_) {
client_name += "T";
service_if_name += "T";
- indent(f_header_) << "template <class Protocol_>" << endl;
+ indent(f_header_) << "template <class Protocol_>" << '\n';
}
- indent(f_header_) << "class " << client_name << ";" << endl << endl;
+ indent(f_header_) << "class " << client_name << ";" << '\n' << '\n';
}
string extends = "";
@@ -2114,31 +2112,31 @@
}
if (style == "CobCl" && gen_templates_) {
- f_header_ << "template <class Protocol_>" << endl;
+ f_header_ << "template <class Protocol_>" << '\n';
}
generate_java_doc(f_header_, tservice);
- f_header_ << "class " << service_if_name << extends << " {" << endl << " public:" << endl;
+ f_header_ << "class " << service_if_name << extends << " {" << '\n' << " public:" << '\n';
indent_up();
- f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << endl;
+ f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
if ((*f_iter)->has_doc())
- f_header_ << endl;
+ f_header_ << '\n';
generate_java_doc(f_header_, *f_iter);
- f_header_ << indent() << "virtual " << function_signature(*f_iter, style) << " = 0;" << endl;
+ f_header_ << indent() << "virtual " << function_signature(*f_iter, style) << " = 0;" << '\n';
}
indent_down();
- f_header_ << "};" << endl << endl;
+ f_header_ << "};" << '\n' << '\n';
if (style == "CobCl" && gen_templates_) {
// generate a backwards-compatible typedef for clients that do not
// know about the new template-style code
f_header_ << "typedef " << service_if_name << "< ::apache::thrift::protocol::TProtocol> "
- << service_name_ << style << "If;" << endl << endl;
+ << service_name_ << style << "If;" << '\n' << '\n';
}
}
@@ -2181,37 +2179,37 @@
extends = " : virtual public " + type_name(tservice->get_extends()) + style + "IfFactory";
}
- f_header_ << "class " << factory_name << extends << " {" << endl << " public:" << endl;
+ f_header_ << "class " << factory_name << extends << " {" << '\n' << " public:" << '\n';
indent_up();
- f_header_ << indent() << "typedef " << service_if_name << " Handler;" << endl << endl << indent()
- << "virtual ~" << factory_name << "() {}" << endl << endl << indent() << "virtual "
+ f_header_ << indent() << "typedef " << service_if_name << " Handler;" << '\n' << '\n' << indent()
+ << "virtual ~" << factory_name << "() {}" << '\n' << '\n' << indent() << "virtual "
<< service_if_name << "* getHandler("
<< "const ::apache::thrift::TConnectionInfo& connInfo)"
- << (extends.empty() ? "" : " override") << " = 0;" << endl << indent()
+ << (extends.empty() ? "" : " override") << " = 0;" << '\n' << indent()
<< "virtual void releaseHandler(" << base_if_name << "* /* handler */)"
- << (extends.empty() ? "" : " override") << " = 0;" << endl << indent();
+ << (extends.empty() ? "" : " override") << " = 0;" << '\n' << indent();
indent_down();
- f_header_ << "};" << endl << endl;
+ f_header_ << "};" << '\n' << '\n';
// Generate the singleton factory class
string singleton_factory_name = service_if_name + "SingletonFactory";
f_header_ << "class " << singleton_factory_name << " : virtual public " << factory_name << " {"
- << endl << " public:" << endl;
+ << '\n' << " public:" << '\n';
indent_up();
f_header_ << indent() << singleton_factory_name << "(const ::std::shared_ptr<" << service_if_name
- << ">& iface) : iface_(iface) {}" << endl << indent() << "virtual ~"
- << singleton_factory_name << "() {}" << endl << endl << indent() << "virtual "
+ << ">& iface) : iface_(iface) {}" << '\n' << indent() << "virtual ~"
+ << singleton_factory_name << "() {}" << '\n' << '\n' << indent() << "virtual "
<< service_if_name << "* getHandler("
- << "const ::apache::thrift::TConnectionInfo&) override {" << endl << indent()
- << " return iface_.get();" << endl << indent() << "}" << endl << indent()
- << "virtual void releaseHandler(" << base_if_name << "* /* handler */) override {}" << endl;
+ << "const ::apache::thrift::TConnectionInfo&) override {" << '\n' << indent()
+ << " return iface_.get();" << '\n' << indent() << "}" << '\n' << indent()
+ << "virtual void releaseHandler(" << base_if_name << "* /* handler */) override {}" << '\n';
- f_header_ << endl << " protected:" << endl << indent() << "::std::shared_ptr<" << service_if_name
- << "> iface_;" << endl;
+ f_header_ << '\n' << " protected:" << '\n' << indent() << "::std::shared_ptr<" << service_if_name
+ << "> iface_;" << '\n';
indent_down();
- f_header_ << "};" << endl << endl;
+ f_header_ << "};" << '\n' << '\n';
}
/**
@@ -2225,14 +2223,14 @@
extends = " , virtual public " + type_name(tservice->get_extends()) + style + "Null";
}
f_header_ << "class " << service_name_ << style << "Null : virtual public " << service_name_
- << style << "If" << extends << " {" << endl << " public:" << endl;
+ << style << "If" << extends << " {" << '\n' << " public:" << '\n';
indent_up();
- f_header_ << indent() << "virtual ~" << service_name_ << style << "Null() {}" << endl;
+ f_header_ << indent() << "virtual ~" << service_name_ << style << "Null() {}" << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
f_header_ << indent() << function_signature(*f_iter, style, "", false)
- << " override {" << endl;
+ << " override {" << '\n';
indent_up();
t_type* returntype = (*f_iter)->get_returntype();
@@ -2240,18 +2238,18 @@
if (style == "") {
if (returntype->is_void() || is_complex_type(returntype)) {
- f_header_ << indent() << "return;" << endl;
+ f_header_ << indent() << "return;" << '\n';
} else {
- f_header_ << indent() << declare_field(&returnfield, true) << endl << indent()
- << "return _return;" << endl;
+ f_header_ << indent() << declare_field(&returnfield, true) << '\n' << indent()
+ << "return _return;" << '\n';
}
} else if (style == "CobSv") {
if (returntype->is_void()) {
- f_header_ << indent() << "return cob();" << endl;
+ f_header_ << indent() << "return cob();" << '\n';
} else {
t_field returnfield(returntype, "_return");
- f_header_ << indent() << declare_field(&returnfield, true) << endl << indent()
- << "return cob(_return);" << endl;
+ f_header_ << indent() << declare_field(&returnfield, true) << '\n' << indent()
+ << "return cob(_return);" << '\n';
}
} else {
@@ -2259,10 +2257,10 @@
}
indent_down();
- f_header_ << indent() << "}" << endl;
+ f_header_ << indent() << "}" << '\n';
}
indent_down();
- f_header_ << "};" << endl << endl;
+ f_header_ << "};" << '\n' << '\n';
}
void t_cpp_generator::generate_function_call(ostream& out,
@@ -2293,7 +2291,7 @@
}
out << arg_prefix << (*f_iter)->get_name();
}
- out << ");" << endl;
+ out << ");" << '\n';
}
void t_cpp_generator::generate_service_async_skeleton(t_service* tservice) {
@@ -2307,58 +2305,58 @@
ofstream_with_content_based_conditional_update f_skeleton;
f_skeleton.open(f_skeleton_name.c_str());
f_skeleton << "// This autogenerated skeleton file illustrates one way to adapt a synchronous"
- << endl << "// interface into an asynchronous interface. You should copy it to another"
- << endl
+ << '\n' << "// interface into an asynchronous interface. You should copy it to another"
+ << '\n'
<< "// filename to avoid overwriting it and rewrite as asynchronous any functions"
- << endl << "// that would otherwise introduce unwanted latency." << endl << endl
- << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl
- << "#include <thrift/protocol/TBinaryProtocol.h>" << endl
- << "#include <thrift/async/TAsyncProtocolProcessor.h>" << endl
- << "#include <thrift/async/TEvhttpServer.h>" << endl
- << "#include <event.h>" << endl
- << "#include <evhttp.h>" << endl << endl
- << "using namespace ::apache::thrift;" << endl
- << "using namespace ::apache::thrift::protocol;" << endl
- << "using namespace ::apache::thrift::transport;" << endl
- << "using namespace ::apache::thrift::async;" << endl << endl;
+ << '\n' << "// that would otherwise introduce unwanted latency." << '\n' << '\n'
+ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << '\n'
+ << "#include <thrift/protocol/TBinaryProtocol.h>" << '\n'
+ << "#include <thrift/async/TAsyncProtocolProcessor.h>" << '\n'
+ << "#include <thrift/async/TEvhttpServer.h>" << '\n'
+ << "#include <event.h>" << '\n'
+ << "#include <evhttp.h>" << '\n' << '\n'
+ << "using namespace ::apache::thrift;" << '\n'
+ << "using namespace ::apache::thrift::protocol;" << '\n'
+ << "using namespace ::apache::thrift::transport;" << '\n'
+ << "using namespace ::apache::thrift::async;" << '\n' << '\n';
// the following code would not compile:
// using namespace ;
// using namespace ::;
if ((!ns.empty()) && (ns.compare(" ::") != 0)) {
- f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << endl << endl;
+ f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << '\n' << '\n';
}
- f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << endl
- << " public:" << endl;
+ f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << '\n'
+ << " public:" << '\n';
indent_up();
- f_skeleton << indent() << svcname << "Handler() {" << endl << indent()
- << " // Your initialization goes here" << endl << indent() << "}" << endl << endl;
+ f_skeleton << indent() << svcname << "Handler() {" << '\n' << indent()
+ << " // Your initialization goes here" << '\n' << indent() << "}" << '\n' << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_java_doc(f_skeleton, *f_iter);
- f_skeleton << indent() << function_signature(*f_iter, "") << " {" << endl << indent()
- << " // Your implementation goes here" << endl << indent() << " printf(\""
- << (*f_iter)->get_name() << "\\n\");" << endl << indent() << "}" << endl << endl;
+ f_skeleton << indent() << function_signature(*f_iter, "") << " {" << '\n' << indent()
+ << " // Your implementation goes here" << '\n' << indent() << " printf(\""
+ << (*f_iter)->get_name() << "\\n\");" << '\n' << indent() << "}" << '\n' << '\n';
}
indent_down();
- f_skeleton << "};" << endl << endl;
+ f_skeleton << "};" << '\n' << '\n';
f_skeleton << "class " << svcname << "AsyncHandler : "
- << "public " << svcname << "CobSvIf {" << endl << " public:" << endl;
+ << "public " << svcname << "CobSvIf {" << '\n' << " public:" << '\n';
indent_up();
- f_skeleton << indent() << svcname << "AsyncHandler() {" << endl << indent()
+ f_skeleton << indent() << svcname << "AsyncHandler() {" << '\n' << indent()
<< " syncHandler_ = std::unique_ptr<" << svcname << "Handler>(new " << svcname
- << "Handler);" << endl << indent() << " // Your initialization goes here" << endl
- << indent() << "}" << endl;
- f_skeleton << indent() << "virtual ~" << service_name_ << "AsyncHandler();" << endl;
+ << "Handler);" << '\n' << indent() << " // Your initialization goes here" << '\n'
+ << indent() << "}" << '\n';
+ f_skeleton << indent() << "virtual ~" << service_name_ << "AsyncHandler();" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- f_skeleton << endl << indent() << function_signature(*f_iter, "CobSv", "", true) << " {"
- << endl;
+ f_skeleton << '\n' << indent() << function_signature(*f_iter, "CobSv", "", true) << " {"
+ << '\n';
indent_up();
t_type* returntype = (*f_iter)->get_returntype();
@@ -2366,32 +2364,32 @@
string target = returntype->is_void() ? "" : "_return";
if (!returntype->is_void()) {
- f_skeleton << indent() << declare_field(&returnfield, true) << endl;
+ f_skeleton << indent() << declare_field(&returnfield, true) << '\n';
}
generate_function_call(f_skeleton, *f_iter, target, "syncHandler_", "");
- f_skeleton << indent() << "return cob(" << target << ");" << endl;
+ f_skeleton << indent() << "return cob(" << target << ");" << '\n';
scope_down(f_skeleton);
}
- f_skeleton << endl << " protected:" << endl << indent() << "std::unique_ptr<" << svcname
- << "Handler> syncHandler_;" << endl;
+ f_skeleton << '\n' << " protected:" << '\n' << indent() << "std::unique_ptr<" << svcname
+ << "Handler> syncHandler_;" << '\n';
indent_down();
- f_skeleton << "};" << endl << endl;
+ f_skeleton << "};" << '\n' << '\n';
- f_skeleton << indent() << "int main(int argc, char **argv) {" << endl;
+ f_skeleton << indent() << "int main(int argc, char **argv) {" << '\n';
indent_up();
f_skeleton
- << indent() << "int port = 9090;" << endl << indent() << "::std::shared_ptr<" << svcname
- << "AsyncHandler> handler(new " << svcname << "AsyncHandler());" << endl << indent()
- << "::std::shared_ptr<" << svcname << "AsyncProcessor> processor(new " << svcname << "AsyncProcessor(handler));" << endl
+ << indent() << "int port = 9090;" << '\n' << indent() << "::std::shared_ptr<" << svcname
+ << "AsyncHandler> handler(new " << svcname << "AsyncHandler());" << '\n' << indent()
+ << "::std::shared_ptr<" << svcname << "AsyncProcessor> processor(new " << svcname << "AsyncProcessor(handler));" << '\n'
<< indent() << "::std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());"
- << endl
+ << '\n'
<< indent() << "::std::shared_ptr<TAsyncProtocolProcessor> protocolProcessor(new TAsyncProtocolProcessor(processor, protocolFactory));"
- << endl << endl << indent()
+ << '\n' << '\n' << indent()
<< "TEvhttpServer server(protocolProcessor, port);"
- << endl << indent() << "server.serve();" << endl << indent() << "return 0;" << endl;
+ << '\n' << indent() << "server.serve();" << '\n' << indent() << "return 0;" << '\n';
indent_down();
- f_skeleton << "}" << endl << endl;
+ f_skeleton << "}" << '\n' << '\n';
}
/**
@@ -2417,35 +2415,35 @@
// Generate the header portion
f_header_ << "class " << service_name_ << "Multiface : "
- << "virtual public " << service_name_ << "If" << extends_multiface << " {" << endl
- << " public:" << endl;
+ << "virtual public " << service_name_ << "If" << extends_multiface << " {" << '\n'
+ << " public:" << '\n';
indent_up();
f_header_ << indent() << service_name_ << "Multiface(" << list_type
- << "& ifaces) : ifaces_(ifaces) {" << endl;
+ << "& ifaces) : ifaces_(ifaces) {" << '\n';
if (!extends.empty()) {
f_header_ << indent()
<< " std::vector<std::shared_ptr<" + service_name_ + "If> >::iterator iter;"
- << endl << indent() << " for (iter = ifaces.begin(); iter != ifaces.end(); ++iter) {"
- << endl << indent() << " " << extends << "Multiface::add(*iter);" << endl
- << indent() << " }" << endl;
+ << '\n' << indent() << " for (iter = ifaces.begin(); iter != ifaces.end(); ++iter) {"
+ << '\n' << indent() << " " << extends << "Multiface::add(*iter);" << '\n'
+ << indent() << " }" << '\n';
}
- f_header_ << indent() << "}" << endl << indent() << "virtual ~" << service_name_
- << "Multiface() {}" << endl;
+ f_header_ << indent() << "}" << '\n' << indent() << "virtual ~" << service_name_
+ << "Multiface() {}" << '\n';
indent_down();
// Protected data members
- f_header_ << " protected:" << endl;
+ f_header_ << " protected:" << '\n';
indent_up();
- f_header_ << indent() << list_type << " ifaces_;" << endl << indent() << service_name_
- << "Multiface() {}" << endl << indent() << "void add(::std::shared_ptr<"
- << service_name_ << "If> iface) {" << endl;
+ f_header_ << indent() << list_type << " ifaces_;" << '\n' << indent() << service_name_
+ << "Multiface() {}" << '\n' << indent() << "void add(::std::shared_ptr<"
+ << service_name_ << "If> iface) {" << '\n';
if (!extends.empty()) {
- f_header_ << indent() << " " << extends << "Multiface::add(iface);" << endl;
+ f_header_ << indent() << " " << extends << "Multiface::add(iface);" << '\n';
}
- f_header_ << indent() << " ifaces_.push_back(iface);" << endl << indent() << "}" << endl;
+ f_header_ << indent() << " ifaces_.push_back(iface);" << '\n' << indent() << "}" << '\n';
indent_down();
- f_header_ << indent() << " public:" << endl;
+ f_header_ << indent() << " public:" << '\n';
indent_up();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -2470,31 +2468,31 @@
}
call += ")";
- f_header_ << indent() << function_signature(*f_iter, "") << " override {" << endl;
+ f_header_ << indent() << function_signature(*f_iter, "") << " override {" << '\n';
indent_up();
- f_header_ << indent() << "size_t sz = ifaces_.size();" << endl << indent() << "size_t i = 0;"
- << endl << indent() << "for (; i < (sz - 1); ++i) {" << endl;
+ f_header_ << indent() << "size_t sz = ifaces_.size();" << '\n' << indent() << "size_t i = 0;"
+ << '\n' << indent() << "for (; i < (sz - 1); ++i) {" << '\n';
indent_up();
- f_header_ << indent() << call << ";" << endl;
+ f_header_ << indent() << call << ";" << '\n';
indent_down();
- f_header_ << indent() << "}" << endl;
+ f_header_ << indent() << "}" << '\n';
if (!(*f_iter)->get_returntype()->is_void()) {
if (is_complex_type((*f_iter)->get_returntype())) {
- f_header_ << indent() << call << ";" << endl << indent() << "return;" << endl;
+ f_header_ << indent() << call << ";" << '\n' << indent() << "return;" << '\n';
} else {
- f_header_ << indent() << "return " << call << ";" << endl;
+ f_header_ << indent() << "return " << call << ";" << '\n';
}
} else {
- f_header_ << indent() << call << ";" << endl;
+ f_header_ << indent() << call << ";" << '\n';
}
indent_down();
- f_header_ << indent() << "}" << endl << endl;
+ f_header_ << indent() << "}" << '\n' << '\n';
}
indent_down();
- f_header_ << indent() << "};" << endl << endl;
+ f_header_ << indent() << "};" << '\n' << '\n';
}
/**
@@ -2545,7 +2543,7 @@
f_header_ << template_header << "class " << service_name_ << style << "Client" << short_suffix
<< " : "
<< "virtual public " << service_name_ << ifstyle << if_suffix << extends_client << " {"
- << endl << " public:" << endl;
+ << '\n' << " public:" << '\n';
indent_up();
if (style != "Cob") {
@@ -2558,18 +2556,18 @@
if (extends.empty()) {
if (style == "Concurrent") {
- f_header_ << ": sync_(sync)" << endl;
+ f_header_ << ": sync_(sync)" << '\n';
}
- f_header_ << "{" << endl;
- f_header_ << indent() << " setProtocol" << short_suffix << "(prot);" << endl << indent()
- << "}" << endl;
+ f_header_ << "{" << '\n';
+ f_header_ << indent() << " setProtocol" << short_suffix << "(prot);" << '\n' << indent()
+ << "}" << '\n';
} else {
- f_header_ << ":" << endl;
+ f_header_ << ":" << '\n';
f_header_ << indent() << " " << extends << style << client_suffix << "(prot, prot";
if (style == "Concurrent") {
f_header_ << ", sync";
}
- f_header_ << ") {}" << endl;
+ f_header_ << ") {}" << '\n';
}
f_header_ << indent() << service_name_ << style << "Client" << short_suffix << "(" << prot_ptr
@@ -2581,38 +2579,38 @@
if (extends.empty()) {
if (style == "Concurrent") {
- f_header_ << ": sync_(sync)" << endl;
+ f_header_ << ": sync_(sync)" << '\n';
}
- f_header_ << "{" << endl;
- f_header_ << indent() << " setProtocol" << short_suffix << "(iprot,oprot);" << endl
- << indent() << "}" << endl;
+ f_header_ << "{" << '\n';
+ f_header_ << indent() << " setProtocol" << short_suffix << "(iprot,oprot);" << '\n'
+ << indent() << "}" << '\n';
} else {
f_header_ << ":" << indent() << " " << extends << style << client_suffix
<< "(iprot, oprot";
if (style == "Concurrent") {
f_header_ << ", sync";
}
- f_header_ << ") {}" << endl;
+ f_header_ << ") {}" << '\n';
}
// create the setProtocol methods
if (extends.empty()) {
- f_header_ << " private:" << endl;
+ f_header_ << " private:" << '\n';
// 1: one parameter
f_header_ << indent() << "void setProtocol" << short_suffix << "(" << prot_ptr << " prot) {"
- << endl;
- f_header_ << indent() << "setProtocol" << short_suffix << "(prot,prot);" << endl;
- f_header_ << indent() << "}" << endl;
+ << '\n';
+ f_header_ << indent() << "setProtocol" << short_suffix << "(prot,prot);" << '\n';
+ f_header_ << indent() << "}" << '\n';
// 2: two parameter
f_header_ << indent() << "void setProtocol" << short_suffix << "(" << prot_ptr << " iprot, "
- << prot_ptr << " oprot) {" << endl;
+ << prot_ptr << " oprot) {" << '\n';
- f_header_ << indent() << " piprot_=iprot;" << endl << indent() << " poprot_=oprot;" << endl
- << indent() << " iprot_ = iprot.get();" << endl << indent()
- << " oprot_ = oprot.get();" << endl;
+ f_header_ << indent() << " piprot_=iprot;" << '\n' << indent() << " poprot_=oprot;" << '\n'
+ << indent() << " iprot_ = iprot.get();" << '\n' << indent()
+ << " oprot_ = oprot.get();" << '\n';
- f_header_ << indent() << "}" << endl;
- f_header_ << " public:" << endl;
+ f_header_ << indent() << "}" << '\n';
+ f_header_ << " public:" << '\n';
}
// Generate getters for the protocols.
@@ -2620,45 +2618,45 @@
// TODO(simpkins): should they be templated?
f_header_ << indent()
<< "std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {"
- << endl << indent() << " return " << _this << "piprot_;" << endl << indent() << "}"
- << endl;
+ << '\n' << indent() << " return " << _this << "piprot_;" << '\n' << indent() << "}"
+ << '\n';
f_header_ << indent()
<< "std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {"
- << endl << indent() << " return " << _this << "poprot_;" << endl << indent() << "}"
- << endl;
+ << '\n' << indent() << " return " << _this << "poprot_;" << '\n' << indent() << "}"
+ << '\n';
} else /* if (style == "Cob") */ {
f_header_ << indent() << service_name_ << style << "Client" << short_suffix << "("
<< "std::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel, "
- << "::apache::thrift::protocol::TProtocolFactory* protocolFactory) :" << endl;
+ << "::apache::thrift::protocol::TProtocolFactory* protocolFactory) :" << '\n';
if (extends.empty()) {
- f_header_ << indent() << " channel_(channel)," << endl << indent()
- << " itrans_(new ::apache::thrift::transport::TMemoryBuffer())," << endl
+ f_header_ << indent() << " channel_(channel)," << '\n' << indent()
+ << " itrans_(new ::apache::thrift::transport::TMemoryBuffer())," << '\n'
<< indent() << " otrans_(new ::apache::thrift::transport::TMemoryBuffer()),"
- << endl;
+ << '\n';
if (gen_templates_) {
// TProtocolFactory classes return generic TProtocol pointers.
// We have to dynamic cast to the Protocol_ type we are expecting.
f_header_ << indent() << " piprot_(::std::dynamic_pointer_cast<Protocol_>("
- << "protocolFactory->getProtocol(itrans_)))," << endl << indent()
+ << "protocolFactory->getProtocol(itrans_)))," << '\n' << indent()
<< " poprot_(::std::dynamic_pointer_cast<Protocol_>("
- << "protocolFactory->getProtocol(otrans_))) {" << endl;
+ << "protocolFactory->getProtocol(otrans_))) {" << '\n';
// Throw a TException if either dynamic cast failed.
- f_header_ << indent() << " if (!piprot_ || !poprot_) {" << endl << indent()
+ f_header_ << indent() << " if (!piprot_ || !poprot_) {" << '\n' << indent()
<< " throw ::apache::thrift::TException(\""
<< "TProtocolFactory returned unexpected protocol type in " << service_name_
- << style << "Client" << short_suffix << " constructor\");" << endl << indent()
- << " }" << endl;
+ << style << "Client" << short_suffix << " constructor\");" << '\n' << indent()
+ << " }" << '\n';
} else {
- f_header_ << indent() << " piprot_(protocolFactory->getProtocol(itrans_))," << endl
- << indent() << " poprot_(protocolFactory->getProtocol(otrans_)) {" << endl;
+ f_header_ << indent() << " piprot_(protocolFactory->getProtocol(itrans_))," << '\n'
+ << indent() << " poprot_(protocolFactory->getProtocol(otrans_)) {" << '\n';
}
- f_header_ << indent() << " iprot_ = piprot_.get();" << endl << indent()
- << " oprot_ = poprot_.get();" << endl << indent() << "}" << endl;
+ f_header_ << indent() << " iprot_ = piprot_.get();" << '\n' << indent()
+ << " oprot_ = poprot_.get();" << '\n' << indent() << "}" << '\n';
} else {
f_header_ << indent() << " " << extends << style << client_suffix
- << "(channel, protocolFactory) {}" << endl;
+ << "(channel, protocolFactory) {}" << '\n';
}
}
@@ -2666,10 +2664,10 @@
generate_java_doc(f_header_, tservice);
f_header_ << indent()
- << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> getChannel() {" << endl
- << indent() << " return " << _this << "channel_;" << endl << indent() << "}" << endl;
+ << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> getChannel() {" << '\n'
+ << indent() << " return " << _this << "channel_;" << '\n' << indent() << "}" << '\n';
if (!gen_no_client_completion_) {
- f_header_ << indent() << "virtual void completed__(bool /* success */) {}" << endl;
+ f_header_ << indent() << "virtual void completed__(bool /* success */) {}" << '\n';
}
}
@@ -2678,7 +2676,7 @@
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_java_doc(f_header_, *f_iter);
indent(f_header_) << function_signature(*f_iter, ifstyle)
- << " override;" << endl;
+ << " override;" << '\n';
// TODO(dreiss): Use private inheritance to avoid generating thise in cob-style.
if (style == "Concurrent" && !(*f_iter)->is_oneway()) {
// concurrent clients need to move the seqid from the send function to the
@@ -2687,12 +2685,12 @@
t_function send_function(g_type_i32, /*returning seqid*/
string("send_") + (*f_iter)->get_name(),
(*f_iter)->get_arglist());
- indent(f_header_) << function_signature(&send_function, "") << ";" << endl;
+ indent(f_header_) << function_signature(&send_function, "") << ";" << '\n';
} else {
t_function send_function(g_type_void,
string("send_") + (*f_iter)->get_name(),
(*f_iter)->get_arglist());
- indent(f_header_) << function_signature(&send_function, "") << ";" << endl;
+ indent(f_header_) << function_signature(&send_function, "") << ";" << '\n';
}
if (!(*f_iter)->is_oneway()) {
if (style == "Concurrent") {
@@ -2702,52 +2700,52 @@
t_function recv_function((*f_iter)->get_returntype(),
string("recv_") + (*f_iter)->get_name(),
&seqIdArgStruct);
- indent(f_header_) << function_signature(&recv_function, "") << ";" << endl;
+ indent(f_header_) << function_signature(&recv_function, "") << ";" << '\n';
} else {
t_struct noargs(program_);
t_function recv_function((*f_iter)->get_returntype(),
string("recv_") + (*f_iter)->get_name(),
&noargs);
- indent(f_header_) << function_signature(&recv_function, "") << ";" << endl;
+ indent(f_header_) << function_signature(&recv_function, "") << ";" << '\n';
}
}
}
indent_down();
if (extends.empty()) {
- f_header_ << " protected:" << endl;
+ f_header_ << " protected:" << '\n';
indent_up();
if (style == "Cob") {
f_header_ << indent()
- << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel_;" << endl
+ << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> channel_;" << '\n'
<< indent()
- << "::std::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> itrans_;" << endl
+ << "::std::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> itrans_;" << '\n'
<< indent()
<< "::std::shared_ptr< ::apache::thrift::transport::TMemoryBuffer> otrans_;"
- << endl;
+ << '\n';
}
f_header_ <<
- indent() << prot_ptr << " piprot_;" << endl <<
- indent() << prot_ptr << " poprot_;" << endl <<
- indent() << protocol_type << "* iprot_;" << endl <<
- indent() << protocol_type << "* oprot_;" << endl;
+ indent() << prot_ptr << " piprot_;" << '\n' <<
+ indent() << prot_ptr << " poprot_;" << '\n' <<
+ indent() << protocol_type << "* iprot_;" << '\n' <<
+ indent() << protocol_type << "* oprot_;" << '\n';
if (style == "Concurrent") {
f_header_ <<
- indent() << "std::shared_ptr< ::apache::thrift::async::TConcurrentClientSyncInfo> sync_;"<<endl;
+ indent() << "std::shared_ptr< ::apache::thrift::async::TConcurrentClientSyncInfo> sync_;" << '\n';
}
indent_down();
}
- f_header_ << "};" << endl << endl;
+ f_header_ << "};" << '\n' << '\n';
if (gen_templates_) {
// Output a backwards compatibility typedef using
// TProtocol as the template parameter.
f_header_ << "typedef " << service_name_ << style
<< "ClientT< ::apache::thrift::protocol::TProtocol> " << service_name_ << style
- << "Client;" << endl << endl;
+ << "Client;" << '\n' << '\n';
}
string scope = service_name_ + style + client_suffix + "::";
@@ -2769,7 +2767,7 @@
if (gen_templates_) {
indent(out) << template_header;
}
- indent(out) << function_signature(*f_iter, ifstyle, scope) << endl;
+ indent(out) << function_signature(*f_iter, ifstyle, scope) << '\n';
scope_up(out);
indent(out) << seqIdCapture << "send_" << funname << "(";
@@ -2788,33 +2786,33 @@
}
out << (*fld_iter)->get_name();
}
- out << ");" << endl;
+ out << ");" << '\n';
if (style != "Cob") {
if (!(*f_iter)->is_oneway()) {
out << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
if (is_complex_type((*f_iter)->get_returntype())) {
- out << "recv_" << funname << "(_return" << seqIdCommaUse << ");" << endl;
+ out << "recv_" << funname << "(_return" << seqIdCommaUse << ");" << '\n';
} else {
- out << "return recv_" << funname << "(" << seqIdUse << ");" << endl;
+ out << "return recv_" << funname << "(" << seqIdUse << ");" << '\n';
}
} else {
- out << "recv_" << funname << "(" << seqIdUse << ");" << endl;
+ out << "recv_" << funname << "(" << seqIdUse << ");" << '\n';
}
}
} else {
if (!(*f_iter)->is_oneway()) {
out << indent() << _this << "channel_->sendAndRecvMessage("
<< "::std::bind(cob, this), " << _this << "otrans_.get(), " << _this << "itrans_.get());"
- << endl;
+ << '\n';
} else {
out << indent() << _this << "channel_->sendMessage("
- << "::std::bind(cob, this), " << _this << "otrans_.get());" << endl;
+ << "::std::bind(cob, this), " << _this << "otrans_.get());" << '\n';
}
}
scope_down(out);
- out << endl;
+ out << '\n';
// if (style != "Cob") // TODO(dreiss): Libify the client and don't generate this for cob-style
if (true) {
@@ -2831,7 +2829,7 @@
if (gen_templates_) {
indent(out) << template_header;
}
- indent(out) << function_signature(&send_function, "", scope) << endl;
+ indent(out) << function_signature(&send_function, "", scope) << '\n';
scope_up(out);
// Function arguments and results
@@ -2846,41 +2844,41 @@
}
// Serialize the request
out <<
- indent() << "int32_t cseqid = " << cseqidVal << ";" << endl;
+ indent() << "int32_t cseqid = " << cseqidVal << ";" << '\n';
if(style == "Concurrent") {
out <<
- indent() << "::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());" << endl;
+ indent() << "::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get());" << '\n';
}
if (style == "Cob") {
out <<
- indent() << _this << "otrans_->resetBuffer();" << endl;
+ indent() << _this << "otrans_->resetBuffer();" << '\n';
}
out <<
indent() << _this << "oprot_->writeMessageBegin(\"" <<
(*f_iter)->get_name() <<
"\", ::apache::thrift::protocol::" << ((*f_iter)->is_oneway() ? "T_ONEWAY" : "T_CALL") <<
- ", cseqid);" << endl << endl <<
- indent() << argsname << " args;" << endl;
+ ", cseqid);" << '\n' << '\n' <<
+ indent() << argsname << " args;" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
out << indent() << "args." << (*fld_iter)->get_name() << " = &" << (*fld_iter)->get_name()
- << ";" << endl;
+ << ";" << '\n';
}
- out << indent() << "args.write(" << _this << "oprot_);" << endl << endl << indent() << _this
- << "oprot_->writeMessageEnd();" << endl << indent() << _this
- << "oprot_->getTransport()->writeEnd();" << endl << indent() << _this
- << "oprot_->getTransport()->flush();" << endl;
+ out << indent() << "args.write(" << _this << "oprot_);" << '\n' << '\n' << indent() << _this
+ << "oprot_->writeMessageEnd();" << '\n' << indent() << _this
+ << "oprot_->getTransport()->writeEnd();" << '\n' << indent() << _this
+ << "oprot_->getTransport()->flush();" << '\n';
if (style == "Concurrent") {
- out << endl << indent() << "sentry.commit();" << endl;
+ out << '\n' << indent() << "sentry.commit();" << '\n';
if (!(*f_iter)->is_oneway()) {
- out << indent() << "return cseqid;" << endl;
+ out << indent() << "return cseqid;" << '\n';
}
}
scope_down(out);
- out << endl;
+ out << '\n';
// Generate recv function only if not an oneway function
if (!(*f_iter)->is_oneway()) {
@@ -2902,124 +2900,123 @@
if (gen_templates_) {
indent(out) << template_header;
}
- indent(out) << function_signature(&recv_function, "", scope) << endl;
+ indent(out) << function_signature(&recv_function, "", scope) << '\n';
scope_up(out);
- out << endl <<
- indent() << "int32_t rseqid = 0;" << endl <<
- indent() << "std::string fname;" << endl <<
- indent() << "::apache::thrift::protocol::TMessageType mtype;" << endl;
+ out << '\n' <<
+ indent() << "int32_t rseqid = 0;" << '\n' <<
+ indent() << "std::string fname;" << '\n' <<
+ indent() << "::apache::thrift::protocol::TMessageType mtype;" << '\n';
if(style == "Concurrent") {
- out <<
- endl <<
- indent() << "// the read mutex gets dropped and reacquired as part of waitForWork()" << endl <<
- indent() << "// The destructor of this sentry wakes up other clients" << endl <<
- indent() << "::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);" << endl;
+ out << '\n' <<
+ indent() << "// the read mutex gets dropped and reacquired as part of waitForWork()" << '\n' <<
+ indent() << "// The destructor of this sentry wakes up other clients" << '\n' <<
+ indent() << "::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid);" << '\n';
}
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << "bool completed = false;" << endl << endl << indent() << "try {";
+ out << indent() << "bool completed = false;" << '\n' << '\n' << indent() << "try {";
indent_up();
}
- out << endl;
+ out << '\n';
if (style == "Concurrent") {
out <<
- indent() << "while(true) {" << endl <<
- indent() << " if(!this->sync_->getPending(fname, mtype, rseqid)) {" << endl;
+ indent() << "while(true) {" << '\n' <<
+ indent() << " if(!this->sync_->getPending(fname, mtype, rseqid)) {" << '\n';
indent_up();
indent_up();
}
out <<
- indent() << _this << "iprot_->readMessageBegin(fname, mtype, rseqid);" << endl;
+ indent() << _this << "iprot_->readMessageBegin(fname, mtype, rseqid);" << '\n';
if (style == "Concurrent") {
scope_down(out);
- out << indent() << "if(seqid == rseqid) {" << endl;
+ out << indent() << "if(seqid == rseqid) {" << '\n';
indent_up();
}
out <<
- indent() << "if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {" << endl <<
- indent() << " ::apache::thrift::TApplicationException x;" << endl <<
- indent() << " x.read(" << _this << "iprot_);" << endl <<
- indent() << " " << _this << "iprot_->readMessageEnd();" << endl <<
- indent() << " " << _this << "iprot_->getTransport()->readEnd();" << endl;
+ indent() << "if (mtype == ::apache::thrift::protocol::T_EXCEPTION) {" << '\n' <<
+ indent() << " ::apache::thrift::TApplicationException x;" << '\n' <<
+ indent() << " x.read(" << _this << "iprot_);" << '\n' <<
+ indent() << " " << _this << "iprot_->readMessageEnd();" << '\n' <<
+ indent() << " " << _this << "iprot_->getTransport()->readEnd();" << '\n';
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << " completed = true;" << endl << indent() << " completed__(true);"
- << endl;
+ out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);"
+ << '\n';
}
if (style == "Concurrent") {
- out << indent() << " sentry.commit();" << endl;
+ out << indent() << " sentry.commit();" << '\n';
}
out <<
- indent() << " throw x;" << endl <<
- indent() << "}" << endl <<
- indent() << "if (mtype != ::apache::thrift::protocol::T_REPLY) {" << endl <<
- indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << endl <<
- indent() << " " << _this << "iprot_->readMessageEnd();" << endl <<
- indent() << " " << _this << "iprot_->getTransport()->readEnd();" << endl;
+ indent() << " throw x;" << '\n' <<
+ indent() << "}" << '\n' <<
+ indent() << "if (mtype != ::apache::thrift::protocol::T_REPLY) {" << '\n' <<
+ indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << '\n' <<
+ indent() << " " << _this << "iprot_->readMessageEnd();" << '\n' <<
+ indent() << " " << _this << "iprot_->getTransport()->readEnd();" << '\n';
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << " completed = true;" << endl << indent() << " completed__(false);"
- << endl;
+ out << indent() << " completed = true;" << '\n' << indent() << " completed__(false);"
+ << '\n';
}
out <<
- indent() << "}" << endl <<
- indent() << "if (fname.compare(\"" << (*f_iter)->get_name() << "\") != 0) {" << endl <<
- indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << endl <<
- indent() << " " << _this << "iprot_->readMessageEnd();" << endl <<
- indent() << " " << _this << "iprot_->getTransport()->readEnd();" << endl;
+ indent() << "}" << '\n' <<
+ indent() << "if (fname.compare(\"" << (*f_iter)->get_name() << "\") != 0) {" << '\n' <<
+ indent() << " " << _this << "iprot_->skip(" << "::apache::thrift::protocol::T_STRUCT);" << '\n' <<
+ indent() << " " << _this << "iprot_->readMessageEnd();" << '\n' <<
+ indent() << " " << _this << "iprot_->getTransport()->readEnd();" << '\n';
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << " completed = true;" << endl << indent() << " completed__(false);"
- << endl;
+ out << indent() << " completed = true;" << '\n' << indent() << " completed__(false);"
+ << '\n';
}
if (style == "Concurrent") {
- out << endl <<
- indent() << " // in a bad state, don't commit" << endl <<
- indent() << " using ::apache::thrift::protocol::TProtocolException;" << endl <<
- indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
+ out << '\n' <<
+ indent() << " // in a bad state, don't commit" << '\n' <<
+ indent() << " using ::apache::thrift::protocol::TProtocolException;" << '\n' <<
+ indent() << " throw TProtocolException(TProtocolException::INVALID_DATA);" << '\n';
}
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (!(*f_iter)->get_returntype()->is_void()
&& !is_complex_type((*f_iter)->get_returntype())) {
t_field returnfield((*f_iter)->get_returntype(), "_return");
- out << indent() << declare_field(&returnfield) << endl;
+ out << indent() << declare_field(&returnfield) << '\n';
}
- out << indent() << resultname << " result;" << endl;
+ out << indent() << resultname << " result;" << '\n';
if (!(*f_iter)->get_returntype()->is_void()) {
- out << indent() << "result.success = &_return;" << endl;
+ out << indent() << "result.success = &_return;" << '\n';
}
- out << indent() << "result.read(" << _this << "iprot_);" << endl << indent() << _this
- << "iprot_->readMessageEnd();" << endl << indent() << _this
- << "iprot_->getTransport()->readEnd();" << endl << endl;
+ out << indent() << "result.read(" << _this << "iprot_);" << '\n' << indent() << _this
+ << "iprot_->readMessageEnd();" << '\n' << indent() << _this
+ << "iprot_->getTransport()->readEnd();" << '\n' << '\n';
// Careful, only look for _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
if (is_complex_type((*f_iter)->get_returntype())) {
out <<
- indent() << "if (result.__isset.success) {" << endl;
+ indent() << "if (result.__isset.success) {" << '\n';
out <<
- indent() << " // _return pointer has now been filled" << endl;
+ indent() << " // _return pointer has now been filled" << '\n';
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << " completed = true;" << endl << indent() << " completed__(true);"
- << endl;
+ out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);"
+ << '\n';
}
if (style == "Concurrent") {
- out << indent() << " sentry.commit();" << endl;
+ out << indent() << " sentry.commit();" << '\n';
}
out <<
- indent() << " return;" << endl <<
- indent() << "}" << endl;
+ indent() << " return;" << '\n' <<
+ indent() << "}" << '\n';
} else {
- out << indent() << "if (result.__isset.success) {" << endl;
+ out << indent() << "if (result.__isset.success) {" << '\n';
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << " completed = true;" << endl << indent() << " completed__(true);"
- << endl;
+ out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);"
+ << '\n';
}
if (style == "Concurrent") {
- out << indent() << " sentry.commit();" << endl;
+ out << indent() << " sentry.commit();" << '\n';
}
- out << indent() << " return _return;" << endl << indent() << "}" << endl;
+ out << indent() << " return _return;" << '\n' << indent() << "}" << '\n';
}
}
@@ -3027,62 +3024,62 @@
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- out << indent() << "if (result.__isset." << (*x_iter)->get_name() << ") {" << endl;
+ out << indent() << "if (result.__isset." << (*x_iter)->get_name() << ") {" << '\n';
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << " completed = true;" << endl << indent() << " completed__(true);"
- << endl;
+ out << indent() << " completed = true;" << '\n' << indent() << " completed__(true);"
+ << '\n';
}
if (style == "Concurrent") {
- out << indent() << " sentry.commit();" << endl;
+ out << indent() << " sentry.commit();" << '\n';
}
- out << indent() << " throw result." << (*x_iter)->get_name() << ";" << endl << indent()
- << "}" << endl;
+ out << indent() << " throw result." << (*x_iter)->get_name() << ";" << '\n' << indent()
+ << "}" << '\n';
}
// We only get here if we are a void function
if ((*f_iter)->get_returntype()->is_void()) {
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << "completed = true;" << endl << indent() << "completed__(true);"
- << endl;
+ out << indent() << "completed = true;" << '\n' << indent() << "completed__(true);"
+ << '\n';
}
if (style == "Concurrent") {
- out << indent() << "sentry.commit();" << endl;
+ out << indent() << "sentry.commit();" << '\n';
}
- indent(out) << "return;" << endl;
+ indent(out) << "return;" << '\n';
} else {
if (style == "Cob" && !gen_no_client_completion_) {
- out << indent() << "completed = true;" << endl << indent() << "completed__(true);"
- << endl;
+ out << indent() << "completed = true;" << '\n' << indent() << "completed__(true);"
+ << '\n';
}
if (style == "Concurrent") {
- out << indent() << "// in a bad state, don't commit" << endl;
+ out << indent() << "// in a bad state, don't commit" << '\n';
}
out << indent() << "throw "
"::apache::thrift::TApplicationException(::apache::thrift::"
"TApplicationException::MISSING_RESULT, \"" << (*f_iter)->get_name()
- << " failed: unknown result\");" << endl;
+ << " failed: unknown result\");" << '\n';
}
if (style == "Concurrent") {
indent_down();
indent_down();
- out <<
- indent() << " }" << endl <<
- indent() << " // seqid != rseqid" << endl <<
- indent() << " this->sync_->updatePending(fname, mtype, rseqid);" << endl <<
- endl <<
- indent() << " // this will temporarily unlock the readMutex, and let other clients get work done" << endl <<
- indent() << " this->sync_->waitForWork(seqid);" << endl <<
- indent() << "} // end while(true)" << endl;
+ out << indent() << " }" << '\n'
+ << indent() << " // seqid != rseqid" << '\n'
+ << indent() << " this->sync_->updatePending(fname, mtype, rseqid);" << '\n'
+ << '\n'
+ << indent()
+ << " // this will temporarily unlock the readMutex, and let other clients get work done" << '\n'
+ << indent() << " this->sync_->waitForWork(seqid);" << '\n'
+ << indent() << "} // end while(true)" << '\n';
}
if (style == "Cob" && !gen_no_client_completion_) {
indent_down();
- out << indent() << "} catch (...) {" << endl << indent() << " if (!completed) {" << endl
- << indent() << " completed__(false);" << endl << indent() << " }" << endl
- << indent() << " throw;" << endl << indent() << "}" << endl;
+ out << indent() << "} catch (...) {" << '\n' << indent() << " if (!completed) {" << '\n'
+ << indent() << " completed__(false);" << '\n' << indent() << " }" << '\n'
+ << indent() << " throw;" << '\n' << indent() << "}" << '\n';
}
// Close function
scope_down(out);
- out << endl;
+ out << '\n';
}
}
}
@@ -3218,61 +3215,61 @@
// Generate the header portion
f_header_ << template_header_ << "class " << class_name_ << " : public " << parent_class << " {"
- << endl;
+ << '\n';
// Protected data members
- f_header_ << " protected:" << endl;
+ f_header_ << " protected:" << '\n';
indent_up();
- f_header_ << indent() << "::std::shared_ptr<" << if_name_ << "> iface_;" << endl;
+ f_header_ << indent() << "::std::shared_ptr<" << if_name_ << "> iface_;" << '\n';
f_header_ << indent() << "virtual " << ret_type_ << "dispatchCall(" << finish_cob_
<< "::apache::thrift::protocol::TProtocol* iprot, "
<< "::apache::thrift::protocol::TProtocol* oprot, "
<< "const std::string& fname, int32_t seqid" << call_context_
- << ") override;" << endl;
+ << ") override;" << '\n';
if (generator_->gen_templates_) {
f_header_ << indent() << "virtual " << ret_type_ << "dispatchCallTemplated(" << finish_cob_
<< "Protocol_* iprot, Protocol_* oprot, "
- << "const std::string& fname, int32_t seqid" << call_context_ << ");" << endl;
+ << "const std::string& fname, int32_t seqid" << call_context_ << ");" << '\n';
}
indent_down();
// Process function declarations
- f_header_ << " private:" << endl;
+ f_header_ << " private:" << '\n';
indent_up();
// Declare processMap_
f_header_ << indent() << "typedef void (" << class_name_ << "::*"
<< "ProcessFunction)(" << finish_cob_decl_ << "int32_t, "
<< "::apache::thrift::protocol::TProtocol*, "
- << "::apache::thrift::protocol::TProtocol*" << call_context_decl_ << ");" << endl;
+ << "::apache::thrift::protocol::TProtocol*" << call_context_decl_ << ");" << '\n';
if (generator_->gen_templates_) {
f_header_ << indent() << "typedef void (" << class_name_ << "::*"
<< "SpecializedProcessFunction)(" << finish_cob_decl_ << "int32_t, "
- << "Protocol_*, Protocol_*" << call_context_decl_ << ");" << endl << indent()
- << "struct ProcessFunctions {" << endl << indent() << " ProcessFunction generic;"
- << endl << indent() << " SpecializedProcessFunction specialized;" << endl << indent()
+ << "Protocol_*, Protocol_*" << call_context_decl_ << ");" << '\n' << indent()
+ << "struct ProcessFunctions {" << '\n' << indent() << " ProcessFunction generic;"
+ << '\n' << indent() << " SpecializedProcessFunction specialized;" << '\n' << indent()
<< " ProcessFunctions(ProcessFunction g, "
- << "SpecializedProcessFunction s) :" << endl << indent() << " generic(g)," << endl
- << indent() << " specialized(s) {}" << endl << indent()
+ << "SpecializedProcessFunction s) :" << '\n' << indent() << " generic(g)," << '\n'
+ << indent() << " specialized(s) {}" << '\n' << indent()
<< " ProcessFunctions() : generic(nullptr), specialized(nullptr) "
- << "{}" << endl << indent() << "};" << endl << indent()
+ << "{}" << '\n' << indent() << "};" << '\n' << indent()
<< "typedef std::map<std::string, ProcessFunctions> "
- << "ProcessMap;" << endl;
+ << "ProcessMap;" << '\n';
} else {
f_header_ << indent() << "typedef std::map<std::string, ProcessFunction> "
- << "ProcessMap;" << endl;
+ << "ProcessMap;" << '\n';
}
- f_header_ << indent() << "ProcessMap processMap_;" << endl;
+ f_header_ << indent() << "ProcessMap processMap_;" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
indent(f_header_) << "void process_" << (*f_iter)->get_name() << "(" << finish_cob_
<< "int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, "
"::apache::thrift::protocol::TProtocol* oprot" << call_context_ << ");"
- << endl;
+ << '\n';
if (generator_->gen_templates_) {
indent(f_header_) << "void process_" << (*f_iter)->get_name() << "(" << finish_cob_
<< "int32_t seqid, Protocol_* iprot, Protocol_* oprot" << call_context_
- << ");" << endl;
+ << ");" << '\n';
}
if (style_ == "Cob") {
// XXX Factor this out, even if it is a pain.
@@ -3282,56 +3279,56 @@
f_header_ << indent() << "void return_" << (*f_iter)->get_name()
<< "(::std::function<void(bool ok)> cob, int32_t seqid, "
<< "::apache::thrift::protocol::TProtocol* oprot, "
- << "void* ctx" << ret_arg << ");" << endl;
+ << "void* ctx" << ret_arg << ");" << '\n';
if (generator_->gen_templates_) {
f_header_ << indent() << "void return_" << (*f_iter)->get_name()
<< "(::std::function<void(bool ok)> cob, int32_t seqid, "
- << "Protocol_* oprot, void* ctx" << ret_arg << ");" << endl;
+ << "Protocol_* oprot, void* ctx" << ret_arg << ");" << '\n';
}
// XXX Don't declare throw if it doesn't exist
f_header_ << indent() << "void throw_" << (*f_iter)->get_name()
<< "(::std::function<void(bool ok)> cob, int32_t seqid, "
<< "::apache::thrift::protocol::TProtocol* oprot, void* ctx, "
- << "::apache::thrift::TDelayedException* _throw);" << endl;
+ << "::apache::thrift::TDelayedException* _throw);" << '\n';
if (generator_->gen_templates_) {
f_header_ << indent() << "void throw_" << (*f_iter)->get_name()
<< "(::std::function<void(bool ok)> cob, int32_t seqid, "
<< "Protocol_* oprot, void* ctx, "
- << "::apache::thrift::TDelayedException* _throw);" << endl;
+ << "::apache::thrift::TDelayedException* _throw);" << '\n';
}
}
}
- f_header_ << " public:" << endl << indent() << class_name_ << "(::std::shared_ptr<" << if_name_
- << "> iface) :" << endl;
+ f_header_ << " public:" << '\n' << indent() << class_name_ << "(::std::shared_ptr<" << if_name_
+ << "> iface) :" << '\n';
if (!extends_.empty()) {
- f_header_ << indent() << " " << extends_ << "(iface)," << endl;
+ f_header_ << indent() << " " << extends_ << "(iface)," << '\n';
}
- f_header_ << indent() << " iface_(iface) {" << endl;
+ f_header_ << indent() << " iface_(iface) {" << '\n';
indent_up();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
f_header_ << indent() << "processMap_[\"" << (*f_iter)->get_name() << "\"] = ";
if (generator_->gen_templates_) {
- f_header_ << "ProcessFunctions(" << endl;
+ f_header_ << "ProcessFunctions(" << '\n';
if (generator_->gen_templates_only_) {
- indent(f_header_) << " nullptr," << endl;
+ indent(f_header_) << " nullptr," << '\n';
} else {
indent(f_header_) << " &" << class_name_ << "::process_" << (*f_iter)->get_name() << ","
- << endl;
+ << '\n';
}
indent(f_header_) << " &" << class_name_ << "::process_" << (*f_iter)->get_name() << ")";
} else {
f_header_ << "&" << class_name_ << "::process_" << (*f_iter)->get_name();
}
- f_header_ << ";" << endl;
+ f_header_ << ";" << '\n';
}
indent_down();
- f_header_ << indent() << "}" << endl << endl << indent() << "virtual ~" << class_name_ << "() {}"
- << endl;
+ f_header_ << indent() << "}" << '\n' << '\n' << indent() << "virtual ~" << class_name_ << "() {}"
+ << '\n';
indent_down();
- f_header_ << "};" << endl << endl;
+ f_header_ << "};" << '\n' << '\n';
if (generator_->gen_templates_) {
// Generate a backwards compatible typedef, for callers who don't know
@@ -3344,7 +3341,7 @@
// Therefore, we define TDummyProtocol solely so we can use it as the
// template parameter here.
f_header_ << "typedef " << class_name_ << "< ::apache::thrift::protocol::TDummyProtocol > "
- << service_name_ << pstyle_ << "Processor;" << endl << endl;
+ << service_name_ << pstyle_ << "Processor;" << '\n' << '\n';
}
}
@@ -3366,32 +3363,32 @@
f_out_ << template_header_ << ret_type_ << class_name_ << template_suffix_ << "::dispatchCall"
<< function_suffix << "(" << finish_cob_ << protocol << "* iprot, " << protocol
<< "* oprot, "
- << "const std::string& fname, int32_t seqid" << call_context_ << ") {" << endl;
+ << "const std::string& fname, int32_t seqid" << call_context_ << ") {" << '\n';
indent_up();
// HOT: member function pointer map
- f_out_ << indent() << typename_str_ << "ProcessMap::iterator pfn;" << endl << indent()
- << "pfn = processMap_.find(fname);" << endl << indent()
- << "if (pfn == processMap_.end()) {" << endl;
+ f_out_ << indent() << typename_str_ << "ProcessMap::iterator pfn;" << '\n' << indent()
+ << "pfn = processMap_.find(fname);" << '\n' << indent()
+ << "if (pfn == processMap_.end()) {" << '\n';
if (extends_.empty()) {
- f_out_ << indent() << " iprot->skip(::apache::thrift::protocol::T_STRUCT);" << endl << indent()
- << " iprot->readMessageEnd();" << endl << indent()
- << " iprot->getTransport()->readEnd();" << endl << indent()
+ f_out_ << indent() << " iprot->skip(::apache::thrift::protocol::T_STRUCT);" << '\n' << indent()
+ << " iprot->readMessageEnd();" << '\n' << indent()
+ << " iprot->getTransport()->readEnd();" << '\n' << indent()
<< " ::apache::thrift::TApplicationException "
"x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, \"Invalid method name: "
- "'\"+fname+\"'\");" << endl << indent()
+ "'\"+fname+\"'\");" << '\n' << indent()
<< " oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid);"
- << endl << indent() << " x.write(oprot);" << endl << indent()
- << " oprot->writeMessageEnd();" << endl << indent()
- << " oprot->getTransport()->writeEnd();" << endl << indent()
- << " oprot->getTransport()->flush();" << endl << indent()
- << (style_ == "Cob" ? " return cob(true);" : " return true;") << endl;
+ << '\n' << indent() << " x.write(oprot);" << '\n' << indent()
+ << " oprot->writeMessageEnd();" << '\n' << indent()
+ << " oprot->getTransport()->writeEnd();" << '\n' << indent()
+ << " oprot->getTransport()->flush();" << '\n' << indent()
+ << (style_ == "Cob" ? " return cob(true);" : " return true;") << '\n';
} else {
f_out_ << indent() << " return " << extends_ << "::dispatchCall("
<< (style_ == "Cob" ? "cob, " : "") << "iprot, oprot, fname, seqid" << call_context_arg_
- << ");" << endl;
+ << ");" << '\n';
}
- f_out_ << indent() << "}" << endl;
+ f_out_ << indent() << "}" << '\n';
if (template_protocol) {
f_out_ << indent() << "(this->*(pfn->second.specialized))";
} else {
@@ -3405,17 +3402,17 @@
f_out_ << indent() << "(this->*(pfn->second))";
}
}
- f_out_ << "(" << cob_arg_ << "seqid, iprot, oprot" << call_context_arg_ << ");" << endl;
+ f_out_ << "(" << cob_arg_ << "seqid, iprot, oprot" << call_context_arg_ << ");" << '\n';
// TODO(dreiss): return pfn ret?
if (style_ == "Cob") {
- f_out_ << indent() << "return;" << endl;
+ f_out_ << indent() << "return;" << '\n';
} else {
- f_out_ << indent() << "return true;" << endl;
+ f_out_ << indent() << "return true;" << '\n';
}
indent_down();
- f_out_ << "}" << endl << endl;
+ f_out_ << "}" << '\n' << '\n';
}
void ProcessorGenerator::generate_process_functions() {
@@ -3437,49 +3434,49 @@
// Generate the factory class definition
f_header_ << template_header_ << "class " << factory_class_name_ << " : public ::apache::thrift::"
<< (style_ == "Cob" ? "async::TAsyncProcessorFactory" : "TProcessorFactory") << " {"
- << endl << " public:" << endl;
+ << '\n' << " public:" << '\n';
indent_up();
f_header_ << indent() << factory_class_name_ << "(const ::std::shared_ptr< " << if_factory_name
- << " >& handlerFactory) noexcept :" << endl << indent()
- << " handlerFactory_(handlerFactory) {}" << endl << endl << indent()
+ << " >& handlerFactory) noexcept :" << '\n' << indent()
+ << " handlerFactory_(handlerFactory) {}" << '\n' << '\n' << indent()
<< "::std::shared_ptr< ::apache::thrift::"
<< (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > "
<< "getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) override;"
- << endl;
+ << '\n';
- f_header_ << endl << " protected:" << endl << indent() << "::std::shared_ptr< "
- << if_factory_name << " > handlerFactory_;" << endl;
+ f_header_ << '\n' << " protected:" << '\n' << indent() << "::std::shared_ptr< "
+ << if_factory_name << " > handlerFactory_;" << '\n';
indent_down();
- f_header_ << "};" << endl << endl;
+ f_header_ << "};" << '\n' << '\n';
// If we are generating templates, output a typedef for the plain
// factory name.
if (generator_->gen_templates_) {
f_header_ << "typedef " << factory_class_name_
<< "< ::apache::thrift::protocol::TDummyProtocol > " << service_name_ << pstyle_
- << "ProcessorFactory;" << endl << endl;
+ << "ProcessorFactory;" << '\n' << '\n';
}
// Generate the getProcessor() method
f_out_ << template_header_ << indent() << "::std::shared_ptr< ::apache::thrift::"
<< (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > "
<< factory_class_name_ << template_suffix_ << "::getProcessor("
- << "const ::apache::thrift::TConnectionInfo& connInfo) {" << endl;
+ << "const ::apache::thrift::TConnectionInfo& connInfo) {" << '\n';
indent_up();
f_out_ << indent() << "::apache::thrift::ReleaseHandler< " << if_factory_name
- << " > cleanup(handlerFactory_);" << endl << indent() << "::std::shared_ptr< "
+ << " > cleanup(handlerFactory_);" << '\n' << indent() << "::std::shared_ptr< "
<< if_name_ << " > handler("
- << "handlerFactory_->getHandler(connInfo), cleanup);" << endl << indent()
+ << "handlerFactory_->getHandler(connInfo), cleanup);" << '\n' << indent()
<< "::std::shared_ptr< ::apache::thrift::"
<< (style_ == "Cob" ? "async::TAsyncProcessor" : "TProcessor") << " > "
- << "processor(new " << class_name_ << template_suffix_ << "(handler));" << endl << indent()
- << "return processor;" << endl;
+ << "processor(new " << class_name_ << template_suffix_ << "(handler));" << '\n' << indent()
+ << "return processor;" << '\n';
indent_down();
- f_out_ << indent() << "}" << endl << endl;
+ f_out_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -3561,45 +3558,45 @@
if (style != "Cob") {
// Open function
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl;
+ out << indent() << "template <class Protocol_>" << '\n';
}
const bool unnamed_oprot_seqid = tfunction->is_oneway() && !(gen_templates_ && !specialized);
out << "void " << tservice->get_name() << "Processor" << class_suffix << "::"
<< "process_" << tfunction->get_name() << "("
<< "int32_t" << (unnamed_oprot_seqid ? ", " : " seqid, ") << prot_type << "* iprot, "
<< prot_type << "*" << (unnamed_oprot_seqid ? ", " : " oprot, ") << "void* callContext)"
- << endl;
+ << '\n';
scope_up(out);
string argsname = tservice->get_name() + "_" + tfunction->get_name() + "_args";
string resultname = tservice->get_name() + "_" + tfunction->get_name() + "_result";
if (tfunction->is_oneway() && !unnamed_oprot_seqid) {
- out << indent() << "(void) seqid;" << endl << indent() << "(void) oprot;" << endl;
+ out << indent() << "(void) seqid;" << '\n' << indent() << "(void) oprot;" << '\n';
}
- out << indent() << "void* ctx = nullptr;" << endl << indent()
- << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
+ out << indent() << "void* ctx = nullptr;" << '\n' << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
<< " ctx = this->eventHandler_->getContext(" << service_func_name << ", callContext);"
- << endl << indent() << "}" << endl << indent()
+ << '\n' << indent() << "}" << '\n' << indent()
<< "::apache::thrift::TProcessorContextFreer freer("
- << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl
- << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << endl << indent()
- << "}" << endl << endl << indent() << argsname << " args;" << endl << indent()
- << "args.read(iprot);" << endl << indent() << "iprot->readMessageEnd();" << endl << indent()
- << "uint32_t bytes = iprot->getTransport()->readEnd();" << endl << endl << indent()
- << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << endl
- << indent() << "}" << endl << endl;
+ << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n'
+ << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << '\n' << indent()
+ << "}" << '\n' << '\n' << indent() << argsname << " args;" << '\n' << indent()
+ << "args.read(iprot);" << '\n' << indent() << "iprot->readMessageEnd();" << '\n' << indent()
+ << "uint32_t bytes = iprot->getTransport()->readEnd();" << '\n' << '\n' << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << '\n'
+ << indent() << "}" << '\n' << '\n';
// Declare result
if (!tfunction->is_oneway()) {
- out << indent() << resultname << " result;" << endl;
+ out << indent() << resultname << " result;" << '\n';
}
// Try block for functions with exceptions
- out << indent() << "try {" << endl;
+ out << indent() << "try {" << '\n';
indent_up();
// Generate the function call
@@ -3623,11 +3620,11 @@
}
out << "args." << (*f_iter)->get_name();
}
- out << ");" << endl;
+ out << ");" << '\n';
// Set isset on success field
if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
- out << indent() << "result.__isset.success = true;" << endl;
+ out << indent() << "result.__isset.success = true;" << '\n';
}
indent_down();
@@ -3636,12 +3633,12 @@
if (!tfunction->is_oneway()) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
out << " catch (" << type_name((*x_iter)->get_type()) << " &" << (*x_iter)->get_name()
- << ") {" << endl;
+ << ") {" << '\n';
if (!tfunction->is_oneway()) {
indent_up();
out << indent() << "result." << (*x_iter)->get_name()
- << " = std::move(" << (*x_iter)->get_name() << ");" << endl
- << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;" << endl;
+ << " = std::move(" << (*x_iter)->get_name() << ");" << '\n'
+ << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;" << '\n';
indent_down();
out << indent() << "}";
} else {
@@ -3651,53 +3648,53 @@
}
if (!tfunction->is_oneway()) {
- out << " catch (const std::exception& e) {" << endl;
+ out << " catch (const std::exception& e) {" << '\n';
} else {
- out << " catch (const std::exception&) {" << endl;
+ out << " catch (const std::exception&) {" << '\n';
}
indent_up();
- out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl
- << indent() << "}" << endl;
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << '\n'
+ << indent() << "}" << '\n';
if (!tfunction->is_oneway()) {
- out << endl << indent() << "::apache::thrift::TApplicationException x(e.what());" << endl
+ out << '\n' << indent() << "::apache::thrift::TApplicationException x(e.what());" << '\n'
<< indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name()
- << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << endl << indent()
- << "x.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" << endl
- << indent() << "oprot->getTransport()->writeEnd();" << endl << indent()
- << "oprot->getTransport()->flush();" << endl;
+ << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << '\n' << indent()
+ << "x.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" << '\n'
+ << indent() << "oprot->getTransport()->writeEnd();" << '\n' << indent()
+ << "oprot->getTransport()->flush();" << '\n';
}
- out << indent() << "return;" << endl;
+ out << indent() << "return;" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << endl
- << indent() << "}" << endl << endl << indent() << "return;" << endl;
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << '\n'
+ << indent() << "}" << '\n' << '\n' << indent() << "return;" << '\n';
indent_down();
- out << "}" << endl << endl;
+ out << "}" << '\n' << '\n';
return;
}
// Serialize the result into a struct
- out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl << indent()
- << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name()
- << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl << indent()
- << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" << endl
- << indent() << "bytes = oprot->getTransport()->writeEnd();" << endl << indent()
- << "oprot->getTransport()->flush();" << endl << endl << indent()
- << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl
- << indent() << "}" << endl;
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << '\n' << indent()
+ << "}" << '\n' << '\n' << indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name()
+ << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << '\n' << indent()
+ << "result.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" << '\n'
+ << indent() << "bytes = oprot->getTransport()->writeEnd();" << '\n' << indent()
+ << "oprot->getTransport()->flush();" << '\n' << '\n' << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << '\n'
+ << indent() << "}" << '\n';
// Close function
scope_down(out);
- out << endl;
+ out << '\n';
}
// Cob style.
@@ -3705,11 +3702,11 @@
// Processor entry point.
// TODO(edhall) update for callContext when TEventServer is ready
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl;
+ out << indent() << "template <class Protocol_>" << '\n';
}
out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::process_"
<< tfunction->get_name() << "(::std::function<void(bool ok)> cob, int32_t seqid, "
- << prot_type << "* iprot, " << prot_type << "* oprot)" << endl;
+ << prot_type << "* iprot, " << prot_type << "* oprot)" << '\n';
scope_up(out);
// TODO(simpkins): we could try to consoldate this
@@ -3717,55 +3714,55 @@
if (gen_templates_ && !specialized) {
// If these are instances of Protocol_, instead of any old TProtocol,
// use the specialized process function instead.
- out << indent() << "Protocol_* _iprot = dynamic_cast<Protocol_*>(iprot);" << endl << indent()
- << "Protocol_* _oprot = dynamic_cast<Protocol_*>(oprot);" << endl << indent()
- << "if (_iprot && _oprot) {" << endl << indent() << " return process_"
- << tfunction->get_name() << "(cob, seqid, _iprot, _oprot);" << endl << indent() << "}"
- << endl << indent() << "T_GENERIC_PROTOCOL(this, iprot, _iprot);" << endl << indent()
- << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << endl << endl;
+ out << indent() << "Protocol_* _iprot = dynamic_cast<Protocol_*>(iprot);" << '\n' << indent()
+ << "Protocol_* _oprot = dynamic_cast<Protocol_*>(oprot);" << '\n' << indent()
+ << "if (_iprot && _oprot) {" << '\n' << indent() << " return process_"
+ << tfunction->get_name() << "(cob, seqid, _iprot, _oprot);" << '\n' << indent() << "}"
+ << '\n' << indent() << "T_GENERIC_PROTOCOL(this, iprot, _iprot);" << '\n' << indent()
+ << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << '\n' << '\n';
}
if (tfunction->is_oneway()) {
- out << indent() << "(void) seqid;" << endl << indent() << "(void) oprot;" << endl;
+ out << indent() << "(void) seqid;" << '\n' << indent() << "(void) oprot;" << '\n';
}
- out << indent() << tservice->get_name() + "_" + tfunction->get_name() << "_args args;" << endl
- << indent() << "void* ctx = nullptr;" << endl << indent()
- << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl
- << indent() << "}" << endl << indent() << "::apache::thrift::TProcessorContextFreer freer("
- << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl
- << indent() << "try {" << endl;
+ out << indent() << tservice->get_name() + "_" + tfunction->get_name() << "_args args;" << '\n'
+ << indent() << "void* ctx = nullptr;" << '\n' << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << '\n'
+ << indent() << "}" << '\n' << indent() << "::apache::thrift::TProcessorContextFreer freer("
+ << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n'
+ << indent() << "try {" << '\n';
indent_up();
- out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << endl << indent()
- << "}" << endl << indent() << "args.read(iprot);" << endl << indent()
- << "iprot->readMessageEnd();" << endl << indent()
- << "uint32_t bytes = iprot->getTransport()->readEnd();" << endl << indent()
- << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << endl
- << indent() << "}" << endl;
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << '\n' << indent()
+ << "}" << '\n' << indent() << "args.read(iprot);" << '\n' << indent()
+ << "iprot->readMessageEnd();" << '\n' << indent()
+ << "uint32_t bytes = iprot->getTransport()->readEnd();" << '\n' << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << '\n'
+ << indent() << "}" << '\n';
scope_down(out);
// TODO(dreiss): Handle TExceptions? Expose to server?
- out << indent() << "catch (const std::exception&) {" << endl << indent()
- << " if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl
- << indent() << " }" << endl << indent() << " return cob(false);" << endl << indent()
- << "}" << endl;
+ out << indent() << "catch (const std::exception&) {" << '\n' << indent()
+ << " if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << '\n'
+ << indent() << " }" << '\n' << indent() << " return cob(false);" << '\n' << indent()
+ << "}" << '\n';
if (tfunction->is_oneway()) {
- out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << endl
- << indent() << "}" << endl;
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << '\n'
+ << indent() << "}" << '\n';
}
// TODO(dreiss): Figure out a strategy for exceptions in async handlers.
- out << indent() << "freer.unregister();" << endl;
+ out << indent() << "freer.unregister();" << '\n';
if (tfunction->is_oneway()) {
// No return. Just hand off our cob.
// TODO(dreiss): Call the cob immediately?
out << indent() << "iface_->" << tfunction->get_name() << "("
- << "::std::bind(cob, true)" << endl;
+ << "::std::bind(cob, true)" << '\n';
indent_up();
indent_up();
} else {
@@ -3781,38 +3778,38 @@
out << indent() << "void (" << tservice->get_name() << "AsyncProcessor" << class_suffix
<< "::*return_fn)(::std::function<void(bool ok)> "
<< "cob, int32_t seqid, " << prot_type << "* oprot, void* ctx" << ret_arg
- << ") =" << endl;
+ << ") =" << '\n';
out << indent() << " &" << tservice->get_name() << "AsyncProcessor" << class_suffix
- << "::return_" << tfunction->get_name() << ";" << endl;
+ << "::return_" << tfunction->get_name() << ";" << '\n';
if (!xceptions.empty()) {
out << indent() << "void (" << tservice->get_name() << "AsyncProcessor" << class_suffix
<< "::*throw_fn)(::std::function<void(bool ok)> "
<< "cob, int32_t seqid, " << prot_type << "* oprot, void* ctx, "
- << "::apache::thrift::TDelayedException* _throw) =" << endl;
+ << "::apache::thrift::TDelayedException* _throw) =" << '\n';
out << indent() << " &" << tservice->get_name() << "AsyncProcessor" << class_suffix
- << "::throw_" << tfunction->get_name() << ";" << endl;
+ << "::throw_" << tfunction->get_name() << ";" << '\n';
}
- out << indent() << "iface_->" << tfunction->get_name() << "(" << endl;
+ out << indent() << "iface_->" << tfunction->get_name() << "(" << '\n';
indent_up();
indent_up();
out << indent() << "::std::bind(return_fn, this, cob, seqid, oprot, ctx" << ret_placeholder
<< ")";
if (!xceptions.empty()) {
- out << ',' << endl << indent() << "::std::bind(throw_fn, this, cob, seqid, oprot, "
+ out << ',' << '\n' << indent() << "::std::bind(throw_fn, this, cob, seqid, oprot, "
<< "ctx, ::std::placeholders::_1)";
}
}
// XXX Whitespace cleanup.
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- out << ',' << endl << indent() << "args." << (*f_iter)->get_name();
+ out << ',' << '\n' << indent() << "args." << (*f_iter)->get_name();
}
- out << ");" << endl;
+ out << ");" << '\n';
indent_down();
indent_down();
scope_down(out);
- out << endl;
+ out << '\n';
// Normal return.
if (!tfunction->is_oneway()) {
@@ -3822,128 +3819,128 @@
ret_arg_name = ", _return";
}
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl;
+ out << indent() << "template <class Protocol_>" << '\n';
}
out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::return_"
<< tfunction->get_name() << "(::std::function<void(bool ok)> cob, int32_t seqid, "
- << prot_type << "* oprot, void* ctx" << ret_arg_decl << ')' << endl;
+ << prot_type << "* oprot, void* ctx" << ret_arg_decl << ')' << '\n';
scope_up(out);
if (gen_templates_ && !specialized) {
// If oprot is a Protocol_ instance,
// use the specialized return function instead.
- out << indent() << "Protocol_* _oprot = dynamic_cast<Protocol_*>(oprot);" << endl
- << indent() << "if (_oprot) {" << endl << indent() << " return return_"
- << tfunction->get_name() << "(cob, seqid, _oprot, ctx" << ret_arg_name << ");" << endl
- << indent() << "}" << endl << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);"
- << endl << endl;
+ out << indent() << "Protocol_* _oprot = dynamic_cast<Protocol_*>(oprot);" << '\n'
+ << indent() << "if (_oprot) {" << '\n' << indent() << " return return_"
+ << tfunction->get_name() << "(cob, seqid, _oprot, ctx" << ret_arg_name << ");" << '\n'
+ << indent() << "}" << '\n' << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);"
+ << '\n' << '\n';
}
out << indent() << tservice->get_name() << "_" << tfunction->get_name() << "_presult result;"
- << endl;
+ << '\n';
if (!tfunction->get_returntype()->is_void()) {
// The const_cast here is unfortunate, but it would be a pain to avoid,
// and we only do a write with this struct, which is const-safe.
out << indent() << "result.success = const_cast<" << type_name(tfunction->get_returntype())
- << "*>(&_return);" << endl << indent() << "result.__isset.success = true;" << endl;
+ << "*>(&_return);" << '\n' << indent() << "result.__isset.success = true;" << '\n';
}
// Serialize the result into a struct
- out << endl << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl
- << indent() << "}" << endl << indent()
+ out << '\n' << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << '\n'
+ << indent() << "}" << '\n' << indent()
<< "::apache::thrift::TProcessorContextFreer freer("
- << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl
- << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl
- << indent() << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\""
- << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl
- << indent() << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();"
- << endl << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << endl
- << indent() << "oprot->getTransport()->flush();" << endl << indent()
- << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl
- << indent() << "}" << endl << indent() << "return cob(true);" << endl;
+ << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n'
+ << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << '\n'
+ << indent() << "}" << '\n' << '\n' << indent() << "oprot->writeMessageBegin(\""
+ << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << '\n'
+ << indent() << "result.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();"
+ << '\n' << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << '\n'
+ << indent() << "oprot->getTransport()->flush();" << '\n' << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << '\n'
+ << indent() << "}" << '\n' << indent() << "return cob(true);" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
}
// Exception return.
if (!tfunction->is_oneway() && !xceptions.empty()) {
if (gen_templates_) {
- out << indent() << "template <class Protocol_>" << endl;
+ out << indent() << "template <class Protocol_>" << '\n';
}
out << "void " << tservice->get_name() << "AsyncProcessor" << class_suffix << "::throw_"
<< tfunction->get_name() << "(::std::function<void(bool ok)> cob, int32_t seqid, "
<< prot_type << "* oprot, void* ctx, "
- << "::apache::thrift::TDelayedException* _throw)" << endl;
+ << "::apache::thrift::TDelayedException* _throw)" << '\n';
scope_up(out);
if (gen_templates_ && !specialized) {
// If oprot is a Protocol_ instance,
// use the specialized throw function instead.
- out << indent() << "Protocol_* _oprot = dynamic_cast<Protocol_*>(oprot);" << endl
- << indent() << "if (_oprot) {" << endl << indent() << " return throw_"
- << tfunction->get_name() << "(cob, seqid, _oprot, ctx, _throw);" << endl << indent()
- << "}" << endl << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << endl
- << endl;
+ out << indent() << "Protocol_* _oprot = dynamic_cast<Protocol_*>(oprot);" << '\n'
+ << indent() << "if (_oprot) {" << '\n' << indent() << " return throw_"
+ << tfunction->get_name() << "(cob, seqid, _oprot, ctx, _throw);" << '\n' << indent()
+ << "}" << '\n' << indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << '\n'
+ << '\n';
}
// Get the event handler context
- out << endl << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl
- << indent() << "}" << endl << indent()
+ out << '\n' << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << '\n'
+ << indent() << "}" << '\n' << indent()
<< "::apache::thrift::TProcessorContextFreer freer("
- << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl;
+ << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << '\n' << '\n';
// Throw the TDelayedException, and catch the result
out << indent() << tservice->get_name() << "_" << tfunction->get_name() << "_result result;"
- << endl << endl << indent() << "try {" << endl;
+ << '\n' << '\n' << indent() << "try {" << '\n';
indent_up();
- out << indent() << "_throw->throw_it();" << endl << indent() << "return cob(false);"
- << endl; // Is this possible? TBD.
+ out << indent() << "_throw->throw_it();" << '\n' << indent() << "return cob(false);"
+ << '\n'; // Is this possible? TBD.
indent_down();
out << indent() << '}';
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
out << " catch (" << type_name((*x_iter)->get_type()) << " &" << (*x_iter)->get_name()
- << ") {" << endl;
+ << ") {" << '\n';
indent_up();
out << indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name()
- << ";" << endl << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;"
- << endl;
+ << ";" << '\n' << indent() << "result.__isset." << (*x_iter)->get_name() << " = true;"
+ << '\n';
scope_down(out);
}
// Handle the case where an undeclared exception is thrown
- out << " catch (std::exception& e) {" << endl;
+ out << " catch (std::exception& e) {" << '\n';
indent_up();
- out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl
- << indent() << "}" << endl << endl << indent()
- << "::apache::thrift::TApplicationException x(e.what());" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << '\n'
+ << indent() << "}" << '\n' << '\n' << indent()
+ << "::apache::thrift::TApplicationException x(e.what());" << '\n' << indent()
<< "oprot->writeMessageBegin(\"" << tfunction->get_name()
- << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << endl << indent()
- << "x.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" << endl
- << indent() << "oprot->getTransport()->writeEnd();" << endl << indent()
- << "oprot->getTransport()->flush();" << endl <<
+ << "\", ::apache::thrift::protocol::T_EXCEPTION, seqid);" << '\n' << indent()
+ << "x.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();" << '\n'
+ << indent() << "oprot->getTransport()->writeEnd();" << '\n' << indent()
+ << "oprot->getTransport()->flush();" << '\n' <<
// We pass true to the cob here, since we did successfully write a
// response, even though it is an exception response.
// It looks like the argument is currently ignored, anyway.
- indent() << "return cob(true);" << endl;
+ indent() << "return cob(true);" << '\n';
scope_down(out);
// Serialize the result into a struct
- out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl
- << indent() << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\""
- << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl
- << indent() << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();"
- << endl << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << endl
- << indent() << "oprot->getTransport()->flush();" << endl << indent()
- << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
- << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl
- << indent() << "}" << endl << indent() << "return cob(true);" << endl;
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << '\n'
+ << indent() << "}" << '\n' << '\n' << indent() << "oprot->writeMessageBegin(\""
+ << tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << '\n'
+ << indent() << "result.write(oprot);" << '\n' << indent() << "oprot->writeMessageEnd();"
+ << '\n' << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << '\n'
+ << indent() << "oprot->getTransport()->flush();" << '\n' << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << '\n' << indent()
+ << " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << '\n'
+ << indent() << "}" << '\n' << indent() << "return cob(true);" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
} // for each function
} // cob style
}
@@ -3963,58 +3960,58 @@
ofstream_with_content_based_conditional_update f_skeleton;
f_skeleton.open(f_skeleton_name.c_str());
- f_skeleton << "// This autogenerated skeleton file illustrates how to build a server." << endl
- << "// You should copy it to another filename to avoid overwriting it." << endl << endl
- << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl
- << "#include <thrift/protocol/TBinaryProtocol.h>" << endl
- << "#include <thrift/server/TSimpleServer.h>" << endl
- << "#include <thrift/transport/TServerSocket.h>" << endl
- << "#include <thrift/transport/TBufferTransports.h>" << endl << endl
- << "using namespace ::apache::thrift;" << endl
- << "using namespace ::apache::thrift::protocol;" << endl
- << "using namespace ::apache::thrift::transport;" << endl
- << "using namespace ::apache::thrift::server;" << endl << endl;
+ f_skeleton << "// This autogenerated skeleton file illustrates how to build a server." << '\n'
+ << "// You should copy it to another filename to avoid overwriting it." << '\n' << '\n'
+ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << '\n'
+ << "#include <thrift/protocol/TBinaryProtocol.h>" << '\n'
+ << "#include <thrift/server/TSimpleServer.h>" << '\n'
+ << "#include <thrift/transport/TServerSocket.h>" << '\n'
+ << "#include <thrift/transport/TBufferTransports.h>" << '\n' << '\n'
+ << "using namespace ::apache::thrift;" << '\n'
+ << "using namespace ::apache::thrift::protocol;" << '\n'
+ << "using namespace ::apache::thrift::transport;" << '\n'
+ << "using namespace ::apache::thrift::server;" << '\n' << '\n';
// the following code would not compile:
// using namespace ;
// using namespace ::;
if ((!ns.empty()) && (ns.compare(" ::") != 0)) {
- f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << endl << endl;
+ f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << '\n' << '\n';
}
- f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << endl
- << " public:" << endl;
+ f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << '\n'
+ << " public:" << '\n';
indent_up();
- f_skeleton << indent() << svcname << "Handler() {" << endl << indent()
- << " // Your initialization goes here" << endl << indent() << "}" << endl << endl;
+ f_skeleton << indent() << svcname << "Handler() {" << '\n' << indent()
+ << " // Your initialization goes here" << '\n' << indent() << "}" << '\n' << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_java_doc(f_skeleton, *f_iter);
- f_skeleton << indent() << function_signature(*f_iter, "") << " {" << endl << indent()
- << " // Your implementation goes here" << endl << indent() << " printf(\""
- << (*f_iter)->get_name() << "\\n\");" << endl << indent() << "}" << endl << endl;
+ f_skeleton << indent() << function_signature(*f_iter, "") << " {" << '\n' << indent()
+ << " // Your implementation goes here" << '\n' << indent() << " printf(\""
+ << (*f_iter)->get_name() << "\\n\");" << '\n' << indent() << "}" << '\n' << '\n';
}
indent_down();
- f_skeleton << "};" << endl << endl;
+ f_skeleton << "};" << '\n' << '\n';
- f_skeleton << indent() << "int main(int argc, char **argv) {" << endl;
+ f_skeleton << indent() << "int main(int argc, char **argv) {" << '\n';
indent_up();
f_skeleton
- << indent() << "int port = 9090;" << endl << indent() << "::std::shared_ptr<" << svcname
- << "Handler> handler(new " << svcname << "Handler());" << endl << indent()
- << "::std::shared_ptr<TProcessor> processor(new " << svcname << "Processor(handler));" << endl
+ << indent() << "int port = 9090;" << '\n' << indent() << "::std::shared_ptr<" << svcname
+ << "Handler> handler(new " << svcname << "Handler());" << '\n' << indent()
+ << "::std::shared_ptr<TProcessor> processor(new " << svcname << "Processor(handler));" << '\n'
<< indent() << "::std::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));"
- << endl << indent()
- << "::std::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());" << endl
+ << '\n' << indent()
+ << "::std::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());" << '\n'
<< indent() << "::std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());"
- << endl << endl << indent()
+ << '\n' << '\n' << indent()
<< "TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);"
- << endl << indent() << "server.serve();" << endl << indent() << "return 0;" << endl;
+ << '\n' << indent() << "server.serve();" << '\n' << indent() << "return 0;" << '\n';
indent_down();
- f_skeleton << "}" << endl << endl;
+ f_skeleton << "}" << '\n' << '\n';
// Close the files
f_skeleton.close();
@@ -4077,12 +4074,12 @@
default:
throw "compiler error: no C++ reader for base type " + t_base_type::t_base_name(tbase) + " " + name;
}
- out << endl;
+ out << '\n';
} else if (type->is_enum()) {
string t = tmp("ecast");
- out << indent() << "int32_t " << t << ";" << endl << indent() << "xfer += iprot->readI32(" << t
- << ");" << endl << indent() << name << " = static_cast<"
- << type_name(type) << ">(" << t << ");" << endl;
+ out << indent() << "int32_t " << t << ";" << '\n' << indent() << "xfer += iprot->readI32(" << t
+ << ");" << '\n' << indent() << name << " = static_cast<"
+ << type_name(type) << ">(" << t << ");" << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
tfield->get_name().c_str(),
@@ -4101,22 +4098,22 @@
string prefix,
bool pointer) {
if (pointer) {
- indent(out) << "if (!" << prefix << ") { " << endl;
+ indent(out) << "if (!" << prefix << ") { " << '\n';
indent(out) << " " << prefix << " = ::std::shared_ptr<" << type_name(tstruct) << ">(new "
- << type_name(tstruct) << ");" << endl;
- indent(out) << "}" << endl;
- indent(out) << "xfer += " << prefix << "->read(iprot);" << endl;
- indent(out) << "bool wasSet = false;" << endl;
+ << type_name(tstruct) << ");" << '\n';
+ indent(out) << "}" << '\n';
+ indent(out) << "xfer += " << prefix << "->read(iprot);" << '\n';
+ indent(out) << "bool wasSet = false;" << '\n';
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
for (f_iter = members.begin(); f_iter != members.end(); ++f_iter) {
indent(out) << "if (" << prefix << "->__isset." << (*f_iter)->get_name()
- << ") { wasSet = true; }" << endl;
+ << ") { wasSet = true; }" << '\n';
}
- indent(out) << "if (!wasSet) { " << prefix << ".reset(); }" << endl;
+ indent(out) << "if (!wasSet) { " << prefix << ".reset(); }" << '\n';
} else {
- indent(out) << "xfer += " << prefix << ".read(iprot);" << endl;
+ indent(out) << "xfer += " << prefix << ".read(iprot);" << '\n';
}
}
@@ -4131,28 +4128,28 @@
t_container* tcontainer = (t_container*)ttype;
bool use_push = tcontainer->has_cpp_name();
- indent(out) << prefix << ".clear();" << endl << indent() << "uint32_t " << size << ";" << endl;
+ indent(out) << prefix << ".clear();" << '\n' << indent() << "uint32_t " << size << ";" << '\n';
// Declare variables, read header
if (ttype->is_map()) {
- out << indent() << "::apache::thrift::protocol::TType " << ktype << ";" << endl << indent()
- << "::apache::thrift::protocol::TType " << vtype << ";" << endl << indent()
- << "xfer += iprot->readMapBegin(" << ktype << ", " << vtype << ", " << size << ");" << endl;
+ out << indent() << "::apache::thrift::protocol::TType " << ktype << ";" << '\n' << indent()
+ << "::apache::thrift::protocol::TType " << vtype << ";" << '\n' << indent()
+ << "xfer += iprot->readMapBegin(" << ktype << ", " << vtype << ", " << size << ");" << '\n';
} else if (ttype->is_set()) {
- out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << endl << indent()
- << "xfer += iprot->readSetBegin(" << etype << ", " << size << ");" << endl;
+ out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << '\n' << indent()
+ << "xfer += iprot->readSetBegin(" << etype << ", " << size << ");" << '\n';
} else if (ttype->is_list()) {
- out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << endl << indent()
- << "xfer += iprot->readListBegin(" << etype << ", " << size << ");" << endl;
+ out << indent() << "::apache::thrift::protocol::TType " << etype << ";" << '\n' << indent()
+ << "xfer += iprot->readListBegin(" << etype << ", " << size << ");" << '\n';
if (!use_push) {
- indent(out) << prefix << ".resize(" << size << ");" << endl;
+ indent(out) << prefix << ".resize(" << size << ");" << '\n';
}
}
// For loop iterates over elements
string i = tmp("_i");
- out << indent() << "uint32_t " << i << ";" << endl << indent() << "for (" << i << " = 0; " << i
- << " < " << size << "; ++" << i << ")" << endl;
+ out << indent() << "uint32_t " << i << ";" << '\n' << indent() << "for (" << i << " = 0; " << i
+ << " < " << size << "; ++" << i << ")" << '\n';
scope_up(out);
@@ -4168,11 +4165,11 @@
// Read container end
if (ttype->is_map()) {
- indent(out) << "xfer += iprot->readMapEnd();" << endl;
+ indent(out) << "xfer += iprot->readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "xfer += iprot->readSetEnd();" << endl;
+ indent(out) << "xfer += iprot->readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "xfer += iprot->readListEnd();" << endl;
+ indent(out) << "xfer += iprot->readListEnd();" << '\n';
}
scope_down(out);
@@ -4187,11 +4184,11 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- out << indent() << declare_field(&fkey) << endl;
+ out << indent() << declare_field(&fkey) << '\n';
generate_deserialize_field(out, &fkey);
indent(out) << declare_field(&fval, false, false, false, true) << " = " << prefix << "[" << key
- << "];" << endl;
+ << "];" << '\n';
generate_deserialize_field(out, &fval);
}
@@ -4200,11 +4197,11 @@
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".insert(" << elem << ");" << endl;
+ indent(out) << prefix << ".insert(" << elem << ");" << '\n';
}
void t_cpp_generator::generate_deserialize_list_element(ostream& out,
@@ -4215,9 +4212,9 @@
if (use_push) {
string elem = tmp("_elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".push_back(" << elem << ");" << endl;
+ indent(out) << prefix << ".push_back(" << elem << ");" << '\n';
} else {
t_field felem(tlist->get_elem_type(), prefix + "[" + index + "]");
generate_deserialize_field(out, &felem);
@@ -4292,7 +4289,7 @@
} else if (type->is_enum()) {
out << "writeI32(static_cast<int32_t>(" << name << "));";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s' TYPE '%s'\n",
name.c_str(),
@@ -4311,15 +4308,15 @@
string prefix,
bool pointer) {
if (pointer) {
- indent(out) << "if (" << prefix << ") {" << endl;
- indent(out) << " xfer += " << prefix << "->write(oprot); " << endl;
+ indent(out) << "if (" << prefix << ") {" << '\n';
+ indent(out) << " xfer += " << prefix << "->write(oprot); " << '\n';
indent(out) << "} else {"
- << "oprot->writeStructBegin(\"" << tstruct->get_name() << "\"); " << endl;
- indent(out) << " oprot->writeStructEnd();" << endl;
- indent(out) << " oprot->writeFieldStop();" << endl;
- indent(out) << "}" << endl;
+ << "oprot->writeStructBegin(\"" << tstruct->get_name() << "\"); " << '\n';
+ indent(out) << " oprot->writeStructEnd();" << '\n';
+ indent(out) << " oprot->writeFieldStop();" << '\n';
+ indent(out) << "}" << '\n';
} else {
- indent(out) << "xfer += " << prefix << ".write(oprot);" << endl;
+ indent(out) << "xfer += " << prefix << ".write(oprot);" << '\n';
}
}
@@ -4329,21 +4326,21 @@
if (ttype->is_map()) {
indent(out) << "xfer += oprot->writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type())
<< ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
+ << "static_cast<uint32_t>(" << prefix << ".size()));" << '\n';
} else if (ttype->is_set()) {
indent(out) << "xfer += oprot->writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type())
<< ", "
- << "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
+ << "static_cast<uint32_t>(" << prefix << ".size()));" << '\n';
} else if (ttype->is_list()) {
indent(out) << "xfer += oprot->writeListBegin("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", "
- << "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
+ << "static_cast<uint32_t>(" << prefix << ".size()));" << '\n';
}
string iter = tmp("_iter");
- out << indent() << type_name(ttype) << "::const_iterator " << iter << ";" << endl << indent()
+ out << indent() << type_name(ttype) << "::const_iterator " << iter << ";" << '\n' << indent()
<< "for (" << iter << " = " << prefix << ".begin(); " << iter << " != " << prefix
- << ".end(); ++" << iter << ")" << endl;
+ << ".end(); ++" << iter << ")" << '\n';
scope_up(out);
if (ttype->is_map()) {
generate_serialize_map_element(out, (t_map*)ttype, iter);
@@ -4355,11 +4352,11 @@
scope_down(out);
if (ttype->is_map()) {
- indent(out) << "xfer += oprot->writeMapEnd();" << endl;
+ indent(out) << "xfer += oprot->writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "xfer += oprot->writeSetEnd();" << endl;
+ indent(out) << "xfer += oprot->writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "xfer += oprot->writeListEnd();" << endl;
+ indent(out) << "xfer += oprot->writeListEnd();" << '\n';
}
scope_down(out);
diff --git a/compiler/cpp/src/thrift/generate/t_d_generator.cc b/compiler/cpp/src/thrift/generate/t_d_generator.cc
index 38194c2..61988df 100644
--- a/compiler/cpp/src/thrift/generate/t_d_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_d_generator.cc
@@ -43,8 +43,6 @@
using std::string;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* D code generator.
*
@@ -105,7 +103,7 @@
// Print header
f_types_ << autogen_comment() << "module " << render_package(*program_) << program_name_
- << "_types;" << endl << endl;
+ << "_types;" << '\n' << '\n';
print_default_imports(f_types_);
@@ -113,10 +111,10 @@
const vector<t_program*>& includes = program_->get_includes();
for (auto include : includes) {
f_types_ << "public import " << render_package(*include) << include->get_name()
- << "_types;" << endl;
+ << "_types;" << '\n';
}
if (!includes.empty())
- f_types_ << endl;
+ f_types_ << '\n';
}
void close_generator() override {
@@ -131,22 +129,22 @@
f_consts.open(f_consts_name.c_str());
f_consts << autogen_comment() << "module " << render_package(*program_) << program_name_
- << "_constants;" << endl << endl;
+ << "_constants;" << '\n' << '\n';
print_default_imports(f_consts);
- f_consts << "import " << render_package(*get_program()) << program_name_ << "_types;" << endl
- << endl;
+ f_consts << "import " << render_package(*get_program()) << program_name_ << "_types;" << '\n'
+ << '\n';
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
this->emit_doc(*c_iter, f_consts);
string name = suffix_if_reserved((*c_iter)->get_name());
t_type* type = (*c_iter)->get_type();
- indent(f_consts) << "immutable(" << render_type_name(type) << ") " << name << ";" << endl;
+ indent(f_consts) << "immutable(" << render_type_name(type) << ") " << name << ";" << '\n';
}
- f_consts << endl << "shared static this() {" << endl;
+ f_consts << '\n' << "shared static this() {" << '\n';
indent_up();
bool first = true;
@@ -154,24 +152,24 @@
if (first) {
first = false;
} else {
- f_consts << endl;
+ f_consts << '\n';
}
t_type* type = (*c_iter)->get_type();
indent(f_consts) << suffix_if_reserved((*c_iter)->get_name()) << " = ";
if (!is_immutable_type(type)) {
f_consts << "cast(immutable(" << render_type_name(type) << ")) ";
}
- f_consts << render_const_value(type, (*c_iter)->get_value()) << ";" << endl;
+ f_consts << render_const_value(type, (*c_iter)->get_value()) << ";" << '\n';
}
indent_down();
- indent(f_consts) << "}" << endl;
+ indent(f_consts) << "}" << '\n';
}
}
void generate_typedef(t_typedef* ttypedef) override {
this->emit_doc(ttypedef, f_types_);
f_types_ << indent() << "alias " << render_type_name(ttypedef->get_type()) << " "
- << ttypedef->get_symbolic() << ";" << endl << endl;
+ << ttypedef->get_symbolic() << ";" << '\n' << '\n';
}
void generate_enum(t_enum* tenum) override {
@@ -179,7 +177,7 @@
this->emit_doc(tenum, f_types_);
string enum_name = suffix_if_reserved(tenum->get_name());
- f_types_ << indent() << "enum " << enum_name << " {" << endl;
+ f_types_ << indent() << "enum " << enum_name << " {" << '\n';
indent_up();
@@ -190,11 +188,11 @@
f_types_ << " = " << (*c_iter)->get_value() << ",";
}
- f_types_ << endl;
+ f_types_ << '\n';
indent_down();
- indent(f_types_) << "}" << endl;
+ indent(f_types_) << "}" << '\n';
- f_types_ << endl;
+ f_types_ << '\n';
}
void generate_struct(t_struct* tstruct) override {
@@ -213,19 +211,19 @@
ofstream_with_content_based_conditional_update f_service;
f_service.open(f_servicename.c_str());
f_service << autogen_comment() << "module " << suffix_if_reserved(render_package(*program_)) << svc_name << ";"
- << endl << endl;
+ << '\n' << '\n';
print_default_imports(f_service);
- f_service << "import " << suffix_if_reserved(render_package(*get_program())) << program_name_ << "_types;" << endl;
+ f_service << "import " << suffix_if_reserved(render_package(*get_program())) << program_name_ << "_types;" << '\n';
t_service* extends_service = tservice->get_extends();
if (extends_service != nullptr) {
f_service << "import " << suffix_if_reserved(render_package(*(extends_service->get_program())))
- << suffix_if_reserved(extends_service->get_name()) << ";" << endl;
+ << suffix_if_reserved(extends_service->get_name()) << ";" << '\n';
}
- f_service << endl;
+ f_service << '\n';
string extends = "";
if (tservice->get_extends() != nullptr) {
@@ -233,7 +231,7 @@
}
this->emit_doc(tservice, f_service);
- f_service << indent() << "interface " << svc_name << extends << " {" << endl;
+ f_service << indent() << "interface " << svc_name << extends << " {" << '\n';
indent_up();
// Collect all the exception types service methods can throw so we can
@@ -247,7 +245,7 @@
this->emit_doc(*fn_iter, f_service);
f_service << indent();
print_function_signature(f_service, *fn_iter);
- f_service << ";" << endl;
+ f_service << ";" << '\n';
const vector<t_field*>& exceptions = (*fn_iter)->get_xceptions()->get_members();
vector<t_field*>::const_iterator ex_iter;
@@ -258,13 +256,13 @@
// Alias the exception types into the current scope.
if (!exception_types.empty())
- f_service << endl;
+ f_service << '\n';
set<t_type*>::const_iterator et_iter;
for (et_iter = exception_types.begin(); et_iter != exception_types.end(); ++et_iter) {
indent(f_service) << "alias " << render_package(*(*et_iter)->get_program())
<< (*et_iter)->get_program()->get_name() << "_types"
<< "." << (*et_iter)->get_name() << " " << (*et_iter)->get_name() << ";"
- << endl;
+ << '\n';
}
// Write the method metadata.
@@ -283,7 +281,7 @@
meta << ",";
}
- meta << endl << indent() << "TMethodMeta(`" << suffix_if_reserved((*fn_iter)->get_name()) << "`, " << endl;
+ meta << '\n' << indent() << "TMethodMeta(`" << suffix_if_reserved((*fn_iter)->get_name()) << "`, " << '\n';
indent_up();
indent(meta) << "[";
@@ -309,7 +307,7 @@
meta << "]";
if (!(*fn_iter)->get_xceptions()->get_members().empty() || (*fn_iter)->is_oneway()) {
- meta << "," << endl << indent() << "[";
+ meta << "," << '\n' << indent() << "[";
bool first = true;
const vector<t_field*>& exceptions = (*fn_iter)->get_xceptions()->get_members();
@@ -329,22 +327,22 @@
}
if ((*fn_iter)->is_oneway()) {
- meta << "," << endl << indent() << "TMethodType.ONEWAY";
+ meta << "," << '\n' << indent() << "TMethodType.ONEWAY";
}
indent_down();
- meta << endl << indent() << ")";
+ meta << '\n' << indent() << ")";
}
indent_down();
string meta_str(meta.str());
if (!meta_str.empty()) {
- f_service << endl << indent() << "enum methodMeta = [" << meta_str << endl << indent() << "];"
- << endl;
+ f_service << '\n' << indent() << "enum methodMeta = [" << meta_str << '\n' << indent() << "];"
+ << '\n';
}
indent_down();
- indent(f_service) << "}" << endl;
+ indent(f_service) << "}" << '\n';
// Server skeleton generation.
string f_skeletonname = package_dir_ + svc_name + "_server.skeleton.d";
@@ -358,14 +356,14 @@
if (!doc->has_doc()) {
return;
}
- indent(out) << "/**" << std::endl;
+ indent(out) << "/**" << '\n';
indent_up();
- // No endl -- comments reliably have a newline at the end.
+ // No line break -- comments reliably have a newline at the end.
// This is true even for stuff like:
// /** method infos */ void foo(/** huh?*/ 1: i64 stuff)
indent(out) << doc->get_doc();
indent_down();
- indent(out) << "*/" << std::endl;
+ indent(out) << "*/" << '\n';
}
private:
@@ -376,59 +374,59 @@
void print_server_skeleton(ostream& out, t_service* tservice) {
string svc_name = suffix_if_reserved(tservice->get_name());
- out << "/*" << endl
- << " * This auto-generated skeleton file illustrates how to build a server. If you" << endl
- << " * intend to customize it, you should edit a copy with another file name to " << endl
- << " * avoid overwriting it when running the generator again." << endl << " */" << endl
- << "module " << render_package(*tservice->get_program()) << svc_name << "_server;" << endl
- << endl << "import std.stdio;" << endl << "import thrift.codegen.processor;" << endl
- << "import thrift.protocol.binary;" << endl << "import thrift.server.simple;" << endl
- << "import thrift.server.transport.socket;" << endl << "import thrift.transport.buffered;"
- << endl << "import thrift.util.hashset;" << endl << endl << "import "
- << render_package(*tservice->get_program()) << svc_name << ";" << endl << "import "
- << render_package(*get_program()) << program_name_ << "_types;" << endl << endl << endl
- << "class " << svc_name << "Handler : " << svc_name << " {" << endl;
+ out << "/*" << '\n'
+ << " * This auto-generated skeleton file illustrates how to build a server. If you" << '\n'
+ << " * intend to customize it, you should edit a copy with another file name to " << '\n'
+ << " * avoid overwriting it when running the generator again." << '\n' << " */" << '\n'
+ << "module " << render_package(*tservice->get_program()) << svc_name << "_server;" << '\n'
+ << '\n' << "import std.stdio;" << '\n' << "import thrift.codegen.processor;" << '\n'
+ << "import thrift.protocol.binary;" << '\n' << "import thrift.server.simple;" << '\n'
+ << "import thrift.server.transport.socket;" << '\n' << "import thrift.transport.buffered;"
+ << '\n' << "import thrift.util.hashset;" << '\n' << '\n' << "import "
+ << render_package(*tservice->get_program()) << svc_name << ";" << '\n' << "import "
+ << render_package(*get_program()) << program_name_ << "_types;" << '\n' << '\n' << '\n'
+ << "class " << svc_name << "Handler : " << svc_name << " {" << '\n';
indent_up();
- out << indent() << "this() {" << endl << indent() << " // Your initialization goes here."
- << endl << indent() << "}" << endl << endl;
+ out << indent() << "this() {" << '\n' << indent() << " // Your initialization goes here."
+ << '\n' << indent() << "}" << '\n' << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
out << indent();
print_function_signature(out, *f_iter);
- out << " {" << endl;
+ out << " {" << '\n';
indent_up();
- out << indent() << "// Your implementation goes here." << endl << indent() << "writeln(\""
- << suffix_if_reserved((*f_iter)->get_name()) << " called\");" << endl;
+ out << indent() << "// Your implementation goes here." << '\n' << indent() << "writeln(\""
+ << suffix_if_reserved((*f_iter)->get_name()) << " called\");" << '\n';
t_type* rt = (*f_iter)->get_returntype();
if (!rt->is_void()) {
- indent(out) << "return typeof(return).init;" << endl;
+ indent(out) << "return typeof(return).init;" << '\n';
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
indent_down();
- out << "}" << endl << endl;
+ out << "}" << '\n' << '\n';
- out << indent() << "void main() {" << endl;
+ out << indent() << "void main() {" << '\n';
indent_up();
- out << indent() << "auto protocolFactory = new TBinaryProtocolFactory!();" << endl << indent()
+ out << indent() << "auto protocolFactory = new TBinaryProtocolFactory!();" << '\n' << indent()
<< "auto processor = new TServiceProcessor!" << svc_name << "(new " << svc_name
- << "Handler);" << endl << indent() << "auto serverTransport = new TServerSocket(9090);"
- << endl << indent() << "auto transportFactory = new TBufferedTransportFactory;" << endl
- << indent() << "auto server = new TSimpleServer(" << endl << indent()
- << " processor, serverTransport, transportFactory, protocolFactory);" << endl << indent()
- << "server.serve();" << endl;
+ << "Handler);" << '\n' << indent() << "auto serverTransport = new TServerSocket(9090);"
+ << '\n' << indent() << "auto transportFactory = new TBufferedTransportFactory;" << '\n'
+ << indent() << "auto server = new TSimpleServer(" << '\n' << indent()
+ << " processor, serverTransport, transportFactory, protocolFactory);" << '\n' << indent()
+ << "server.serve();" << '\n';
indent_down();
- out << "}" << endl;
+ out << "}" << '\n';
}
/**
@@ -439,9 +437,9 @@
const vector<t_field*>& members = tstruct->get_members();
if (is_exception) {
- indent(out) << "class " << suffix_if_reserved(tstruct->get_name()) << " : TException {" << endl;
+ indent(out) << "class " << suffix_if_reserved(tstruct->get_name()) << " : TException {" << '\n';
} else {
- indent(out) << "struct " << suffix_if_reserved(tstruct->get_name()) << " {" << endl;
+ indent(out) << "struct " << suffix_if_reserved(tstruct->get_name()) << " {" << '\n';
}
indent_up();
@@ -449,11 +447,11 @@
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
indent(out) << render_type_name((*m_iter)->get_type()) << " " << suffix_if_reserved((*m_iter)->get_name()) << ";"
- << endl;
+ << '\n';
}
if (!members.empty())
- indent(out) << endl;
+ indent(out) << '\n';
indent(out) << "mixin TStructHelpers!(";
if (!members.empty()) {
@@ -471,7 +469,7 @@
} else {
out << ",";
}
- out << endl;
+ out << '\n';
indent(out) << "TFieldMeta(`" << suffix_if_reserved((*m_iter)->get_name()) << "`, " << (*m_iter)->get_key();
@@ -485,13 +483,13 @@
}
indent_down();
- out << endl << indent() << "]";
+ out << '\n' << indent() << "]";
}
- out << ");" << endl;
+ out << ");" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -559,13 +557,13 @@
} else if (type->is_enum()) {
out << "cast(" << render_type_name(type) << ")" << value->get_integer();
} else {
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
- indent(out) << render_type_name(type) << " v;" << endl;
+ indent(out) << render_type_name(type) << " v;" << '\n';
if (type->is_struct() || type->is_xception()) {
indent(out) << "v = " << (type->is_xception() ? "new " : "") << render_type_name(type)
- << "();" << endl;
+ << "();" << '\n';
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -583,7 +581,7 @@
+ v_iter->first->get_string();
}
string val = render_const_value(field_type, v_iter->second);
- indent(out) << "v.set!`" << v_iter->first->get_string() << "`(" << val << ");" << endl;
+ indent(out) << "v.set!`" << v_iter->first->get_string() << "`(" << val << ");" << '\n';
}
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
@@ -597,7 +595,7 @@
if (!is_immutable_type(ktype)) {
out << "cast(immutable(" << render_type_name(ktype) << "))";
}
- out << key << "] = " << val << ";" << endl;
+ out << key << "] = " << val << ";" << '\n';
}
} else if (type->is_list()) {
t_type* etype = ((t_list*)type)->get_elem_type();
@@ -605,7 +603,7 @@
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string val = render_const_value(etype, *v_iter);
- indent(out) << "v ~= " << val << ";" << endl;
+ indent(out) << "v ~= " << val << ";" << '\n';
}
} else if (type->is_set()) {
t_type* etype = ((t_set*)type)->get_elem_type();
@@ -613,12 +611,12 @@
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string val = render_const_value(etype, *v_iter);
- indent(out) << "v ~= " << val << ";" << endl;
+ indent(out) << "v ~= " << val << ";" << '\n';
}
} else {
throw "Compiler error: Invalid type in render_const_value: " + type->get_name();
}
- indent(out) << "return v;" << endl;
+ indent(out) << "return v;" << '\n';
indent_down();
indent(out) << "}()";
@@ -728,8 +726,8 @@
*/
void print_default_imports(ostream& out) {
- indent(out) << "import thrift.base;" << endl << "import thrift.codegen.base;" << endl
- << "import thrift.util.hashset;" << endl << endl;
+ indent(out) << "import thrift.base;" << '\n' << "import thrift.codegen.base;" << '\n'
+ << "import thrift.util.hashset;" << '\n' << '\n';
}
/**
diff --git a/compiler/cpp/src/thrift/generate/t_dart_generator.cc b/compiler/cpp/src/thrift/generate/t_dart_generator.cc
index fda989b..0055043 100644
--- a/compiler/cpp/src/thrift/generate/t_dart_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_dart_generator.cc
@@ -37,9 +37,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-static const string endl2 = "\n\n";
-
/**
* Use the current Thrift version for static libraries. When releasing, update
* the version in these files.
@@ -89,11 +86,11 @@
}
void scope_up(std::ostream& out, std::string prefix=" ") {
- out << prefix << "{" << endl;
+ out << prefix << "{" << '\n';
indent_up();
}
- void scope_down(std::ostream& out, std::string postfix=endl) {
+ void scope_down(std::ostream& out, std::string postfix="\n") {
indent_down();
indent(out) << "}" << postfix;
}
@@ -339,7 +336,7 @@
* @return List of imports for services
*/
string t_dart_generator::service_imports() {
- return "import 'dart:async';" + endl;
+ return string("import 'dart:async';") + "\n";
}
/**
@@ -348,14 +345,14 @@
* @return List of imports necessary for thrift
*/
string t_dart_generator::dart_thrift_imports() {
- string imports = "import 'dart:typed_data' show Uint8List;" + endl +
- "import 'package:thrift/thrift.dart';" + endl;
+ string imports = string("import 'dart:typed_data' show Uint8List;") + "\n" +
+ string("import 'package:thrift/thrift.dart';") + "\n";
// add import for this library
if (package_prefix_.empty()) {
- imports += "import 'package:" + library_name_ + "/" + library_name_ + ".dart';" + endl;
+ imports += "import 'package:" + library_name_ + "/" + library_name_ + ".dart';" + "\n";
} else {
- imports += "import 'package:" + package_prefix_ + library_name_ + ".dart';" + endl;
+ imports += "import 'package:" + package_prefix_ + library_name_ + ".dart';" + "\n";
}
// add imports for included thrift files
@@ -364,9 +361,9 @@
string include_name = find_library_name(include);
string named_import = "t_" + include_name;
if (package_prefix_.empty()) {
- imports += "import 'package:" + include_name + "/" + include_name + ".dart' as " + named_import + ";" + endl;
+ imports += "import 'package:" + include_name + "/" + include_name + ".dart' as " + named_import + ";" + "\n";
} else {
- imports += "import 'package:" + package_prefix_ + include_name + ".dart' as " + named_import + ";" + endl;
+ imports += "import 'package:" + package_prefix_ + include_name + ".dart' as " + named_import + ";" + "\n";
}
}
@@ -395,8 +392,8 @@
ofstream_with_content_based_conditional_update f_library;
f_library.open(f_library_name.c_str());
- f_library << autogen_comment() << endl;
- f_library << "library " << library_prefix_ << library_name_ << ";" << endl2;
+ f_library << autogen_comment() << '\n';
+ f_library << "library " << library_prefix_ << library_name_ << ";" << '\n' << '\n';
f_library << library_exports_;
f_library.close();
@@ -409,7 +406,7 @@
} else {
subdir = library_name_;
}
- library_exports_ += "export '" + subdir + "/" + file_name + ".dart' show " + class_name + ";" + endl;
+ library_exports_ += "export '" + subdir + "/" + file_name + ".dart' show " + class_name + ";" + "\n";
}
void t_dart_generator::generate_dart_pubspec() {
@@ -417,30 +414,30 @@
ofstream_with_content_based_conditional_update f_pubspec;
f_pubspec.open(f_pubspec_name.c_str());
- indent(f_pubspec) << "name: " << library_name_ << endl;
- indent(f_pubspec) << "version: 0.0.1" << endl;
- indent(f_pubspec) << "description: Autogenerated by Thrift Compiler" << endl;
- f_pubspec << endl;
+ indent(f_pubspec) << "name: " << library_name_ << '\n';
+ indent(f_pubspec) << "version: 0.0.1" << '\n';
+ indent(f_pubspec) << "description: Autogenerated by Thrift Compiler" << '\n';
+ f_pubspec << '\n';
- indent(f_pubspec) << "environment:" << endl;
+ indent(f_pubspec) << "environment:" << '\n';
indent_up();
- indent(f_pubspec) << "sdk: '>=1.24.3 <3.0.0'" << endl;
+ indent(f_pubspec) << "sdk: '>=1.24.3 <3.0.0'" << '\n';
indent_down();
- f_pubspec << endl;
+ f_pubspec << '\n';
- indent(f_pubspec) << "dependencies:" << endl;
+ indent(f_pubspec) << "dependencies:" << '\n';
indent_up();
if (pubspec_lib_.empty()) {
// default to relative path within working directory, which works for tests
- indent(f_pubspec) << "thrift: # ^" << dart_thrift_version << endl;
+ indent(f_pubspec) << "thrift: # ^" << dart_thrift_version << '\n';
indent_up();
- indent(f_pubspec) << "path: ../../../../lib/dart" << endl;
+ indent(f_pubspec) << "path: ../../../../lib/dart" << '\n';
indent_down();
} else {
const vector<std::string> lines = split(pubspec_lib_, '|');
for (const auto & line : lines) {
- indent(f_pubspec) << line << endl;
+ indent(f_pubspec) << line << '\n';
}
}
@@ -448,14 +445,14 @@
const vector<t_program*>& includes = program_->get_includes();
for (auto include : includes) {
string include_name = find_library_name(include);
- indent(f_pubspec) << include_name << ":" << endl;
+ indent(f_pubspec) << include_name << ":" << '\n';
indent_up();
- indent(f_pubspec) << "path: ../" << include_name << endl;
+ indent(f_pubspec) << "path: ../" << include_name << '\n';
indent_down();
}
indent_down();
- f_pubspec << endl;
+ f_pubspec << '\n';
f_pubspec.close();
}
@@ -483,7 +480,7 @@
f_enum.open(f_enum_name.c_str());
// Comment and add library
- f_enum << autogen_comment() << dart_library(file_name) << endl;
+ f_enum << autogen_comment() << dart_library(file_name) << '\n';
string class_name = tenum->get_name();
export_class_to_library(file_name, class_name);
@@ -495,34 +492,34 @@
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
indent(f_enum) << "static const int " << (*c_iter)->get_name() << " = " << value << ";"
- << endl;
+ << '\n';
}
// Create a static Set with all valid values for this enum
- f_enum << endl;
+ f_enum << '\n';
- indent(f_enum) << "static final Set<int> VALID_VALUES = new Set.from([" << endl;
+ indent(f_enum) << "static final Set<int> VALID_VALUES = new Set.from([" << '\n';
indent_up();
bool firstValue = true;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
// populate set
indent(f_enum) << (firstValue ? "" : ", ");
- f_enum << (*c_iter)->get_name() << endl;
+ f_enum << (*c_iter)->get_name() << '\n';
firstValue = false;
}
indent_down();
- indent(f_enum) << "]);" << endl;
+ indent(f_enum) << "]);" << '\n';
- indent(f_enum) << "static final Map<int, String> VALUES_TO_NAMES = {" << endl;
+ indent(f_enum) << "static final Map<int, String> VALUES_TO_NAMES = {" << '\n';
indent_up();
firstValue = true;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
indent(f_enum) << (firstValue ? "" : ", ");
- f_enum << (*c_iter)->get_name() << ": '" << (*c_iter)->get_name() << "'" << endl;
+ f_enum << (*c_iter)->get_name() << ": '" << (*c_iter)->get_name() << "'" << '\n';
firstValue = false;
}
indent_down();
- indent(f_enum) << "};" << endl;
+ indent(f_enum) << "};" << '\n';
scope_down(f_enum); // end class
@@ -545,8 +542,8 @@
f_consts.open(f_consts_name.c_str());
// Print header
- f_consts << autogen_comment() << dart_library(file_name) << endl;
- f_consts << dart_thrift_imports() << endl;
+ f_consts << autogen_comment() << dart_library(file_name) << '\n';
+ f_consts << dart_thrift_imports() << '\n';
export_class_to_library(file_name, class_name);
indent(f_consts) << "class " << class_name;
@@ -559,7 +556,7 @@
(*c_iter)->get_type(),
(*c_iter)->get_value(),
false);
- f_consts << endl;
+ f_consts << '\n';
}
scope_down(f_consts);
@@ -585,13 +582,13 @@
}
string v2 = render_const_value(out, name, type, value);
out << name;
- out << " = " << v2 << ";" << endl << endl;
+ out << " = " << v2 << ";" << '\n' << '\n';
} else if (type->is_enum()) {
if (!defval) {
out << type_name(type) << " ";
}
out << name;
- out << " = " << value->get_integer() << ";" << endl << endl;
+ out << " = " << value->get_integer() << ";" << '\n' << '\n';
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -610,11 +607,11 @@
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, name, field_type, v_iter->second);
- out << endl;
+ out << '\n';
indent(out) << ".." << v_iter->first->get_string() << " = " << val;
}
indent_down();
- out << ";" << endl;
+ out << ";" << '\n';
} else if (type->is_map()) {
if (!defval) {
out << type_name(type) << " ";
@@ -630,11 +627,11 @@
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, name, ktype, v_iter->first);
string val = render_const_value(out, name, vtype, v_iter->second);
- indent(out) << key << ": " << val << "," << endl;
+ indent(out) << key << ": " << val << "," << '\n';
}
- scope_down(out, ";" + endl);
+ scope_down(out, string(";") + "\n");
- out << endl;
+ out << '\n';
} else if (type->is_list() || type->is_set()) {
if (!defval) {
out << type_name(type) << " ";
@@ -642,10 +639,10 @@
out << name << " = ";
t_type* etype;
if (type->is_list()) {
- out << "[" << endl;
+ out << "[" << '\n';
etype = ((t_list*)type)->get_elem_type();
} else {
- out << "new " << type_name(type) << ".from([" << endl;
+ out << "new " << type_name(type) << ".from([" << '\n';
etype = ((t_set*)type)->get_elem_type();
}
const vector<t_const_value*>& val = value->get_list();
@@ -654,14 +651,14 @@
indent_up();
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string val = render_const_value(out, name, etype, *v_iter);
- indent(out) << val << "," << endl;
+ indent(out) << val << "," << '\n';
}
indent_down();
if (type->is_list()) {
- indent(out) << "];" << endl;
+ indent(out) << "];" << '\n';
} else {
- indent(out) << "]);" << endl;
+ indent(out) << "]);" << '\n';
}
} else {
@@ -707,7 +704,7 @@
} else {
string t = tmp("tmp");
print_const_value(out, t, type, value, true);
- out << endl;
+ out << '\n';
render << t;
}
@@ -744,11 +741,11 @@
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
- f_struct << autogen_comment() << dart_library(file_name) << endl;
+ f_struct << autogen_comment() << dart_library(file_name) << '\n';
string imports;
- f_struct << dart_thrift_imports() << endl;
+ f_struct << dart_thrift_imports() << '\n';
generate_dart_struct_definition(f_struct, tstruct, is_exception, false, file_name);
@@ -785,7 +782,7 @@
scope_up(out);
indent(out) << "static final TStruct _STRUCT_DESC = new TStruct(\"" << class_name
- << "\");" << endl;
+ << "\");" << '\n';
// Members are public for -dart, private for -dartbean
const vector<t_field*>& members = tstruct->get_members();
@@ -795,33 +792,33 @@
indent(out) << "static final TField _" << constant_name((*m_iter)->get_name())
<< "_FIELD_DESC = new TField(\"" << (*m_iter)->get_name() << "\", "
<< type_to_enum((*m_iter)->get_type()) << ", " << (*m_iter)->get_key() << ");"
- << endl;
+ << '\n';
}
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
generate_dart_doc(out, *m_iter);
indent(out) << type_name((*m_iter)->get_type()) + " _"
- << get_member_name((*m_iter)->get_name()) << init_value(*m_iter) << ";" << endl;
+ << get_member_name((*m_iter)->get_name()) << init_value(*m_iter) << ";" << '\n';
indent(out) << "static const int " << upcase_string((*m_iter)->get_name())
- << " = " << (*m_iter)->get_key() << ";" << endl;
+ << " = " << (*m_iter)->get_key() << ";" << '\n';
}
- out << endl;
+ out << '\n';
// Inner Isset class
if (members.size() > 0) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (!type_can_be_null((*m_iter)->get_type())) {
string field_name = get_member_name((*m_iter)->get_name());
- indent(out) << "bool __isset_" << field_name << " = false;" << endl;
+ indent(out) << "bool __isset_" << field_name << " = false;" << '\n';
}
}
}
- out << endl;
+ out << '\n';
// Default constructor
indent(out) << tstruct->get_name() << "()";
@@ -838,7 +835,7 @@
}
}
scope_down(out);
- out << endl;
+ out << '\n';
generate_dart_bean_boilerplate(out, tstruct);
generate_generic_field_getters(out, tstruct);
@@ -854,7 +851,7 @@
generate_dart_struct_tostring(out, tstruct);
generate_dart_validator(out, tstruct);
scope_down(out);
- out << endl;
+ out << '\n';
}
/**
@@ -870,20 +867,20 @@
vector<t_field*>::const_iterator f_iter;
// Declare stack tmp variables and read struct header
- indent(out) << "TField field;" << endl;
- indent(out) << "iprot.readStructBegin();" << endl;
+ indent(out) << "TField field;" << '\n';
+ indent(out) << "iprot.readStructBegin();" << '\n';
// Loop over reading in fields
indent(out) << "while (true)";
scope_up(out);
// Read beginning field marker
- indent(out) << "field = iprot.readFieldBegin();" << endl;
+ indent(out) << "field = iprot.readFieldBegin();" << '\n';
// Check for field STOP marker and break
indent(out) << "if (field.type == TType.STOP)";
scope_up(out);
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
scope_down(out);
// Switch statement on the field we are reading
@@ -892,7 +889,7 @@
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case " << upcase_string((*f_iter)->get_name()) << ":" << endl;
+ indent(out) << "case " << upcase_string((*f_iter)->get_name()) << ":" << '\n';
indent_up();
indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ")";
@@ -903,33 +900,33 @@
scope_down(out, " else");
scope_up(out);
- indent(out) << "TProtocolUtil.skip(iprot, field.type);" << endl;
+ indent(out) << "TProtocolUtil.skip(iprot, field.type);" << '\n';
scope_down(out);
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
}
// In the default case we skip the field
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent_up();
- indent(out) << "TProtocolUtil.skip(iprot, field.type);" << endl;
- indent(out) << "break;" << endl;
+ indent(out) << "TProtocolUtil.skip(iprot, field.type);" << '\n';
+ indent(out) << "break;" << '\n';
indent_down();
scope_down(out);
// Read field end marker
- indent(out) << "iprot.readFieldEnd();" << endl;
+ indent(out) << "iprot.readFieldEnd();" << '\n';
scope_down(out);
- indent(out) << "iprot.readStructEnd();" << endl2;
+ indent(out) << "iprot.readStructEnd();" << '\n' << '\n';
// in non-beans style, check for required fields of primitive type
// (which can be checked here but not in the general validate method)
indent(out) << "// check for required fields of primitive type, which can't be "
- "checked in the validate method" << endl;
+ "checked in the validate method" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
string field_name = get_member_name((*f_iter)->get_name());
@@ -937,15 +934,15 @@
scope_up(out);
indent(out) << " throw new TProtocolError(TProtocolErrorType.UNKNOWN, \"Required field '"
<< field_name
- << "' was not found in serialized data! Struct: \" + toString());" << endl;
- scope_down(out, endl2);
+ << "' was not found in serialized data! Struct: \" + toString());" << '\n';
+ scope_down(out, "\n\n");
}
}
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl;
+ indent(out) << "validate();" << '\n';
- scope_down(out, endl2);
+ scope_down(out, "\n\n");
}
// generates dart method to perform various checks
@@ -957,7 +954,7 @@
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "// check for required fields" << endl;
+ indent(out) << "// check for required fields" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
string field_name = get_member_name((*f_iter)->get_name());
@@ -966,17 +963,17 @@
scope_up(out);
indent(out) << "throw new TProtocolError(TProtocolErrorType.UNKNOWN, \"Required field '"
<< field_name << "' was not present! Struct: \" + toString());"
- << endl;
+ << '\n';
scope_down(out);
} else {
indent(out) << "// alas, we cannot check '" << field_name
- << "' because it's a primitive and you chose the non-beans generator." << endl;
+ << "' because it's a primitive and you chose the non-beans generator." << '\n';
}
}
}
// check that fields of type enum have valid values
- indent(out) << "// check that fields of type enum have valid values" << endl;
+ indent(out) << "// check that fields of type enum have valid values" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* field = (*f_iter);
t_type* type = field->get_type();
@@ -988,12 +985,12 @@
scope_up(out);
indent(out) << "throw new TProtocolError(TProtocolErrorType.UNKNOWN, \"The field '"
<< field_name << "' has been assigned the invalid value "
- << "$" << field_name << "\");" << endl;
+ << "$" << field_name << "\");" << '\n';
scope_down(out);
}
}
- scope_down(out, endl2);
+ scope_down(out, "\n\n");
}
/**
@@ -1009,9 +1006,9 @@
vector<t_field*>::const_iterator f_iter;
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl2;
+ indent(out) << "validate();" << '\n' << '\n';
- indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << endl;
+ indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
string field_name = get_member_name((*f_iter)->get_name());
@@ -1027,13 +1024,13 @@
}
indent(out) << "oprot.writeFieldBegin(_" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
+ << "_FIELD_DESC);" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "this.");
// Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
+ indent(out) << "oprot.writeFieldEnd();" << '\n';
if (null_allowed) {
scope_down(out);
@@ -1043,10 +1040,10 @@
}
}
// Write the struct map
- indent(out) << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();"
- << endl;
+ indent(out) << "oprot.writeFieldStop();" << '\n' << indent() << "oprot.writeStructEnd();"
+ << '\n';
- scope_down(out, endl2);
+ scope_down(out, "\n\n");
}
/**
@@ -1064,7 +1061,7 @@
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << endl2;
+ indent(out) << "oprot.writeStructBegin(_STRUCT_DESC);" << '\n' << '\n';
bool first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1079,23 +1076,23 @@
scope_up(out);
indent(out) << "oprot.writeFieldBegin(_" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
+ << "_FIELD_DESC);" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "this.");
// Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
+ indent(out) << "oprot.writeFieldEnd();" << '\n';
scope_down(out, "");
}
- out << endl;
+ out << '\n';
// Write the struct map
- indent(out) << "oprot.writeFieldStop();" << endl << indent()
- << "oprot.writeStructEnd();" << endl;
+ indent(out) << "oprot.writeFieldStop();" << '\n' << indent()
+ << "oprot.writeStructEnd();" << '\n';
- scope_down(out, endl2);
+ scope_down(out, "\n\n");
}
void t_dart_generator::generate_generic_field_getters(std::ostream& out,
@@ -1113,19 +1110,19 @@
t_field* field = *f_iter;
std::string field_name = get_member_name(field->get_name());
- indent(out) << "case " << upcase_string(field_name) << ":" << endl;
+ indent(out) << "case " << upcase_string(field_name) << ":" << '\n';
indent_up();
- indent(out) << "return this." << field_name << ";" << endl;
+ indent(out) << "return this." << field_name << ";" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent_up();
- indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << endl;
+ indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << '\n';
indent_down();
scope_down(out); // switch
- scope_down(out, endl2); // method
+ scope_down(out, "\n\n"); // method
}
void t_dart_generator::generate_generic_field_setters(std::ostream& out,
@@ -1145,31 +1142,31 @@
t_field* field = *f_iter;
std::string field_name = get_member_name(field->get_name());
- indent(out) << "case " << upcase_string(field_name) << ":" << endl;
+ indent(out) << "case " << upcase_string(field_name) << ":" << '\n';
indent_up();
indent(out) << "if (value == null)";
scope_up(out);
- indent(out) << "unset" << get_cap_name(field_name) << "();" << endl;
+ indent(out) << "unset" << get_cap_name(field_name) << "();" << '\n';
scope_down(out, " else");
scope_up(out);
- indent(out) << "this." << field_name << " = value;" << endl;
+ indent(out) << "this." << field_name << " = value;" << '\n';
scope_down(out);
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
- out << endl;
+ out << '\n';
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent_up();
- indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << endl;
+ indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << '\n';
indent_down();
scope_down(out); // switch
- scope_down(out, endl2); // method
+ scope_down(out, "\n\n"); // method
}
// Creates a generic isSet method that takes the field number as argument
@@ -1179,7 +1176,7 @@
// create the isSet method
indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a "
- "value) and false otherwise" << endl;
+ "value) and false otherwise" << '\n';
indent(out) << "bool isSet(int fieldID)";
scope_up(out);
@@ -1188,19 +1185,19 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* field = *f_iter;
- indent(out) << "case " << upcase_string(field->get_name()) << ":" << endl;
+ indent(out) << "case " << upcase_string(field->get_name()) << ":" << '\n';
indent_up();
- indent(out) << "return " << generate_isset_check(field) << ";" << endl;
+ indent(out) << "return " << generate_isset_check(field) << ";" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent_up();
- indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << endl;
+ indent(out) << "throw new ArgumentError(\"Field $fieldID doesn't exist!\");" << '\n';
indent_down();
scope_down(out); // switch
- scope_down(out, endl2); // method
+ scope_down(out, "\n\n"); // method
}
/**
@@ -1219,37 +1216,37 @@
std::string field_name = get_member_name(field->get_name());
std::string cap_name = get_cap_name(field_name);
- indent(out) << "// " << field_name << endl;
+ indent(out) << "// " << field_name << '\n';
// Simple getter
generate_dart_doc(out, field);
- indent(out) << type_name(type) << " get " << field_name << " => this._" << field_name << ";" << endl2;
+ indent(out) << type_name(type) << " get " << field_name << " => this._" << field_name << ";" << '\n' << '\n';
// Simple setter
generate_dart_doc(out, field);
indent(out) << "set " << field_name << "(" << type_name(type) << " " << field_name << ")";
scope_up(out);
- indent(out) << "this._" << field_name << " = " << field_name << ";" << endl;
+ indent(out) << "this._" << field_name << " = " << field_name << ";" << '\n';
generate_isset_set(out, field);
- scope_down(out, endl2);
+ scope_down(out, "\n\n");
// isSet method
indent(out) << "bool is" << get_cap_name("set") << cap_name << "()";
if (type_can_be_null(type)) {
- out << " => this." << field_name << " != null;" << endl2;
+ out << " => this." << field_name << " != null;" << '\n' << '\n';
} else {
- out << " => this.__isset_" << field_name << ";" << endl2;
+ out << " => this.__isset_" << field_name << ";" << '\n' << '\n';
}
// Unsetter
indent(out) << "unset" << cap_name << "()";
scope_up(out);
if (type_can_be_null(type)) {
- indent(out) << "this." << field_name << " = null;" << endl;
+ indent(out) << "this." << field_name << " = null;" << '\n';
} else {
- indent(out) << "this.__isset_" << field_name << " = false;" << endl;
+ indent(out) << "this.__isset_" << field_name << " = false;" << '\n';
}
- scope_down(out, endl2);
+ scope_down(out, "\n\n");
}
}
@@ -1264,7 +1261,7 @@
scope_up(out);
indent(out) << "StringBuffer ret = new StringBuffer(\""
- << tstruct->get_name() << "(\");" << endl2;
+ << tstruct->get_name() << "(\");" << '\n' << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -1281,36 +1278,36 @@
std::string field_name = get_member_name(field->get_name());
if (!first) {
- indent(out) << "ret.write(\", \");" << endl;
+ indent(out) << "ret.write(\", \");" << '\n';
}
- indent(out) << "ret.write(\"" << field_name << ":\");" << endl;
+ indent(out) << "ret.write(\"" << field_name << ":\");" << '\n';
bool can_be_null = type_can_be_null(field->get_type());
if (can_be_null) {
indent(out) << "if (this." << field_name << " == null)";
scope_up(out);
- indent(out) << "ret.write(\"null\");" << endl;
+ indent(out) << "ret.write(\"null\");" << '\n';
scope_down(out, " else");
scope_up(out);
}
if (field->get_type()->is_binary()) {
- indent(out) << "ret.write(\"BINARY\");" << endl;
+ indent(out) << "ret.write(\"BINARY\");" << '\n';
} else if (field->get_type()->is_enum()) {
indent(out) << "String " << field_name << "_name = "
<< get_ttype_class_name(field->get_type())
- << ".VALUES_TO_NAMES[this." << field_name << "];" << endl;
+ << ".VALUES_TO_NAMES[this." << field_name << "];" << '\n';
indent(out) << "if (" << field_name << "_name != null)";
scope_up(out);
- indent(out) << "ret.write(" << field_name << "_name);" << endl;
- indent(out) << "ret.write(\" (\");" << endl;
+ indent(out) << "ret.write(" << field_name << "_name);" << '\n';
+ indent(out) << "ret.write(\" (\");" << '\n';
scope_down(out);
- indent(out) << "ret.write(this." << field_name << ");" << endl;
+ indent(out) << "ret.write(this." << field_name << ");" << '\n';
indent(out) << "if (" << field_name << "_name != null)";
scope_up(out);
- indent(out) << "ret.write(\")\");" << endl;
+ indent(out) << "ret.write(\")\");" << '\n';
scope_down(out);
} else {
- indent(out) << "ret.write(this." << field_name << ");" << endl;
+ indent(out) << "ret.write(this." << field_name << ");" << '\n';
}
if (can_be_null) {
@@ -1320,15 +1317,15 @@
scope_down(out);
}
- out << endl;
+ out << '\n';
first = false;
}
- indent(out) << "ret.write(\")\");" << endl2;
+ indent(out) << "ret.write(\")\");" << '\n' << '\n';
- indent(out) << "return ret.toString();" << endl;
+ indent(out) << "return ret.toString();" << '\n';
- scope_down(out, endl2);
+ scope_down(out, "\n\n");
}
/**
@@ -1391,9 +1388,9 @@
string f_service_name = src_dir_ + "/" + file_name + ".dart";
f_service_.open(f_service_name.c_str());
- f_service_ << autogen_comment() << dart_library(file_name) << endl;
- f_service_ << service_imports() << dart_thrift_imports() << endl;
- f_service_ << endl;
+ f_service_ << autogen_comment() << dart_library(file_name) << '\n';
+ f_service_ << service_imports() << dart_thrift_imports() << '\n';
+ f_service_ << '\n';
generate_service_interface(tservice);
generate_service_client(tservice);
@@ -1424,12 +1421,12 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- f_service_ << endl;
+ f_service_ << '\n';
generate_dart_doc(f_service_, *f_iter);
- indent(f_service_) << function_signature(*f_iter) << ";" << endl;
+ indent(f_service_) << function_signature(*f_iter) << ";" << '\n';
}
- scope_down(f_service_, endl2);
+ scope_down(f_service_, "\n\n");
}
/**
@@ -1465,31 +1462,31 @@
indent(f_service_) << "class " << class_name << extends_client
<< " implements " << service_name_;
scope_up(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
indent(f_service_) << class_name << "(TProtocol iprot, [TProtocol oprot = null])";
if (!extends.empty()) {
indent_up();
- f_service_ << endl;
- indent(f_service_) << ": super(iprot, oprot);" << endl;
+ f_service_ << '\n';
+ indent(f_service_) << ": super(iprot, oprot);" << '\n';
indent_down();
} else {
scope_up(f_service_);
- indent(f_service_) << "_iprot = iprot;" << endl;
- indent(f_service_) << "_oprot = (oprot == null) ? iprot : oprot;" << endl;
+ indent(f_service_) << "_iprot = iprot;" << '\n';
+ indent(f_service_) << "_oprot = (oprot == null) ? iprot : oprot;" << '\n';
scope_down(f_service_);
}
- f_service_ << endl;
+ f_service_ << '\n';
if (extends.empty()) {
- indent(f_service_) << "TProtocol _iprot;" << endl2;
- indent(f_service_) << "TProtocol get iprot => _iprot;" << endl2;
- indent(f_service_) << "TProtocol _oprot;" << endl2;
- indent(f_service_) << "TProtocol get oprot => _oprot;" << endl2;
- indent(f_service_) << "int _seqid = 0;" << endl2;
- indent(f_service_) << "int get seqid => _seqid;" << endl2;
- indent(f_service_) << "int nextSeqid() => ++_seqid;" << endl2;
+ indent(f_service_) << "TProtocol _iprot;" << '\n' << '\n';
+ indent(f_service_) << "TProtocol get iprot => _iprot;" << '\n' << '\n';
+ indent(f_service_) << "TProtocol _oprot;" << '\n' << '\n';
+ indent(f_service_) << "TProtocol get oprot => _oprot;" << '\n' << '\n';
+ indent(f_service_) << "int _seqid = 0;" << '\n' << '\n';
+ indent(f_service_) << "int get seqid => _seqid;" << '\n' << '\n';
+ indent(f_service_) << "int nextSeqid() => ++_seqid;" << '\n' << '\n';
}
// Generate client method implementations
@@ -1510,40 +1507,40 @@
// Serialize the request
indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << (*f_iter)->get_name() << "\", "
<< ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
- << ", nextSeqid()));" << endl;
- indent(f_service_) << argsname << " args = new " << argsname << "();" << endl;
+ << ", nextSeqid()));" << '\n';
+ indent(f_service_) << argsname << " args = new " << argsname << "();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
string arg_field_name = get_member_name((*fld_iter)->get_name());
indent(f_service_) << "args." << arg_field_name << " = "
- << arg_field_name << ";" << endl;
+ << arg_field_name << ";" << '\n';
}
- indent(f_service_) << "args.write(oprot);" << endl;
- indent(f_service_) << "oprot.writeMessageEnd();" << endl2;
+ indent(f_service_) << "args.write(oprot);" << '\n';
+ indent(f_service_) << "oprot.writeMessageEnd();" << '\n' << '\n';
- indent(f_service_) << "await oprot.transport.flush();" << endl2;
+ indent(f_service_) << "await oprot.transport.flush();" << '\n' << '\n';
if (!(*f_iter)->is_oneway()) {
- indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << endl;
+ indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << '\n';
indent(f_service_) << "if (msg.type == TMessageType.EXCEPTION)";
scope_up(f_service_);
- indent(f_service_) << "TApplicationError error = TApplicationError.read(iprot);" << endl;
- indent(f_service_) << "iprot.readMessageEnd();" << endl;
- indent(f_service_) << "throw error;" << endl;
- scope_down(f_service_, endl2);
+ indent(f_service_) << "TApplicationError error = TApplicationError.read(iprot);" << '\n';
+ indent(f_service_) << "iprot.readMessageEnd();" << '\n';
+ indent(f_service_) << "throw error;" << '\n';
+ scope_down(f_service_, "\n\n");
string result_class = get_result_class_name((*f_iter)->get_name());
- indent(f_service_) << result_class << " result = new " << result_class << "();" << endl;
- indent(f_service_) << "result.read(iprot);" << endl;
- indent(f_service_) << "iprot.readMessageEnd();" << endl;
+ indent(f_service_) << result_class << " result = new " << result_class << "();" << '\n';
+ indent(f_service_) << "result.read(iprot);" << '\n';
+ indent(f_service_) << "iprot.readMessageEnd();" << '\n';
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
indent(f_service_) << "if (result." << generate_isset_check("success") << ")";
scope_up(f_service_);
- indent(f_service_) << "return result.success;" << endl;
- scope_down(f_service_, endl2);
+ indent(f_service_) << "return result.success;" << '\n';
+ scope_down(f_service_, "\n\n");
}
t_struct* xs = (*f_iter)->get_xceptions();
@@ -1553,23 +1550,23 @@
string result_field_name = get_member_name((*x_iter)->get_name());
indent(f_service_) << "if (result." << result_field_name << " != null)";
scope_up(f_service_);
- indent(f_service_) << "throw result." << result_field_name << ";" << endl;
+ indent(f_service_) << "throw result." << result_field_name << ";" << '\n';
scope_down(f_service_);
}
// If you get here it's an exception, unless a void function
if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
} else {
indent(f_service_) << "throw new TApplicationError(TApplicationErrorType.MISSING_RESULT, \""
- << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+ << (*f_iter)->get_name() << " failed: unknown result\");" << '\n';
}
}
- scope_down(f_service_, endl2);
+ scope_down(f_service_, "\n\n");
}
- scope_down(f_service_, endl2);
+ scope_down(f_service_, "\n\n");
}
/**
@@ -1583,7 +1580,7 @@
vector<t_function*>::iterator f_iter;
// typedef
- indent(f_service_) << "typedef void ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot);" << endl2;
+ indent(f_service_) << "typedef void ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot);" << '\n' << '\n';
// Extends stuff
string extends = "";
@@ -1602,57 +1599,57 @@
indent(f_service_) << class_name << "(" << service_name_ << " iface)";
if (!extends.empty()) {
indent_up();
- f_service_ << endl;
+ f_service_ << '\n';
indent(f_service_) << ": super(iface)";
indent_down();
}
scope_up(f_service_);
if (extends.empty()) {
- indent(f_service_) << "iface_ = iface;" << endl;
+ indent(f_service_) << "iface_ = iface;" << '\n';
}
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
indent(f_service_) << "PROCESS_MAP[\"" << (*f_iter)->get_name()
- << "\"] = " << get_member_name((*f_iter)->get_name()) << ";" << endl;
+ << "\"] = " << get_member_name((*f_iter)->get_name()) << ";" << '\n';
}
- scope_down(f_service_, endl2);
+ scope_down(f_service_, "\n\n");
- indent(f_service_) << service_name_ << " iface_;" << endl;
+ indent(f_service_) << service_name_ << " iface_;" << '\n';
if (extends.empty()) {
- indent(f_service_) << "final Map<String, ProcessFunction> PROCESS_MAP = {};" << endl;
+ indent(f_service_) << "final Map<String, ProcessFunction> PROCESS_MAP = {};" << '\n';
}
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the server implementation
indent(f_service_) << "bool process(TProtocol iprot, TProtocol oprot)";
scope_up(f_service_);
- indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << endl;
- indent(f_service_) << "ProcessFunction fn = PROCESS_MAP[msg.name];" << endl;
+ indent(f_service_) << "TMessage msg = iprot.readMessageBegin();" << '\n';
+ indent(f_service_) << "ProcessFunction fn = PROCESS_MAP[msg.name];" << '\n';
indent(f_service_) << "if (fn == null)";
scope_up(f_service_);
- indent(f_service_) << "TProtocolUtil.skip(iprot, TType.STRUCT);" << endl;
- indent(f_service_) << "iprot.readMessageEnd();" << endl;
+ indent(f_service_) << "TProtocolUtil.skip(iprot, TType.STRUCT);" << '\n';
+ indent(f_service_) << "iprot.readMessageEnd();" << '\n';
indent(f_service_) << "TApplicationError x = new TApplicationError(TApplicationErrorType.UNKNOWN_METHOD, "
- "\"Invalid method name: '\"+msg.name+\"'\");" << endl;
- indent(f_service_) << "oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl;
- indent(f_service_) << "x.write(oprot);" << endl;
- indent(f_service_) << "oprot.writeMessageEnd();" << endl;
- indent(f_service_) << "oprot.transport.flush();" << endl;
- indent(f_service_) << "return true;" << endl;
+ "\"Invalid method name: '\"+msg.name+\"'\");" << '\n';
+ indent(f_service_) << "oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << '\n';
+ indent(f_service_) << "x.write(oprot);" << '\n';
+ indent(f_service_) << "oprot.writeMessageEnd();" << '\n';
+ indent(f_service_) << "oprot.transport.flush();" << '\n';
+ indent(f_service_) << "return true;" << '\n';
scope_down(f_service_);
- indent(f_service_) << "fn(msg.seqid, iprot, oprot);" << endl;
- indent(f_service_) << "return true;" << endl;
- scope_down(f_service_, endl2); // process function
+ indent(f_service_) << "fn(msg.seqid, iprot, oprot);" << '\n';
+ indent(f_service_) << "return true;" << '\n';
+ scope_down(f_service_, "\n\n"); // process function
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_process_function(tservice, *f_iter);
}
- scope_down(f_service_, endl2); // class
+ scope_down(f_service_, "\n\n"); // class
}
/**
@@ -1700,16 +1697,16 @@
string argsname = get_args_class_name(tfunction->get_name());
string resultname = get_result_class_name(tfunction->get_name());
- indent(f_service_) << argsname << " args = new " << argsname << "();" << endl;
- indent(f_service_) << "args.read(iprot);" << endl;
- indent(f_service_) << "iprot.readMessageEnd();" << endl;
+ indent(f_service_) << argsname << " args = new " << argsname << "();" << '\n';
+ indent(f_service_) << "args.read(iprot);" << '\n';
+ indent(f_service_) << "iprot.readMessageEnd();" << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
if (!tfunction->is_oneway()) {
- indent(f_service_) << resultname << " result = new " << resultname << "();" << endl;
+ indent(f_service_) << resultname << " result = new " << resultname << "();" << '\n';
}
if (!tfunction->is_oneway() && xceptions.size() > 0) {
@@ -1736,7 +1733,7 @@
}
f_service_ << "args." << get_member_name((*f_iter)->get_name());
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
if (!tfunction->is_oneway() && xceptions.size() > 0) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
@@ -1747,36 +1744,36 @@
scope_up(f_service_);
if (!tfunction->is_oneway()) {
indent(f_service_) << "result." << result_field_name << " = "
- << result_field_name << ";" << endl;
+ << result_field_name << ";" << '\n';
}
}
scope_down(f_service_, " ");
f_service_ << "catch (th)";
scope_up(f_service_);
- indent(f_service_) << "// Internal error" << endl;
+ indent(f_service_) << "// Internal error" << '\n';
indent(f_service_) << "TApplicationError x = new "
"TApplicationError(TApplicationErrorType.INTERNAL_ERROR, \"Internal error processing "
- << tfunction->get_name() << "\");" << endl;
+ << tfunction->get_name() << "\");" << '\n';
indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.EXCEPTION, seqid));" << endl;
- indent(f_service_) << "x.write(oprot);" << endl;
- indent(f_service_) << "oprot.writeMessageEnd();" << endl;
- indent(f_service_) << "oprot.transport.flush();" << endl;
- indent(f_service_) << "return;" << endl;
+ << "\", TMessageType.EXCEPTION, seqid));" << '\n';
+ indent(f_service_) << "x.write(oprot);" << '\n';
+ indent(f_service_) << "oprot.writeMessageEnd();" << '\n';
+ indent(f_service_) << "oprot.transport.flush();" << '\n';
+ indent(f_service_) << "return;" << '\n';
scope_down(f_service_);
}
if (tfunction->is_oneway()) {
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
} else {
indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.REPLY, seqid));" << endl;
- indent(f_service_) << "result.write(oprot);" << endl;
- indent(f_service_) << "oprot.writeMessageEnd();" << endl;
- indent(f_service_) << "oprot.transport.flush();" << endl;
+ << "\", TMessageType.REPLY, seqid));" << '\n';
+ indent(f_service_) << "result.write(oprot);" << '\n';
+ indent(f_service_) << "oprot.writeMessageEnd();" << '\n';
+ indent(f_service_) << "oprot.transport.flush();" << '\n';
}
- scope_down(f_service_, endl2);
+ scope_down(f_service_, "\n\n");
}
/**
@@ -1840,7 +1837,7 @@
} else if (type->is_enum()) {
out << "readI32();";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
field_name.c_str(),
@@ -1852,8 +1849,8 @@
* Generates an unserializer for a struct, invokes read()
*/
void t_dart_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
- indent(out) << prefix << " = new " << type_name(tstruct) << "();" << endl;
- indent(out) << prefix << ".read(iprot);" << endl;
+ indent(out) << prefix << " = new " << type_name(tstruct) << "();" << '\n';
+ indent(out) << prefix << ".read(iprot);" << '\n';
}
/**
@@ -1875,14 +1872,14 @@
// Declare variables, read header
if (ttype->is_map()) {
- indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << endl;
+ indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << endl;
+ indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "TList " << obj << " = iprot.readListBegin();" << endl;
+ indent(out) << "TList " << obj << " = iprot.readListBegin();" << '\n';
}
- indent(out) << prefix << " = new " << type_name(ttype) << "();" << endl;
+ indent(out) << prefix << " = new " << type_name(ttype) << "();" << '\n';
// For loop iterates over elements
string i = tmp("_i");
@@ -1903,11 +1900,11 @@
// Read container end
if (ttype->is_map()) {
- indent(out) << "iprot.readMapEnd();" << endl;
+ indent(out) << "iprot.readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "iprot.readSetEnd();" << endl;
+ indent(out) << "iprot.readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "iprot.readListEnd();" << endl;
+ indent(out) << "iprot.readListEnd();" << '\n';
}
scope_down(out);
@@ -1922,13 +1919,13 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- indent(out) << declare_field(&fkey) << endl;
- indent(out) << declare_field(&fval) << endl;
+ indent(out) << declare_field(&fkey) << '\n';
+ indent(out) << declare_field(&fval) << '\n';
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
- indent(out) << prefix << "[" << key << "] = " << val << ";" << endl;
+ indent(out) << prefix << "[" << key << "] = " << val << ";" << '\n';
}
/**
@@ -1938,11 +1935,11 @@
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".add(" << elem << ");" << endl;
+ indent(out) << prefix << ".add(" << elem << ");" << '\n';
}
/**
@@ -1954,11 +1951,11 @@
string elem = tmp("_elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".add(" << elem << ");" << endl;
+ indent(out) << prefix << ".add(" << elem << ");" << '\n';
}
/**
@@ -2022,7 +2019,7 @@
} else if (type->is_enum()) {
out << "writeI32(" << name << ");";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
prefix.c_str(),
@@ -2039,7 +2036,7 @@
*/
void t_dart_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- indent(out) << prefix << ".write(oprot);" << endl;
+ indent(out) << prefix << ".write(oprot);" << '\n';
}
/**
@@ -2056,14 +2053,14 @@
string iter = tmp("_key");
indent(out) << "oprot.writeMapBegin(new TMap(" << type_to_enum(((t_map*)ttype)->get_key_type())
<< ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix << ".length));"
- << endl;
+ << '\n';
} else if (ttype->is_set()) {
indent(out) << "oprot.writeSetBegin(new TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type())
- << ", " << prefix << ".length));" << endl;
+ << ", " << prefix << ".length));" << '\n';
} else if (ttype->is_list()) {
indent(out) << "oprot.writeListBegin(new TList("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".length));"
- << endl;
+ << '\n';
}
string iter = tmp("elem");
@@ -2086,11 +2083,11 @@
scope_down(out);
if (ttype->is_map()) {
- indent(out) << "oprot.writeMapEnd();" << endl;
+ indent(out) << "oprot.writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "oprot.writeSetEnd();" << endl;
+ indent(out) << "oprot.writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "oprot.writeListEnd();" << endl;
+ indent(out) << "oprot.writeListEnd();" << '\n';
}
scope_down(out);
@@ -2496,7 +2493,7 @@
void t_dart_generator::generate_isset_set(ostream& out, t_field* field) {
if (!type_can_be_null(field->get_type())) {
string field_name = get_member_name(field->get_name());
- indent(out) << "this.__isset_" << field_name << " = true;" << endl;
+ indent(out) << "this.__isset_" << field_name << " = true;" << '\n';
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
index c599836..d5e8d5d 100644
--- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
@@ -53,8 +53,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
class t_delphi_generator : public t_oop_generator {
public:
t_delphi_generator(t_program* program,
@@ -409,12 +407,12 @@
const std::string DELPHI_KEYWORDS[81] = {
// keywords
- "and", "array", "as", "asm", "at", "automated", "begin", "case", "class", "const", "constructor",
- "destructor", "dispinterface", "div", "do", "downto", "else", "end", "except", "exports", "file",
- "finalization", "finally", "for", "function", "goto", "if", "implementation", "in", "inherited",
- "initialization", "inline", "interface", "is", "label", "library", "mod", "nil", "not", "object",
- "of", "on", "or", "out", "packed", "private", "procedure", "program", "property", "protected",
- "public", "published", "raise", "record", "repeat", "resourcestring", "set", "shl", "shr", "string",
+ "and", "array", "as", "asm", "at", "automated", "begin", "case", "class", "const", "constructor",
+ "destructor", "dispinterface", "div", "do", "downto", "else", "end", "except", "exports", "file",
+ "finalization", "finally", "for", "function", "goto", "if", "implementation", "in", "inherited",
+ "initialization", "inline", "interface", "is", "label", "library", "mod", "nil", "not", "object",
+ "of", "on", "or", "out", "packed", "private", "procedure", "program", "property", "protected",
+ "public", "published", "raise", "record", "repeat", "resourcestring", "set", "shl", "shr", "string",
"then", "threadvar", "to", "try", "type", "unit", "until", "uses", "var", "while", "with", "xor",
// predefined types (lowercase!)
"ansistring", "boolean", "double", "int64", "integer", "shortint", "smallint", "string", "unicodestring"
@@ -427,19 +425,19 @@
// reserved method names (lowercase!)
const std::string DELPHI_RESERVED_METHOD[31] = {
- "afterconstruction", "beforedestruction", "classinfo", "classname", "classnameis", "classparent",
- "classtype", "cleanupinstance", "create", "defaulthandler", "destroy", "dispatch", "equals",
- "fieldaddress", "free", "freeinstance", "gethashcode", "getinterface", "getinterfaceentry",
- "getinterfacetable", "inheritsfrom", "initinstance", "instancesize", "methodaddress", "methodname",
+ "afterconstruction", "beforedestruction", "classinfo", "classname", "classnameis", "classparent",
+ "classtype", "cleanupinstance", "create", "defaulthandler", "destroy", "dispatch", "equals",
+ "fieldaddress", "free", "freeinstance", "gethashcode", "getinterface", "getinterfaceentry",
+ "getinterfacetable", "inheritsfrom", "initinstance", "instancesize", "methodaddress", "methodname",
"newinstance", "read", "safecallexception", "tostring", "unitname", "write"
};
// reserved exception class method names (lowercase!)
const std::string DELPHI_RESERVED_METHOD_EXCEPTION[23] = {
- "setinnerexception", "setstackinfo", "getstacktrace", "raisingexception", "createfmt", "createres",
- "createresfmt", "createhelp", "createfmthelp", "createreshelp", "createresfmthelp", "getbaseexception",
- "baseexception", "helpcontext", "innerexception", "message", "stacktrace", "stackinfo",
- "getexceptionstackinfoproc", "getstackinfostringproc", "cleanupstackinfoproc", "raiseouterexception",
+ "setinnerexception", "setstackinfo", "getstacktrace", "raisingexception", "createfmt", "createres",
+ "createresfmt", "createhelp", "createfmthelp", "createreshelp", "createresfmthelp", "getbaseexception",
+ "baseexception", "helpcontext", "innerexception", "message", "stacktrace", "stackinfo",
+ "getexceptionstackinfoproc", "getstackinfostringproc", "cleanupstackinfoproc", "raiseouterexception",
"throwouterexception"
};
@@ -628,10 +626,10 @@
}
// neither reserved nor keyword?
- if (!(b_reserved || b_keyword)) {
+ if (!(b_reserved || b_keyword)) {
return name;
}
-
+
// apply the rule: old style '_' postfix or more modern '&' prefix?
// underscore always on non-keywords or when explicitly asked via arg
if( (!b_keyword) || old_names_ || b_force_underscore) {
@@ -707,25 +705,25 @@
}
unitname = normalize_name(unitname,false,false,true/*force underscore*/);
-
+
std::string f_name = get_out_dir() + "/" + unitname + ".pas";
ofstream_with_content_based_conditional_update f_all;
f_all.open(f_name);
- f_all << autogen_comment() << endl;
+ f_all << autogen_comment() << '\n';
generate_delphi_doc(f_all, program_);
- f_all << "unit " << unitname << ";" << endl << endl;
- f_all << "{$WARN SYMBOL_DEPRECATED OFF}" << endl;
+ f_all << "unit " << unitname << ";" << '\n' << '\n';
+ f_all << "{$WARN SYMBOL_DEPRECATED OFF}" << '\n';
if(com_types_) {
- f_all << "{$MINENUMSIZE 4}" << endl;
+ f_all << "{$MINENUMSIZE 4}" << '\n';
}
if(rtti_) {
- f_all << "{$IFOPT M+} {$DEFINE TYPEINFO_WAS_ON} {$ELSE} {$UNDEF TYPEINFO_WAS_ON} {$ENDIF}" << endl;
+ f_all << "{$IFOPT M+} {$DEFINE TYPEINFO_WAS_ON} {$ELSE} {$UNDEF TYPEINFO_WAS_ON} {$ENDIF}" << '\n';
}
- f_all << endl;
- f_all << "interface" << endl << endl;
- f_all << "uses" << endl;
+ f_all << '\n';
+ f_all << "interface" << '\n' << '\n';
+ f_all << "uses" << '\n';
indent_up();
@@ -733,12 +731,12 @@
for (s_iter = uses_list.begin(); s_iter != uses_list.end(); ++s_iter) {
if (s_iter != uses_list.begin()) {
f_all << ",";
- f_all << endl;
+ f_all << '\n';
}
indent(f_all) << *s_iter;
}
- f_all << ";" << endl << endl;
+ f_all << ";" << '\n' << '\n';
indent_down();
@@ -749,70 +747,70 @@
}
}
- f_all << "const" << endl;
+ f_all << "const" << '\n';
indent_up();
- indent(f_all) << "c" << tmp_unit << "_Option_Register_Types = " << (register_types_ ? "True" : "False") << ";" << endl;
- indent(f_all) << "c" << tmp_unit << "_Option_ConstPrefix = " << (constprefix_ ? "True" : "False") << ";" << endl;
- indent(f_all) << "c" << tmp_unit << "_Option_Events = " << (events_ ? "True" : "False") << ";" << endl;
- indent(f_all) << "c" << tmp_unit << "_Option_XmlDoc = " << (xmldoc_ ? "True" : "False") << ";" << endl;
- indent(f_all) << "c" << tmp_unit << "_Option_Async = " << (async_ ? "True" : "False") << ";" << endl;
- indent(f_all) << "c" << tmp_unit << "_Option_COM_types = " << (com_types_ ? "True" : "False") << ";" << endl;
- indent(f_all) << "c" << tmp_unit << "_Option_Old_Names = " << (old_names_ ? "True" : "False") << ";" << endl;
- indent(f_all) << "c" << tmp_unit << "_Option_RTTI = " << (rtti_ ? "True" : "False") << ";" << endl;
+ indent(f_all) << "c" << tmp_unit << "_Option_Register_Types = " << (register_types_ ? "True" : "False") << ";" << '\n';
+ indent(f_all) << "c" << tmp_unit << "_Option_ConstPrefix = " << (constprefix_ ? "True" : "False") << ";" << '\n';
+ indent(f_all) << "c" << tmp_unit << "_Option_Events = " << (events_ ? "True" : "False") << ";" << '\n';
+ indent(f_all) << "c" << tmp_unit << "_Option_XmlDoc = " << (xmldoc_ ? "True" : "False") << ";" << '\n';
+ indent(f_all) << "c" << tmp_unit << "_Option_Async = " << (async_ ? "True" : "False") << ";" << '\n';
+ indent(f_all) << "c" << tmp_unit << "_Option_COM_types = " << (com_types_ ? "True" : "False") << ";" << '\n';
+ indent(f_all) << "c" << tmp_unit << "_Option_Old_Names = " << (old_names_ ? "True" : "False") << ";" << '\n';
+ indent(f_all) << "c" << tmp_unit << "_Option_RTTI = " << (rtti_ ? "True" : "False") << ";" << '\n';
indent_down();
- f_all << endl;
- f_all << "type" << endl;
+ f_all << '\n';
+ f_all << "type" << '\n';
if (has_forward) {
- f_all << s_forward_decr.str() << endl;
+ f_all << s_forward_decr.str() << '\n';
}
if (has_enum) {
- indent(f_all) << endl;
- indent(f_all) << "{$SCOPEDENUMS ON}" << endl << endl;
+ indent(f_all) << '\n';
+ indent(f_all) << "{$SCOPEDENUMS ON}" << '\n' << '\n';
f_all << s_enum.str();
- indent(f_all) << "{$SCOPEDENUMS OFF}" << endl << endl;
+ indent(f_all) << "{$SCOPEDENUMS OFF}" << '\n' << '\n';
}
f_all << s_struct.str();
f_all << s_service.str();
f_all << s_const.str();
- f_all << "implementation" << endl << endl;
+ f_all << "implementation" << '\n' << '\n';
f_all << s_struct_impl.str();
f_all << s_service_impl.str();
f_all << s_const_impl.str();
if (register_types_) {
- f_all << endl;
- f_all << "// Type factory methods and registration" << endl;
+ f_all << '\n';
+ f_all << "// Type factory methods and registration" << '\n';
f_all << s_type_factory_funcs.str();
- f_all << "procedure RegisterTypeFactories;" << endl;
- f_all << "begin" << endl;
+ f_all << "procedure RegisterTypeFactories;" << '\n';
+ f_all << "begin" << '\n';
f_all << s_type_factory_registration.str();
- f_all << "end;" << endl;
+ f_all << "end;" << '\n';
}
- f_all << endl;
+ f_all << '\n';
string constants_class = make_constants_classname();
- f_all << "initialization" << endl;
+ f_all << "initialization" << '\n';
if (has_const) {
- f_all << "{$IF CompilerVersion < 21.0} // D2010" << endl;
- f_all << " " << constants_class.c_str() << "_Initialize;" << endl;
- f_all << "{$IFEND}" << endl;
+ f_all << "{$IF CompilerVersion < 21.0} // D2010" << '\n';
+ f_all << " " << constants_class.c_str() << "_Initialize;" << '\n';
+ f_all << "{$IFEND}" << '\n';
}
if (register_types_) {
- f_all << " RegisterTypeFactories;" << endl;
+ f_all << " RegisterTypeFactories;" << '\n';
}
- f_all << endl;
+ f_all << '\n';
- f_all << "finalization" << endl;
+ f_all << "finalization" << '\n';
if (has_const) {
- f_all << "{$IF CompilerVersion < 21.0} // D2010" << endl;
- f_all << " " << constants_class.c_str() << "_Finalize;" << endl;
- f_all << "{$IFEND}" << endl;
+ f_all << "{$IF CompilerVersion < 21.0} // D2010" << '\n';
+ f_all << " " << constants_class.c_str() << "_Finalize;" << '\n';
+ f_all << "{$IFEND}" << '\n';
}
- f_all << endl << endl;
+ f_all << '\n' << '\n';
- f_all << "end." << endl;
+ f_all << "end." << '\n';
f_all.close();
if (!typedefs_pending.empty()) {
@@ -828,8 +826,8 @@
void t_delphi_generator::delphi_type_usings(ostream& out) {
indent_up();
indent(out) << "Classes, SysUtils, Generics.Collections, Thrift.Collections, Thrift.Protocol,"
- << endl;
- indent(out) << "Thrift.Transport;" << endl << endl;
+ << '\n';
+ indent(out) << "Thrift.Transport;" << '\n' << '\n';
indent_down();
}
@@ -842,7 +840,7 @@
indent_up();
indent(s_forward_decr) << type_name(tstruct, tstruct->is_xception(), true) << " = " << what << ";"
- << endl;
+ << '\n';
indent_down();
add_defined_type(tstruct);
@@ -867,7 +865,7 @@
// if( ! container)
// s_struct << "type "; //the "type A = type B" syntax leads to E2574 with generics
- s_struct << type_name(ttypedef->get_type()) << ";" << endl << endl;
+ s_struct << type_name(ttypedef->get_type()) << ";" << '\n' << '\n';
indent_down();
add_defined_type(ttypedef);
@@ -948,7 +946,7 @@
indent_up();
generate_delphi_doc(s_enum, tenum);
indent(s_enum) << type_name(tenum, true, true) << " = "
- << "(" << endl;
+ << "(" << '\n';
indent_up();
vector<t_enum_value*> constants = tenum->get_constants();
if (constants.empty()) {
@@ -959,15 +957,15 @@
int value = (*c_iter)->get_value();
if (c_iter != constants.begin()) {
s_enum << ",";
- s_enum << endl;
+ s_enum << '\n';
}
generate_delphi_doc(s_enum, *c_iter);
indent(s_enum) << normalize_name((*c_iter)->get_name()) << " = " << value;
}
}
- s_enum << endl;
+ s_enum << '\n';
indent_down();
- indent(s_enum) << ");" << endl << endl;
+ indent(s_enum) << ");" << '\n' << '\n';
indent_down();
}
@@ -981,7 +979,7 @@
result << "'";
for (signed char const c: value) {
if( (c >= 0) && (c < 32)) { // convert ctrl chars, but leave UTF-8 alone
- result << "#" << (int)c;
+ result << "#" << (int)c;
} else if (c == '\'') {
result << "''"; // duplicate any single quotes we find
} else {
@@ -989,7 +987,7 @@
}
}
result << "'";
-
+
return result.str();
}
@@ -1037,8 +1035,8 @@
string constants_class = make_constants_classname();
indent_up();
- indent(s_const) << constants_class.c_str() << " = class" << endl;
- indent(s_const) << "private" << endl;
+ indent(s_const) << constants_class.c_str() << " = class" << '\n';
+ indent(s_const) << "private" << '\n';
indent_up();
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -1050,7 +1048,7 @@
}
}
indent_down();
- indent(s_const) << "public" << endl;
+ indent(s_const) << "public" << '\n';
indent_up();
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
generate_delphi_doc(s_const, *c_iter);
@@ -1059,12 +1057,12 @@
(*c_iter)->get_type(),
(*c_iter)->get_value());
}
- indent(s_const) << "{$IF CompilerVersion >= 21.0}" << endl;
- indent(s_const) << "class constructor Create;" << endl;
- indent(s_const) << "class destructor Destroy;" << endl;
- indent(s_const) << "{$IFEND}" << endl;
+ indent(s_const) << "{$IF CompilerVersion >= 21.0}" << '\n';
+ indent(s_const) << "class constructor Create;" << '\n';
+ indent(s_const) << "class destructor Destroy;" << '\n';
+ indent(s_const) << "{$IFEND}" << '\n';
indent_down();
- indent(s_const) << "end;" << endl << endl;
+ indent(s_const) << "end;" << '\n' << '\n';
indent_down();
std::ostringstream vars, code;
@@ -1079,22 +1077,22 @@
}
indent_down_impl();
- indent_impl(s_const_impl) << "{$IF CompilerVersion >= 21.0}" << endl;
+ indent_impl(s_const_impl) << "{$IF CompilerVersion >= 21.0}" << '\n';
indent_impl(s_const_impl) << "class constructor " << constants_class.c_str() << ".Create;"
- << endl;
+ << '\n';
if (!vars.str().empty()) {
- indent_impl(s_const_impl) << "var" << endl;
+ indent_impl(s_const_impl) << "var" << '\n';
s_const_impl << vars.str();
}
- indent_impl(s_const_impl) << "begin" << endl;
+ indent_impl(s_const_impl) << "begin" << '\n';
if (!code.str().empty()) {
s_const_impl << code.str();
}
- indent_impl(s_const_impl) << "end;" << endl << endl;
+ indent_impl(s_const_impl) << "end;" << '\n' << '\n';
indent_impl(s_const_impl) << "class destructor " << constants_class.c_str() << ".Destroy;"
- << endl;
- indent_impl(s_const_impl) << "begin" << endl;
+ << '\n';
+ indent_impl(s_const_impl) << "begin" << '\n';
indent_up_impl();
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
if (const_needs_var((*c_iter)->get_type())) {
@@ -1104,10 +1102,10 @@
(*c_iter)->get_value());
}
}
- indent_impl(s_const_impl) << "inherited;" << endl;
+ indent_impl(s_const_impl) << "inherited;" << '\n';
indent_down_impl();
- indent_impl(s_const_impl) << "end;" << endl;
- indent_impl(s_const_impl) << "{$ELSE}" << endl;
+ indent_impl(s_const_impl) << "end;" << '\n';
+ indent_impl(s_const_impl) << "{$ELSE}" << '\n';
vars.str("");
code.str("");
@@ -1124,19 +1122,19 @@
}
indent_down_impl();
- indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Initialize;" << endl;
+ indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Initialize;" << '\n';
if (!vars.str().empty()) {
- indent_impl(s_const_impl) << "var" << endl;
+ indent_impl(s_const_impl) << "var" << '\n';
s_const_impl << vars.str();
}
- indent_impl(s_const_impl) << "begin" << endl;
+ indent_impl(s_const_impl) << "begin" << '\n';
if (!code.str().empty()) {
s_const_impl << code.str();
}
- indent_impl(s_const_impl) << "end;" << endl << endl;
+ indent_impl(s_const_impl) << "end;" << '\n' << '\n';
- indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Finalize;" << endl;
- indent_impl(s_const_impl) << "begin" << endl;
+ indent_impl(s_const_impl) << "procedure " << constants_class.c_str() << "_Finalize;" << '\n';
+ indent_impl(s_const_impl) << "begin" << '\n';
indent_up_impl();
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
finalize_field(s_const_impl,
@@ -1146,8 +1144,8 @@
constants_class);
}
indent_down_impl();
- indent_impl(s_const_impl) << "end;" << endl;
- indent_impl(s_const_impl) << "{$IFEND}" << endl << endl;
+ indent_impl(s_const_impl) << "end;" << '\n';
+ indent_impl(s_const_impl) << "{$IFEND}" << '\n' << '\n';
}
void t_delphi_generator::print_const_def_value(std::ostream& vars,
@@ -1183,7 +1181,7 @@
string val = render_const_value(vars, out, name, field_type, v_iter->second);
indent_impl(out) << cls_prefix << normalize_name(name) << "."
<< prop_name(v_iter->first->get_string(), type->is_xception())
- << " := " << val << ";" << endl;
+ << " := " << val << ";" << '\n';
}
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
@@ -1194,7 +1192,7 @@
string key = render_const_value(vars, out, name, ktype, v_iter->first);
string val = render_const_value(vars, out, name, vtype, v_iter->second);
indent_impl(out) << cls_prefix << normalize_name(name) << "[" << key << "]"
- << " := " << val << ";" << endl;
+ << " := " << val << ";" << '\n';
}
} else if (type->is_list() || type->is_set()) {
t_type* etype;
@@ -1208,7 +1206,7 @@
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string val = render_const_value(vars, out, name, etype, *v_iter);
- indent_impl(out) << cls_prefix << normalize_name(name) << ".Add(" << val << ");" << endl;
+ indent_impl(out) << cls_prefix << normalize_name(name) << ".Add(" << val << ");" << '\n';
}
}
}
@@ -1218,7 +1216,7 @@
t_type* type,
t_const_value* value) {
(void)value;
- indent(out) << "class var F" << name << ": " << type_name(type) << ";" << endl;
+ indent(out) << "class var F" << name << ": " << type_name(type) << ";" << '\n';
}
bool t_delphi_generator::const_needs_var(t_type* type) {
@@ -1236,11 +1234,11 @@
(void)value;
if (const_needs_var(type)) {
indent(out) << "class property " << name << ": " << type_name(type) << " read F" << name << ";"
- << endl;
+ << '\n';
} else {
std::ostringstream vars; // dummy
string v2 = render_const_value(vars, out, name, type, value);
- indent(out) << "const " << name << " = " << v2 << ";" << endl;
+ indent(out) << "const " << name << " = " << v2 << ";" << '\n';
}
}
@@ -1257,14 +1255,14 @@
if (truetype->is_base_type()) {
// already done
// string v2 = render_const_value( vars, out, name, type, value);
- // indent_impl(out) << name << " := " << v2 << ";" << endl;
+ // indent_impl(out) << name << " := " << v2 << ";" << '\n';
} else if (truetype->is_enum()) {
indent_impl(out) << name << " := " << type_name(type) << "." << value->get_identifier_name()
- << ";" << endl;
+ << ";" << '\n';
} else {
string typname;
typname = type_name(truetype, true, false, type->is_xception(), type->is_xception());
- indent_impl(out) << name << " := " << typname << ".Create;" << endl;
+ indent_impl(out) << name << " := " << typname << ".Create;" << '\n';
print_const_def_value(vars, out, name, truetype, value);
}
}
@@ -1341,7 +1339,7 @@
render << type_name(type, false) << "." << value->get_identifier_name();
} else {
string t = tmp("tmp");
- vars << " " << t << " : " << type_name(type) << ";" << endl;
+ vars << " " << t << " : " << type_name(type) << ";" << '\n';
print_const_value(vars, out, t, type, value);
render << t;
}
@@ -1418,26 +1416,26 @@
(*m_iter)->get_value());
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
indent_impl(code) << prop_name((*m_iter), is_exception, "F__isset_") << " := True;"
- << endl;
+ << '\n';
}
}
}
indent_down_impl();
indent_impl(out) << "constructor " << cls_prefix << cls_nm << "."
- << "Create;" << endl;
+ << "Create;" << '\n';
if (!vars.str().empty()) {
- out << "var" << endl;
+ out << "var" << '\n';
out << vars.str();
}
- indent_impl(out) << "begin" << endl;
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
if (is_exception && (!is_x_factory)) {
- indent_impl(out) << "inherited Create('');" << endl;
+ indent_impl(out) << "inherited Create('');" << '\n';
} else {
- indent_impl(out) << "inherited;" << endl;
+ indent_impl(out) << "inherited;" << '\n';
}
if (!code.str().empty()) {
@@ -1445,28 +1443,28 @@
}
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
if ((members.size() > 0) && is_exception && (!is_x_factory)) {
indent_impl(out) << "constructor " << cls_prefix << cls_nm << "."
<< "Create(" << constructor_argument_list(tstruct, indent_impl()) << ");"
- << endl;
- indent_impl(out) << "begin" << endl;
+ << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << "Create;" << endl;
+ indent_impl(out) << "Create;" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string propname = prop_name((*m_iter)->get_name(), is_exception);
string param_name = constructor_param_name((*m_iter)->get_name());
- indent_impl(out) << propname << " := " << param_name << ";" << endl;
+ indent_impl(out) << propname << " := " << param_name << ";" << '\n';
}
- indent_impl(out) << "UpdateMessageProperty;" << endl;
+ indent_impl(out) << "UpdateMessageProperty;" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
indent_impl(out) << "destructor " << cls_prefix << cls_nm << "."
- << "Destroy;" << endl;
- indent_impl(out) << "begin" << endl;
+ << "Destroy;" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1477,46 +1475,46 @@
finalize_field(out, prop_name(*m_iter, is_exception), t, (*m_iter)->get_value());
}
- indent_impl(out) << "inherited;" << endl;
+ indent_impl(out) << "inherited;" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
if (is_exception && (!is_x_factory)) {
indent_impl(out) << "function " << cls_prefix << cls_nm << "." << exception_factory_name
- << ": I" << exception_factory_name << ";" << endl;
- indent_impl(out) << "begin" << endl;
+ << ": I" << exception_factory_name << ";" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << "if F" << exception_factory_name << " = nil" << endl;
- indent_impl(out) << "then F" << exception_factory_name << " := T" << exception_factory_name << "Impl.Create;" << endl << endl;
- indent_impl(out) << "result := F" << exception_factory_name << ";" << endl;
+ indent_impl(out) << "if F" << exception_factory_name << " = nil" << '\n';
+ indent_impl(out) << "then F" << exception_factory_name << " := T" << exception_factory_name << "Impl.Create;" << '\n' << '\n';
+ indent_impl(out) << "result := F" << exception_factory_name << ";" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
- indent_impl(out) << "function " << cls_prefix << cls_nm << ".QueryInterface(const IID: TGUID; out Obj): HRESULT;" << endl;
- indent_impl(out) << "begin" << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
+ indent_impl(out) << "function " << cls_prefix << cls_nm << ".QueryInterface(const IID: TGUID; out Obj): HRESULT;" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << "if GetInterface(IID, Obj)" << endl;
- indent_impl(out) << "then result := S_OK" << endl;
- indent_impl(out) << "else result := E_NOINTERFACE;" << endl;
+ indent_impl(out) << "if GetInterface(IID, Obj)" << '\n';
+ indent_impl(out) << "then result := S_OK" << '\n';
+ indent_impl(out) << "else result := E_NOINTERFACE;" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
- indent_impl(out) << "function " << cls_prefix << cls_nm << "._AddRef: Integer;" << endl;
- indent_impl(out) << "begin" << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
+ indent_impl(out) << "function " << cls_prefix << cls_nm << "._AddRef: Integer;" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << "result := -1; // not refcounted" << endl;
+ indent_impl(out) << "result := -1; // not refcounted" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
- indent_impl(out) << "function " << cls_prefix << cls_nm << "._Release: Integer;" << endl;
- indent_impl(out) << "begin" << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
+ indent_impl(out) << "function " << cls_prefix << cls_nm << "._Release: Integer;" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << "result := -1; // not refcounted" << endl;
+ indent_impl(out) << "result := -1; // not refcounted" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
if (tstruct->is_union()) {
indent_impl(out) << "procedure " << cls_prefix << cls_nm << "."
- << "ClearUnionValues;" << endl;
- indent_impl(out) << "begin" << endl;
+ << "ClearUnionValues;" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = (*m_iter)->get_type();
@@ -1536,7 +1534,7 @@
exception_factory_name);
}
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1601,12 +1599,12 @@
print_delphi_struct_type_factory_func(out, tstruct);
out << ": ";
out << struct_intf_name;
- out << ";" << endl;
- out << "begin" << endl;
+ out << ";" << '\n';
+ out << "begin" << '\n';
indent_up();
- indent(out) << "Result := " << cls_nm << ".Create;" << endl;
+ indent(out) << "Result := " << cls_nm << ".Create;" << '\n';
indent_down();
- out << "end;" << endl << endl;
+ out << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_delphi_struct_type_factory_registration(ostream& out,
@@ -1628,7 +1626,7 @@
indent(out) << " TypeRegistry.RegisterTypeFactory<" << struct_intf_name << ">(";
print_delphi_struct_type_factory_func(out, tstruct);
out << ");";
- out << endl;
+ out << '\n';
}
void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
@@ -1662,11 +1660,11 @@
generate_delphi_doc(out, tstruct);
if(rtti_) {
- indent(out) << "{$TYPEINFO ON}" << endl;
- indent(out) << "{$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])}" << endl;
- indent(out) << struct_intf_name << " = interface(IBaseWithTypeInfo)" << endl;
+ indent(out) << "{$TYPEINFO ON}" << '\n';
+ indent(out) << "{$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])}" << '\n';
+ indent(out) << struct_intf_name << " = interface(IBaseWithTypeInfo)" << '\n';
} else {
- indent(out) << struct_intf_name << " = interface(IBase)" << endl;
+ indent(out) << struct_intf_name << " = interface(IBase)" << '\n';
}
indent_up();
@@ -1678,20 +1676,20 @@
}
if (is_x_factory) {
- out << endl;
- indent(out) << "// Create Exception Object" << endl;
- indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << endl;
+ out << '\n';
+ indent(out) << "// Create Exception Object" << '\n';
+ indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << '\n';
}
if (members.size() > 0) {
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
generate_property(out, *m_iter, true, is_exception);
}
}
if (members.size() > 0) {
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
generate_delphi_isset_reader_writer_definition(out, *m_iter, is_exception);
@@ -1700,22 +1698,22 @@
}
if (members.size() > 0) {
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = prop_name(*m_iter, is_exception, "__isset_");
indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << " write Set" << isset_name << ";"
- << endl;
+ << '\n';
}
}
}
indent_down();
- indent(out) << "end;" << endl;
+ indent(out) << "end;" << '\n';
if(rtti_) {
- indent(out) << "{$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF}" << endl;
+ indent(out) << "{$IFNDEF TYPEINFO_WAS_ON} {$TYPEINFO OFF} {$ENDIF}" << '\n';
}
- indent(out) << endl;
+ indent(out) << '\n';
}
generate_delphi_doc(out, tstruct);
@@ -1729,40 +1727,40 @@
} else {
out << "TInterfacedObject, IBase, ISupportsToString, " << struct_intf_name;
}
- out << ")" << endl;
+ out << ")" << '\n';
if (is_exception && (!is_x_factory)) {
- indent(out) << "public" << endl;
+ indent(out) << "public" << '\n';
indent_up();
- indent(out) << "type" << endl;
+ indent(out) << "type" << '\n';
indent_up();
generate_delphi_struct_definition(out, tstruct, is_exception, in_class, is_result, true);
indent_down();
indent_down();
}
- indent(out) << "private" << endl;
+ indent(out) << "private" << '\n';
indent_up();
if (is_exception && (!is_x_factory)) {
- indent(out) << "F" << exception_factory_name << " :" << struct_intf_name << ";" << endl << endl;
+ indent(out) << "F" << exception_factory_name << " :" << struct_intf_name << ";" << '\n' << '\n';
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- indent(out) << declare_field(*m_iter, false, "F", is_exception) << endl;
+ indent(out) << declare_field(*m_iter, false, "F", is_exception) << '\n';
}
if (members.size() > 0) {
- indent(out) << endl;
+ indent(out) << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = prop_name(*m_iter, is_exception, "F__isset_");
- indent(out) << isset_name << ": System.Boolean;" << endl;
+ indent(out) << isset_name << ": System.Boolean;" << '\n';
}
}
}
- indent(out) << endl;
+ indent(out) << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
generate_delphi_property_reader_definition(out, *m_iter, is_exception);
@@ -1770,106 +1768,106 @@
}
if (tstruct->is_union()) {
- out << endl;
- indent(out) << "// Clear values(for union's property setter)" << endl;
- indent(out) << "procedure ClearUnionValues;" << endl;
+ out << '\n';
+ indent(out) << "// Clear values(for union's property setter)" << '\n';
+ indent(out) << "procedure ClearUnionValues;" << '\n';
}
if (members.size() > 0) {
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = prop_name(*m_iter, is_exception, "__isset_");
- indent(out) << "function Get" << isset_name << ": System.Boolean;" << endl;
- indent(out) << "procedure Set" << isset_name << "( const value : System.Boolean);" << endl;
+ indent(out) << "function Get" << isset_name << ": System.Boolean;" << '\n';
+ indent(out) << "procedure Set" << isset_name << "( const value : System.Boolean);" << '\n';
}
}
}
if (is_exception && (!is_x_factory)) {
- out << endl;
+ out << '\n';
indent_down();
- indent(out) << "strict protected" << endl;
- indent_up();
- indent(out) << "function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall;" << endl;
- indent(out) << "function _AddRef: Integer; stdcall;" << endl;
- indent(out) << "function _Release: Integer; stdcall;" << endl;
- out << endl;
+ indent(out) << "strict protected" << '\n';
+ indent_up();
+ indent(out) << "function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall;" << '\n';
+ indent(out) << "function _AddRef: Integer; stdcall;" << '\n';
+ indent(out) << "function _Release: Integer; stdcall;" << '\n';
+ out << '\n';
}
indent_down();
- indent(out) << "public" << endl;
+ indent(out) << "public" << '\n';
indent_up();
if ((members.size() > 0) && is_exception && (!is_x_factory)) {
- indent(out) << "constructor Create; overload;" << endl;
+ indent(out) << "constructor Create; overload;" << '\n';
indent(out) << "constructor Create(" << constructor_argument_list(tstruct, indent())
- << "); overload;" << endl;
+ << "); overload;" << '\n';
} else {
- indent(out) << "constructor Create;" << endl;
+ indent(out) << "constructor Create;" << '\n';
}
- indent(out) << "destructor Destroy; override;" << endl;
+ indent(out) << "destructor Destroy; override;" << '\n';
- out << endl;
- indent(out) << "function ToString: string; override;" << endl;
+ out << '\n';
+ indent(out) << "function ToString: string; override;" << '\n';
if (is_exception && (!is_x_factory)) {
- out << endl;
- indent(out) << "// Exception Factory" << endl;
- indent(out) << "function " << exception_factory_name << ": " << struct_intf_name << ";" << endl;
+ out << '\n';
+ indent(out) << "// Exception Factory" << '\n';
+ indent(out) << "function " << exception_factory_name << ": " << struct_intf_name << ";" << '\n';
}
- out << endl;
- indent(out) << "// IBase" << endl;
- indent(out) << "procedure Read( const iprot: IProtocol);" << endl;
- indent(out) << "procedure Write( const oprot: IProtocol);" << endl;
+ out << '\n';
+ indent(out) << "// IBase" << '\n';
+ indent(out) << "procedure Read( const iprot: IProtocol);" << '\n';
+ indent(out) << "procedure Write( const oprot: IProtocol);" << '\n';
if (is_exception && is_x_factory) {
- out << endl;
- indent(out) << "// Create Exception Object" << endl;
- indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << endl;
+ out << '\n';
+ indent(out) << "// Create Exception Object" << '\n';
+ indent(out) << "function CreateException: " << type_name(tstruct, true, true) << ";" << '\n';
}
if (members.size() > 0) {
- out << endl;
- indent(out) << "// Properties" << endl;
+ out << '\n';
+ indent(out) << "// Properties" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
generate_property(out, *m_iter, true, is_exception);
}
}
if (members.size() > 0) {
- out << endl;
- indent(out) << "// isset" << endl;
+ out << '\n';
+ indent(out) << "// isset" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = prop_name(*m_iter, is_exception, "__isset_");
indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << " write Set" << isset_name << ";"
- << endl;
+ << '\n';
}
}
}
indent_down();
- indent(out) << "end;" << endl << endl;
+ indent(out) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_service(t_service* tservice) {
indent_up();
generate_delphi_doc(s_service, tservice);
- indent(s_service) << normalize_clsnm(service_name_, "T") << " = class" << endl;
- indent(s_service) << "public" << endl;
+ indent(s_service) << normalize_clsnm(service_name_, "T") << " = class" << '\n';
+ indent(s_service) << "public" << '\n';
indent_up();
- indent(s_service) << "type" << endl;
+ indent(s_service) << "type" << '\n';
generate_service_interface(tservice);
generate_service_client(tservice);
generate_service_server(tservice);
generate_service_helpers(tservice);
indent_down();
indent_down();
- indent(s_service) << "end;" << endl;
- indent(s_service) << endl;
+ indent(s_service) << "end;" << '\n';
+ indent(s_service) << '\n';
indent_down();
}
@@ -1893,9 +1891,9 @@
extends = type_name(tservice->get_extends(), true, true);
extends_iface = extends + "." + iface_name;
generate_delphi_doc(s_service, tservice);
- indent(s_service) << iface_name << " = interface(" << extends_iface << ")" << endl;
+ indent(s_service) << iface_name << " = interface(" << extends_iface << ")" << '\n';
} else {
- indent(s_service) << iface_name << " = interface" << endl;
+ indent(s_service) << iface_name << " = interface" << '\n';
}
indent_up();
@@ -1904,10 +1902,10 @@
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_delphi_doc(s_service, *f_iter);
- indent(s_service) << function_signature(*f_iter, for_async) << endl;
+ indent(s_service) << function_signature(*f_iter, for_async) << '\n';
}
indent_down();
- indent(s_service) << "end;" << endl << endl;
+ indent(s_service) << "end;" << '\n' << '\n';
indent_down();
}
@@ -1921,7 +1919,7 @@
std::wstring guid_wstr(guid_chars);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
std::string guid_str = convert.to_bytes(guid_wstr);
- indent(out) << "['" << guid_str << "']" << endl;
+ indent(out) << "['" << guid_str << "']" << '\n';
}
}
#else
@@ -1955,78 +1953,78 @@
extends = type_name(tservice->get_extends(), true, true);
extends_client = extends + ".TClient";
}
- indent(s_service) << "TClient = class( " << extends_client << ", " << implements << ")" << endl;
+ indent(s_service) << "TClient = class( " << extends_client << ", " << implements << ")" << '\n';
- indent(s_service) << "public" << endl;
+ indent(s_service) << "public" << '\n';
indent_up();
- indent(s_service) << "constructor Create( prot: IProtocol); overload;" << endl;
+ indent(s_service) << "constructor Create( prot: IProtocol); overload;" << '\n';
indent_impl(s_service_impl) << "constructor " << normalize_clsnm(service_name_, "T")
- << ".TClient.Create( prot: IProtocol);" << endl;
- indent_impl(s_service_impl) << "begin" << endl;
+ << ".TClient.Create( prot: IProtocol);" << '\n';
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "Create( prot, prot );" << endl;
+ indent_impl(s_service_impl) << "Create( prot, prot );" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
indent(s_service)
- << "constructor Create( const iprot: IProtocol; const oprot: IProtocol); overload;" << endl;
+ << "constructor Create( const iprot: IProtocol; const oprot: IProtocol); overload;" << '\n';
indent_impl(s_service_impl) << "constructor " << normalize_clsnm(service_name_, "T")
<< ".TClient.Create( const iprot: IProtocol; const oprot: IProtocol);"
- << endl;
- indent_impl(s_service_impl) << "begin" << endl;
+ << '\n';
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "inherited Create;" << endl;
- indent_impl(s_service_impl) << "iprot_ := iprot;" << endl;
- indent_impl(s_service_impl) << "oprot_ := oprot;" << endl;
+ indent_impl(s_service_impl) << "inherited Create;" << '\n';
+ indent_impl(s_service_impl) << "iprot_ := iprot;" << '\n';
+ indent_impl(s_service_impl) << "oprot_ := oprot;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
indent_down();
if (extends.empty()) {
- indent(s_service) << "protected" << endl;
+ indent(s_service) << "protected" << '\n';
indent_up();
- indent(s_service) << "iprot_: IProtocol;" << endl;
- indent(s_service) << "oprot_: IProtocol;" << endl;
- indent(s_service) << "seqid_: System.Integer;" << endl;
+ indent(s_service) << "iprot_: IProtocol;" << '\n';
+ indent(s_service) << "oprot_: IProtocol;" << '\n';
+ indent(s_service) << "seqid_: System.Integer;" << '\n';
indent_down();
- indent(s_service) << "public" << endl;
+ indent(s_service) << "public" << '\n';
indent_up();
- indent(s_service) << "property InputProtocol: IProtocol read iprot_;" << endl;
- indent(s_service) << "property OutputProtocol: IProtocol read oprot_;" << endl;
+ indent(s_service) << "property InputProtocol: IProtocol read iprot_;" << '\n';
+ indent(s_service) << "property OutputProtocol: IProtocol read oprot_;" << '\n';
indent_down();
}
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::const_iterator f_iter;
- indent(s_service) << "protected" << endl;
+ indent(s_service) << "protected" << '\n';
indent_up();
- indent(s_service) << "// Iface" << endl;
+ indent(s_service) << "// Iface" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string funname = (*f_iter)->get_name();
generate_delphi_doc(s_service, *f_iter);
- indent(s_service) << function_signature(*f_iter, false) << endl;
+ indent(s_service) << function_signature(*f_iter, false) << '\n';
}
if( async_) {
- indent(s_service) << endl;
- indent(s_service) << "// IAsync" << endl;
+ indent(s_service) << '\n';
+ indent(s_service) << "// IAsync" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string funname = (*f_iter)->get_name();
generate_delphi_doc(s_service, *f_iter);
- indent(s_service) << function_signature(*f_iter, true) << endl;
+ indent(s_service) << function_signature(*f_iter, true) << '\n';
}
}
indent_down();
- indent(s_service) << "public" << endl;
+ indent(s_service) << "public" << '\n';
indent_up();
string full_cls = normalize_clsnm(service_name_, "T") + ".TClient";
@@ -2044,20 +2042,20 @@
bool for_async = (mode != 0);
mode--;
- indent_impl(s_service_impl) << function_signature(*f_iter, for_async, full_cls) << endl;
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << function_signature(*f_iter, for_async, full_cls) << '\n';
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
t_type* ttype = (*f_iter)->get_returntype();
if( for_async) {
if (is_void(ttype)) {
// Delphi forces us to specify a type with IFuture<T>, so we use Integer=0 for void methods
- indent_impl(s_service_impl) << "result := TTask.Future<System.Integer>(function: System.Integer" << endl;
+ indent_impl(s_service_impl) << "result := TTask.Future<System.Integer>(function: System.Integer" << '\n';
} else {
string rettype = type_name(ttype, false, true, false, true);
- indent_impl(s_service_impl) << "result := TTask.Future<" << rettype << ">(function: " << rettype << endl;
+ indent_impl(s_service_impl) << "result := TTask.Future<" << rettype << ">(function: " << rettype << '\n';
}
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
}
@@ -2072,26 +2070,26 @@
}
s_service_impl << normalize_name((*fld_iter)->get_name());
}
- s_service_impl << ");" << endl;
+ s_service_impl << ");" << '\n';
if (!(*f_iter)->is_oneway()) {
s_service_impl << indent_impl();
if (!(*f_iter)->get_returntype()->is_void()) {
s_service_impl << "Result := ";
}
- s_service_impl << "recv_" << funname << "();" << endl;
+ s_service_impl << "recv_" << funname << "();" << '\n';
}
if( for_async) {
if (is_void(ttype)) {
- indent_impl(s_service_impl) << "Result := 0;" << endl; // no IFuture<void> in Delphi
+ indent_impl(s_service_impl) << "Result := 0;" << '\n'; // no IFuture<void> in Delphi
}
indent_down_impl();
- indent_impl(s_service_impl) << "end);" << endl;
+ indent_impl(s_service_impl) << "end);" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
}
t_function send_function(g_type_void,
@@ -2105,41 +2103,41 @@
string argsvar = tmp("_args");
string msgvar = tmp("_msg");
- indent(s_service) << function_signature(&send_function, false) << endl;
- indent_impl(s_service_impl) << function_signature(&send_function, false, full_cls) << endl;
- indent_impl(s_service_impl) << "var" << endl;
+ indent(s_service) << function_signature(&send_function, false) << '\n';
+ indent_impl(s_service_impl) << function_signature(&send_function, false, full_cls) << '\n';
+ indent_impl(s_service_impl) << "var" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << argsvar << " : " << args_intfnm << ";" << endl;
- indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << endl;
+ indent_impl(s_service_impl) << argsvar << " : " << args_intfnm << ";" << '\n';
+ indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "seqid_ := seqid_ + 1;" << endl;
+ indent_impl(s_service_impl) << "seqid_ := seqid_ + 1;" << '\n';
indent_impl(s_service_impl) << "Thrift.Protocol.Init( " << msgvar << ", '" << funname
<< "', " << ((*f_iter)->is_oneway() ? "TMessageType.Oneway"
: "TMessageType.Call")
- << ", seqid_);" << endl;
+ << ", seqid_);" << '\n';
- indent_impl(s_service_impl) << "oprot_.WriteMessageBegin( " << msgvar << " );" << endl;
- indent_impl(s_service_impl) << argsvar << " := " << args_clsnm << "Impl.Create();" << endl;
+ indent_impl(s_service_impl) << "oprot_.WriteMessageBegin( " << msgvar << " );" << '\n';
+ indent_impl(s_service_impl) << argsvar << " := " << args_clsnm << "Impl.Create();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
indent_impl(s_service_impl) << argsvar << "." << prop_name(*fld_iter)
<< " := " << normalize_name((*fld_iter)->get_name()) << ";"
- << endl;
+ << '\n';
}
- indent_impl(s_service_impl) << argsvar << ".Write(oprot_);" << endl;
+ indent_impl(s_service_impl) << argsvar << ".Write(oprot_);" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
indent_impl(s_service_impl) << argsvar << "." << prop_name(*fld_iter)
- << " := " << empty_value((*fld_iter)->get_type()) << ";" << endl;
+ << " := " << empty_value((*fld_iter)->get_type()) << ";" << '\n';
}
- indent_impl(s_service_impl) << "oprot_.WriteMessageEnd();" << endl;
- indent_impl(s_service_impl) << "oprot_.Transport.Flush();" << endl;
+ indent_impl(s_service_impl) << "oprot_.WriteMessageEnd();" << '\n';
+ indent_impl(s_service_impl) << "oprot_.Transport.Flush();" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
if (!(*f_iter)->is_oneway()) {
string org_resultname = (*f_iter)->get_name() + "_result";
@@ -2159,72 +2157,72 @@
string appexvar = tmp("_ax");
string retvar = tmp("_ret");
- indent(s_service) << function_signature(&recv_function, false) << endl;
- indent_impl(s_service_impl) << function_signature(&recv_function, false, full_cls) << endl;
- indent_impl(s_service_impl) << "var" << endl;
+ indent(s_service) << function_signature(&recv_function, false) << '\n';
+ indent_impl(s_service_impl) << function_signature(&recv_function, false, full_cls) << '\n';
+ indent_impl(s_service_impl) << "var" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << endl;
+ indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << '\n';
if (xceptions.size() > 0) {
- indent_impl(s_service_impl) << exceptvar << " : Exception;" << endl;
+ indent_impl(s_service_impl) << exceptvar << " : Exception;" << '\n';
}
- indent_impl(s_service_impl) << appexvar << " : TApplicationException;" << endl;
- indent_impl(s_service_impl) << retvar << " : " << result_intfnm << ";" << endl;
+ indent_impl(s_service_impl) << appexvar << " : TApplicationException;" << '\n';
+ indent_impl(s_service_impl) << retvar << " : " << result_intfnm << ";" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << msgvar << " := iprot_.ReadMessageBegin();" << endl;
- indent_impl(s_service_impl) << "if (" << msgvar << ".Type_ = TMessageType.Exception) then begin" << endl;
+ indent_impl(s_service_impl) << msgvar << " := iprot_.ReadMessageBegin();" << '\n';
+ indent_impl(s_service_impl) << "if (" << msgvar << ".Type_ = TMessageType.Exception) then begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << appexvar << " := TApplicationException.Read(iprot_);" << endl;
- indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << endl;
- indent_impl(s_service_impl) << "raise " << appexvar << ";" << endl;
+ indent_impl(s_service_impl) << appexvar << " := TApplicationException.Read(iprot_);" << '\n';
+ indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << '\n';
+ indent_impl(s_service_impl) << "raise " << appexvar << ";" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
- indent_impl(s_service_impl) << retvar << " := " << result_clsnm << "Impl.Create();" << endl;
- indent_impl(s_service_impl) << retvar << ".Read(iprot_);" << endl;
- indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << endl;
+ indent_impl(s_service_impl) << retvar << " := " << result_clsnm << "Impl.Create();" << '\n';
+ indent_impl(s_service_impl) << retvar << ".Read(iprot_);" << '\n';
+ indent_impl(s_service_impl) << "iprot_.ReadMessageEnd();" << '\n';
if (!(*f_iter)->get_returntype()->is_void()) {
- indent_impl(s_service_impl) << "if (" << retvar << ".__isset_success) then begin" << endl;
+ indent_impl(s_service_impl) << "if (" << retvar << ".__isset_success) then begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "Result := " << retvar << ".Success;" << endl;
+ indent_impl(s_service_impl) << "Result := " << retvar << ".Success;" << '\n';
t_type* type = (*f_iter)->get_returntype();
if (type->is_struct() || type->is_xception() || type->is_map() || type->is_list()
|| type->is_set()) {
- indent_impl(s_service_impl) << retvar << ".Success := nil;" << endl;
+ indent_impl(s_service_impl) << retvar << ".Success := nil;" << '\n';
}
- indent_impl(s_service_impl) << "Exit;" << endl;
+ indent_impl(s_service_impl) << "Exit;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
}
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
indent_impl(s_service_impl) << "if (" << retvar << "." << prop_name(*x_iter, false, "__isset_")
- << ") then begin" << endl;
+ << ") then begin" << '\n';
indent_up_impl();
indent_impl(s_service_impl) << exceptvar << " := " << retvar << "." << prop_name(*x_iter)
- << ".CreateException;" << endl;
- indent_impl(s_service_impl) << "raise " << exceptvar << ";" << endl;
+ << ".CreateException;" << '\n';
+ indent_impl(s_service_impl) << "raise " << exceptvar << ";" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
}
if (!(*f_iter)->get_returntype()->is_void()) {
indent_impl(s_service_impl)
<< "raise TApplicationExceptionMissingResult.Create('"
- << (*f_iter)->get_name() << " failed: unknown result');" << endl;
+ << (*f_iter)->get_name() << " failed: unknown result');" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
}
}
indent_down();
- indent(s_service) << "end;" << endl << endl;
+ indent(s_service) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_service_server(t_service* tservice) {
@@ -2239,164 +2237,164 @@
if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends(), true, true);
extends_processor = extends + ".TProcessorImpl";
- indent(s_service) << "TProcessorImpl = class(" << extends_processor << ", IProcessor)" << endl;
+ indent(s_service) << "TProcessorImpl = class(" << extends_processor << ", IProcessor)" << '\n';
} else {
- indent(s_service) << "TProcessorImpl = class( TInterfacedObject, IProcessor)" << endl;
+ indent(s_service) << "TProcessorImpl = class( TInterfacedObject, IProcessor)" << '\n';
}
- indent(s_service) << "public" << endl;
+ indent(s_service) << "public" << '\n';
indent_up();
- indent(s_service) << "constructor Create( iface_: Iface );" << endl;
- indent(s_service) << "destructor Destroy; override;" << endl;
+ indent(s_service) << "constructor Create( iface_: Iface );" << '\n';
+ indent(s_service) << "destructor Destroy; override;" << '\n';
indent_down();
- indent_impl(s_service_impl) << "constructor " << full_cls << ".Create( iface_: Iface );" << endl;
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << "constructor " << full_cls << ".Create( iface_: Iface );" << '\n';
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
if (tservice->get_extends() != nullptr) {
- indent_impl(s_service_impl) << "inherited Create( iface_);" << endl;
+ indent_impl(s_service_impl) << "inherited Create( iface_);" << '\n';
} else {
- indent_impl(s_service_impl) << "inherited Create;" << endl;
+ indent_impl(s_service_impl) << "inherited Create;" << '\n';
}
- indent_impl(s_service_impl) << "Self.iface_ := iface_;" << endl;
+ indent_impl(s_service_impl) << "Self.iface_ := iface_;" << '\n';
if (tservice->get_extends() != nullptr) {
- indent_impl(s_service_impl) << "ASSERT( processMap_ <> nil); // inherited" << endl;
+ indent_impl(s_service_impl) << "ASSERT( processMap_ <> nil); // inherited" << '\n';
} else {
indent_impl(s_service_impl)
- << "processMap_ := TThriftDictionaryImpl<string, TProcessFunction>.Create;" << endl;
+ << "processMap_ := TThriftDictionaryImpl<string, TProcessFunction>.Create;" << '\n';
}
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
indent_impl(s_service_impl) << "processMap_.AddOrSetValue( '" << (*f_iter)->get_name() << "', "
- << (*f_iter)->get_name() << "_Process);" << endl;
+ << (*f_iter)->get_name() << "_Process);" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
- indent_impl(s_service_impl) << "destructor " << full_cls << ".Destroy;" << endl;
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << "destructor " << full_cls << ".Destroy;" << '\n';
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "inherited;" << endl;
+ indent_impl(s_service_impl) << "inherited;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
- indent(s_service) << "private" << endl;
+ indent(s_service) << "private" << '\n';
indent_up();
- indent(s_service) << "iface_: Iface;" << endl;
+ indent(s_service) << "iface_: Iface;" << '\n';
indent_down();
if (tservice->get_extends() == nullptr) {
- indent(s_service) << "protected" << endl;
+ indent(s_service) << "protected" << '\n';
indent_up();
- indent(s_service) << "type" << endl;
+ indent(s_service) << "type" << '\n';
indent_up();
indent(s_service) << "TProcessFunction = reference to procedure( seqid: System.Integer; const iprot: "
"IProtocol; const oprot: IProtocol"
- << (events_ ? "; const events : IRequestEvents" : "") << ");" << endl;
+ << (events_ ? "; const events : IRequestEvents" : "") << ");" << '\n';
indent_down();
indent_down();
- indent(s_service) << "protected" << endl;
+ indent(s_service) << "protected" << '\n';
indent_up();
- indent(s_service) << "processMap_: IThriftDictionary<string, TProcessFunction>;" << endl;
+ indent(s_service) << "processMap_: IThriftDictionary<string, TProcessFunction>;" << '\n';
indent_down();
}
- indent(s_service) << "public" << endl;
+ indent(s_service) << "public" << '\n';
indent_up();
if (extends.empty()) {
indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol; const "
- "events : IProcessorEvents): System.Boolean;" << endl;
+ "events : IProcessorEvents): System.Boolean;" << '\n';
} else {
indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol; const "
- "events : IProcessorEvents): System.Boolean; reintroduce;" << endl;
+ "events : IProcessorEvents): System.Boolean; reintroduce;" << '\n';
}
indent_impl(s_service_impl) << "function " << full_cls << ".Process( const iprot: IProtocol; "
"const oprot: IProtocol; const events "
- ": IProcessorEvents): System.Boolean;" << endl;
+ ": IProcessorEvents): System.Boolean;" << '\n';
;
- indent_impl(s_service_impl) << "var" << endl;
+ indent_impl(s_service_impl) << "var" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "msg : Thrift.Protocol.TThriftMessage;" << endl;
- indent_impl(s_service_impl) << "fn : TProcessFunction;" << endl;
- indent_impl(s_service_impl) << "x : TApplicationException;" << endl;
+ indent_impl(s_service_impl) << "msg : Thrift.Protocol.TThriftMessage;" << '\n';
+ indent_impl(s_service_impl) << "fn : TProcessFunction;" << '\n';
+ indent_impl(s_service_impl) << "x : TApplicationException;" << '\n';
if (events_) {
- indent_impl(s_service_impl) << "context : IRequestEvents;" << endl;
+ indent_impl(s_service_impl) << "context : IRequestEvents;" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "try" << endl;
+ indent_impl(s_service_impl) << "try" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "msg := iprot.ReadMessageBegin();" << endl;
- indent_impl(s_service_impl) << "fn := nil;" << endl;
- indent_impl(s_service_impl) << "if not processMap_.TryGetValue(msg.Name, fn)" << endl;
- indent_impl(s_service_impl) << "or not Assigned(fn) then begin" << endl;
+ indent_impl(s_service_impl) << "msg := iprot.ReadMessageBegin();" << '\n';
+ indent_impl(s_service_impl) << "fn := nil;" << '\n';
+ indent_impl(s_service_impl) << "if not processMap_.TryGetValue(msg.Name, fn)" << '\n';
+ indent_impl(s_service_impl) << "or not Assigned(fn) then begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "TProtocolUtil.Skip(iprot, TType.Struct);" << endl;
- indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << endl;
+ indent_impl(s_service_impl) << "TProtocolUtil.Skip(iprot, TType.Struct);" << '\n';
+ indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << '\n';
indent_impl(s_service_impl) << "x := "
"TApplicationExceptionUnknownMethod.Create("
- "'Invalid method name: ''' + msg.Name + '''');" << endl;
+ "'Invalid method name: ''' + msg.Name + '''');" << '\n';
indent_impl(s_service_impl)
<< "Thrift.Protocol.Init( msg, msg.Name, TMessageType.Exception, msg.SeqID);"
- << endl;
- indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << endl;
- indent_impl(s_service_impl) << "x.Write(oprot);" << endl;
- indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << endl;
- indent_impl(s_service_impl) << "oprot.Transport.Flush();" << endl;
- indent_impl(s_service_impl) << "Result := True;" << endl;
- indent_impl(s_service_impl) << "Exit;" << endl;
+ << '\n';
+ indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << '\n';
+ indent_impl(s_service_impl) << "x.Write(oprot);" << '\n';
+ indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << '\n';
+ indent_impl(s_service_impl) << "oprot.Transport.Flush();" << '\n';
+ indent_impl(s_service_impl) << "Result := True;" << '\n';
+ indent_impl(s_service_impl) << "Exit;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
if (events_) {
- indent_impl(s_service_impl) << "if events <> nil" << endl;
- indent_impl(s_service_impl) << "then context := events.CreateRequestContext(msg.Name)" << endl;
- indent_impl(s_service_impl) << "else context := nil;" << endl;
- indent_impl(s_service_impl) << "try" << endl;
+ indent_impl(s_service_impl) << "if events <> nil" << '\n';
+ indent_impl(s_service_impl) << "then context := events.CreateRequestContext(msg.Name)" << '\n';
+ indent_impl(s_service_impl) << "else context := nil;" << '\n';
+ indent_impl(s_service_impl) << "try" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot, context);" << endl;
+ indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot, context);" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "finally" << endl;
+ indent_impl(s_service_impl) << "finally" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "if context <> nil then begin" << endl;
+ indent_impl(s_service_impl) << "if context <> nil then begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "context.CleanupContext;" << endl;
- indent_impl(s_service_impl) << "context := nil;" << endl;
+ indent_impl(s_service_impl) << "context.CleanupContext;" << '\n';
+ indent_impl(s_service_impl) << "context := nil;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
} else {
- indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot);" << endl;
+ indent_impl(s_service_impl) << "fn(msg.SeqID, iprot, oprot);" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "except" << endl;
+ indent_impl(s_service_impl) << "except" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "on TTransportExceptionTimedOut do begin" << endl;
+ indent_impl(s_service_impl) << "on TTransportExceptionTimedOut do begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "Result := True;" << endl;
- indent_impl(s_service_impl) << "Exit;" << endl;
+ indent_impl(s_service_impl) << "Result := True;" << '\n';
+ indent_impl(s_service_impl) << "Exit;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
- indent_impl(s_service_impl) << "else begin" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
+ indent_impl(s_service_impl) << "else begin" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "Result := False;" << endl;
- indent_impl(s_service_impl) << "Exit;" << endl;
+ indent_impl(s_service_impl) << "Result := False;" << '\n';
+ indent_impl(s_service_impl) << "Exit;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
- indent_impl(s_service_impl) << "Result := True;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
+ indent_impl(s_service_impl) << "Result := True;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_process_function(tservice, *f_iter);
}
indent_down();
- indent(s_service) << "end;" << endl << endl;
+ indent(s_service) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_function_helpers(t_function* tfunction) {
@@ -2439,46 +2437,46 @@
indent(s_service) << "procedure " << funcname
<< "_Process( seqid: System.Integer; const iprot: IProtocol; const oprot: IProtocol"
- << (events_ ? "; const events : IRequestEvents" : "") << ");" << endl;
+ << (events_ ? "; const events : IRequestEvents" : "") << ");" << '\n';
if (tfunction->is_oneway()) {
- indent_impl(s_service_impl) << "// one way processor" << endl;
+ indent_impl(s_service_impl) << "// one way processor" << '\n';
} else {
- indent_impl(s_service_impl) << "// both way processor" << endl;
+ indent_impl(s_service_impl) << "// both way processor" << '\n';
}
indent_impl(s_service_impl)
<< "procedure " << full_cls << "." << funcname
<< "_Process( seqid: System.Integer; const iprot: IProtocol; const oprot: IProtocol"
- << (events_ ? "; const events : IRequestEvents" : "") << ");" << endl;
- indent_impl(s_service_impl) << "var" << endl;
+ << (events_ ? "; const events : IRequestEvents" : "") << ");" << '\n';
+ indent_impl(s_service_impl) << "var" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "args: " << args_intfnm << ";" << endl;
+ indent_impl(s_service_impl) << "args: " << args_intfnm << ";" << '\n';
if (!tfunction->is_oneway()) {
- indent_impl(s_service_impl) << "msg: Thrift.Protocol.TThriftMessage;" << endl;
- indent_impl(s_service_impl) << "ret: " << result_intfnm << ";" << endl;
- indent_impl(s_service_impl) << "appx : TApplicationException;" << endl;
+ indent_impl(s_service_impl) << "msg: Thrift.Protocol.TThriftMessage;" << '\n';
+ indent_impl(s_service_impl) << "ret: " << result_intfnm << ";" << '\n';
+ indent_impl(s_service_impl) << "appx : TApplicationException;" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "begin" << endl;
+ indent_impl(s_service_impl) << "begin" << '\n';
indent_up_impl();
if (!tfunction->is_oneway()) {
- indent_impl(s_service_impl) << "ret := " << result_clsnm << "Impl.Create;" << endl;
+ indent_impl(s_service_impl) << "ret := " << result_clsnm << "Impl.Create;" << '\n';
}
- indent_impl(s_service_impl) << "try" << endl;
+ indent_impl(s_service_impl) << "try" << '\n';
indent_up_impl();
if (events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.PreRead;" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.PreRead;" << '\n';
}
- indent_impl(s_service_impl) << "args := " << args_clsnm << "Impl.Create;" << endl;
- indent_impl(s_service_impl) << "args.Read(iprot);" << endl;
- indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << endl;
+ indent_impl(s_service_impl) << "args := " << args_clsnm << "Impl.Create;" << '\n';
+ indent_impl(s_service_impl) << "args.Read(iprot);" << '\n';
+ indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << '\n';
if (events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.PostRead;" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.PostRead;" << '\n';
}
t_struct* xs = tfunction->get_xceptions();
@@ -2503,88 +2501,88 @@
}
s_service_impl << "args." << prop_name(*f_iter);
}
- s_service_impl << ");" << endl;
+ s_service_impl << ");" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent_impl(s_service_impl) << "args." << prop_name(*f_iter)
- << " := " << empty_value((*f_iter)->get_type()) << ";" << endl;
+ << " := " << empty_value((*f_iter)->get_type()) << ";" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "except" << endl;
+ indent_impl(s_service_impl) << "except" << '\n';
indent_up_impl();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
indent_impl(s_service_impl) << "on E: " << type_name((*x_iter)->get_type(), true, true)
- << " do begin" << endl;
+ << " do begin" << '\n';
indent_up_impl();
if (!tfunction->is_oneway()) {
string factory_name = normalize_clsnm((*x_iter)->get_type()->get_name(), "", true)
+ "Factory";
indent_impl(s_service_impl) << "ret." << prop_name(*x_iter) << " := E." << factory_name << ";"
- << endl;
+ << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
}
- indent_impl(s_service_impl) << "on E: Exception do begin" << endl;
+ indent_impl(s_service_impl) << "on E: Exception do begin" << '\n';
indent_up_impl();
if(events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.UnhandledError(E);" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.UnhandledError(E);" << '\n';
}
if (!tfunction->is_oneway()) {
indent_impl(s_service_impl) << "appx := TApplicationExceptionInternalError.Create(E.Message);"
- << endl;
- indent_impl(s_service_impl) << "try" << endl;
+ << '\n';
+ indent_impl(s_service_impl) << "try" << '\n';
indent_up_impl();
if(events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << '\n';
}
indent_impl(s_service_impl) << "Thrift.Protocol.Init( msg, '"
<< tfunction->get_name() << "', TMessageType.Exception, seqid);"
- << endl;
- indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << endl;
- indent_impl(s_service_impl) << "appx.Write(oprot);" << endl;
- indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << endl;
- indent_impl(s_service_impl) << "oprot.Transport.Flush();" << endl;
+ << '\n';
+ indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << '\n';
+ indent_impl(s_service_impl) << "appx.Write(oprot);" << '\n';
+ indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << '\n';
+ indent_impl(s_service_impl) << "oprot.Transport.Flush();" << '\n';
if(events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << '\n';
}
- indent_impl(s_service_impl) << "Exit;" << endl;
+ indent_impl(s_service_impl) << "Exit;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "finally" << endl;
+ indent_impl(s_service_impl) << "finally" << '\n';
indent_up_impl();
- indent_impl(s_service_impl) << "appx.Free;" << endl;
+ indent_impl(s_service_impl) << "appx.Free;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl;
+ indent_impl(s_service_impl) << "end;" << '\n';
if (!tfunction->is_oneway()) {
if (events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << '\n';
}
indent_impl(s_service_impl) << "Thrift.Protocol.Init( msg, '"
<< tfunction->get_name() << "', TMessageType.Reply, seqid); "
- << endl;
- indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg); " << endl;
- indent_impl(s_service_impl) << "ret.Write(oprot);" << endl;
- indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << endl;
- indent_impl(s_service_impl) << "oprot.Transport.Flush();" << endl;
+ << '\n';
+ indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg); " << '\n';
+ indent_impl(s_service_impl) << "ret.Write(oprot);" << '\n';
+ indent_impl(s_service_impl) << "oprot.WriteMessageEnd();" << '\n';
+ indent_impl(s_service_impl) << "oprot.Transport.Flush();" << '\n';
if (events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.PostWrite;" << '\n';
}
} else if (events_) {
- indent_impl(s_service_impl) << "if events <> nil then events.OnewayComplete;" << endl;
+ indent_impl(s_service_impl) << "if events <> nil then events.OnewayComplete;" << '\n';
}
indent_down_impl();
- indent_impl(s_service_impl) << "end;" << endl << endl;
+ indent_impl(s_service_impl) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_deserialize_field(ostream& out,
@@ -2657,7 +2655,7 @@
out << "ReadI32()";
out << ");";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
tfield->get_name().c_str(),
@@ -2677,8 +2675,8 @@
typ_name = type_name(tstruct, true, false);
}
- indent_impl(out) << prefix << name << " := " << typ_name << ".Create;" << endl;
- indent_impl(out) << prefix << name << ".Read(iprot);" << endl;
+ indent_impl(out) << prefix << name << " := " << typ_name << ".Create;" << '\n';
+ indent_impl(out) << prefix << name << ".Read(iprot);" << '\n';
}
void t_delphi_generator::generate_deserialize_container(ostream& out,
@@ -2706,22 +2704,22 @@
} else if (ttype->is_list()) {
local_var = obj + ": TThriftList;";
}
- local_vars << " " << local_var << endl;
+ local_vars << " " << local_var << '\n';
counter = tmp("_i");
local_var = counter + ": System.Integer;";
- local_vars << " " << local_var << endl;
+ local_vars << " " << local_var << '\n';
- indent_impl(out) << name << " := " << type_name(ttype, true) << ".Create;" << endl;
+ indent_impl(out) << name << " := " << type_name(ttype, true) << ".Create;" << '\n';
if (ttype->is_map()) {
- indent_impl(out) << obj << " := iprot.ReadMapBegin();" << endl;
+ indent_impl(out) << obj << " := iprot.ReadMapBegin();" << '\n';
} else if (ttype->is_set()) {
- indent_impl(out) << obj << " := iprot.ReadSetBegin();" << endl;
+ indent_impl(out) << obj << " := iprot.ReadSetBegin();" << '\n';
} else if (ttype->is_list()) {
- indent_impl(out) << obj << " := iprot.ReadListBegin();" << endl;
+ indent_impl(out) << obj << " := iprot.ReadListBegin();" << '\n';
}
- indent_impl(out) << "for " << counter << " := 0 to " << obj << ".Count - 1 do begin" << endl;
+ indent_impl(out) << "for " << counter << " := 0 to " << obj << ".Count - 1 do begin" << '\n';
indent_up_impl();
if (ttype->is_map()) {
generate_deserialize_map_element(out, is_xception, (t_map*)ttype, name, local_vars);
@@ -2731,14 +2729,14 @@
generate_deserialize_list_element(out, is_xception, (t_list*)ttype, name, local_vars);
}
indent_down_impl();
- indent_impl(out) << "end;" << endl;
+ indent_impl(out) << "end;" << '\n';
if (ttype->is_map()) {
- indent_impl(out) << "iprot.ReadMapEnd();" << endl;
+ indent_impl(out) << "iprot.ReadMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent_impl(out) << "iprot.ReadSetEnd();" << endl;
+ indent_impl(out) << "iprot.ReadSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent_impl(out) << "iprot.ReadListEnd();" << endl;
+ indent_impl(out) << "iprot.ReadListEnd();" << '\n';
}
}
@@ -2755,13 +2753,13 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- local_vars << " " << declare_field(&fkey) << endl;
- local_vars << " " << declare_field(&fval) << endl;
+ local_vars << " " << declare_field(&fkey) << '\n';
+ local_vars << " " << declare_field(&fval) << '\n';
generate_deserialize_field(out, is_xception, &fkey, "", local_vars);
generate_deserialize_field(out, is_xception, &fval, "", local_vars);
- indent_impl(out) << prefix << ".AddOrSetValue( " << key << ", " << val << ");" << endl;
+ indent_impl(out) << prefix << ".AddOrSetValue( " << key << ", " << val << ");" << '\n';
}
void t_delphi_generator::generate_deserialize_set_element(ostream& out,
@@ -2771,9 +2769,9 @@
ostream& local_vars) {
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
- local_vars << " " << declare_field(&felem) << endl;
+ local_vars << " " << declare_field(&felem) << '\n';
generate_deserialize_field(out, is_xception, &felem, "", local_vars);
- indent_impl(out) << prefix << ".Add(" << elem << ");" << endl;
+ indent_impl(out) << prefix << ".Add(" << elem << ");" << '\n';
}
void t_delphi_generator::generate_deserialize_list_element(ostream& out,
@@ -2783,9 +2781,9 @@
ostream& local_vars) {
string elem = tmp("_elem");
t_field felem(tlist->get_elem_type(), elem);
- local_vars << " " << declare_field(&felem) << endl;
+ local_vars << " " << declare_field(&felem) << '\n';
generate_deserialize_field(out, is_xception, &felem, "", local_vars);
- indent_impl(out) << prefix << ".Add(" << elem << ");" << endl;
+ indent_impl(out) << prefix << ".Add(" << elem << ");" << '\n';
}
void t_delphi_generator::generate_serialize_field(ostream& out,
@@ -2856,7 +2854,7 @@
} else if (type->is_enum()) {
out << "WriteI32(System.Integer(" << name << "));";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE '%s%s' TYPE '%s'\n",
prefix.c_str(),
@@ -2871,7 +2869,7 @@
ostream& local_vars) {
(void)local_vars;
(void)tstruct;
- out << indent_impl() << prefix << ".Write(oprot);" << endl;
+ out << indent_impl() << prefix << ".Write(oprot);" << '\n';
}
void t_delphi_generator::generate_serialize_container(ostream& out,
@@ -2882,42 +2880,42 @@
string obj;
if (ttype->is_map()) {
obj = tmp("map");
- local_vars << " " << obj << " : TThriftMap;" << endl;
+ local_vars << " " << obj << " : TThriftMap;" << '\n';
indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", "
<< type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix
- << ".Count);" << endl;
- indent_impl(out) << "oprot.WriteMapBegin( " << obj << ");" << endl;
+ << ".Count);" << '\n';
+ indent_impl(out) << "oprot.WriteMapBegin( " << obj << ");" << '\n';
} else if (ttype->is_set()) {
obj = tmp("set_");
- local_vars << " " << obj << " : TThriftSet;" << endl;
+ local_vars << " " << obj << " : TThriftSet;" << '\n';
indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", "
<< type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << prefix
- << ".Count);" << endl;
- indent_impl(out) << "oprot.WriteSetBegin( " << obj << ");" << endl;
+ << ".Count);" << '\n';
+ indent_impl(out) << "oprot.WriteSetBegin( " << obj << ");" << '\n';
} else if (ttype->is_list()) {
obj = tmp("list_");
- local_vars << " " << obj << " : TThriftList;" << endl;
+ local_vars << " " << obj << " : TThriftList;" << '\n';
indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", "
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix
- << ".Count);" << endl;
- indent_impl(out) << "oprot.WriteListBegin( " << obj << ");" << endl;
+ << ".Count);" << '\n';
+ indent_impl(out) << "oprot.WriteListBegin( " << obj << ");" << '\n';
}
string iter = tmp("_iter");
if (ttype->is_map()) {
- local_vars << " " << iter << ": " << type_name(((t_map*)ttype)->get_key_type()) << ";" << endl;
- indent_impl(out) << "for " << iter << " in " << prefix << ".Keys do begin" << endl;
+ local_vars << " " << iter << ": " << type_name(((t_map*)ttype)->get_key_type()) << ";" << '\n';
+ indent_impl(out) << "for " << iter << " in " << prefix << ".Keys do begin" << '\n';
indent_up_impl();
} else if (ttype->is_set()) {
local_vars << " " << iter << ": " << type_name(((t_set*)ttype)->get_elem_type()) << ";"
- << endl;
- indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << endl;
+ << '\n';
+ indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << '\n';
indent_up_impl();
} else if (ttype->is_list()) {
local_vars << " " << iter << ": " << type_name(((t_list*)ttype)->get_elem_type()) << ";"
- << endl;
- indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << endl;
+ << '\n';
+ indent_impl(out) << "for " << iter << " in " << prefix << " do begin" << '\n';
indent_up_impl();
}
@@ -2930,14 +2928,14 @@
}
indent_down_impl();
- indent_impl(out) << "end;" << endl;
+ indent_impl(out) << "end;" << '\n';
if (ttype->is_map()) {
- indent_impl(out) << "oprot.WriteMapEnd();" << endl;
+ indent_impl(out) << "oprot.WriteMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent_impl(out) << "oprot.WriteSetEnd();" << endl;
+ indent_impl(out) << "oprot.WriteSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent_impl(out) << "oprot.WriteListEnd();" << endl;
+ indent_impl(out) << "oprot.WriteListEnd();" << '\n';
}
}
@@ -2989,10 +2987,10 @@
bool is_xception = ftype->is_xception();
generate_delphi_doc(out, tfield);
indent(out) << "property " << prop_name(tfield, struct_is_xception) << ": "
- << type_name(ftype, false, true, is_xception, true)
- << " read " << prop_name(tfield, struct_is_xception, fieldPrefix)
- << " write " << prop_name(tfield, struct_is_xception, "Set")
- << ";" << endl;
+ << type_name(ftype, false, true, is_xception, true)
+ << " read " << prop_name(tfield, struct_is_xception, fieldPrefix)
+ << " write " << prop_name(tfield, struct_is_xception, "Set")
+ << ";" << '\n';
}
std::string t_delphi_generator::prop_name(t_field* tfield, bool is_xception, std::string prefix) {
@@ -3217,7 +3215,7 @@
}
string signature = "";
-
+
if( for_async) {
if (is_void(ttype)) {
signature = "function " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "Async("
@@ -3296,10 +3294,10 @@
if (line.size() > 80) {
if (firstline) {
- result << endl << newline_indent;
+ result << '\n' << newline_indent;
firstline = false;
}
- result << line << endl;
+ result << line << '\n';
line = newline_indent;
} else if (line.size() > 0) {
line += " ";
@@ -3419,7 +3417,7 @@
indent(out) << "procedure " << prop_name(tfield, is_xception_class, "Set")
<< "( const Value: " << type_name(ftype, false, true, is_xception, true) << ");"
- << endl;
+ << '\n';
}
void t_delphi_generator::generate_delphi_property_reader_definition(ostream& out,
@@ -3429,14 +3427,14 @@
bool is_xception = ftype->is_xception();
indent(out) << "function " << prop_name(tfield, is_xception_class, "Get") << ": "
- << type_name(ftype, false, true, is_xception, true) << ";" << endl;
+ << type_name(ftype, false, true, is_xception, true) << ";" << '\n';
}
void t_delphi_generator::generate_delphi_isset_reader_writer_definition(ostream& out,
t_field* tfield,
bool is_xception) {
- indent(out) << "function " << prop_name(tfield, is_xception,"Get__isset_") << ": System.Boolean;" << endl;
- indent(out) << "procedure " << prop_name(tfield, is_xception, "Set__isset_") << "( const value : System.Boolean);" << endl;
+ indent(out) << "function " << prop_name(tfield, is_xception,"Get__isset_") << ": System.Boolean;" << '\n';
+ indent(out) << "procedure " << prop_name(tfield, is_xception, "Set__isset_") << "( const value : System.Boolean);" << '\n';
}
void t_delphi_generator::generate_delphi_clear_union_value(ostream& out,
@@ -3460,14 +3458,14 @@
bool is_xception = ftype->is_xception();
indent_impl(out) << "if " << prop_name(tfield, is_xception_class,"F__isset_") << " then begin"
- << endl;
+ << '\n';
indent_up_impl();
- indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := False;" << endl;
+ indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := False;" << '\n';
indent_impl(out) << prop_name(tfield, is_xception_class,fieldPrefix) << " := "
<< "Default( " << type_name(ftype, false, true, is_xception, true) << ");"
- << endl;
+ << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl;
+ indent_impl(out) << "end;" << '\n';
}
void t_delphi_generator::generate_delphi_property_writer_impl(ostream& out,
@@ -3488,24 +3486,24 @@
indent_impl(out) << "procedure " << cls_prefix << name << "."
<< prop_name(tfield, is_xception_class,"Set")
<< "( const Value: " << type_name(ftype, false, true, is_xception, true) << ");"
- << endl;
- indent_impl(out) << "begin" << endl;
+ << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
if (is_union) {
- indent_impl(out) << "ClearUnionValues;" << endl;
+ indent_impl(out) << "ClearUnionValues;" << '\n';
}
if (tfield->get_req() != t_field::T_REQUIRED) {
- indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := True;" << endl;
+ indent_impl(out) << prop_name(tfield, is_xception_class,"F__isset_") << " := True;" << '\n';
}
- indent_impl(out) << prop_name(tfield, is_xception_class,fieldPrefix) << " := Value;" << endl;
+ indent_impl(out) << prop_name(tfield, is_xception_class,fieldPrefix) << " := Value;" << '\n';
if (is_xception_class && (!is_xception_factory)) {
indent_impl(out) << xception_factory_name << "." << prop_name(tfield, is_xception_class)
- << " := Value;" << endl;
+ << " := Value;" << '\n';
}
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_delphi_property_reader_impl(ostream& out,
@@ -3522,13 +3520,13 @@
indent_impl(out) << "function " << cls_prefix << name << "."
<< prop_name(tfield, is_xception_class,"Get") << ": "
- << type_name(ftype, false, true, is_xception, true) << ";" << endl;
- indent_impl(out) << "begin" << endl;
+ << type_name(ftype, false, true, is_xception, true) << ";" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
indent_impl(out) << "Result := " << prop_name(tfield, is_xception_class,fieldPrefix) << ";"
- << endl;
+ << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_delphi_isset_reader_writer_impl(ostream& out,
@@ -3541,22 +3539,22 @@
(void)type;
string isset_name = prop_name(tfield, is_xception, "__isset_");
-
+
indent_impl(out) << "function " << cls_prefix << name << "."
- << "Get" << isset_name << ": System.Boolean;" << endl;
- indent_impl(out) << "begin" << endl;
+ << "Get" << isset_name << ": System.Boolean;" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << "Result := " << fieldPrefix << isset_name << ";" << endl;
+ indent_impl(out) << "Result := " << fieldPrefix << isset_name << ";" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
-
+ indent_impl(out) << "end;" << '\n' << '\n';
+
indent_impl(out) << "procedure " << cls_prefix << name << "."
- << "Set" << isset_name << "( const value: System.Boolean);" << endl;
- indent_impl(out) << "begin" << endl;
+ << "Set" << isset_name << "( const value: System.Boolean);" << '\n';
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << fieldPrefix << isset_name << " := value;" << endl;
+ indent_impl(out) << fieldPrefix << isset_name << " := value;" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_delphi_create_exception_impl(ostream& out,
@@ -3569,14 +3567,14 @@
string cls_nm = type_name(tstruct, true, false, is_exception, is_exception);
indent_impl(out) << "function " << cls_nm << ".CreateException: " << exception_cls_nm << ";"
- << endl;
+ << '\n';
- indent_impl(out) << "begin" << endl;
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << "Result := " << exception_cls_nm << ".Create;" << endl;
+ indent_impl(out) << "Result := " << exception_cls_nm << ".Create;" << '\n';
string factory_name = normalize_clsnm(tstruct->get_name(), "", true) + "Factory";
- indent_impl(out) << "Result.F" << factory_name << " := Self;" << endl;
+ indent_impl(out) << "Result.F" << factory_name << " := Self;" << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -3586,20 +3584,20 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
propname = prop_name(*f_iter, is_exception);
if ((*f_iter)->get_req() != t_field::T_REQUIRED) {
- indent_impl(out) << "if " << prop_name(*f_iter, is_exception,"__isset_") << " then begin" << endl;
+ indent_impl(out) << "if " << prop_name(*f_iter, is_exception,"__isset_") << " then begin" << '\n';
indent_up_impl();
}
- indent_impl(out) << "Result." << propname << " := " << propname << ";" << endl;
+ indent_impl(out) << "Result." << propname << " := " << propname << ";" << '\n';
if ((*f_iter)->get_req() != t_field::T_REQUIRED) {
indent_down_impl();
- indent_impl(out) << "end;" << endl;
+ indent_impl(out) << "end;" << '\n';
}
}
- indent_impl(out) << "Result.UpdateMessageProperty;" << endl;
+ indent_impl(out) << "Result.UpdateMessageProperty;" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out,
@@ -3614,53 +3612,53 @@
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- indent_impl(code_block) << "begin" << endl;
+ indent_impl(code_block) << "begin" << '\n';
indent_up_impl();
- indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl;
- indent_impl(code_block) << "tracker := iprot.NextRecursionLevel;" << endl;
+ indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << '\n';
+ indent_impl(code_block) << "tracker := iprot.NextRecursionLevel;" << '\n';
// local bools for required fields
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
indent_impl(local_vars) << prop_name(*f_iter, is_exception,"_req_isset_") << " : System.Boolean;"
- << endl;
+ << '\n';
indent_impl(code_block) << prop_name(*f_iter, is_exception,"_req_isset_") << " := FALSE;"
- << endl;
+ << '\n';
}
}
- indent_impl(code_block) << "struc := iprot.ReadStructBegin;" << endl;
+ indent_impl(code_block) << "struc := iprot.ReadStructBegin;" << '\n';
- indent_impl(code_block) << "try" << endl;
+ indent_impl(code_block) << "try" << '\n';
indent_up_impl();
- indent_impl(code_block) << "while (true) do begin" << endl;
+ indent_impl(code_block) << "while (true) do begin" << '\n';
indent_up_impl();
- indent_impl(code_block) << "field_ := iprot.ReadFieldBegin();" << endl;
+ indent_impl(code_block) << "field_ := iprot.ReadFieldBegin();" << '\n';
- indent_impl(code_block) << "if (field_.Type_ = TType.Stop) then Break;" << endl;
+ indent_impl(code_block) << "if (field_.Type_ = TType.Stop) then Break;" << '\n';
bool first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (first) {
- code_block << endl;
- indent_impl(code_block) << "case field_.ID of" << endl;
+ code_block << '\n';
+ indent_impl(code_block) << "case field_.ID of" << '\n';
indent_up_impl();
}
first = false;
if (f_iter != fields.begin()) {
- code_block << endl;
+ code_block << '\n';
}
- indent_impl(code_block) << (*f_iter)->get_key() << ": begin" << endl;
+ indent_impl(code_block) << (*f_iter)->get_key() << ": begin" << '\n';
indent_up_impl();
indent_impl(code_block) << "if (field_.Type_ = " << type_to_enum((*f_iter)->get_type())
- << ") then begin" << endl;
+ << ") then begin" << '\n';
indent_up_impl();
generate_deserialize_field(code_block, is_exception, *f_iter, "Self.", local_vars);
@@ -3668,82 +3666,82 @@
// required field?
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
indent_impl(code_block) << prop_name(*f_iter, is_exception,"_req_isset_") << " := TRUE;"
- << endl;
+ << '\n';
}
indent_down_impl();
- indent_impl(code_block) << "end else begin" << endl;
+ indent_impl(code_block) << "end else begin" << '\n';
indent_up_impl();
- indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << endl;
+ indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << '\n';
indent_down_impl();
- indent_impl(code_block) << "end;" << endl;
+ indent_impl(code_block) << "end;" << '\n';
indent_down_impl();
indent_impl(code_block) << "end;";
}
if (!first) {
- code_block << endl;
+ code_block << '\n';
indent_down_impl();
- indent_impl(code_block) << "else" << endl;
+ indent_impl(code_block) << "else" << '\n';
indent_up_impl();
}
- indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << endl;
+ indent_impl(code_block) << "TProtocolUtil.Skip(iprot, field_.Type_);" << '\n';
if (!first) {
indent_down_impl();
- indent_impl(code_block) << "end;" << endl;
+ indent_impl(code_block) << "end;" << '\n';
}
- indent_impl(code_block) << "iprot.ReadFieldEnd;" << endl;
+ indent_impl(code_block) << "iprot.ReadFieldEnd;" << '\n';
indent_down_impl();
- indent_impl(code_block) << "end;" << endl;
+ indent_impl(code_block) << "end;" << '\n';
indent_down_impl();
- indent_impl(code_block) << "finally" << endl;
+ indent_impl(code_block) << "finally" << '\n';
indent_up_impl();
- indent_impl(code_block) << "iprot.ReadStructEnd;" << endl;
+ indent_impl(code_block) << "iprot.ReadStructEnd;" << '\n';
indent_down_impl();
- indent_impl(code_block) << "end;" << endl;
+ indent_impl(code_block) << "end;" << '\n';
// all required fields have been read?
first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
if(first) {
- code_block << endl;
+ code_block << '\n';
first = false;
}
- indent_impl(code_block) << "if not " << prop_name(*f_iter, is_exception,"_req_isset_") << endl;
+ indent_impl(code_block) << "if not " << prop_name(*f_iter, is_exception,"_req_isset_") << '\n';
indent_impl(code_block)
<< "then raise TProtocolExceptionInvalidData.Create("
<< "'required field " << prop_name(*f_iter, is_exception) << " not set');"
- << endl;
+ << '\n';
}
}
-
+
if( is_exception && (!is_x_factory)) {
- code_block << endl;
- indent_impl(code_block) << "UpdateMessageProperty;" << endl;
+ code_block << '\n';
+ indent_impl(code_block) << "UpdateMessageProperty;" << '\n';
}
indent_down_impl();
- indent_impl(code_block) << "end;" << endl << endl;
+ indent_impl(code_block) << "end;" << '\n' << '\n';
string cls_nm;
cls_nm = type_name(tstruct, true, is_exception && (!is_x_factory), is_x_factory, is_x_factory);
indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Read( const iprot: IProtocol);"
- << endl;
- indent_impl(out) << "var" << endl;
+ << '\n';
+ indent_impl(out) << "var" << '\n';
indent_up_impl();
- indent_impl(out) << "field_ : TThriftField;" << endl;
- indent_impl(out) << "struc : TThriftStruct;" << endl;
+ indent_impl(out) << "field_ : TThriftField;" << '\n';
+ indent_impl(out) << "struc : TThriftStruct;" << '\n';
indent_down_impl();
- out << local_vars.str() << endl;
+ out << local_vars.str() << '\n';
out << code_block.str();
}
@@ -3760,51 +3758,51 @@
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- indent_impl(code_block) << "begin" << endl;
+ indent_impl(code_block) << "begin" << '\n';
indent_up_impl();
- indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl;
- indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << endl;
+ indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << '\n';
+ indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << '\n';
- indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << endl;
- indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << endl;
+ indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << '\n';
+ indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << '\n';
if (fields.size() > 0) {
- indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << endl;
+ indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent_impl(code_block) << "if (" << prop_name(*f_iter, is_exception,"__isset_") << ") then"
- << endl;
- indent_impl(code_block) << "begin" << endl;
+ << '\n';
+ indent_impl(code_block) << "begin" << '\n';
indent_up_impl();
- indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << endl;
+ indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << '\n';
indent_impl(code_block) << "field_.Type_ := " << type_to_enum((*f_iter)->get_type()) << ";"
- << endl;
- indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << endl;
- indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << endl;
+ << '\n';
+ indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << '\n';
+ indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << '\n';
generate_serialize_field(code_block, is_exception, *f_iter, "Self.", local_vars);
- indent_impl(code_block) << "oprot.WriteFieldEnd();" << endl;
+ indent_impl(code_block) << "oprot.WriteFieldEnd();" << '\n';
indent_down_impl();
}
}
- indent_impl(code_block) << "oprot.WriteFieldStop();" << endl;
- indent_impl(code_block) << "oprot.WriteStructEnd();" << endl;
+ indent_impl(code_block) << "oprot.WriteFieldStop();" << '\n';
+ indent_impl(code_block) << "oprot.WriteStructEnd();" << '\n';
indent_down_impl();
- indent_impl(code_block) << "end;" << endl << endl;
+ indent_impl(code_block) << "end;" << '\n' << '\n';
string cls_nm;
cls_nm = type_name(tstruct, true, is_exception && (!is_x_factory), is_x_factory, is_x_factory);
indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( const oprot: IProtocol);"
- << endl;
- indent_impl(out) << "var" << endl;
+ << '\n';
+ indent_impl(out) << "var" << '\n';
indent_up_impl();
- indent_impl(out) << "struc : TThriftStruct;" << endl;
+ indent_impl(out) << "struc : TThriftStruct;" << '\n';
if (fields.size() > 0) {
- indent_impl(out) << "field_ : TThriftField;" << endl;
+ indent_impl(out) << "field_ : TThriftField;" << '\n';
}
out << local_vars.str();
@@ -3825,17 +3823,17 @@
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- indent_impl(code_block) << "begin" << endl;
+ indent_impl(code_block) << "begin" << '\n';
indent_up_impl();
- indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl;
- indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << endl;
+ indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << '\n';
+ indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << '\n';
- indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << endl;
- indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << endl;
+ indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << '\n';
+ indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << '\n';
if (fields.size() > 0) {
- indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << endl;
+ indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << '\n';
}
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -3846,54 +3844,54 @@
bool has_isset = (!is_required);
if (is_required && null_allowed) {
null_allowed = false;
- indent_impl(code_block) << "if (Self." << fieldname << " = nil)" << endl;
+ indent_impl(code_block) << "if (Self." << fieldname << " = nil)" << '\n';
indent_impl(code_block) << "then raise TProtocolExceptionInvalidData.Create("
<< "'required field " << fieldname << " not set');"
- << endl;
+ << '\n';
}
if (null_allowed) {
indent_impl(code_block) << "if (Self." << fieldname << " <> nil)";
if (has_isset) {
code_block << " and " << isset_name;
}
- code_block << " then begin" << endl;
+ code_block << " then begin" << '\n';
indent_up_impl();
} else {
if (has_isset) {
- indent_impl(code_block) << "if (" << isset_name << ") then begin" << endl;
+ indent_impl(code_block) << "if (" << isset_name << ") then begin" << '\n';
indent_up_impl();
}
}
- indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << endl;
+ indent_impl(code_block) << "field_.Name := '" << (*f_iter)->get_name() << "';" << '\n';
indent_impl(code_block) << "field_.Type_ := " << type_to_enum((*f_iter)->get_type()) << ";"
- << endl;
- indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << endl;
- indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << endl;
+ << '\n';
+ indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << '\n';
+ indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << '\n';
generate_serialize_field(code_block, is_exception, *f_iter, "Self.", local_vars);
- indent_impl(code_block) << "oprot.WriteFieldEnd();" << endl;
+ indent_impl(code_block) << "oprot.WriteFieldEnd();" << '\n';
if (null_allowed || has_isset) {
indent_down_impl();
- indent_impl(code_block) << "end;" << endl;
+ indent_impl(code_block) << "end;" << '\n';
}
}
- indent_impl(code_block) << "oprot.WriteFieldStop();" << endl;
- indent_impl(code_block) << "oprot.WriteStructEnd();" << endl;
+ indent_impl(code_block) << "oprot.WriteFieldStop();" << '\n';
+ indent_impl(code_block) << "oprot.WriteStructEnd();" << '\n';
indent_down_impl();
- indent_impl(code_block) << "end;" << endl << endl;
+ indent_impl(code_block) << "end;" << '\n' << '\n';
string cls_nm;
cls_nm = type_name(tstruct, true, is_exception && (!is_x_factory), is_x_factory, is_x_factory);
indent_impl(out) << "procedure " << cls_prefix << cls_nm << ".Write( const oprot: IProtocol);"
- << endl;
- indent_impl(out) << "var" << endl;
+ << '\n';
+ indent_impl(out) << "var" << '\n';
indent_up_impl();
- indent_impl(out) << "struc : TThriftStruct;" << endl;
+ indent_impl(out) << "struc : TThriftStruct;" << '\n';
if (fields.size() > 0) {
- indent_impl(out) << "field_ : TThriftField;" << endl;
+ indent_impl(out) << "field_ : TThriftField;" << '\n';
}
out << local_vars.str();
indent_down_impl();
@@ -3921,28 +3919,28 @@
string tmp_first = tmp("_first");
bool useFirstFlag = false;
- indent_impl(out) << "function " << cls_prefix << cls_nm << ".ToString: string;" << endl;
- indent_impl(out) << "var" << endl;
+ indent_impl(out) << "function " << cls_prefix << cls_nm << ".ToString: string;" << '\n';
+ indent_impl(out) << "var" << '\n';
indent_up_impl();
- indent_impl(out) << tmp_sb << " : TThriftStringBuilder;" << endl;
+ indent_impl(out) << tmp_sb << " : TThriftStringBuilder;" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool is_optional = ((*f_iter)->get_req() != t_field::T_REQUIRED);
if (is_optional) {
- indent_impl(out) << tmp_first << " : System.Boolean;" << endl;
+ indent_impl(out) << tmp_first << " : System.Boolean;" << '\n';
useFirstFlag = true;
}
break;
}
indent_down_impl();
- indent_impl(out) << "begin" << endl;
+ indent_impl(out) << "begin" << '\n';
indent_up_impl();
- indent_impl(out) << tmp_sb << " := TThriftStringBuilder.Create('(');" << endl;
- indent_impl(out) << "try" << endl;
+ indent_impl(out) << tmp_sb << " := TThriftStringBuilder.Create('(');" << '\n';
+ indent_impl(out) << "try" << '\n';
indent_up_impl();
if (useFirstFlag) {
- indent_impl(out) << tmp_first << " := TRUE;" << endl;
+ indent_impl(out) << tmp_first << " := TRUE;" << '\n';
}
bool had_required = false; // set to true after first required field has been processed
@@ -3955,26 +3953,26 @@
if (is_optional) {
out << " and " << prop_name(*f_iter, is_exception,"__isset_");
}
- out << " then begin" << endl;
+ out << " then begin" << '\n';
indent_up_impl();
} else {
if (is_optional) {
indent_impl(out) << "if (" << prop_name(*f_iter, is_exception, "__isset_") << ") then begin"
- << endl;
+ << '\n';
indent_up_impl();
}
}
if (useFirstFlag && (!had_required)) {
- indent_impl(out) << "if not " << tmp_first << " then " << tmp_sb << ".Append(',');" << endl;
+ indent_impl(out) << "if not " << tmp_first << " then " << tmp_sb << ".Append(',');" << '\n';
if (is_optional) {
- indent_impl(out) << tmp_first << " := FALSE;" << endl;
+ indent_impl(out) << tmp_first << " := FALSE;" << '\n';
}
indent_impl(out) << tmp_sb << ".Append('" << prop_name((*f_iter), is_exception) << ": ');"
- << endl;
+ << '\n';
} else {
indent_impl(out) << tmp_sb << ".Append(', " << prop_name((*f_iter), is_exception) << ": ');"
- << endl;
+ << '\n';
}
t_type* ttype = (*f_iter)->get_type();
@@ -3985,23 +3983,23 @@
if (ttype->is_xception() || ttype->is_struct()) {
indent_impl(out) << "if (Self." << prop_name((*f_iter), is_exception) << " = nil) then " << tmp_sb
<< ".Append('<null>') else " << tmp_sb << ".Append( Self."
- << prop_name((*f_iter), is_exception) << ".ToString());" << endl;
+ << prop_name((*f_iter), is_exception) << ".ToString());" << '\n';
} else if (ttype->is_enum()) {
- indent_impl(out) << tmp_sb << ".Append(EnumUtils<"
- << type_name(ttype, false, true, false, false)
- << ">.ToString( System.Ord( Self."
- << prop_name((*f_iter), is_exception) << ")));" << endl;
+ indent_impl(out) << tmp_sb << ".Append(EnumUtils<"
+ << type_name(ttype, false, true, false, false)
+ << ">.ToString( System.Ord( Self."
+ << prop_name((*f_iter), is_exception) << ")));" << '\n';
} else if (ttype->is_uuid()) {
indent_impl(out) << tmp_sb << ".Append( GUIDToString(Self." << prop_name((*f_iter), is_exception) << "));"
- << endl;
+ << '\n';
} else {
indent_impl(out) << tmp_sb << ".Append( Self." << prop_name((*f_iter), is_exception) << ");"
- << endl;
+ << '\n';
}
if (null_allowed || is_optional) {
indent_down_impl();
- indent_impl(out) << "end;" << endl;
+ indent_impl(out) << "end;" << '\n';
}
if (!is_optional) {
@@ -4009,21 +4007,21 @@
}
}
- indent_impl(out) << tmp_sb << ".Append(')');" << endl;
- indent_impl(out) << "Result := " << tmp_sb << ".ToString;" << endl;
+ indent_impl(out) << tmp_sb << ".Append(')');" << '\n';
+ indent_impl(out) << "Result := " << tmp_sb << ".ToString;" << '\n';
if (useFirstFlag) {
- indent_impl(out) << "if " << tmp_first << " then {prevent warning};" << endl;
+ indent_impl(out) << "if " << tmp_first << " then {prevent warning};" << '\n';
}
indent_down_impl();
- indent_impl(out) << "finally" << endl;
+ indent_impl(out) << "finally" << '\n';
indent_up_impl();
- indent_impl(out) << tmp_sb << ".Free;" << endl;
+ indent_impl(out) << tmp_sb << ".Free;" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl;
+ indent_impl(out) << "end;" << '\n';
indent_down_impl();
- indent_impl(out) << "end;" << endl << endl;
+ indent_impl(out) << "end;" << '\n' << '\n';
}
bool t_delphi_generator::is_void(t_type* type) {
diff --git a/compiler/cpp/src/thrift/generate/t_erl_generator.cc b/compiler/cpp/src/thrift/generate/t_erl_generator.cc
index 7293972..f28c7fd 100644
--- a/compiler/cpp/src/thrift/generate/t_erl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_erl_generator.cc
@@ -39,8 +39,6 @@
using std::stringstream;
using std::vector;
-static const std::string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* Erlang code generator.
*
@@ -268,14 +266,14 @@
hrl_header(f_types_hrl_file_, program_module_name + "_types");
- f_types_file_ << erl_autogen_comment() << endl
- << "-module(" << program_module_name << "_types)." << endl
- << erl_imports() << endl;
+ f_types_file_ << erl_autogen_comment() << '\n'
+ << "-module(" << program_module_name << "_types)." << '\n'
+ << erl_imports() << '\n';
- f_types_file_ << "-include(\"" << program_module_name << "_types.hrl\")." << endl
- << endl;
+ f_types_file_ << "-include(\"" << program_module_name << "_types.hrl\")." << '\n'
+ << '\n';
- f_types_hrl_file_ << render_includes() << endl;
+ f_types_hrl_file_ << render_includes() << '\n';
// consts files
string f_consts_name = get_out_dir() + program_module_name + "_constants.erl";
@@ -284,28 +282,28 @@
f_consts_file_.open(f_consts_name.c_str());
f_consts_hrl_file_.open(f_consts_hrl_name.c_str());
- f_consts_file_ << erl_autogen_comment() << endl
- << "-module(" << program_module_name << "_constants)." << endl
- << erl_imports() << endl
- << "-include(\"" << program_module_name << "_types.hrl\")." << endl
- << endl;
+ f_consts_file_ << erl_autogen_comment() << '\n'
+ << "-module(" << program_module_name << "_constants)." << '\n'
+ << erl_imports() << '\n'
+ << "-include(\"" << program_module_name << "_types.hrl\")." << '\n'
+ << '\n';
- f_consts_hrl_file_ << erl_autogen_comment() << endl << erl_imports() << endl
- << "-include(\"" << program_module_name << "_types.hrl\")." << endl << endl;
+ f_consts_hrl_file_ << erl_autogen_comment() << '\n' << erl_imports() << '\n'
+ << "-include(\"" << program_module_name << "_types.hrl\")." << '\n' << '\n';
}
/**
* Boilerplate at beginning and end of header files
*/
void t_erl_generator::hrl_header(ostream& out, string name) {
- out << erl_autogen_comment() << endl
- << "-ifndef(_" << name << "_included)." << endl << "-define(_" << name << "_included, yeah)."
- << endl;
+ out << erl_autogen_comment() << '\n'
+ << "-ifndef(_" << name << "_included)." << '\n' << "-define(_" << name << "_included, yeah)."
+ << '\n';
}
void t_erl_generator::hrl_footer(ostream& out, string name) {
(void)name;
- out << "-endif." << endl;
+ out << "-endif." << '\n';
}
/**
@@ -365,13 +363,13 @@
export_types_string("struct_names", 0);
export_types_string("exception_names", 0);
- f_types_file_ << "-export([" << export_types_lines_.str() << "])." << endl << endl;
+ f_types_file_ << "-export([" << export_types_lines_.str() << "])." << '\n' << '\n';
f_types_file_ << f_info_.str();
- f_types_file_ << "struct_info(_) -> erlang:error(function_clause)." << endl << endl;
+ f_types_file_ << "struct_info(_) -> erlang:error(function_clause)." << '\n' << '\n';
f_types_file_ << f_info_ext_.str();
- f_types_file_ << "struct_info_ext(_) -> erlang:error(function_clause)." << endl << endl;
+ f_types_file_ << "struct_info_ext(_) -> erlang:error(function_clause)." << '\n' << '\n';
generate_const_functions();
@@ -527,10 +525,10 @@
string name = (*c_iter)->get_name();
indent(f_types_hrl_file_) << "-define(" << constify(make_safe_for_module_name(program_name_))
<< "_" << constify(tenum->get_name()) << "_" << constify(name) << ", "
- << value << ")." << endl;
+ << value << ")." << '\n';
}
- f_types_hrl_file_ << endl;
+ f_types_hrl_file_ << '\n';
}
void t_erl_generator::generate_enum_info(t_enum* tenum){
@@ -551,7 +549,7 @@
}
indent_down();
}
- f_types_file_ << "\n";
+ f_types_file_ << '\n';
indent(f_types_file_) << "];\n\n";
indent_down();
}
@@ -579,7 +577,7 @@
v_consts_.push_back(tconst);
f_consts_hrl_file_ << "-define(" << constify(make_safe_for_module_name(program_name_)) << "_"
- << constify(name) << ", " << render_const_value(type, value) << ")." << endl << endl;
+ << constify(name) << ", " << render_const_value(type, value) << ")." << '\n' << '\n';
}
/**
@@ -809,7 +807,7 @@
* @param tstruct The struct definition
*/
void t_erl_generator::generate_erl_struct_definition(ostream& out, t_struct* tstruct) {
- indent(out) << "%% struct " << type_name(tstruct) << endl << endl;
+ indent(out) << "%% struct " << type_name(tstruct) << '\n' << '\n';
std::stringstream buf;
buf << indent() << "-record(" << type_name(tstruct) << ", {";
@@ -819,13 +817,13 @@
for (vector<t_field*>::const_iterator m_iter = members.begin(); m_iter != members.end();) {
generate_erl_struct_member(buf, *m_iter);
if (++m_iter != members.end()) {
- buf << "," << endl << field_indent;
+ buf << "," << '\n' << field_indent;
}
}
buf << "}).";
- out << buf.str() << endl;
- out << "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}." << endl << endl;
+ out << buf.str() << '\n';
+ out << "-type " + type_name(tstruct) << "() :: #" + type_name(tstruct) + "{}." << '\n' << '\n';
}
/**
@@ -871,19 +869,19 @@
* Generates the read method for a struct
*/
void t_erl_generator::generate_erl_struct_info(ostream& out, t_struct* tstruct) {
- indent(out) << "struct_info(" << type_name(tstruct) << ") ->" << endl;
+ indent(out) << "struct_info(" << type_name(tstruct) << ") ->" << '\n';
indent_up();
- out << indent() << render_type_term(tstruct, true) << ";" << endl;
+ out << indent() << render_type_term(tstruct, true) << ";" << '\n';
indent_down();
- out << endl;
+ out << '\n';
}
void t_erl_generator::generate_erl_extended_struct_info(ostream& out, t_struct* tstruct) {
- indent(out) << "struct_info_ext(" << type_name(tstruct) << ") ->" << endl;
+ indent(out) << "struct_info_ext(" << type_name(tstruct) << ") ->" << '\n';
indent_up();
- out << indent() << render_type_term(tstruct, true, true) << ";" << endl;
+ out << indent() << render_type_term(tstruct, true, true) << ";" << '\n';
indent_down();
- out << endl;
+ out << '\n';
}
/**
@@ -909,11 +907,11 @@
if (tservice->get_extends() != nullptr) {
f_service_hrl_ << "-include(\""
<< make_safe_for_module_name(tservice->get_extends()->get_name())
- << "_thrift.hrl\"). % inherit " << endl;
+ << "_thrift.hrl\"). % inherit " << '\n';
}
f_service_hrl_ << "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")."
- << endl << endl;
+ << '\n' << '\n';
// Generate the three main parts of the service (well, two for now in PHP)
generate_service_helpers(tservice); // cpiro: New Erlang Order
@@ -924,13 +922,13 @@
// indent_down();
- f_service_file_ << erl_autogen_comment() << endl << "-module(" << service_name_ << "_thrift)."
- << endl << "-behaviour(thrift_service)." << endl << endl << erl_imports() << endl;
+ f_service_file_ << erl_autogen_comment() << '\n' << "-module(" << service_name_ << "_thrift)."
+ << '\n' << "-behaviour(thrift_service)." << '\n' << '\n' << erl_imports() << '\n';
f_service_file_ << "-include(\"" << make_safe_for_module_name(tservice->get_name())
- << "_thrift.hrl\")." << endl << endl;
+ << "_thrift.hrl\")." << '\n' << '\n';
- f_service_file_ << "-export([" << export_lines_.str() << "])." << endl << endl;
+ f_service_file_ << "-export([" << export_lines_.str() << "])." << '\n' << '\n';
f_service_file_ << f_service_.str();
@@ -946,7 +944,7 @@
vector<t_function*> functions = tservice->get_functions();
size_t num_functions = functions.size();
- indent(f_service_) << "function_names() -> " << endl;
+ indent(f_service_) << "function_names() -> " << '\n';
indent_up();
indent(f_service_) << "[";
@@ -972,14 +970,14 @@
vector<t_function*>::iterator f_iter;
// indent(f_service_) <<
- // "% HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+ // "% HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n';
export_string("struct_info", 1);
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_erl_function_helpers(*f_iter);
}
- f_service_ << "struct_info(_) -> erlang:error(function_clause)." << endl;
+ f_service_ << "struct_info(_) -> erlang:error(function_clause)." << '\n';
}
/**
@@ -1002,26 +1000,26 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- f_service_ << "%%% interface" << endl;
+ f_service_ << "%%% interface" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- f_service_ << indent() << "% " << function_signature(*f_iter) << endl;
+ f_service_ << indent() << "% " << function_signature(*f_iter) << '\n';
generate_function_info(tservice, *f_iter);
}
// Inheritance - pass unknown functions to base class
if (tservice->get_extends() != nullptr) {
- indent(f_service_) << "function_info(Function, InfoType) ->" << endl;
+ indent(f_service_) << "function_info(Function, InfoType) ->" << '\n';
indent_up();
indent(f_service_) << make_safe_for_module_name(tservice->get_extends()->get_name())
- << "_thrift:function_info(Function, InfoType)." << endl;
+ << "_thrift:function_info(Function, InfoType)." << '\n';
indent_down();
} else {
// return function_clause error for non-existent functions
- indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)." << endl;
+ indent(f_service_) << "function_info(_Func, _Info) -> erlang:error(function_clause)." << '\n';
}
- indent(f_service_) << endl;
+ indent(f_service_) << '\n';
}
/**
@@ -1036,30 +1034,30 @@
t_struct* arg_struct = tfunction->get_arglist();
// function_info(Function, params_type):
- indent(f_service_) << "function_info(" << name_atom << ", params_type) ->" << endl;
+ indent(f_service_) << "function_info(" << name_atom << ", params_type) ->" << '\n';
indent_up();
- indent(f_service_) << render_type_term(arg_struct, true) << ";" << endl;
+ indent(f_service_) << render_type_term(arg_struct, true) << ";" << '\n';
indent_down();
// function_info(Function, reply_type):
- indent(f_service_) << "function_info(" << name_atom << ", reply_type) ->" << endl;
+ indent(f_service_) << "function_info(" << name_atom << ", reply_type) ->" << '\n';
indent_up();
if (!tfunction->get_returntype()->is_void())
- indent(f_service_) << render_type_term(tfunction->get_returntype(), false) << ";" << endl;
+ indent(f_service_) << render_type_term(tfunction->get_returntype(), false) << ";" << '\n';
else if (tfunction->is_oneway())
- indent(f_service_) << "oneway_void;" << endl;
+ indent(f_service_) << "oneway_void;" << '\n';
else
indent(f_service_) << "{struct, []}"
- << ";" << endl;
+ << ";" << '\n';
indent_down();
// function_info(Function, exceptions):
- indent(f_service_) << "function_info(" << name_atom << ", exceptions) ->" << endl;
+ indent(f_service_) << "function_info(" << name_atom << ", exceptions) ->" << '\n';
indent_up();
- indent(f_service_) << render_type_term(xs, true) << ";" << endl;
+ indent(f_service_) << render_type_term(xs, true) << ";" << '\n';
indent_down();
}
@@ -1246,11 +1244,11 @@
}
if (++i != end) {
- buf << "," << endl << field_indent;
+ buf << "," << '\n' << field_indent;
}
}
- buf << "]}" << endl;
+ buf << "]}" << '\n';
return buf.str();
} else {
return "{struct, {" + atomify(type_module(type)) + ", " + type_name(type) + "}}";
diff --git a/compiler/cpp/src/thrift/generate/t_generator.cc b/compiler/cpp/src/thrift/generate/t_generator.cc
index 970281e..6860237 100644
--- a/compiler/cpp/src/thrift/generate/t_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_generator.cc
@@ -77,8 +77,8 @@
}
std::set<std::string> t_generator::lang_keywords_for_validation() const {
- // Nothing by default. It makes no sense to restrict the whole world to use non-PHP keywords only.
- // Override on a per-generator(!) basis if you cannot live without it, e.g. that particular language has no
+ // Nothing by default. It makes no sense to restrict the whole world to use non-PHP keywords only.
+ // Override on a per-generator(!) basis if you cannot live without it, e.g. that particular language has no
// mechanism or way to deal with it properly, so we absolutely need to fail on it as the last possible resort.
return {};
}
@@ -172,11 +172,11 @@
docs.getline(line, 1024);
if (strlen(line) > 0) {
- indent(out) << line_prefix << line << std::endl;
+ indent(out) << line_prefix << line << '\n';
} else if (line_prefix.empty()){
- out << std::endl;
+ out << '\n';
} else if(!docs.eof()) {
- indent(out) << line_prefix << std::endl;
+ indent(out) << line_prefix << '\n';
}
}
if (!comment_end.empty())
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc
index db30c8b..72a9f06 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -518,7 +518,7 @@
f_consts_ << go_autogen_comment() << go_package() << render_includes(true);
- f_const_values_ << endl << "func init() {" << endl;
+ f_const_values_ << '\n' << "func init() {" << '\n';
// Create file for the GoUnusedProtection__ variable
string f_unused_prot_name_ = package_dir_ + "/" + "GoUnusedProtection__.go";
@@ -744,7 +744,7 @@
* Closes the type files
*/
void t_go_generator::close_generator() {
- f_const_values_ << "}" << endl << endl;
+ f_const_values_ << "}" << '\n' << '\n';
f_consts_ << f_const_values_.str();
// Close types and constants files
@@ -768,11 +768,11 @@
return;
}
- f_types_ << "type " << new_type_name << " " << base_type << endl << endl;
+ f_types_ << "type " << new_type_name << " " << base_type << '\n' << '\n';
// Generate a convenience function that converts an instance of a type
// (which may be a constant) into a pointer to an instance of a type.
f_types_ << "func " << new_type_name << "Ptr(v " << new_type_name << ") *" << new_type_name
- << " { return &v }" << endl << endl;
+ << " { return &v }" << '\n' << '\n';
}
/**
@@ -785,14 +785,14 @@
std::ostringstream to_string_mapping, from_string_mapping;
std::string tenum_name(publicize(tenum->get_name()));
generate_go_docstring(f_types_, tenum);
- f_types_ << "type " << tenum_name << " int64" << endl << "const (" << endl;
+ f_types_ << "type " << tenum_name << " int64" << '\n' << "const (" << '\n';
- to_string_mapping << indent() << "func (p " << tenum_name << ") String() string {" << endl;
- to_string_mapping << indent() << " switch p {" << endl;
+ to_string_mapping << indent() << "func (p " << tenum_name << ") String() string {" << '\n';
+ to_string_mapping << indent() << " switch p {" << '\n';
from_string_mapping << indent() << "func " << tenum_name << "FromString(s string) (" << tenum_name
- << ", error) {" << endl;
- from_string_mapping << indent() << " switch s {" << endl;
+ << ", error) {" << '\n';
+ from_string_mapping << indent() << " switch s {" << '\n';
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
@@ -804,68 +804,68 @@
string iter_std_name(escape_string((*c_iter)->get_name()));
string iter_name((*c_iter)->get_name());
f_types_ << indent() << " " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = "
- << value << endl;
+ << value << '\n';
// Dictionaries to/from string names of enums
to_string_mapping << indent() << " case " << tenum_name << "_" << iter_name << ": return \""
- << iter_std_name << "\"" << endl;
+ << iter_std_name << "\"" << '\n';
if (iter_std_name != escape_string(iter_name)) {
from_string_mapping << indent() << " case \"" << iter_std_name << "\", \""
<< escape_string(iter_name) << "\": return " << tenum_name << "_"
- << iter_name << ", nil " << endl;
+ << iter_name << ", nil " << '\n';
} else {
from_string_mapping << indent() << " case \"" << iter_std_name << "\": return " << tenum_name
- << "_" << iter_name << ", nil " << endl;
+ << "_" << iter_name << ", nil " << '\n';
}
}
- to_string_mapping << indent() << " }" << endl;
- to_string_mapping << indent() << " return \"<UNSET>\"" << endl;
- to_string_mapping << indent() << "}" << endl;
- from_string_mapping << indent() << " }" << endl;
+ to_string_mapping << indent() << " }" << '\n';
+ to_string_mapping << indent() << " return \"<UNSET>\"" << '\n';
+ to_string_mapping << indent() << "}" << '\n';
+ from_string_mapping << indent() << " }" << '\n';
from_string_mapping << indent() << " return " << tenum_name << "(0),"
- << " fmt.Errorf(\"not a valid " << tenum_name << " string\")" << endl;
- from_string_mapping << indent() << "}" << endl;
+ << " fmt.Errorf(\"not a valid " << tenum_name << " string\")" << '\n';
+ from_string_mapping << indent() << "}" << '\n';
- f_types_ << ")" << endl << endl << to_string_mapping.str() << endl << from_string_mapping.str()
- << endl << endl;
+ f_types_ << ")" << '\n' << '\n' << to_string_mapping.str() << '\n' << from_string_mapping.str()
+ << '\n' << '\n';
// Generate a convenience function that converts an instance of an enum
// (which may be a constant) into a pointer to an instance of that enum
// type.
f_types_ << "func " << tenum_name << "Ptr(v " << tenum_name << ") *" << tenum_name
- << " { return &v }" << endl << endl;
+ << " { return &v }" << '\n' << '\n';
// Generate MarshalText
- f_types_ << "func (p " << tenum_name << ") MarshalText() ([]byte, error) {" << endl;
- f_types_ << "return []byte(p.String()), nil" << endl;
- f_types_ << "}" << endl << endl;
+ f_types_ << "func (p " << tenum_name << ") MarshalText() ([]byte, error) {" << '\n';
+ f_types_ << "return []byte(p.String()), nil" << '\n';
+ f_types_ << "}" << '\n' << '\n';
// Generate UnmarshalText
- f_types_ << "func (p *" << tenum_name << ") UnmarshalText(text []byte) error {" << endl;
- f_types_ << "q, err := " << tenum_name << "FromString(string(text))" << endl;
- f_types_ << "if (err != nil) {" << endl << "return err" << endl << "}" << endl;
- f_types_ << "*p = q" << endl;
- f_types_ << "return nil" << endl;
- f_types_ << "}" << endl << endl;
+ f_types_ << "func (p *" << tenum_name << ") UnmarshalText(text []byte) error {" << '\n';
+ f_types_ << "q, err := " << tenum_name << "FromString(string(text))" << '\n';
+ f_types_ << "if (err != nil) {" << '\n' << "return err" << '\n' << "}" << '\n';
+ f_types_ << "*p = q" << '\n';
+ f_types_ << "return nil" << '\n';
+ f_types_ << "}" << '\n' << '\n';
// Generate Scan for sql.Scanner interface
- f_types_ << "func (p *" << tenum_name << ") Scan(value interface{}) error {" <<endl;
- f_types_ << "v, ok := value.(int64)" <<endl;
- f_types_ << "if !ok {" <<endl;
- f_types_ << "return errors.New(\"Scan value is not int64\")" <<endl;
- f_types_ << "}" <<endl;
- f_types_ << "*p = " << tenum_name << "(v)" << endl;
- f_types_ << "return nil" << endl;
- f_types_ << "}" << endl << endl;
+ f_types_ << "func (p *" << tenum_name << ") Scan(value interface{}) error {" << '\n';
+ f_types_ << "v, ok := value.(int64)" << '\n';
+ f_types_ << "if !ok {" << '\n';
+ f_types_ << "return errors.New(\"Scan value is not int64\")" << '\n';
+ f_types_ << "}" << '\n';
+ f_types_ << "*p = " << tenum_name << "(v)" << '\n';
+ f_types_ << "return nil" << '\n';
+ f_types_ << "}" << '\n' << '\n';
// Generate Value for driver.Valuer interface
- f_types_ << "func (p * " << tenum_name << ") Value() (driver.Value, error) {" <<endl;
- f_types_ << " if p == nil {" << endl;
- f_types_ << " return nil, nil" << endl;
- f_types_ << " }" << endl;
- f_types_ << "return int64(*p), nil" << endl;
- f_types_ << "}" << endl;
+ f_types_ << "func (p * " << tenum_name << ") Value() (driver.Value, error) {" << '\n';
+ f_types_ << " if p == nil {" << '\n';
+ f_types_ << " return nil, nil" << '\n';
+ f_types_ << " }" << '\n';
+ f_types_ << "return int64(*p), nil" << '\n';
+ f_types_ << "}" << '\n';
}
@@ -877,12 +877,12 @@
string name = publicize(tconst->get_name());
t_const_value* value = tconst->get_value();
if (type->is_enum() || (type->is_base_type() && ((t_base_type*)type)->get_base() != t_base_type::TYPE_UUID)) {
- indent(f_consts_) << "const " << name << " = " << render_const_value(type, value, name) << endl;
+ indent(f_consts_) << "const " << name << " = " << render_const_value(type, value, name) << '\n';
} else {
- f_const_values_ << indent() << name << " = " << render_const_value(type, value, name) << endl
- << endl;
+ f_const_values_ << indent() << name << " = " << render_const_value(type, value, name) << '\n'
+ << '\n';
- f_consts_ << indent() << "var " << name << " " << type_to_go_type(type) << endl;
+ f_consts_ << indent() << "var " << name << " " << type_to_go_type(type) << '\n';
}
}
@@ -1079,8 +1079,8 @@
if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
- out << endl << indent() << publicize(v_iter->first->get_string()) << ": "
- << render_const_value(field_type, v_iter->second, name, is_optional) << "," << endl;
+ out << '\n' << indent() << publicize(v_iter->first->get_string()) << ": "
+ << render_const_value(field_type, v_iter->second, name, is_optional) << "," << '\n';
}
indent_down();
@@ -1090,13 +1090,13 @@
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
- out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_type(vtype) << "{" << endl;
+ out << "map[" << type_to_go_key_type(ktype) << "]" << type_to_go_type(vtype) << "{" << '\n';
indent_up();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << indent() << render_const_value(ktype, v_iter->first, name) << ": "
- << render_const_value(vtype, v_iter->second, name) << "," << endl;
+ << render_const_value(vtype, v_iter->second, name) << "," << '\n';
}
indent_down();
@@ -1104,7 +1104,7 @@
} else if (type->is_list()) {
t_type* etype = ((t_list*)type)->get_elem_type();
const vector<t_const_value*>& val = value->get_list();
- out << "[]" << type_to_go_type(etype) << "{" << endl;
+ out << "[]" << type_to_go_type(etype) << "{" << '\n';
indent_up();
vector<t_const_value*>::const_iterator v_iter;
@@ -1117,7 +1117,7 @@
} else if (type->is_set()) {
t_type* etype = ((t_set*)type)->get_elem_type();
const vector<t_const_value*>& val = value->get_list();
- out << "[]" << type_to_go_type(etype) << "{" << endl;
+ out << "[]" << type_to_go_type(etype) << "{" << '\n';
indent_up();
vector<t_const_value*>::const_iterator v_iter;
@@ -1158,12 +1158,12 @@
generate_go_struct_definition(f_types_, tstruct, is_exception);
// generate Validate function
std::string tstruct_name(publicize(tstruct->get_name(), false));
- f_types_ << "func (p *" << tstruct_name << ") Validate() error {" << endl;
+ f_types_ << "func (p *" << tstruct_name << ") Validate() error {" << '\n';
indent_up();
go_validator_generator(this).generate_struct_validator(f_types_, tstruct);
- f_types_ << indent() << "return nil" << endl;
+ f_types_ << indent() << "return nil" << '\n';
indent_down();
- f_types_ << "}" << endl;
+ f_types_ << "}" << '\n';
}
void t_go_generator::get_publicized_name_and_def_value(t_field* tfield,
@@ -1186,13 +1186,13 @@
t_const_value* def_value;
get_publicized_name_and_def_value(member, &publicized_name, &def_value);
if (!pointer_field && def_value != nullptr && !omit_initialization(member)) {
- out << endl << indent() << publicized_name << ": "
+ out << '\n' << indent() << publicized_name << ": "
<< render_field_initial_value(member, member->get_name(), pointer_field) << ","
- << endl;
+ << '\n';
}
}
- out << "}" << endl;
+ out << "}" << '\n';
}
/**
@@ -1211,7 +1211,7 @@
std::string tstruct_name(publicize(tstruct->get_name(), is_args || is_result));
generate_go_docstring(out, tstruct);
- out << indent() << "type " << tstruct_name << " struct {" << endl;
+ out << indent() << "type " << tstruct_name << " struct {" << '\n';
/*
Here we generate the structure specification for the fastbinary codec.
These specifications have the following structure:
@@ -1253,9 +1253,9 @@
}
int last_unused = sorted_keys_pos - 1;
if (first_unused < last_unused) {
- indent(out) << "// unused fields # " << first_unused << " to " << last_unused << endl;
+ indent(out) << "// unused fields # " << first_unused << " to " << last_unused << '\n';
} else if (first_unused == last_unused) {
- indent(out) << "// unused field # " << first_unused << endl;
+ indent(out) << "// unused field # " << first_unused << '\n';
}
}
@@ -1296,25 +1296,25 @@
out << ",required";
}
- out << "\" " << gotag << "`" << endl;
+ out << "\" " << gotag << "`" << '\n';
sorted_keys_pos++;
}
} else {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
// This fills in default values, as opposed to nulls
out << indent() << publicize((*m_iter)->get_name()) << " "
- << type_to_go_type((*m_iter)->get_type()) << endl;
+ << type_to_go_type((*m_iter)->get_type()) << '\n';
}
}
indent_down();
- out << indent() << "}" << endl << endl;
- out << indent() << "func New" << tstruct_name << "() *" << tstruct_name << " {" << endl;
+ out << indent() << "}" << '\n' << '\n';
+ out << indent() << "func New" << tstruct_name << "() *" << tstruct_name << " {" << '\n';
indent_up();
out << indent() << "return &";
generate_go_struct_initializer(out, tstruct, is_result || is_args);
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
// Default values for optional fields
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string publicized_name;
@@ -1328,7 +1328,7 @@
if (def_value != nullptr) {
out << " = " << render_const_value(fieldType, def_value, (*m_iter)->get_name());
}
- out << endl;
+ out << '\n';
}
// num_setable is used for deciding if Count* methods will be generated for union fields.
@@ -1342,24 +1342,24 @@
string goOptType = type_to_go_type_with_opt(fieldType, true);
string maybepointer = goOptType != goType ? "*" : "";
out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() "
- << goType << " {" << endl;
+ << goType << " {" << '\n';
indent_up();
- out << indent() << "if !p.IsSet" << publicized_name << "() {" << endl;
+ out << indent() << "if !p.IsSet" << publicized_name << "() {" << '\n';
indent_up();
- out << indent() << "return " << def_var_name << endl;
+ out << indent() << "return " << def_var_name << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "return " << maybepointer << "p." << publicized_name << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "return " << maybepointer << "p." << publicized_name << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else {
- out << endl;
+ out << '\n';
out << indent() << "func (p *" << tstruct_name << ") Get" << publicized_name << "() "
- << goType << " {" << endl;
+ << goType << " {" << '\n';
indent_up();
- out << indent() << "return p." << publicized_name << endl;
+ out << indent() << "return p." << publicized_name << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
@@ -1374,57 +1374,57 @@
generate_go_struct_equals(out, tstruct, tstruct_name);
}
- out << indent() << "func (p *" << tstruct_name << ") String() string {" << endl;
+ out << indent() << "func (p *" << tstruct_name << ") String() string {" << '\n';
indent_up();
- out << indent() << "if p == nil {" << endl;
+ out << indent() << "if p == nil {" << '\n';
indent_up();
- out << indent() << "return \"<nil>\"" << endl;
+ out << indent() << "return \"<nil>\"" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
out << indent() << "return fmt.Sprintf(\"" << escape_string(tstruct_name) << "(%+v)\", *p)"
- << endl;
+ << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
if (is_exception) {
- out << indent() << "func (p *" << tstruct_name << ") Error() string {" << endl;
+ out << indent() << "func (p *" << tstruct_name << ") Error() string {" << '\n';
indent_up();
- out << indent() << "return p.String()" << endl;
+ out << indent() << "return p.String()" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
- out << indent() << "func (" << tstruct_name << ") TExceptionType() thrift.TExceptionType {" << endl;
+ out << indent() << "func (" << tstruct_name << ") TExceptionType() thrift.TExceptionType {" << '\n';
indent_up();
- out << indent() << "return thrift.TExceptionTypeCompiled" << endl;
+ out << indent() << "return thrift.TExceptionTypeCompiled" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
out << indent() << "var _ thrift.TException = (*" << tstruct_name << ")(nil)"
- << endl << endl;
+ << '\n' << '\n';
}
if (!read_write_private_) {
// Generate the implementation of slog.LogValuer,
// see: https://issues.apache.org/jira/browse/THRIFT-5745
- out << indent() << "func (p *" << tstruct_name << ") LogValue() slog.Value {" << endl;
+ out << indent() << "func (p *" << tstruct_name << ") LogValue() slog.Value {" << '\n';
indent_up();
- out << indent() << "if p == nil {" << endl;
+ out << indent() << "if p == nil {" << '\n';
indent_up();
- out << indent() << "return slog.AnyValue(nil)" << endl;
+ out << indent() << "return slog.AnyValue(nil)" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "v := thrift.SlogTStructWrapper{" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "v := thrift.SlogTStructWrapper{" << '\n';
indent_up();
- out << indent() << "Type: \"*" << package_name_ << "." << tstruct_name << "\"," << endl;
- out << indent() << "Value: p," << endl;
+ out << indent() << "Type: \"*" << package_name_ << "." << tstruct_name << "\"," << '\n';
+ out << indent() << "Value: p," << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "return slog.AnyValue(v)" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "return slog.AnyValue(v)" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
out << indent() << "var _ slog.LogValuer = (*" << tstruct_name << ")(nil)"
- << endl << endl;
+ << '\n' << '\n';
}
}
@@ -1444,25 +1444,25 @@
const string field_name(publicize(escape_string((*f_iter)->get_name())));
if ((*f_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*f_iter)) {
out << indent() << "func (p *" << tstruct_name << ") IsSet" << field_name << "() bool {"
- << endl;
+ << '\n';
indent_up();
t_type* ttype = (*f_iter)->get_type()->get_true_type();
bool is_byteslice = ttype->is_binary();
bool compare_to_nil_only = ttype->is_set() || ttype->is_list() || ttype->is_map()
|| (is_byteslice && !(*f_iter)->get_value());
if (is_pointer_field(*f_iter) || compare_to_nil_only) {
- out << indent() << "return p." << field_name << " != nil" << endl;
+ out << indent() << "return p." << field_name << " != nil" << '\n';
} else {
string def_var_name = tstruct_name + "_" + field_name + "_DEFAULT";
if (is_byteslice) {
out << indent() << "return !bytes.Equal(p." << field_name << ", " << def_var_name << ")"
- << endl;
+ << '\n';
} else {
- out << indent() << "return p." << field_name << " != " << def_var_name << endl;
+ out << indent() << "return p." << field_name << " != " << def_var_name << '\n';
}
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
}
}
@@ -1480,9 +1480,9 @@
const string escaped_tstruct_name(escape_string(tstruct->get_name()));
out << indent() << "func (p *" << tstruct_name << ") CountSetFields" << tstruct_name << "() int {"
- << endl;
+ << '\n';
indent_up();
- out << indent() << "count := 0" << endl;
+ out << indent() << "count := 0" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED)
continue;
@@ -1494,16 +1494,16 @@
const string field_name(publicize(escape_string((*f_iter)->get_name())));
- out << indent() << "if (p.IsSet" << field_name << "()) {" << endl;
+ out << indent() << "if (p.IsSet" << field_name << "()) {" << '\n';
indent_up();
- out << indent() << "count++" << endl;
+ out << indent() << "count++" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
- out << indent() << "return count" << endl << endl;
+ out << indent() << "return count" << '\n' << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
/**
@@ -1518,33 +1518,33 @@
vector<t_field*>::const_iterator f_iter;
string escaped_tstruct_name(escape_string(tstruct->get_name()));
out << indent() << "func (p *" << tstruct_name << ") " << read_method_name_ << "(ctx context.Context, iprot thrift.TProtocol) error {"
- << endl;
+ << '\n';
indent_up();
- out << indent() << "if _, err := iprot.ReadStructBegin(ctx); err != nil {" << endl;
+ out << indent() << "if _, err := iprot.ReadStructBegin(ctx); err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T read error: \", p), err)"
- << endl;
- out << indent() << "}" << endl << endl;
+ << '\n';
+ out << indent() << "}" << '\n' << '\n';
// Required variables does not have IsSet functions, so we need tmp vars to check them.
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
const string field_name(publicize(escape_string((*f_iter)->get_name())));
- indent(out) << "var isset" << field_name << " bool = false;" << endl;
+ indent(out) << "var isset" << field_name << " bool = false;" << '\n';
}
}
- out << endl;
+ out << '\n';
// Loop over reading in fields
- indent(out) << "for {" << endl;
+ indent(out) << "for {" << '\n';
indent_up();
// Read beginning field marker
- out << indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)" << endl;
- out << indent() << "if err != nil {" << endl;
+ out << indent() << "_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)" << '\n';
+ out << indent() << "if err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf("
- "\"%T field %d read error: \", p, fieldId), err)" << endl;
- out << indent() << "}" << endl;
+ "\"%T field %d read error: \", p, fieldId), err)" << '\n';
+ out << indent() << "}" << '\n';
// Check for field STOP marker and break
- out << indent() << "if fieldTypeId == thrift.STOP { break; }" << endl;
+ out << indent() << "if fieldTypeId == thrift.STOP { break; }" << '\n';
string thriftFieldTypeId;
// Generate deserialization code for known cases
@@ -1553,7 +1553,7 @@
// Switch statement on the field we are reading, false if no fields present
bool have_switch = !fields.empty();
if (have_switch) {
- indent(out) << "switch fieldId {" << endl;
+ indent(out) << "switch fieldId {" << '\n';
}
// All the fields we know
@@ -1569,7 +1569,7 @@
field_method_suffix *= -1;
}
- out << indent() << "case " << field_id << ":" << endl;
+ out << indent() << "case " << field_id << ":" << '\n';
indent_up();
thriftFieldTypeId = type_to_enum((*f_iter)->get_type());
@@ -1577,23 +1577,23 @@
thriftFieldTypeId = "thrift.STRING";
}
- out << indent() << "if fieldTypeId == " << thriftFieldTypeId << " {" << endl;
+ out << indent() << "if fieldTypeId == " << thriftFieldTypeId << " {" << '\n';
out << indent() << " if err := p." << field_method_prefix << field_method_suffix << "(ctx, iprot); err != nil {"
- << endl;
- out << indent() << " return err" << endl;
- out << indent() << " }" << endl;
+ << '\n';
+ out << indent() << " return err" << '\n';
+ out << indent() << " }" << '\n';
// Mark required field as read
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
const string field_name(publicize(escape_string((*f_iter)->get_name())));
- out << indent() << " isset" << field_name << " = true" << endl;
+ out << indent() << " isset" << field_name << " = true" << '\n';
}
- out << indent() << "} else {" << endl;
- out << indent() << " if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << endl;
- out << indent() << " return err" << endl;
- out << indent() << " }" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "} else {" << '\n';
+ out << indent() << " if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << '\n';
+ out << indent() << " return err" << '\n';
+ out << indent() << " }" << '\n';
+ out << indent() << "}" << '\n';
indent_down();
@@ -1601,46 +1601,46 @@
// Begin switch default case
if (have_switch) {
- out << indent() << "default:" << endl;
+ out << indent() << "default:" << '\n';
indent_up();
}
// Skip unknown fields in either case
- out << indent() << "if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << endl;
- out << indent() << " return err" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := iprot.Skip(ctx, fieldTypeId); err != nil {" << '\n';
+ out << indent() << " return err" << '\n';
+ out << indent() << "}" << '\n';
// End switch default case
if (have_switch) {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
// Read field end marker
- out << indent() << "if err := iprot.ReadFieldEnd(ctx); err != nil {" << endl;
- out << indent() << " return err" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := iprot.ReadFieldEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return err" << '\n';
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "if err := iprot.ReadStructEnd(ctx); err != nil {" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "if err := iprot.ReadStructEnd(ctx); err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf("
- "\"%T read struct end error: \", p), err)" << endl;
- out << indent() << "}" << endl;
+ "\"%T read struct end error: \", p), err)" << '\n';
+ out << indent() << "}" << '\n';
// Return error if any required fields are missing.
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
const string field_name(publicize(escape_string((*f_iter)->get_name())));
- out << indent() << "if !isset" << field_name << "{" << endl;
+ out << indent() << "if !isset" << field_name << "{" << '\n';
out << indent() << " return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, "
- "fmt.Errorf(\"Required field " << field_name << " is not set\"));" << endl;
- out << indent() << "}" << endl;
+ "fmt.Errorf(\"Required field " << field_name << " is not set\"));" << '\n';
+ out << indent() << "}" << '\n';
}
}
- out << indent() << "return nil" << endl;
+ out << indent() << "return nil" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
string field_type_name(publicize((*f_iter)->get_type()->get_name()));
@@ -1655,12 +1655,12 @@
}
out << indent() << "func (p *" << tstruct_name << ") " << field_method_prefix << field_method_suffix
- << "(ctx context.Context, iprot thrift.TProtocol) error {" << endl;
+ << "(ctx context.Context, iprot thrift.TProtocol) error {" << '\n';
indent_up();
generate_deserialize_field(out, *f_iter, false, "p.");
indent_down();
- out << indent() << " return nil" << endl;
- out << indent() << "}" << endl << endl;
+ out << indent() << " return nil" << '\n';
+ out << indent() << "}" << '\n' << '\n';
}
}
@@ -1673,18 +1673,18 @@
string name(tstruct->get_name());
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "func (p *" << tstruct_name << ") " << write_method_name_ << "(ctx context.Context, oprot thrift.TProtocol) error {" << endl;
+ indent(out) << "func (p *" << tstruct_name << ") " << write_method_name_ << "(ctx context.Context, oprot thrift.TProtocol) error {" << '\n';
indent_up();
if (tstruct->is_union() && uses_countsetfields) {
std::string tstruct_name(publicize(tstruct->get_name()));
- out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << endl
+ out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << '\n'
<< indent()
<< " return fmt.Errorf(\"%T write union: exactly one field must be set (%d set)\", p, c)"
- << endl << indent() << "}" << endl;
+ << '\n' << indent() << "}" << '\n';
}
- out << indent() << "if err := oprot.WriteStructBegin(ctx, \"" << name << "\"); err != nil {" << endl;
+ out << indent() << "if err := oprot.WriteStructBegin(ctx, \"" << name << "\"); err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf("
- "\"%T write struct begin error: \", p), err) }" << endl;
+ "\"%T write struct begin error: \", p), err) }" << '\n';
string field_name;
string escape_field_name;
@@ -1692,7 +1692,7 @@
t_field::e_req field_required;
int32_t field_id = -1;
- out << indent() << "if p != nil {" << endl;
+ out << indent() << "if p != nil {" << '\n';
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1708,20 +1708,20 @@
}
out << indent() << "if err := p." << field_method_prefix << field_method_suffix
- << "(ctx, oprot); err != nil { return err }" << endl;
+ << "(ctx, oprot); err != nil { return err }" << '\n';
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
// Write the struct map
- out << indent() << "if err := oprot.WriteFieldStop(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"write field stop error: \", err) }" << endl;
- out << indent() << "if err := oprot.WriteStructEnd(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"write struct stop error: \", err) }" << endl;
- out << indent() << "return nil" << endl;
+ out << indent() << "if err := oprot.WriteFieldStop(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"write field stop error: \", err) }" << '\n';
+ out << indent() << "if err := oprot.WriteStructEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"write struct stop error: \", err) }" << '\n';
+ out << indent() << "return nil" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
string field_method_prefix("writeField");
@@ -1738,35 +1738,35 @@
}
out << indent() << "func (p *" << tstruct_name << ") " << field_method_prefix << field_method_suffix
- << "(ctx context.Context, oprot thrift.TProtocol) (err error) {" << endl;
+ << "(ctx context.Context, oprot thrift.TProtocol) (err error) {" << '\n';
indent_up();
if (field_required == t_field::T_OPTIONAL) {
- out << indent() << "if p.IsSet" << publicize(field_name) << "() {" << endl;
+ out << indent() << "if p.IsSet" << publicize(field_name) << "() {" << '\n';
indent_up();
}
out << indent() << "if err := oprot.WriteFieldBegin(ctx, \"" << escape_field_name << "\", "
- << type_to_enum((*f_iter)->get_type()) << ", " << field_id << "); err != nil {" << endl;
+ << type_to_enum((*f_iter)->get_type()) << ", " << field_id << "); err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field begin error "
- << field_id << ":" << escape_field_name << ": \", p), err) }" << endl;
+ << field_id << ":" << escape_field_name << ": \", p), err) }" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "p.");
// Write field closer
- out << indent() << "if err := oprot.WriteFieldEnd(ctx); err != nil {" << endl;
+ out << indent() << "if err := oprot.WriteFieldEnd(ctx); err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T write field end error "
- << field_id << ":" << escape_field_name << ": \", p), err) }" << endl;
+ << field_id << ":" << escape_field_name << ": \", p), err) }" << '\n';
if (field_required == t_field::T_OPTIONAL) {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
indent_down();
- out << indent() << " return err" << endl;
- out << indent() << "}" << endl << endl;
+ out << indent() << " return err" << '\n';
+ out << indent() << "}" << '\n' << '\n';
}
}
@@ -1777,20 +1777,20 @@
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
indent(out) << "func (p *" << tstruct_name << ") " << equals_method_name_ << "(other *"
- << tstruct_name << ") bool {" << endl;
+ << tstruct_name << ") bool {" << '\n';
indent_up();
string field_name;
string publicize_field_name;
- out << indent() << "if p == other {" << endl;
+ out << indent() << "if p == other {" << '\n';
indent_up();
- out << indent() << "return true" << endl;
+ out << indent() << "return true" << '\n';
indent_down();
- out << indent() << "} else if p == nil || other == nil {" << endl;
+ out << indent() << "} else if p == nil || other == nil {" << '\n';
indent_up();
- out << indent() << "return false" << endl;
+ out << indent() << "return false" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
field_name = (*f_iter)->get_name();
@@ -1806,23 +1806,23 @@
&& (ttype->is_base_type() || ttype->is_enum() || ttype->is_container())) {
string tgtv = "(*" + tgt + ")";
string srcv = "(*" + src + ")";
- out << indent() << "if " << tgt << " != " << src << " {" << endl;
+ out << indent() << "if " << tgt << " != " << src << " {" << '\n';
indent_up();
- out << indent() << "if " << tgt << " == nil || " << src << " == nil {" << endl;
+ out << indent() << "if " << tgt << " == nil || " << src << " == nil {" << '\n';
indent_up();
- out << indent() << "return false" << endl;
+ out << indent() << "return false" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
generate_go_equals(out, field_type, tgtv, srcv);
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
} else {
generate_go_equals(out, field_type, tgt, src);
}
}
- out << indent() << "return true" << endl;
+ out << indent() << "return true" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
/**
@@ -1842,7 +1842,7 @@
if(!skip_remote_) {
generate_service_remote(tservice);
}
- f_types_ << endl;
+ f_types_ << '\n';
}
/**
@@ -1853,7 +1853,7 @@
void t_go_generator::generate_service_helpers(t_service* tservice) {
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- f_types_ << "// HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+ f_types_ << "// HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
@@ -1920,17 +1920,17 @@
vector<t_function*> functions = tservice->get_functions();
if (!functions.empty()) {
- f_types_ << endl;
+ f_types_ << '\n';
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_go_docstring(f_types_, (*f_iter));
- f_types_ << indent() << function_signature_if(*f_iter, "", true) << endl;
+ f_types_ << indent() << function_signature_if(*f_iter, "", true) << '\n';
}
}
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -1963,23 +1963,23 @@
extends_field = extends_client.substr(extends_client.find(".") + 1);
generate_go_docstring(f_types_, tservice);
- f_types_ << indent() << "type " << serviceName << "Client struct {" << endl;
+ f_types_ << indent() << "type " << serviceName << "Client struct {" << '\n';
indent_up();
if (!extends_client.empty()) {
- f_types_ << indent() << "*" << extends_client << endl;
+ f_types_ << indent() << "*" << extends_client << '\n';
} else {
- f_types_ << indent() << "c thrift.TClient" << endl;
- f_types_ << indent() << "meta thrift.ResponseMeta" << endl;
+ f_types_ << indent() << "c thrift.TClient" << '\n';
+ f_types_ << indent() << "meta thrift.ResponseMeta" << '\n';
}
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
// Legacy constructor function
f_types_ << indent() << "func New" << serviceName
<< "ClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *" << serviceName
- << "Client {" << endl;
+ << "Client {" << '\n';
indent_up();
f_types_ << indent() << "return &" << serviceName << "Client";
@@ -1987,72 +1987,72 @@
f_types_ << "{" << extends_field << ": " << extends_client_new << "Factory(t, f)}";
} else {
indent_up();
- f_types_ << "{" << endl;
- f_types_ << indent() << "c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t))," << endl;
+ f_types_ << "{" << '\n';
+ f_types_ << indent() << "c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t))," << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
}
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
// Legacy constructor function with custom input & output protocols
f_types_
<< indent() << "func New" << serviceName
<< "ClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *"
- << serviceName << "Client {" << endl;
+ << serviceName << "Client {" << '\n';
indent_up();
f_types_ << indent() << "return &" << serviceName << "Client";
if (!extends.empty()) {
f_types_ << "{" << extends_field << ": " << extends_client_new << "Protocol(t, iprot, oprot)}"
- << endl;
+ << '\n';
} else {
indent_up();
- f_types_ << "{" << endl;
- f_types_ << indent() << "c: thrift.NewTStandardClient(iprot, oprot)," << endl;
+ f_types_ << "{" << '\n';
+ f_types_ << indent() << "c: thrift.NewTStandardClient(iprot, oprot)," << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
}
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
// Constructor function
f_types_ << indent() << "func New" << serviceName
- << "Client(c thrift.TClient) *" << serviceName << "Client {" << endl;
+ << "Client(c thrift.TClient) *" << serviceName << "Client {" << '\n';
indent_up();
- f_types_ << indent() << "return &" << serviceName << "Client{" << endl;
+ f_types_ << indent() << "return &" << serviceName << "Client{" << '\n';
indent_up();
if (!extends.empty()) {
- f_types_ << indent() << extends_field << ": " << extends_client_new << "(c)," << endl;
+ f_types_ << indent() << extends_field << ": " << extends_client_new << "(c)," << '\n';
} else {
- f_types_ << indent() << "c: c," << endl;
+ f_types_ << indent() << "c: c," << '\n';
}
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
if (extends.empty()) {
- f_types_ << indent() << "func (p *" << serviceName << "Client) Client_() thrift.TClient {" << endl;
+ f_types_ << indent() << "func (p *" << serviceName << "Client) Client_() thrift.TClient {" << '\n';
indent_up();
- f_types_ << indent() << "return p.c" << endl;
+ f_types_ << indent() << "return p.c" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
- f_types_ << indent() << "func (p *" << serviceName << "Client) LastResponseMeta_() thrift.ResponseMeta {" << endl;
+ f_types_ << indent() << "func (p *" << serviceName << "Client) LastResponseMeta_() thrift.ResponseMeta {" << '\n';
indent_up();
- f_types_ << indent() << "return p.meta" << endl;
+ f_types_ << indent() << "return p.meta" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
- f_types_ << indent() << "func (p *" << serviceName << "Client) SetLastResponseMeta_(meta thrift.ResponseMeta) {" << endl;
+ f_types_ << indent() << "func (p *" << serviceName << "Client) SetLastResponseMeta_(meta thrift.ResponseMeta) {" << '\n';
indent_up();
- f_types_ << indent() << "p.meta = meta" << endl;
+ f_types_ << indent() << "p.meta = meta" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
}
// Generate client method implementations
@@ -2067,59 +2067,59 @@
// Open function
generate_go_docstring(f_types_, (*f_iter));
f_types_ << indent() << "func (p *" << serviceName << "Client) "
- << function_signature_if(*f_iter, "", true) << " {" << endl;
+ << function_signature_if(*f_iter, "", true) << " {" << '\n';
indent_up();
std::string method = (*f_iter)->get_name();
std::string argsType = publicize(method + "_args", true);
std::string argsName = tmp("_args");
- f_types_ << indent() << "var " << argsName << " " << argsType << endl;
+ f_types_ << indent() << "var " << argsName << " " << argsType << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_types_ << indent() << argsName << "." << publicize((*fld_iter)->get_name())
- << " = " << variable_name_to_go_name((*fld_iter)->get_name()) << endl;
+ << " = " << variable_name_to_go_name((*fld_iter)->get_name()) << '\n';
}
if (!(*f_iter)->is_oneway()) {
std::string metaName = tmp("_meta");
std::string resultName = tmp("_result");
std::string resultType = publicize(method + "_result", true);
- f_types_ << indent() << "var " << resultName << " " << resultType << endl;
- f_types_ << indent() << "var " << metaName << " thrift.ResponseMeta" << endl;
+ f_types_ << indent() << "var " << resultName << " " << resultType << '\n';
+ f_types_ << indent() << "var " << metaName << " thrift.ResponseMeta" << '\n';
f_types_ << indent() << metaName << ", _err = p.Client_().Call(ctx, \""
- << method << "\", &" << argsName << ", &" << resultName << ")" << endl;
- f_types_ << indent() << "p.SetLastResponseMeta_(" << metaName << ")" << endl;
- f_types_ << indent() << "if _err != nil {" << endl;
+ << method << "\", &" << argsName << ", &" << resultName << ")" << '\n';
+ f_types_ << indent() << "p.SetLastResponseMeta_(" << metaName << ")" << '\n';
+ f_types_ << indent() << "if _err != nil {" << '\n';
indent_up();
- f_types_ << indent() << "return" << endl;
+ f_types_ << indent() << "return" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
if (!xceptions.empty()) {
- f_types_ << indent() << "switch {" << endl;
+ f_types_ << indent() << "switch {" << '\n';
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
const std::string pubname = publicize((*x_iter)->get_name());
const std::string field = resultName + "." + pubname;
- f_types_ << indent() << "case " << field << "!= nil:" << endl;
+ f_types_ << indent() << "case " << field << "!= nil:" << '\n';
indent_up();
if (!(*f_iter)->get_returntype()->is_void()) {
- f_types_ << indent() << "return _r, " << field << endl;
+ f_types_ << indent() << "return _r, " << field << '\n';
} else {
- f_types_ << indent() << "return "<< field << endl;
+ f_types_ << indent() << "return "<< field << '\n';
}
indent_down();
}
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
}
if ((*f_iter)->get_returntype()->is_struct()) {
@@ -2130,37 +2130,37 @@
// struct in go.
std::string retName = tmp("_ret");
f_types_ << indent() << "if " << retName << " := " << resultName
- << ".GetSuccess(); " << retName << " != nil {" << endl;
+ << ".GetSuccess(); " << retName << " != nil {" << '\n';
indent_up();
- f_types_ << indent() << "return " << retName << ", nil" << endl;
+ f_types_ << indent() << "return " << retName << ", nil" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
f_types_ << indent() << "return nil, "
<< "thrift.NewTApplicationException(thrift.MISSING_RESULT, \""
- << method << " failed: unknown result\")" << endl;
+ << method << " failed: unknown result\")" << '\n';
} else if (!(*f_iter)->get_returntype()->is_void()) {
- f_types_ << indent() << "return " << resultName << ".GetSuccess(), nil" << endl;
+ f_types_ << indent() << "return " << resultName << ".GetSuccess(), nil" << '\n';
} else {
- f_types_ << indent() << "return nil" << endl;
+ f_types_ << indent() << "return nil" << '\n';
}
} else {
// Since we don't have response meta for oneway calls, overwrite it with
// an empty one to avoid users getting the meta from last call and
// mistaken it as from the oneway call.
- f_types_ << indent() << "p.SetLastResponseMeta_(thrift.ResponseMeta{})" << endl;
+ f_types_ << indent() << "p.SetLastResponseMeta_(thrift.ResponseMeta{})" << '\n';
// TODO: would be nice to not to duplicate the call generation
f_types_ << indent() << "if _, err := p.Client_().Call(ctx, \""
- << method << "\", &" << argsName << ", nil); err != nil {" << endl;
+ << method << "\", &" << argsName << ", nil); err != nil {" << '\n';
indent_up();
- f_types_ << indent() << "return err" << endl;
+ f_types_ << indent() << "return err" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
- f_types_ << indent() << "return nil" << endl;
+ f_types_ << indent() << "}" << '\n';
+ f_types_ << indent() << "return nil" << '\n';
}
indent_down();
- f_types_ << "}" << endl << endl;
+ f_types_ << "}" << '\n' << '\n';
}
}
@@ -2223,21 +2223,21 @@
system_packages.push_back("thrift \"" + gen_thrift_import_ + "\"");
f_remote << go_autogen_comment();
- f_remote << indent() << "package main" << endl << endl;
- f_remote << indent() << "import (" << endl;
+ f_remote << indent() << "package main" << '\n' << '\n';
+ f_remote << indent() << "import (" << '\n';
f_remote << render_system_packages(system_packages);
f_remote << indent() << render_included_programs(unused_protection);
f_remote << render_program_import(program_, unused_protection);
- f_remote << indent() << ")" << endl;
- f_remote << indent() << endl;
+ f_remote << indent() << ")" << '\n';
+ f_remote << indent() << '\n';
f_remote << indent() << unused_protection; // filled in render_included_programs()
- f_remote << indent() << endl;
- f_remote << indent() << "func Usage() {" << endl;
+ f_remote << indent() << '\n';
+ f_remote << indent() << "func Usage() {" << '\n';
f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Usage of \", os.Args[0], \" "
"[-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:\")"
- << endl;
- f_remote << indent() << " flag.PrintDefaults()" << endl;
- f_remote << indent() << " fmt.Fprintln(os.Stderr, \"\\nFunctions:\")" << endl;
+ << '\n';
+ f_remote << indent() << " flag.PrintDefaults()" << '\n';
+ f_remote << indent() << " fmt.Fprintln(os.Stderr, \"\\nFunctions:\")" << '\n';
string package_name_aliased = package_identifiers_[get_real_go_module(program_)];
@@ -2259,143 +2259,143 @@
f_remote << args[i]->get_type()->get_name() << " " << args[i]->get_name();
}
- f_remote << ")\")" << endl;
+ f_remote << ")\")" << '\n';
}
- f_remote << indent() << " fmt.Fprintln(os.Stderr)" << endl;
- f_remote << indent() << " os.Exit(0)" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << endl;
+ f_remote << indent() << " fmt.Fprintln(os.Stderr)" << '\n';
+ f_remote << indent() << " os.Exit(0)" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << '\n';
- f_remote << indent() << "type httpHeaders map[string]string" << endl;
- f_remote << indent() << endl;
- f_remote << indent() << "func (h httpHeaders) String() string {" << endl;
- f_remote << indent() << " var m map[string]string = h" << endl;
- f_remote << indent() << " return fmt.Sprintf(\"%s\", m)" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << endl;
- f_remote << indent() << "func (h httpHeaders) Set(value string) error {" << endl;
- f_remote << indent() << " parts := strings.Split(value, \": \")" << endl;
- f_remote << indent() << " if len(parts) != 2 {" << endl;
- f_remote << indent() << " return fmt.Errorf(\"header should be of format 'Key: Value'\")" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << " h[parts[0]] = parts[1]" << endl;
- f_remote << indent() << " return nil" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << endl;
+ f_remote << indent() << "type httpHeaders map[string]string" << '\n';
+ f_remote << indent() << '\n';
+ f_remote << indent() << "func (h httpHeaders) String() string {" << '\n';
+ f_remote << indent() << " var m map[string]string = h" << '\n';
+ f_remote << indent() << " return fmt.Sprintf(\"%s\", m)" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << '\n';
+ f_remote << indent() << "func (h httpHeaders) Set(value string) error {" << '\n';
+ f_remote << indent() << " parts := strings.Split(value, \": \")" << '\n';
+ f_remote << indent() << " if len(parts) != 2 {" << '\n';
+ f_remote << indent() << " return fmt.Errorf(\"header should be of format 'Key: Value'\")" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << " h[parts[0]] = parts[1]" << '\n';
+ f_remote << indent() << " return nil" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << '\n';
- f_remote << indent() << "func main() {" << endl;
+ f_remote << indent() << "func main() {" << '\n';
indent_up();
- f_remote << indent() << "flag.Usage = Usage" << endl;
- f_remote << indent() << "var host string" << endl;
- f_remote << indent() << "var port int" << endl;
- f_remote << indent() << "var protocol string" << endl;
- f_remote << indent() << "var urlString string" << endl;
- f_remote << indent() << "var framed bool" << endl;
- f_remote << indent() << "var useHttp bool" << endl;
- f_remote << indent() << "headers := make(httpHeaders)" << endl;
- f_remote << indent() << "var parsedUrl *url.URL" << endl;
- f_remote << indent() << "var trans thrift.TTransport" << endl;
- f_remote << indent() << "_ = strconv.Atoi" << endl;
- f_remote << indent() << "_ = math.Abs" << endl;
- f_remote << indent() << "flag.Usage = Usage" << endl;
+ f_remote << indent() << "flag.Usage = Usage" << '\n';
+ f_remote << indent() << "var host string" << '\n';
+ f_remote << indent() << "var port int" << '\n';
+ f_remote << indent() << "var protocol string" << '\n';
+ f_remote << indent() << "var urlString string" << '\n';
+ f_remote << indent() << "var framed bool" << '\n';
+ f_remote << indent() << "var useHttp bool" << '\n';
+ f_remote << indent() << "headers := make(httpHeaders)" << '\n';
+ f_remote << indent() << "var parsedUrl *url.URL" << '\n';
+ f_remote << indent() << "var trans thrift.TTransport" << '\n';
+ f_remote << indent() << "_ = strconv.Atoi" << '\n';
+ f_remote << indent() << "_ = math.Abs" << '\n';
+ f_remote << indent() << "flag.Usage = Usage" << '\n';
f_remote << indent() << "flag.StringVar(&host, \"h\", \"localhost\", \"Specify host and port\")"
- << endl;
- f_remote << indent() << "flag.IntVar(&port, \"p\", 9090, \"Specify port\")" << endl;
+ << '\n';
+ f_remote << indent() << "flag.IntVar(&port, \"p\", 9090, \"Specify port\")" << '\n';
f_remote << indent() << "flag.StringVar(&protocol, \"P\", \"binary\", \""
- "Specify the protocol (binary, compact, simplejson, json)\")" << endl;
- f_remote << indent() << "flag.StringVar(&urlString, \"u\", \"\", \"Specify the url\")" << endl;
+ "Specify the protocol (binary, compact, simplejson, json)\")" << '\n';
+ f_remote << indent() << "flag.StringVar(&urlString, \"u\", \"\", \"Specify the url\")" << '\n';
f_remote << indent() << "flag.BoolVar(&framed, \"framed\", false, \"Use framed transport\")"
- << endl;
- f_remote << indent() << "flag.BoolVar(&useHttp, \"http\", false, \"Use http\")" << endl;
- f_remote << indent() << "flag.Var(headers, \"H\", \"Headers to set on the http(s) request (e.g. -H \\\"Key: Value\\\")\")" << endl;
- f_remote << indent() << "flag.Parse()" << endl;
- f_remote << indent() << endl;
- f_remote << indent() << "if len(urlString) > 0 {" << endl;
- f_remote << indent() << " var err error" << endl;
- f_remote << indent() << " parsedUrl, err = url.Parse(urlString)" << endl;
- f_remote << indent() << " if err != nil {" << endl;
- f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << endl;
- f_remote << indent() << " flag.Usage()" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << " host = parsedUrl.Host" << endl;
+ << '\n';
+ f_remote << indent() << "flag.BoolVar(&useHttp, \"http\", false, \"Use http\")" << '\n';
+ f_remote << indent() << "flag.Var(headers, \"H\", \"Headers to set on the http(s) request (e.g. -H \\\"Key: Value\\\")\")" << '\n';
+ f_remote << indent() << "flag.Parse()" << '\n';
+ f_remote << indent() << '\n';
+ f_remote << indent() << "if len(urlString) > 0 {" << '\n';
+ f_remote << indent() << " var err error" << '\n';
+ f_remote << indent() << " parsedUrl, err = url.Parse(urlString)" << '\n';
+ f_remote << indent() << " if err != nil {" << '\n';
+ f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n';
+ f_remote << indent() << " flag.Usage()" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << " host = parsedUrl.Host" << '\n';
f_remote << indent() << " useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == \"http\" || parsedUrl.Scheme == \"https\""
- << endl;
- f_remote << indent() << "} else if useHttp {" << endl;
+ << '\n';
+ f_remote << indent() << "} else if useHttp {" << '\n';
f_remote << indent() << " _, err := url.Parse(fmt.Sprint(\"http://\", host, \":\", port))"
- << endl;
- f_remote << indent() << " if err != nil {" << endl;
- f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << endl;
- f_remote << indent() << " flag.Usage()" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << endl;
- f_remote << indent() << "cmd := flag.Arg(0)" << endl;
- f_remote << indent() << "var err error" << endl;
- f_remote << indent() << "var cfg *thrift.TConfiguration = nil" << endl;
- f_remote << indent() << "if useHttp {" << endl;
- f_remote << indent() << " trans, err = thrift.NewTHttpClient(parsedUrl.String())" << endl;
- f_remote << indent() << " if len(headers) > 0 {" << endl;
- f_remote << indent() << " httptrans := trans.(*thrift.THttpClient)" << endl;
- f_remote << indent() << " for key, value := range headers {" << endl;
- f_remote << indent() << " httptrans.SetHeader(key, value)" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << "} else {" << endl;
- f_remote << indent() << " portStr := fmt.Sprint(port)" << endl;
- f_remote << indent() << " if strings.Contains(host, \":\") {" << endl;
- f_remote << indent() << " host, portStr, err = net.SplitHostPort(host)" << endl;
- f_remote << indent() << " if err != nil {" << endl;
+ << '\n';
+ f_remote << indent() << " if err != nil {" << '\n';
+ f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error parsing URL: \", err)" << '\n';
+ f_remote << indent() << " flag.Usage()" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << '\n';
+ f_remote << indent() << "cmd := flag.Arg(0)" << '\n';
+ f_remote << indent() << "var err error" << '\n';
+ f_remote << indent() << "var cfg *thrift.TConfiguration = nil" << '\n';
+ f_remote << indent() << "if useHttp {" << '\n';
+ f_remote << indent() << " trans, err = thrift.NewTHttpClient(parsedUrl.String())" << '\n';
+ f_remote << indent() << " if len(headers) > 0 {" << '\n';
+ f_remote << indent() << " httptrans := trans.(*thrift.THttpClient)" << '\n';
+ f_remote << indent() << " for key, value := range headers {" << '\n';
+ f_remote << indent() << " httptrans.SetHeader(key, value)" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << "} else {" << '\n';
+ f_remote << indent() << " portStr := fmt.Sprint(port)" << '\n';
+ f_remote << indent() << " if strings.Contains(host, \":\") {" << '\n';
+ f_remote << indent() << " host, portStr, err = net.SplitHostPort(host)" << '\n';
+ f_remote << indent() << " if err != nil {" << '\n';
f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error with host:\", err)"
- << endl;
- f_remote << indent() << " os.Exit(1)" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << " trans = thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg)" << endl;
- f_remote << indent() << " if err != nil {" << endl;
- f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error resolving address:\", err)" << endl;
- f_remote << indent() << " os.Exit(1)" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << " if framed {" << endl;
- f_remote << indent() << " trans = thrift.NewTFramedTransportConf(trans, cfg)" << endl;
- f_remote << indent() << " }" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << "if err != nil {" << endl;
- f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error creating transport\", err)" << endl;
- f_remote << indent() << " os.Exit(1)" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << "defer trans.Close()" << endl;
- f_remote << indent() << "var protocolFactory thrift.TProtocolFactory" << endl;
- f_remote << indent() << "switch protocol {" << endl;
- f_remote << indent() << "case \"compact\":" << endl;
- f_remote << indent() << " protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg)" << endl;
- f_remote << indent() << " break" << endl;
- f_remote << indent() << "case \"simplejson\":" << endl;
- f_remote << indent() << " protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << endl;
- f_remote << indent() << " break" << endl;
- f_remote << indent() << "case \"json\":" << endl;
- f_remote << indent() << " protocolFactory = thrift.NewTJSONProtocolFactory()" << endl;
- f_remote << indent() << " break" << endl;
- f_remote << indent() << "case \"binary\", \"\":" << endl;
- f_remote << indent() << " protocolFactory = thrift.NewTBinaryProtocolFactoryConf(cfg)" << endl;
- f_remote << indent() << " break" << endl;
- f_remote << indent() << "default:" << endl;
+ << '\n';
+ f_remote << indent() << " os.Exit(1)" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << " trans = thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg)" << '\n';
+ f_remote << indent() << " if err != nil {" << '\n';
+ f_remote << indent() << " fmt.Fprintln(os.Stderr, \"error resolving address:\", err)" << '\n';
+ f_remote << indent() << " os.Exit(1)" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << " if framed {" << '\n';
+ f_remote << indent() << " trans = thrift.NewTFramedTransportConf(trans, cfg)" << '\n';
+ f_remote << indent() << " }" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << "if err != nil {" << '\n';
+ f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error creating transport\", err)" << '\n';
+ f_remote << indent() << " os.Exit(1)" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << "defer trans.Close()" << '\n';
+ f_remote << indent() << "var protocolFactory thrift.TProtocolFactory" << '\n';
+ f_remote << indent() << "switch protocol {" << '\n';
+ f_remote << indent() << "case \"compact\":" << '\n';
+ f_remote << indent() << " protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg)" << '\n';
+ f_remote << indent() << " break" << '\n';
+ f_remote << indent() << "case \"simplejson\":" << '\n';
+ f_remote << indent() << " protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << '\n';
+ f_remote << indent() << " break" << '\n';
+ f_remote << indent() << "case \"json\":" << '\n';
+ f_remote << indent() << " protocolFactory = thrift.NewTJSONProtocolFactory()" << '\n';
+ f_remote << indent() << " break" << '\n';
+ f_remote << indent() << "case \"binary\", \"\":" << '\n';
+ f_remote << indent() << " protocolFactory = thrift.NewTBinaryProtocolFactoryConf(cfg)" << '\n';
+ f_remote << indent() << " break" << '\n';
+ f_remote << indent() << "default:" << '\n';
f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid protocol specified: \", protocol)"
- << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " os.Exit(1)" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << "iprot := protocolFactory.GetProtocol(trans)" << endl;
- f_remote << indent() << "oprot := protocolFactory.GetProtocol(trans)" << endl;
+ << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " os.Exit(1)" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << "iprot := protocolFactory.GetProtocol(trans)" << '\n';
+ f_remote << indent() << "oprot := protocolFactory.GetProtocol(trans)" << '\n';
f_remote << indent() << "client := " << package_name_aliased << ".New" << publicize(service_name_)
- << "Client(thrift.NewTStandardClient(iprot, oprot))" << endl;
- f_remote << indent() << "if err := trans.Open(); err != nil {" << endl;
+ << "Client(thrift.NewTStandardClient(iprot, oprot))" << '\n';
+ f_remote << indent() << "if err := trans.Open(); err != nil {" << '\n';
f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Error opening socket to \", "
- "host, \":\", port, \" \", err)" << endl;
- f_remote << indent() << " os.Exit(1)" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << endl;
- f_remote << indent() << "switch cmd {" << endl;
+ "host, \":\", port, \" \", err)" << '\n';
+ f_remote << indent() << " os.Exit(1)" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << '\n';
+ f_remote << indent() << "switch cmd {" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* arg_struct = (*f_iter)->get_arglist();
@@ -2404,13 +2404,13 @@
string funcName((*f_iter)->get_name());
string pubName(publicize(funcName));
string argumentsName(publicize(funcName + "_args", true, func_to_service[funcName]));
- f_remote << indent() << "case \"" << escape_string(funcName) << "\":" << endl;
+ f_remote << indent() << "case \"" << escape_string(funcName) << "\":" << '\n';
indent_up();
- f_remote << indent() << "if flag.NArg() - 1 != " << num_args << " {" << endl;
+ f_remote << indent() << "if flag.NArg() - 1 != " << num_args << " {" << '\n';
f_remote << indent() << " fmt.Fprintln(os.Stderr, \"" << escape_string(pubName) << " requires "
- << num_args << " args\")" << endl;
- f_remote << indent() << " flag.Usage()" << endl;
- f_remote << indent() << "}" << endl;
+ << num_args << " args\")" << '\n';
+ f_remote << indent() << " flag.Usage()" << '\n';
+ f_remote << indent() << "}" << '\n';
for (std::vector<t_field*>::size_type i = 0; i < num_args; ++i) {
std::vector<t_field*>::size_type flagArg = i + 1;
@@ -2419,13 +2419,13 @@
if (the_type2->is_enum()) {
f_remote << indent() << "tmp" << i << ", err := (strconv.Atoi(flag.Arg(" << flagArg << ")))"
- << endl;
- f_remote << indent() << "if err != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
+ << '\n';
+ f_remote << indent() << "if err != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
f_remote << indent() << "argvalue" << i << " := " << package_name_aliased << "."
- << publicize(the_type->get_name()) << "(tmp" << i << ")" << endl;
+ << publicize(the_type->get_name()) << "(tmp" << i << ")" << '\n';
} else if (the_type2->is_base_type()) {
t_base_type::t_base e = ((t_base_type*)the_type2)->get_base();
string err(tmp("err"));
@@ -2437,72 +2437,72 @@
case t_base_type::TYPE_STRING:
if (the_type2->is_binary()) {
f_remote << indent() << "argvalue" << i << " := []byte(flag.Arg(" << flagArg << "))"
- << endl;
+ << '\n';
} else {
- f_remote << indent() << "argvalue" << i << " := flag.Arg(" << flagArg << ")" << endl;
+ f_remote << indent() << "argvalue" << i << " := flag.Arg(" << flagArg << ")" << '\n';
}
break;
case t_base_type::TYPE_BOOL:
f_remote << indent() << "argvalue" << i << " := flag.Arg(" << flagArg << ") == \"true\""
- << endl;
+ << '\n';
break;
case t_base_type::TYPE_I8:
f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg("
- << flagArg << ")))" << endl;
- f_remote << indent() << "if " << err << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << "argvalue" << i << " := int8(tmp" << i << ")" << endl;
+ << flagArg << ")))" << '\n';
+ f_remote << indent() << "if " << err << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << "argvalue" << i << " := int8(tmp" << i << ")" << '\n';
break;
case t_base_type::TYPE_I16:
f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg("
- << flagArg << ")))" << endl;
- f_remote << indent() << "if " << err << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << "argvalue" << i << " := int16(tmp" << i << ")" << endl;
+ << flagArg << ")))" << '\n';
+ f_remote << indent() << "if " << err << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << "argvalue" << i << " := int16(tmp" << i << ")" << '\n';
break;
case t_base_type::TYPE_I32:
f_remote << indent() << "tmp" << i << ", " << err << " := (strconv.Atoi(flag.Arg("
- << flagArg << ")))" << endl;
- f_remote << indent() << "if " << err << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << "argvalue" << i << " := int32(tmp" << i << ")" << endl;
+ << flagArg << ")))" << '\n';
+ f_remote << indent() << "if " << err << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << "argvalue" << i << " := int32(tmp" << i << ")" << '\n';
break;
case t_base_type::TYPE_I64:
f_remote << indent() << "argvalue" << i << ", " << err
- << " := (strconv.ParseInt(flag.Arg(" << flagArg << "), 10, 64))" << endl;
- f_remote << indent() << "if " << err << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
+ << " := (strconv.ParseInt(flag.Arg(" << flagArg << "), 10, 64))" << '\n';
+ f_remote << indent() << "if " << err << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
break;
case t_base_type::TYPE_DOUBLE:
f_remote << indent() << "argvalue" << i << ", " << err
- << " := (strconv.ParseFloat(flag.Arg(" << flagArg << "), 64))" << endl;
- f_remote << indent() << "if " << err << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
+ << " := (strconv.ParseFloat(flag.Arg(" << flagArg << "), 64))" << '\n';
+ f_remote << indent() << "if " << err << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
break;
case t_base_type::TYPE_UUID:
f_remote << indent() << "argvalue" << i << ", " << err
- << " := (thrift.ParseTuuid(flag.Arg(" << flagArg << ")))" << endl;
- f_remote << indent() << "if " << err << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
+ << " := (thrift.ParseTuuid(flag.Arg(" << flagArg << ")))" << '\n';
+ f_remote << indent() << "if " << err << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
break;
default:
@@ -2524,26 +2524,26 @@
tstruct_module = package_name_aliased;
}
- f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << endl;
+ f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << '\n';
f_remote << indent() << mbTrans << " := thrift.NewTMemoryBufferLen(len(" << arg << "))"
- << endl;
- f_remote << indent() << "defer " << mbTrans << ".Close()" << endl;
+ << '\n';
+ f_remote << indent() << "defer " << mbTrans << ".Close()" << '\n';
f_remote << indent() << "_, " << err1 << " := " << mbTrans << ".WriteString(" << arg << ")"
- << endl;
- f_remote << indent() << "if " << err1 << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << endl;
+ << '\n';
+ f_remote << indent() << "if " << err1 << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << '\n';
f_remote << indent() << jsProt << " := " << factory << ".GetProtocol(" << mbTrans << ")"
- << endl;
+ << '\n';
f_remote << indent() << "argvalue" << i << " := " << tstruct_module << ".New" << tstruct_name
- << "()" << endl;
- f_remote << indent() << err2 << " := argvalue" << i << "." << read_method_name_ << "(context.Background(), " << jsProt << ")" << endl;
- f_remote << indent() << "if " << err2 << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
+ << "()" << '\n';
+ f_remote << indent() << err2 << " := argvalue" << i << "." << read_method_name_ << "(context.Background(), " << jsProt << ")" << '\n';
+ f_remote << indent() << "if " << err2 << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
} else if (the_type2->is_container() || the_type2->is_xception()) {
string arg(tmp("arg"));
string mbTrans(tmp("mbTrans"));
@@ -2552,29 +2552,29 @@
string jsProt(tmp("jsProt"));
string err2(tmp("err"));
std::string argName(publicize(args[i]->get_name()));
- f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << endl;
+ f_remote << indent() << arg << " := flag.Arg(" << flagArg << ")" << '\n';
f_remote << indent() << mbTrans << " := thrift.NewTMemoryBufferLen(len(" << arg << "))"
- << endl;
- f_remote << indent() << "defer " << mbTrans << ".Close()" << endl;
+ << '\n';
+ f_remote << indent() << "defer " << mbTrans << ".Close()" << '\n';
f_remote << indent() << "_, " << err1 << " := " << mbTrans << ".WriteString(" << arg << ")"
- << endl;
- f_remote << indent() << "if " << err1 << " != nil { " << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
- f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << endl;
+ << '\n';
+ f_remote << indent() << "if " << err1 << " != nil { " << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
+ f_remote << indent() << factory << " := thrift.NewTJSONProtocolFactory()" << '\n';
f_remote << indent() << jsProt << " := " << factory << ".GetProtocol(" << mbTrans << ")"
- << endl;
+ << '\n';
f_remote << indent() << "containerStruct" << i << " := " << package_name_aliased << ".New"
- << argumentsName << "()" << endl;
+ << argumentsName << "()" << '\n';
f_remote << indent() << err2 << " := containerStruct" << i << ".ReadField" << (i + 1) << "(context.Background(), "
- << jsProt << ")" << endl;
- f_remote << indent() << "if " << err2 << " != nil {" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " return" << endl;
- f_remote << indent() << "}" << endl;
+ << jsProt << ")" << '\n';
+ f_remote << indent() << "if " << err2 << " != nil {" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " return" << '\n';
+ f_remote << indent() << "}" << '\n';
f_remote << indent() << "argvalue" << i << " := containerStruct" << i << "." << argName
- << endl;
+ << '\n';
} else {
throw("Invalid argument type in generate_service_remote");
}
@@ -2585,9 +2585,9 @@
typedef_module = package_name_aliased;
}
f_remote << indent() << "value" << i << " := " << typedef_module << "."
- << publicize(the_type->get_name()) << "(argvalue" << i << ")" << endl;
+ << publicize(the_type->get_name()) << "(argvalue" << i << ")" << '\n';
} else {
- f_remote << indent() << "value" << i << " := argvalue" << i << endl;
+ f_remote << indent() << "value" << i << " := argvalue" << i << '\n';
}
}
@@ -2634,20 +2634,20 @@
}
}
- f_remote << "))" << endl;
- f_remote << indent() << "fmt.Print(\"\\n\")" << endl;
- f_remote << indent() << "break" << endl;
+ f_remote << "))" << '\n';
+ f_remote << indent() << "fmt.Print(\"\\n\")" << '\n';
+ f_remote << indent() << "break" << '\n';
indent_down();
}
- f_remote << indent() << "case \"\":" << endl;
- f_remote << indent() << " Usage()" << endl;
- f_remote << indent() << " break" << endl;
- f_remote << indent() << "default:" << endl;
- f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid function \", cmd)" << endl;
- f_remote << indent() << "}" << endl;
+ f_remote << indent() << "case \"\":" << '\n';
+ f_remote << indent() << " Usage()" << '\n';
+ f_remote << indent() << " break" << '\n';
+ f_remote << indent() << "default:" << '\n';
+ f_remote << indent() << " fmt.Fprintln(os.Stderr, \"Invalid function \", cmd)" << '\n';
+ f_remote << indent() << "}" << '\n';
indent_down();
- f_remote << indent() << "}" << endl;
+ f_remote << indent() << "}" << '\n';
// Close service file
f_remote.close();
format_go_output(f_remote_name);
@@ -2696,80 +2696,80 @@
string self(tmp("self"));
if (extends_processor.empty()) {
- f_types_ << indent() << "type " << serviceName << "Processor struct {" << endl;
- f_types_ << indent() << " processorMap map[string]thrift.TProcessorFunction" << endl;
- f_types_ << indent() << " handler " << serviceName << endl;
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "type " << serviceName << "Processor struct {" << '\n';
+ f_types_ << indent() << " processorMap map[string]thrift.TProcessorFunction" << '\n';
+ f_types_ << indent() << " handler " << serviceName << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
f_types_ << indent() << "func (p *" << serviceName
<< "Processor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {"
- << endl;
- f_types_ << indent() << " p.processorMap[key] = processor" << endl;
- f_types_ << indent() << "}" << endl << endl;
+ << '\n';
+ f_types_ << indent() << " p.processorMap[key] = processor" << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
f_types_ << indent() << "func (p *" << serviceName
<< "Processor) GetProcessorFunction(key string) "
- "(processor thrift.TProcessorFunction, ok bool) {" << endl;
- f_types_ << indent() << " processor, ok = p.processorMap[key]" << endl;
- f_types_ << indent() << " return processor, ok" << endl;
- f_types_ << indent() << "}" << endl << endl;
+ "(processor thrift.TProcessorFunction, ok bool) {" << '\n';
+ f_types_ << indent() << " processor, ok = p.processorMap[key]" << '\n';
+ f_types_ << indent() << " return processor, ok" << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
f_types_ << indent() << "func (p *" << serviceName
- << "Processor) ProcessorMap() map[string]thrift.TProcessorFunction {" << endl;
- f_types_ << indent() << " return p.processorMap" << endl;
- f_types_ << indent() << "}" << endl << endl;
+ << "Processor) ProcessorMap() map[string]thrift.TProcessorFunction {" << '\n';
+ f_types_ << indent() << " return p.processorMap" << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName
- << ") *" << serviceName << "Processor {" << endl << endl;
+ << ") *" << serviceName << "Processor {" << '\n' << '\n';
f_types_
<< indent() << " " << self << " := &" << serviceName
<< "Processor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}"
- << endl;
+ << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string escapedFuncName(escape_string((*f_iter)->get_name()));
f_types_ << indent() << " " << self << ".processorMap[\"" << escapedFuncName << "\"] = &"
<< pServiceName << "Processor" << publicize((*f_iter)->get_name())
- << "{handler:handler}" << endl;
+ << "{handler:handler}" << '\n';
}
string x(tmp("x"));
- f_types_ << indent() << "return " << self << endl;
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "return " << self << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
f_types_ << indent() << "func (p *" << serviceName
<< "Processor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err "
- "thrift.TException) {" << endl;
- f_types_ << indent() << " name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)" << endl;
- f_types_ << indent() << " if err2 != nil { return false, thrift.WrapTException(err2) }" << endl;
- f_types_ << indent() << " if processor, ok := p.GetProcessorFunction(name); ok {" << endl;
- f_types_ << indent() << " return processor.Process(ctx, seqId, iprot, oprot)" << endl;
- f_types_ << indent() << " }" << endl;
- f_types_ << indent() << " iprot.Skip(ctx, thrift.STRUCT)" << endl;
- f_types_ << indent() << " iprot.ReadMessageEnd(ctx)" << endl;
+ "thrift.TException) {" << '\n';
+ f_types_ << indent() << " name, _, seqId, err2 := iprot.ReadMessageBegin(ctx)" << '\n';
+ f_types_ << indent() << " if err2 != nil { return false, thrift.WrapTException(err2) }" << '\n';
+ f_types_ << indent() << " if processor, ok := p.GetProcessorFunction(name); ok {" << '\n';
+ f_types_ << indent() << " return processor.Process(ctx, seqId, iprot, oprot)" << '\n';
+ f_types_ << indent() << " }" << '\n';
+ f_types_ << indent() << " iprot.Skip(ctx, thrift.STRUCT)" << '\n';
+ f_types_ << indent() << " iprot.ReadMessageEnd(ctx)" << '\n';
f_types_ << indent() << " " << x
<< " := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, \"Unknown function "
- "\" + name)" << endl;
- f_types_ << indent() << " oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)" << endl;
- f_types_ << indent() << " " << x << ".Write(ctx, oprot)" << endl;
- f_types_ << indent() << " oprot.WriteMessageEnd(ctx)" << endl;
- f_types_ << indent() << " oprot.Flush(ctx)" << endl;
- f_types_ << indent() << " return false, " << x << endl;
- f_types_ << indent() << "" << endl;
- f_types_ << indent() << "}" << endl << endl;
+ "\" + name)" << '\n';
+ f_types_ << indent() << " oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId)" << '\n';
+ f_types_ << indent() << " " << x << ".Write(ctx, oprot)" << '\n';
+ f_types_ << indent() << " oprot.WriteMessageEnd(ctx)" << '\n';
+ f_types_ << indent() << " oprot.Flush(ctx)" << '\n';
+ f_types_ << indent() << " return false, " << x << '\n';
+ f_types_ << indent() << "" << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
} else {
- f_types_ << indent() << "type " << serviceName << "Processor struct {" << endl;
- f_types_ << indent() << " *" << extends_processor << endl;
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "type " << serviceName << "Processor struct {" << '\n';
+ f_types_ << indent() << " *" << extends_processor << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName
- << ") *" << serviceName << "Processor {" << endl;
+ << ") *" << serviceName << "Processor {" << '\n';
f_types_ << indent() << " " << self << " := &" << serviceName << "Processor{"
- << extends_processor_new << "(handler)}" << endl;
+ << extends_processor_new << "(handler)}" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string escapedFuncName(escape_string((*f_iter)->get_name()));
f_types_ << indent() << " " << self << ".AddToProcessorMap(\"" << escapedFuncName
<< "\", &" << pServiceName << "Processor" << publicize((*f_iter)->get_name())
- << "{handler:handler})" << endl;
+ << "{handler:handler})" << '\n';
}
- f_types_ << indent() << " return " << self << endl;
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << " return " << self << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
}
// Generate the process subfunctions
@@ -2777,7 +2777,7 @@
generate_process_function(tservice, *f_iter);
}
- f_types_ << endl;
+ f_types_ << '\n';
}
/**
@@ -2794,90 +2794,90 @@
// t_struct* xs = tfunction->get_xceptions();
// const std::vector<t_field*>& xceptions = xs->get_members();
- f_types_ << indent() << "type " << processorName << " struct {" << endl;
- f_types_ << indent() << " handler " << publicize(tservice->get_name()) << endl;
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "type " << processorName << " struct {" << '\n';
+ f_types_ << indent() << " handler " << publicize(tservice->get_name()) << '\n';
+ f_types_ << indent() << "}" << '\n' << '\n';
f_types_ << indent() << "func (p *" << processorName
<< ") Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err "
- "thrift.TException) {" << endl;
+ "thrift.TException) {" << '\n';
indent_up();
string write_err;
if (!tfunction->is_oneway()) {
write_err = tmp("_write_err");
- f_types_ << indent() << "var " << write_err << " error" << endl;
+ f_types_ << indent() << "var " << write_err << " error" << '\n';
}
- f_types_ << indent() << "args := " << argsname << "{}" << endl;
- f_types_ << indent() << "if err2 := args." << read_method_name_ << "(ctx, iprot); err2 != nil {" << endl;
+ f_types_ << indent() << "args := " << argsname << "{}" << '\n';
+ f_types_ << indent() << "if err2 := args." << read_method_name_ << "(ctx, iprot); err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << endl;
+ f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << '\n';
if (!tfunction->is_oneway()) {
f_types_ << indent()
<< "x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error())"
- << endl;
+ << '\n';
f_types_ << indent() << "oprot.WriteMessageBegin(ctx, \"" << escape_string(tfunction->get_name())
- << "\", thrift.EXCEPTION, seqId)" << endl;
- f_types_ << indent() << "x.Write(ctx, oprot)" << endl;
- f_types_ << indent() << "oprot.WriteMessageEnd(ctx)" << endl;
- f_types_ << indent() << "oprot.Flush(ctx)" << endl;
+ << "\", thrift.EXCEPTION, seqId)" << '\n';
+ f_types_ << indent() << "x.Write(ctx, oprot)" << '\n';
+ f_types_ << indent() << "oprot.WriteMessageEnd(ctx)" << '\n';
+ f_types_ << indent() << "oprot.Flush(ctx)" << '\n';
}
- f_types_ << indent() << "return false, thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << "return false, thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
- f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << endl << endl;
+ f_types_ << indent() << "}" << '\n';
+ f_types_ << indent() << "iprot.ReadMessageEnd(ctx)" << '\n' << '\n';
// Even though we never create the goroutine in oneway handlers,
// always have (nop) tickerCancel defined makes the writing part of code
// generating easier and less error-prone.
- f_types_ << indent() << "tickerCancel := func() {}" << endl;
+ f_types_ << indent() << "tickerCancel := func() {}" << '\n';
// Only create the goroutine for non-oneways.
if (!tfunction->is_oneway()) {
- f_types_ << indent() << "// Start a goroutine to do server side connectivity check." << endl;
- f_types_ << indent() << "if thrift.ServerConnectivityCheckInterval > 0 {" << endl;
+ f_types_ << indent() << "// Start a goroutine to do server side connectivity check." << '\n';
+ f_types_ << indent() << "if thrift.ServerConnectivityCheckInterval > 0 {" << '\n';
indent_up();
- f_types_ << indent() << "var cancel context.CancelCauseFunc" << endl;
- f_types_ << indent() << "ctx, cancel = context.WithCancelCause(ctx)" << endl;
- f_types_ << indent() << "defer cancel(nil)" << endl;
- f_types_ << indent() << "var tickerCtx context.Context" << endl;
- f_types_ << indent() << "tickerCtx, tickerCancel = context.WithCancel(context.Background())" << endl;
- f_types_ << indent() << "defer tickerCancel()" << endl;
- f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelCauseFunc) {" << endl;
+ f_types_ << indent() << "var cancel context.CancelCauseFunc" << '\n';
+ f_types_ << indent() << "ctx, cancel = context.WithCancelCause(ctx)" << '\n';
+ f_types_ << indent() << "defer cancel(nil)" << '\n';
+ f_types_ << indent() << "var tickerCtx context.Context" << '\n';
+ f_types_ << indent() << "tickerCtx, tickerCancel = context.WithCancel(context.Background())" << '\n';
+ f_types_ << indent() << "defer tickerCancel()" << '\n';
+ f_types_ << indent() << "go func(ctx context.Context, cancel context.CancelCauseFunc) {" << '\n';
indent_up();
- f_types_ << indent() << "ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)" << endl;
- f_types_ << indent() << "defer ticker.Stop()" << endl;
- f_types_ << indent() << "for {" << endl;
+ f_types_ << indent() << "ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval)" << '\n';
+ f_types_ << indent() << "defer ticker.Stop()" << '\n';
+ f_types_ << indent() << "for {" << '\n';
indent_up();
- f_types_ << indent() << "select {" << endl;
- f_types_ << indent() << "case <-ctx.Done():" << endl;
+ f_types_ << indent() << "select {" << '\n';
+ f_types_ << indent() << "case <-ctx.Done():" << '\n';
indent_up();
- f_types_ << indent() << "return" << endl;
+ f_types_ << indent() << "return" << '\n';
indent_down();
- f_types_ << indent() << "case <-ticker.C:" << endl;
+ f_types_ << indent() << "case <-ticker.C:" << '\n';
indent_up();
- f_types_ << indent() << "if !iprot.Transport().IsOpen() {" << endl;
+ f_types_ << indent() << "if !iprot.Transport().IsOpen() {" << '\n';
indent_up();
- f_types_ << indent() << "cancel(thrift.ErrAbandonRequest)" << endl;
- f_types_ << indent() << "return" << endl;
+ f_types_ << indent() << "cancel(thrift.ErrAbandonRequest)" << '\n';
+ f_types_ << indent() << "return" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
indent_down();
- f_types_ << indent() << "}(tickerCtx, cancel)" << endl;
+ f_types_ << indent() << "}(tickerCtx, cancel)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
} else {
// Make sure we don't get the defined but unused compiling error.
- f_types_ << indent() << "_ = tickerCancel" << endl << endl;
+ f_types_ << indent() << "_ = tickerCancel" << '\n' << '\n';
}
if (!tfunction->is_oneway()) {
- f_types_ << indent() << "result := " << resultname << "{}" << endl;
+ f_types_ << indent() << "result := " << resultname << "{}" << '\n';
}
bool need_reference = type_need_reference(tfunction->get_returntype());
@@ -2908,93 +2908,93 @@
f_types_ << "args." << publicize((*f_iter)->get_name());
}
- f_types_ << "); err2 != nil {" << endl;
+ f_types_ << "); err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << "tickerCancel()" << endl;
- f_types_ << indent() << "err = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << "tickerCancel()" << '\n';
+ f_types_ << indent() << "err = thrift.WrapTException(err2)" << '\n';
t_struct* exceptions = tfunction->get_xceptions();
const vector<t_field*>& x_fields = exceptions->get_members();
if (!x_fields.empty()) {
- f_types_ << indent() << "switch v := err2.(type) {" << endl;
+ f_types_ << indent() << "switch v := err2.(type) {" << '\n';
vector<t_field*>::const_iterator xf_iter;
for (xf_iter = x_fields.begin(); xf_iter != x_fields.end(); ++xf_iter) {
f_types_ << indent() << "case " << type_to_go_type(((*xf_iter)->get_type())) << ":"
- << endl;
+ << '\n';
indent_up();
- f_types_ << indent() << "result." << publicize((*xf_iter)->get_name()) << " = v" << endl;
+ f_types_ << indent() << "result." << publicize((*xf_iter)->get_name()) << " = v" << '\n';
indent_down();
}
- f_types_ << indent() << "default:" << endl;
+ f_types_ << indent() << "default:" << '\n';
indent_up();
}
if (!tfunction->is_oneway()) {
// Avoid writing the error to the wire if it's ErrAbandonRequest
- f_types_ << indent() << "if errors.Is(err2, thrift.ErrAbandonRequest) {" << endl;
+ f_types_ << indent() << "if errors.Is(err2, thrift.ErrAbandonRequest) {" << '\n';
indent_up();
- f_types_ << indent() << "return false, thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << "return false, thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
- f_types_ << indent() << "if errors.Is(err2, context.Canceled) {" << endl;
+ f_types_ << indent() << "}" << '\n';
+ f_types_ << indent() << "if errors.Is(err2, context.Canceled) {" << '\n';
indent_up();
- f_types_ << indent() << "if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) {" << endl;
+ f_types_ << indent() << "if err := context.Cause(ctx); errors.Is(err, thrift.ErrAbandonRequest) {" << '\n';
indent_up();
- f_types_ << indent() << "return false, thrift.WrapTException(err)" << endl;
+ f_types_ << indent() << "return false, thrift.WrapTException(err)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
string exc(tmp("_exc"));
f_types_ << indent() << exc << " := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "
"\"Internal error processing " << escape_string(tfunction->get_name())
- << ": \" + err2.Error())" << endl;
+ << ": \" + err2.Error())" << '\n';
f_types_ << indent() << "if err2 := oprot.WriteMessageBegin(ctx, \"" << escape_string(tfunction->get_name())
- << "\", thrift.EXCEPTION, seqId); err2 != nil {" << endl;
+ << "\", thrift.EXCEPTION, seqId); err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
f_types_ << indent() << "if err2 := " << exc << ".Write(ctx, oprot); "
- << write_err << " == nil && err2 != nil {" << endl;
+ << write_err << " == nil && err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
f_types_ << indent() << "if err2 := oprot.WriteMessageEnd(ctx); "
- << write_err << " == nil && err2 != nil {" << endl;
+ << write_err << " == nil && err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
f_types_ << indent() << "if err2 := oprot.Flush(ctx); "
- << write_err << " == nil && err2 != nil {" << endl;
+ << write_err << " == nil && err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
- f_types_ << indent() << "if " << write_err << " != nil {" << endl;
+ f_types_ << indent() << "if " << write_err << " != nil {" << '\n';
indent_up();
- f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << endl;
+ f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
// return success=true as long as writing to the wire was successful.
- f_types_ << indent() << "return true, err" << endl;
+ f_types_ << indent() << "return true, err" << '\n';
}
if (!x_fields.empty()) {
indent_down();
- f_types_ << indent() << "}" << endl; // closes switch
+ f_types_ << indent() << "}" << '\n'; // closes switch
}
indent_down();
@@ -3002,63 +3002,63 @@
if (!tfunction->is_oneway()) {
if (!tfunction->get_returntype()->is_void()) {
- f_types_ << " else {" << endl; // make sure we set Success retval only on success
+ f_types_ << " else {" << '\n'; // make sure we set Success retval only on success
indent_up();
f_types_ << indent() << "result.Success = ";
if (need_reference) {
f_types_ << "&";
}
- f_types_ << "retval" << endl;
+ f_types_ << "retval" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
} else {
- f_types_ << endl;
+ f_types_ << '\n';
}
- f_types_ << indent() << "tickerCancel()" << endl;
+ f_types_ << indent() << "tickerCancel()" << '\n';
f_types_ << indent() << "if err2 := oprot.WriteMessageBegin(ctx, \""
<< escape_string(tfunction->get_name()) << "\", thrift.REPLY, seqId); err2 != nil {"
- << endl;
+ << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
f_types_ << indent() << "if err2 := result." << write_method_name_ << "(ctx, oprot); "
- << write_err << " == nil && err2 != nil {" << endl;
+ << write_err << " == nil && err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
f_types_ << indent() << "if err2 := oprot.WriteMessageEnd(ctx); "
- << write_err << " == nil && err2 != nil {" << endl;
+ << write_err << " == nil && err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
- f_types_ << indent() << "if err2 := oprot.Flush(ctx); " << write_err << " == nil && err2 != nil {" << endl;
+ f_types_ << indent() << "if err2 := oprot.Flush(ctx); " << write_err << " == nil && err2 != nil {" << '\n';
indent_up();
- f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << endl;
+ f_types_ << indent() << write_err << " = thrift.WrapTException(err2)" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
- f_types_ << indent() << "if " << write_err << " != nil {" << endl;
+ f_types_ << indent() << "if " << write_err << " != nil {" << '\n';
indent_up();
- f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << endl;
+ f_types_ << indent() << "return false, thrift.WrapTException(" << write_err << ")" << '\n';
indent_down();
- f_types_ << indent() << "}" << endl;
+ f_types_ << indent() << "}" << '\n';
// return success=true as long as writing to the wire was successful.
- f_types_ << indent() << "return true, err" << endl;
+ f_types_ << indent() << "return true, err" << '\n';
} else {
- f_types_ << endl;
- f_types_ << indent() << "tickerCancel()" << endl;
- f_types_ << indent() << "return true, err" << endl;
+ f_types_ << '\n';
+ f_types_ << indent() << "tickerCancel()" << '\n';
+ f_types_ << indent() << "return true, err" << '\n';
}
indent_down();
- f_types_ << indent() << "}" << endl << endl;
+ f_types_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -3096,7 +3096,7 @@
string type_name = inkey ? type_to_go_key_type(tfield->get_type())
: type_to_go_type(tfield->get_type());
- out << "var " << tfield->get_name() << " " << type_name << endl;
+ out << "var " << tfield->get_name() << " " << type_name << '\n';
}
indent(out) << "if v, err := iprot.";
@@ -3153,11 +3153,11 @@
out << "ReadI32(ctx)";
}
- out << "; err != nil {" << endl;
+ out << "; err != nil {" << '\n';
out << indent() << "return thrift.PrependError(\"error reading field " << tfield->get_key()
- << ": \", err)" << endl;
+ << ": \", err)" << '\n';
- out << "} else {" << endl;
+ out << "} else {" << '\n';
string wrap;
if (type->is_enum() || orig_type->is_typedef()) {
@@ -3168,13 +3168,13 @@
string maybe_address = (is_pointer_field(tfield) ? "&" : "");
if (wrap == "") {
- indent(out) << name << " = " << maybe_address << "v" << endl;
+ indent(out) << name << " = " << maybe_address << "v" << '\n';
} else {
- indent(out) << "temp := " << wrap << "(v)" << endl;
- indent(out) << name << " = " << maybe_address << "temp" << endl;
+ indent(out) << "temp := " << wrap << "(v)" << '\n';
+ indent(out) << name << " = " << maybe_address << "temp" << '\n';
}
- out << "}" << endl;
+ out << "}" << '\n';
} else {
throw "INVALID TYPE IN generate_deserialize_field '" + type->get_name() + "' for field '"
+ tfield->get_name() + "'";
@@ -3193,10 +3193,10 @@
out << indent() << prefix << eq << (pointer_field ? "&" : "");
generate_go_struct_initializer(out, tstruct);
- out << indent() << "if err := " << prefix << "." << read_method_name_ << "(ctx, iprot); err != nil {" << endl;
+ out << indent() << "if err := " << prefix << "." << read_method_name_ << "(ctx, iprot); err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T error reading struct: \", "
- << prefix << "), err)" << endl;
- out << indent() << "}" << endl;
+ << prefix << "), err)" << '\n';
+ out << indent() << "}" << '\n';
}
/**
@@ -3217,33 +3217,33 @@
// Declare variables, read header
if (ttype->is_map()) {
- out << indent() << "_, _, size, err := iprot.ReadMapBegin(ctx)" << endl;
- out << indent() << "if err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error reading map begin: \", err)" << endl;
- out << indent() << "}" << endl;
- out << indent() << "tMap := make(" << type_to_go_type(orig_type) << ", size)" << endl;
- out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << endl;
+ out << indent() << "_, _, size, err := iprot.ReadMapBegin(ctx)" << '\n';
+ out << indent() << "if err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error reading map begin: \", err)" << '\n';
+ out << indent() << "}" << '\n';
+ out << indent() << "tMap := make(" << type_to_go_type(orig_type) << ", size)" << '\n';
+ out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tMap" << '\n';
} else if (ttype->is_set()) {
- out << indent() << "_, size, err := iprot.ReadSetBegin(ctx)" << endl;
- out << indent() << "if err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error reading set begin: \", err)" << endl;
- out << indent() << "}" << endl;
- out << indent() << "tSet := make(" << type_to_go_type(orig_type) << ", 0, size)" << endl;
- out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSet" << endl;
+ out << indent() << "_, size, err := iprot.ReadSetBegin(ctx)" << '\n';
+ out << indent() << "if err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error reading set begin: \", err)" << '\n';
+ out << indent() << "}" << '\n';
+ out << indent() << "tSet := make(" << type_to_go_type(orig_type) << ", 0, size)" << '\n';
+ out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSet" << '\n';
} else if (ttype->is_list()) {
- out << indent() << "_, size, err := iprot.ReadListBegin(ctx)" << endl;
- out << indent() << "if err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error reading list begin: \", err)" << endl;
- out << indent() << "}" << endl;
- out << indent() << "tSlice := make(" << type_to_go_type(orig_type) << ", 0, size)" << endl;
- out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSlice" << endl;
+ out << indent() << "_, size, err := iprot.ReadListBegin(ctx)" << '\n';
+ out << indent() << "if err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error reading list begin: \", err)" << '\n';
+ out << indent() << "}" << '\n';
+ out << indent() << "tSlice := make(" << type_to_go_type(orig_type) << ", 0, size)" << '\n';
+ out << indent() << prefix << eq << " " << (pointer_field ? "&" : "") << "tSlice" << '\n';
} else {
throw "INVALID TYPE IN generate_deserialize_container '" + ttype->get_name() + "' for prefix '"
+ prefix + "'";
}
// For loop iterates over elements
- out << indent() << "for i := 0; i < size; i ++ {" << endl;
+ out << indent() << "for i := 0; i < size; i ++ {" << '\n';
indent_up();
if (pointer_field) {
@@ -3258,21 +3258,21 @@
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
// Read container end
if (ttype->is_map()) {
- out << indent() << "if err := iprot.ReadMapEnd(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error reading map end: \", err)" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := iprot.ReadMapEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error reading map end: \", err)" << '\n';
+ out << indent() << "}" << '\n';
} else if (ttype->is_set()) {
- out << indent() << "if err := iprot.ReadSetEnd(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error reading set end: \", err)" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := iprot.ReadSetEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error reading set end: \", err)" << '\n';
+ out << indent() << "}" << '\n';
} else if (ttype->is_list()) {
- out << indent() << "if err := iprot.ReadListEnd(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error reading list end: \", err)" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := iprot.ReadListEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error reading list end: \", err)" << '\n';
+ out << indent() << "}" << '\n';
}
}
@@ -3292,7 +3292,7 @@
fval.set_req(t_field::T_OPT_IN_REQ_OUT);
generate_deserialize_field(out, &fkey, true, "", false, false, true);
generate_deserialize_field(out, &fval, true, "", false, false, false, true);
- indent(out) << prefix << "[" << key << "] = " << val << endl;
+ indent(out) << prefix << "[" << key << "] = " << val << '\n';
}
/**
@@ -3307,7 +3307,7 @@
t_field felem(tset->get_elem_type(), elem);
felem.set_req(t_field::T_OPT_IN_REQ_OUT);
generate_deserialize_field(out, &felem, true, "", false, false, false, true);
- indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl;
+ indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << '\n';
}
/**
@@ -3322,7 +3322,7 @@
t_field felem(((t_list*)tlist)->get_elem_type(), elem);
felem.set_req(t_field::T_OPT_IN_REQ_OUT);
generate_deserialize_field(out, &felem, true, "", false, false, false, true);
- indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl;
+ indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << '\n';
}
/**
@@ -3406,10 +3406,10 @@
out << "WriteI32(ctx, int32(" << name << "))";
}
- out << "; err != nil {" << endl;
+ out << "; err != nil {" << '\n';
out << indent() << "return thrift.PrependError(fmt.Sprintf(\"%T."
<< escape_string(tfield->get_name()) << " (" << tfield->get_key()
- << ") field write error: \", p), err) }" << endl;
+ << ") field write error: \", p), err) }" << '\n';
} else {
throw "compiler error: Invalid type in generate_serialize_field '" + type->get_name()
+ "' for field '" + name + "'";
@@ -3424,10 +3424,10 @@
*/
void t_go_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- out << indent() << "if err := " << prefix << "." << write_method_name_ << "(ctx, oprot); err != nil {" << endl;
+ out << indent() << "if err := " << prefix << "." << write_method_name_ << "(ctx, oprot); err != nil {" << '\n';
out << indent() << " return thrift.PrependError(fmt.Sprintf(\"%T error writing struct: \", "
- << prefix << "), err)" << endl;
- out << indent() << "}" << endl;
+ << prefix << "), err)" << '\n';
+ out << indent() << "}" << '\n';
}
void t_go_generator::generate_serialize_container(ostream& out,
@@ -3441,21 +3441,21 @@
out << indent() << "if err := oprot.WriteMapBegin(ctx, "
<< type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "len(" << prefix << ")); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error writing map begin: \", err)" << endl;
- out << indent() << "}" << endl;
+ << "len(" << prefix << ")); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error writing map begin: \", err)" << '\n';
+ out << indent() << "}" << '\n';
} else if (ttype->is_set()) {
out << indent() << "if err := oprot.WriteSetBegin(ctx, "
<< type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
- << "len(" << prefix << ")); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error writing set begin: \", err)" << endl;
- out << indent() << "}" << endl;
+ << "len(" << prefix << ")); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error writing set begin: \", err)" << '\n';
+ out << indent() << "}" << '\n';
} else if (ttype->is_list()) {
out << indent() << "if err := oprot.WriteListBegin(ctx, "
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", "
- << "len(" << prefix << ")); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error writing list begin: \", err)" << endl;
- out << indent() << "}" << endl;
+ << "len(" << prefix << ")); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error writing list begin: \", err)" << '\n';
+ out << indent() << "}" << '\n';
} else {
throw "compiler error: Invalid type in generate_serialize_container '" + ttype->get_name()
+ "' for prefix '" + prefix + "'";
@@ -3463,66 +3463,66 @@
if (ttype->is_map()) {
t_map* tmap = (t_map*)ttype;
- out << indent() << "for k, v := range " << prefix << " {" << endl;
+ out << indent() << "for k, v := range " << prefix << " {" << '\n';
indent_up();
generate_serialize_map_element(out, tmap, "k", "v");
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
} else if (ttype->is_set()) {
t_set* tset = (t_set*)ttype;
- out << indent() << "for i := 0; i<len(" << prefix << "); i++ {" << endl;
+ out << indent() << "for i := 0; i<len(" << prefix << "); i++ {" << '\n';
indent_up();
- out << indent() << "for j := i+1; j<len(" << prefix << "); j++ {" << endl;
+ out << indent() << "for j := i+1; j<len(" << prefix << "); j++ {" << '\n';
indent_up();
string wrapped_prefix = prefix;
if (pointer_field) {
wrapped_prefix = "(" + prefix + ")";
}
string goType = type_to_go_type(tset->get_elem_type());
- out << indent() << "if func(tgt, src " << goType << ") bool {" << endl;
+ out << indent() << "if func(tgt, src " << goType << ") bool {" << '\n';
indent_up();
generate_go_equals(out, tset->get_elem_type(), "tgt", "src");
- out << indent() << "return true" << endl;
+ out << indent() << "return true" << '\n';
indent_down();
- out << indent() << "}(" << wrapped_prefix << "[i], " << wrapped_prefix << "[j]) {" << endl;
+ out << indent() << "}(" << wrapped_prefix << "[i], " << wrapped_prefix << "[j]) {" << '\n';
indent_up();
out << indent()
<< "return thrift.PrependError(\"\", fmt.Errorf(\"%T error writing set field: slice is not "
"unique\", "
- << wrapped_prefix << "))" << endl;
+ << wrapped_prefix << "))" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "for _, v := range " << prefix << " {" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "for _, v := range " << prefix << " {" << '\n';
indent_up();
generate_serialize_set_element(out, tset, "v");
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
} else if (ttype->is_list()) {
t_list* tlist = (t_list*)ttype;
- out << indent() << "for _, v := range " << prefix << " {" << endl;
+ out << indent() << "for _, v := range " << prefix << " {" << '\n';
indent_up();
generate_serialize_list_element(out, tlist, "v");
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
if (ttype->is_map()) {
- out << indent() << "if err := oprot.WriteMapEnd(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error writing map end: \", err)" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := oprot.WriteMapEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error writing map end: \", err)" << '\n';
+ out << indent() << "}" << '\n';
} else if (ttype->is_set()) {
- out << indent() << "if err := oprot.WriteSetEnd(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error writing set end: \", err)" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := oprot.WriteSetEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error writing set end: \", err)" << '\n';
+ out << indent() << "}" << '\n';
} else if (ttype->is_list()) {
- out << indent() << "if err := oprot.WriteListEnd(ctx); err != nil {" << endl;
- out << indent() << " return thrift.PrependError(\"error writing list end: \", err)" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if err := oprot.WriteListEnd(ctx); err != nil {" << '\n';
+ out << indent() << " return thrift.PrependError(\"error writing list end: \", err)" << '\n';
+ out << indent() << "}" << '\n';
}
}
@@ -3609,7 +3609,7 @@
out << tgt << " != " << src;
}
- out << " { return false }" << endl;
+ out << " { return false }" << '\n';
} else {
throw "compiler error: Invalid type in generate_go_equals '" + ttype->get_name() + "' for '"
+ tgt + "'";
@@ -3625,7 +3625,7 @@
string src) {
(void)ttype;
out << indent() << "if !" << tgt << "." << equals_method_name_ << "(" << src
- << ") { return false }" << endl;
+ << ") { return false }" << '\n';
}
/**
@@ -3635,16 +3635,16 @@
t_type* ttype,
string tgt,
string src) {
- out << indent() << "if len(" << tgt << ") != len(" << src << ") { return false }" << endl;
+ out << indent() << "if len(" << tgt << ") != len(" << src << ") { return false }" << '\n';
if (ttype->is_map()) {
t_map* tmap = (t_map*)ttype;
- out << indent() << "for k, _tgt := range " << tgt << " {" << endl;
+ out << indent() << "for k, _tgt := range " << tgt << " {" << '\n';
indent_up();
string element_source = tmp("_src");
- out << indent() << element_source << " := " << src << "[k]" << endl;
+ out << indent() << element_source << " := " << src << "[k]" << '\n';
generate_go_equals(out, tmap->get_val_type(), "_tgt", element_source);
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
} else if (ttype->is_list() || ttype->is_set()) {
t_type* elem;
if (ttype->is_list()) {
@@ -3654,13 +3654,13 @@
t_set* temp = (t_set*)ttype;
elem = temp->get_elem_type();
}
- out << indent() << "for i, _tgt := range " << tgt << " {" << endl;
+ out << indent() << "for i, _tgt := range " << tgt << " {" << '\n';
indent_up();
string element_source = tmp("_src");
- out << indent() << element_source << " := " << src << "[i]" << endl;
+ out << indent() << element_source << " := " << src << "[i]" << '\n';
generate_go_equals(out, elem, "_tgt", element_source);
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
} else {
throw "INVALID TYPE IN generate_go_equals_container '" + ttype->get_name();
}
@@ -3699,7 +3699,7 @@
if (fields.size() > 0) {
if (has_doc) {
- ss << endl;
+ ss << '\n';
}
has_doc = true;
@@ -3713,7 +3713,7 @@
if (p->has_doc()) {
ss << ": " << p->get_doc();
} else {
- ss << endl;
+ ss << '\n';
}
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.h b/compiler/cpp/src/thrift/generate/t_go_generator.h
index a67485c..55f544e 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.h
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.h
@@ -44,8 +44,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
const string DEFAULT_THRIFT_IMPORT = "github.com/apache/thrift/lib/go/thrift";
static std::string package_flag;
diff --git a/compiler/cpp/src/thrift/generate/t_gv_generator.cc b/compiler/cpp/src/thrift/generate/t_gv_generator.cc
index f8616ff..c91200b 100644
--- a/compiler/cpp/src/thrift/generate/t_gv_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_gv_generator.cc
@@ -38,8 +38,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* Graphviz code generator
*/
@@ -110,10 +108,10 @@
MKDIR(get_out_dir().c_str());
string fname = get_out_dir() + program_->get_name() + ".gv";
f_out_.open(fname.c_str());
- f_out_ << "digraph \"" << escape_string(program_name_) << "\" {" << endl;
- f_out_ << "node [style=filled, shape=record];" << endl;
- f_out_ << "edge [arrowsize=0.5];" << endl;
- f_out_ << "rankdir=LR" << endl;
+ f_out_ << "digraph \"" << escape_string(program_name_) << "\" {" << '\n';
+ f_out_ << "node [style=filled, shape=record];" << '\n';
+ f_out_ << "edge [arrowsize=0.5];" << '\n';
+ f_out_ << "rankdir=LR" << '\n';
}
/**
@@ -126,29 +124,29 @@
// Print edges
std::list<string>::iterator iter = edges.begin();
for (; iter != edges.end(); iter++) {
- f_out_ << (*iter) << endl;
+ f_out_ << (*iter) << '\n';
}
// Print graph end } and close file
- f_out_ << "}" << endl;
+ f_out_ << "}" << '\n';
f_out_.close();
}
void t_gv_generator::generate_typedef(t_typedef* ttypedef) {
string name = ttypedef->get_name();
- f_out_ << "node [fillcolor=azure];" << endl;
+ f_out_ << "node [fillcolor=azure];" << '\n';
f_out_ << name << " [label=\"";
f_out_ << escape_string(name);
f_out_ << " :: ";
print_type(ttypedef->get_type(), name);
- f_out_ << "\"];" << endl;
+ f_out_ << "\"];" << '\n';
}
void t_gv_generator::generate_enum(t_enum* tenum) {
string name = tenum->get_name();
- f_out_ << "node [fillcolor=white];" << endl;
+ f_out_ << "node [fillcolor=white];" << '\n';
f_out_ << name << " [label=\"enum " << escape_string(name);
vector<t_enum_value*> values = tenum->get_constants();
@@ -159,13 +157,13 @@
f_out_ << (*val_iter)->get_value();
}
- f_out_ << "\"];" << endl;
+ f_out_ << "\"];" << '\n';
}
void t_gv_generator::generate_const(t_const* tconst) {
string name = tconst->get_name();
- f_out_ << "node [fillcolor=aliceblue];" << endl;
+ f_out_ << "node [fillcolor=aliceblue];" << '\n';
f_out_ << "const_" << name << " [label=\"";
f_out_ << escape_string(name);
@@ -174,22 +172,22 @@
f_out_ << " :: ";
print_type(tconst->get_type(), "const_" + name);
- f_out_ << "\"];" << endl;
+ f_out_ << "\"];" << '\n';
}
void t_gv_generator::generate_struct(t_struct* tstruct) {
string name = tstruct->get_name();
if (tstruct->is_xception()) {
- f_out_ << "node [fillcolor=lightpink];" << endl;
+ f_out_ << "node [fillcolor=lightpink];" << '\n';
f_out_ << name << " [label=\"";
f_out_ << "exception " << escape_string(name);
} else if (tstruct->is_union()) {
- f_out_ << "node [fillcolor=lightcyan];" << endl;
+ f_out_ << "node [fillcolor=lightcyan];" << '\n';
f_out_ << name << " [label=\"";
f_out_ << "union " << escape_string(name);
} else {
- f_out_ << "node [fillcolor=beige];" << endl;
+ f_out_ << "node [fillcolor=beige];" << '\n';
f_out_ << name << " [label=\"";
f_out_ << "struct " << escape_string(name);
}
@@ -208,7 +206,7 @@
print_type((*mem_iter)->get_type(), name + ":field_" + field_name);
}
- f_out_ << "\"];" << endl;
+ f_out_ << "\"];" << '\n';
}
void t_gv_generator::print_type(t_type* ttype, string struct_field_ref) {
@@ -296,10 +294,10 @@
void t_gv_generator::generate_service(t_service* tservice) {
string service_name = get_service_name(tservice);
- f_out_ << "subgraph cluster_" << service_name << " {" << endl;
- f_out_ << "node [fillcolor=bisque];" << endl;
- f_out_ << "style=dashed;" << endl;
- f_out_ << "label = \"" << escape_string(service_name) << " service\";" << endl;
+ f_out_ << "subgraph cluster_" << service_name << " {" << '\n';
+ f_out_ << "node [fillcolor=bisque];" << '\n';
+ f_out_ << "style=dashed;" << '\n';
+ f_out_ << "label = \"" << escape_string(service_name) << " service\";" << '\n';
// TODO: service extends
@@ -327,7 +325,7 @@
"function_" + service_name + fn_name + ":param_" + (*arg_iter)->get_name());
}
// end of node
- f_out_ << "\"];" << endl;
+ f_out_ << "\"];" << '\n';
// Exception edges
if (exception_arrows) {
@@ -340,7 +338,7 @@
}
}
- f_out_ << " }" << endl;
+ f_out_ << " }" << '\n';
}
std::string t_gv_generator::display_name() const {
diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
index b236e0b..40d4ce2 100644
--- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
@@ -37,8 +37,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* Haxe code generator.
*
@@ -424,10 +422,10 @@
f_enum.open(f_enum_name.c_str());
// Comment and package it
- f_enum << autogen_comment() << haxe_package() << ";" << endl << endl;
+ f_enum << autogen_comment() << haxe_package() << ";" << '\n' << '\n';
// Add haxe imports
- f_enum << string() + "import org.apache.thrift.helper.*;" << endl << endl;
+ f_enum << string() + "import org.apache.thrift.helper.*;" << '\n' << '\n';
generate_rtti_decoration(f_enum);
generate_macro_decoration(f_enum);
@@ -439,11 +437,11 @@
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
indent(f_enum) << "public static inline var " << (*c_iter)->get_name() << " : Int = " << value
- << ";" << endl;
+ << ";" << '\n';
}
// Create a static Set with all valid values for this enum
- f_enum << endl;
+ f_enum << '\n';
indent(f_enum) << "public static var VALID_VALUES = { new IntSet( [";
indent_up();
@@ -454,19 +452,19 @@
firstValue = false;
}
indent_down();
- f_enum << "]); };" << endl;
+ f_enum << "]); };" << '\n';
indent(f_enum) << "public static var VALUES_TO_NAMES = { [";
indent_up();
firstValue = true;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
- f_enum << (firstValue ? "" : ",") << endl;
+ f_enum << (firstValue ? "" : ",") << '\n';
indent(f_enum) << (*c_iter)->get_name() << " => \"" << (*c_iter)->get_name() << "\"";
firstValue = false;
}
- f_enum << endl;
+ f_enum << '\n';
indent_down();
- indent(f_enum) << "]; };" << endl;
+ indent(f_enum) << "]; };" << '\n';
scope_down(f_enum); // end class
@@ -486,15 +484,15 @@
f_consts.open(f_consts_name.c_str());
// Print header
- f_consts << autogen_comment() << haxe_package() << ";" << endl << endl;
+ f_consts << autogen_comment() << haxe_package() << ";" << '\n' << '\n';
- f_consts << endl;
+ f_consts << '\n';
f_consts << haxe_type_imports();
generate_rtti_decoration(f_consts);
generate_macro_decoration(f_consts);
- indent(f_consts) << "class " << get_cap_name(program_name_) << "Constants {" << endl << endl;
+ indent(f_consts) << "class " << get_cap_name(program_name_) << "Constants {" << '\n' << '\n';
indent_up();
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -504,7 +502,7 @@
(*c_iter)->get_value());
}
indent_down();
- indent(f_consts) << "}" << endl;
+ indent(f_consts) << "}" << '\n';
f_consts.close();
}
@@ -527,7 +525,7 @@
}
out << " : " << get_cap_name(type_name(type)) << " = ";
render_const_value(out, type, value);
- out << ";" << endl << endl;
+ out << ";" << '\n' << '\n';
}
std::string t_haxe_generator::render_const_value_str( t_type* type, t_const_value* value) {
@@ -594,9 +592,9 @@
void t_haxe_generator::render_struct_initializer(std::ostream& out,
t_struct* type,
t_const_value* value) {
- out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl;
+ out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n';
indent_up();
- indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl;
+ indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n';
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -615,24 +613,24 @@
}
indent(out) << "tmp." << v_iter->first->get_string() << " = ";
render_const_value(out, field_type, v_iter->second);
- out << ";" << endl;
+ out << ";" << '\n';
}
- indent(out) << "return tmp;" << endl;
+ indent(out) << "return tmp;" << '\n';
indent_down();
- indent(out) << "})()"; // no endl
+ indent(out) << "})()"; // no line break
}
void t_haxe_generator::render_map_initializer(std::ostream& out,
t_map* type,
t_const_value* value) {
- out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl;
+ out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n';
indent_up();
- indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl;
+ indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n';
t_type* key_type = ((t_map*)type)->get_key_type();
t_type* val_type = ((t_map*)type)->get_val_type();
-
+
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& values = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) {
@@ -640,56 +638,56 @@
render_const_value(out, key_type, v_iter->first);
out << ", ";
render_const_value(out, val_type, v_iter->second);
- out << ");" << endl;
+ out << ");" << '\n';
}
-
- indent(out) << "return tmp;" << endl;
+
+ indent(out) << "return tmp;" << '\n';
indent_down();
- indent(out) << "})()"; // no endl
+ indent(out) << "})()"; // no line break
}
void t_haxe_generator::render_list_initializer(std::ostream& out,
t_list* type,
t_const_value* value) {
- out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl;
+ out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n';
indent_up();
- indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl;
+ indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n';
t_type* elm_type = type->get_elem_type();
-
+
const vector<t_const_value*>& values = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) {
indent(out) << "tmp.add(";
render_const_value(out, elm_type, *v_iter);
- out << ");" << endl;
+ out << ");" << '\n';
}
-
- indent(out) << "return tmp;" << endl;
+
+ indent(out) << "return tmp;" << '\n';
indent_down();
- indent(out) << "})()"; // no endl
+ indent(out) << "})()"; // no line break
}
void t_haxe_generator::render_set_initializer(std::ostream& out,
t_set* type,
t_const_value* value) {
- out << "(function() : " << get_cap_name(type_name(type)) << " {" << endl;
+ out << "(function() : " << get_cap_name(type_name(type)) << " {" << '\n';
indent_up();
- indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << endl;
+ indent(out) << "var tmp = new " << get_cap_name(type_name(type)) << "();" << '\n';
t_type* elm_type = type->get_elem_type();
-
+
const vector<t_const_value*>& values = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = values.begin(); v_iter != values.end(); ++v_iter) {
indent(out) << "tmp.add(";
render_const_value(out, elm_type, *v_iter);
- out << ");" << endl;
+ out << ");" << '\n';
}
-
- indent(out) << "return tmp;" << endl;
+
+ indent(out) << "return tmp;" << '\n';
indent_down();
- indent(out) << "})()"; // no endl
+ indent(out) << "})()"; // no line break
}
@@ -723,14 +721,14 @@
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
- f_struct << autogen_comment() << haxe_package() << ";" << endl;
+ f_struct << autogen_comment() << haxe_package() << ";" << '\n';
- f_struct << endl;
+ f_struct << '\n';
string imports;
f_struct << haxe_type_imports() << haxe_thrift_imports()
- << haxe_thrift_gen_imports(tstruct, imports) << endl;
+ << haxe_thrift_gen_imports(tstruct, imports) << '\n';
generate_haxe_struct_definition(f_struct, tstruct, is_exception, is_result);
@@ -762,11 +760,11 @@
if (is_exception) {
out << "extends TException ";
}
- out << "implements TBase {" << endl << endl;
+ out << "implements TBase {" << '\n' << '\n';
indent_up();
indent(out) << "static var STRUCT_DESC = { new TStruct(\"" << tstruct->get_name() << "\"); };"
- << endl;
+ << '\n';
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
@@ -775,69 +773,69 @@
indent(out) << "static var " << constant_name((*m_iter)->get_name())
<< "_FIELD_DESC = { new TField(\"" << (*m_iter)->get_name() << "\", "
<< type_to_enum((*m_iter)->get_type()) << ", " << (*m_iter)->get_key() << "); };"
- << endl;
+ << '\n';
}
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
generate_haxe_doc(out, *m_iter);
// indent(out) << "private var _" << (*m_iter)->get_name() + " : " +
- // type_name((*m_iter)->get_type()) << ";" << endl;
- indent(out) << "@:isVar" << endl;
+ // type_name((*m_iter)->get_type()) << ";" << '\n';
+ indent(out) << "@:isVar" << '\n';
indent(out) << "public var "
<< (*m_iter)->get_name() + "(get,set) : "
- + get_cap_name(type_name((*m_iter)->get_type())) << ";" << endl;
+ + get_cap_name(type_name((*m_iter)->get_type())) << ";" << '\n';
}
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
indent(out) << "inline static var " << upcase_string((*m_iter)->get_name())
- << "_FIELD_ID : Int = " << (*m_iter)->get_key() << ";" << endl;
+ << "_FIELD_ID : Int = " << (*m_iter)->get_key() << ";" << '\n';
}
- out << endl;
+ out << '\n';
// Inner Isset class
if (members.size() > 0) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (!type_can_be_null((*m_iter)->get_type())) {
indent(out) << "private var __isset_" << (*m_iter)->get_name() << " : Bool = false;"
- << endl;
+ << '\n';
}
}
}
- out << endl;
+ out << '\n';
// Static initializer to populate global class to struct metadata map
if (false) {
// TODO: reactivate when needed
generate_haxe_meta_data_map(out, tstruct);
- indent(out) << "{" << endl;
+ indent(out) << "{" << '\n';
indent_up();
indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ", metaDataMap);"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
+ indent(out) << "}" << '\n';
}
// Default constructor
- indent(out) << "public function new() {" << endl;
+ indent(out) << "public function new() {" << '\n';
indent_up();
if (is_exception) {
- indent(out) << "super();" << endl;
+ indent(out) << "super();" << '\n';
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_value() != nullptr) {
indent(out) << "this." << (*m_iter)->get_name() << " = ";
render_const_value( out, (*m_iter)->get_type(), (*m_iter)->get_value());
- out << ";" << endl;
+ out << ";" << '\n';
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
generate_property_getters_setters(out, tstruct);
generate_generic_field_getters_setters(out, tstruct);
@@ -852,7 +850,7 @@
generate_haxe_struct_tostring(out, tstruct, is_exception);
generate_haxe_validator(out, tstruct);
scope_down(out);
- out << endl;
+ out << '\n';
}
/**
@@ -861,123 +859,123 @@
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_struct_reader(ostream& out, t_struct* tstruct) {
- out << indent() << "public function read( iprot : TProtocol) : Void {" << endl;
+ out << indent() << "public function read( iprot : TProtocol) : Void {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "iprot.IncrementRecursionDepth();" << endl;
- indent(out) << "try" << endl;
+ indent(out) << "iprot.IncrementRecursionDepth();" << '\n';
+ indent(out) << "try" << '\n';
scope_up(out);
// Declare stack tmp variables and read struct header
- out << indent() << "var field : TField;" << endl << indent() << "iprot.readStructBegin();"
- << endl;
+ out << indent() << "var field : TField;" << '\n' << indent() << "iprot.readStructBegin();"
+ << '\n';
// Loop over reading in fields
- indent(out) << "while (true)" << endl;
+ indent(out) << "while (true)" << '\n';
scope_up(out);
// Read beginning field marker
- indent(out) << "field = iprot.readFieldBegin();" << endl;
+ indent(out) << "field = iprot.readFieldBegin();" << '\n';
// Check for field STOP marker and break
- indent(out) << "if (field.type == TType.STOP) { " << endl;
+ indent(out) << "if (field.type == TType.STOP) { " << '\n';
indent_up();
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
// Switch statement on the field we are reading
- indent(out) << "switch (field.id)" << endl;
+ indent(out) << "switch (field.id)" << '\n';
scope_up(out);
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case " << upcase_string((*f_iter)->get_name()) << "_FIELD_ID:" << endl;
+ indent(out) << "case " << upcase_string((*f_iter)->get_name()) << "_FIELD_ID:" << '\n';
indent_up();
- indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+ indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n';
indent_up();
generate_deserialize_field(out, *f_iter, "this.");
generate_isset_set(out, *f_iter);
indent_down();
- out << indent() << "} else { " << endl << indent() << " TProtocolUtil.skip(iprot, field.type);"
- << endl << indent() << "}" << endl;
+ out << indent() << "} else { " << '\n' << indent() << " TProtocolUtil.skip(iprot, field.type);"
+ << '\n' << indent() << "}" << '\n';
indent_down();
}
// In the default case we skip the field
- out << indent() << "default:" << endl << indent() << " TProtocolUtil.skip(iprot, field.type);"
- << endl;
+ out << indent() << "default:" << '\n' << indent() << " TProtocolUtil.skip(iprot, field.type);"
+ << '\n';
scope_down(out);
// Read field end marker
- indent(out) << "iprot.readFieldEnd();" << endl;
+ indent(out) << "iprot.readFieldEnd();" << '\n';
scope_down(out);
- out << indent() << "iprot.readStructEnd();" << endl << endl;
+ out << indent() << "iprot.readStructEnd();" << '\n' << '\n';
- indent(out) << "iprot.DecrementRecursionDepth();" << endl;
+ indent(out) << "iprot.DecrementRecursionDepth();" << '\n';
scope_down(out);
- indent(out) << "catch(e:Dynamic)" << endl;
+ indent(out) << "catch(e:Dynamic)" << '\n';
scope_up(out);
- indent(out) << "iprot.DecrementRecursionDepth();" << endl;
- indent(out) << "throw e;" << endl;
+ indent(out) << "iprot.DecrementRecursionDepth();" << '\n';
+ indent(out) << "throw e;" << '\n';
scope_down(out);
// check for required fields of primitive type
// (which can be checked here but not in the general validate method)
- out << endl << indent() << "// check for required fields of primitive type, which can't be "
- "checked in the validate method" << endl;
+ out << '\n' << indent() << "// check for required fields of primitive type, which can't be "
+ "checked in the validate method" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
- out << indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << endl << indent()
+ out << indent() << "if (!__isset_" << (*f_iter)->get_name() << ") {" << '\n' << indent()
<< " throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '"
<< (*f_iter)->get_name()
- << "' was not found in serialized data! Struct: \" + toString());" << endl << indent()
- << "}" << endl;
+ << "' was not found in serialized data! Struct: \" + toString());" << '\n' << indent()
+ << "}" << '\n';
}
}
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl;
+ indent(out) << "validate();" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
// generates haxe method to perform various checks
// (e.g. check that all required fields are set)
void t_haxe_generator::generate_haxe_validator(ostream& out, t_struct* tstruct) {
- indent(out) << "public function validate() : Void {" << endl;
+ indent(out) << "public function validate() : Void {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- out << indent() << "// check for required fields" << endl;
+ out << indent() << "// check for required fields" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
if (type_can_be_null((*f_iter)->get_type())) {
- indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl;
+ indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << '\n';
indent(out)
<< " throw new TProtocolException(TProtocolException.UNKNOWN, \"Required field '"
- << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
- indent(out) << "}" << endl;
+ << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << '\n';
+ indent(out) << "}" << '\n';
} else {
indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name()
- << "' because it's a primitive." << endl;
+ << "' because it's a primitive." << '\n';
}
}
}
// check that fields of type enum have valid values
- out << indent() << "// check that fields of type enum have valid values" << endl;
+ out << indent() << "// check that fields of type enum have valid values" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* field = (*f_iter);
t_type* type = field->get_type();
@@ -985,18 +983,18 @@
if (type->is_enum()) {
indent(out) << "if (" << generate_isset_check(field) << " && !"
<< get_cap_name(get_enum_class_name(type)) << ".VALID_VALUES.contains("
- << field->get_name() << ")){" << endl;
+ << field->get_name() << ")){" << '\n';
indent_up();
indent(out) << "throw new TProtocolException(TProtocolException.UNKNOWN, \"The field '"
<< field->get_name() << "' has been assigned the invalid value \" + "
- << field->get_name() << ");" << endl;
+ << field->get_name() << ");" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1005,7 +1003,7 @@
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_struct_writer(ostream& out, t_struct* tstruct) {
- out << indent() << "public function write(oprot:TProtocol) : Void {" << endl;
+ out << indent() << "public function write(oprot:TProtocol) : Void {" << '\n';
indent_up();
string name = tstruct->get_name();
@@ -1013,57 +1011,57 @@
vector<t_field*>::const_iterator f_iter;
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl;
- indent(out) << "oprot.IncrementRecursionDepth();" << endl;
- indent(out) << "try" << endl;
+ indent(out) << "validate();" << '\n';
+ indent(out) << "oprot.IncrementRecursionDepth();" << '\n';
+ indent(out) << "try" << '\n';
scope_up(out);
- indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
+ indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
if (could_be_unset) {
- indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
+ indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n';
indent_up();
}
bool null_allowed = type_can_be_null((*f_iter)->get_type());
if (null_allowed) {
- out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
+ out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << '\n';
indent_up();
}
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
+ << "_FIELD_DESC);" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "this.");
// Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
+ indent(out) << "oprot.writeFieldEnd();" << '\n';
if (null_allowed) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
if (could_be_unset) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
- indent(out) << "oprot.writeFieldStop();" << endl;
- indent(out) << "oprot.writeStructEnd();" << endl;
+ indent(out) << "oprot.writeFieldStop();" << '\n';
+ indent(out) << "oprot.writeStructEnd();" << '\n';
- indent(out) << "oprot.DecrementRecursionDepth();" << endl;
+ indent(out) << "oprot.DecrementRecursionDepth();" << '\n';
scope_down(out);
- indent(out) << "catch(e:Dynamic)" << endl;
+ indent(out) << "catch(e:Dynamic)" << '\n';
scope_up(out);
- indent(out) << "oprot.DecrementRecursionDepth();" << endl;
- indent(out) << "throw e;" << endl;
+ indent(out) << "oprot.DecrementRecursionDepth();" << '\n';
+ indent(out) << "throw e;" << '\n';
scope_down(out);
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
/**
@@ -1075,59 +1073,59 @@
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_struct_result_writer(ostream& out, t_struct* tstruct) {
- out << indent() << "public function write(oprot:TProtocol) : Void {" << endl;
+ out << indent() << "public function write(oprot:TProtocol) : Void {" << '\n';
indent_up();
string name = tstruct->get_name();
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "oprot.IncrementRecursionDepth();" << endl;
- indent(out) << "try" << endl;
+ indent(out) << "oprot.IncrementRecursionDepth();" << '\n';
+ indent(out) << "try" << '\n';
scope_up(out);
- indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
+ indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n';
bool first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (first) {
first = false;
- out << endl << indent() << "if ";
+ out << '\n' << indent() << "if ";
} else {
out << " else if ";
}
- out << "(this." << generate_isset_check(*f_iter) << ") {" << endl;
+ out << "(this." << generate_isset_check(*f_iter) << ") {" << '\n';
indent_up();
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
+ << "_FIELD_DESC);" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "this.");
// Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
+ indent(out) << "oprot.writeFieldEnd();" << '\n';
indent_down();
indent(out) << "}";
}
- indent(out) << endl;
- indent(out) << "oprot.writeFieldStop();" << endl;
- indent(out) << "oprot.writeStructEnd();" << endl;
+ indent(out) << '\n';
+ indent(out) << "oprot.writeFieldStop();" << '\n';
+ indent(out) << "oprot.writeStructEnd();" << '\n';
- indent(out) << "oprot.DecrementRecursionDepth();" << endl;
+ indent(out) << "oprot.DecrementRecursionDepth();" << '\n';
scope_down(out);
- indent(out) << "catch(e:Dynamic)" << endl;
+ indent(out) << "catch(e:Dynamic)" << '\n';
scope_up(out);
- indent(out) << "oprot.DecrementRecursionDepth();" << endl;
- indent(out) << "throw e;" << endl;
+ indent(out) << "oprot.DecrementRecursionDepth();" << '\n';
+ indent(out) << "throw e;" << '\n';
scope_down(out);
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_haxe_generator::generate_reflection_getters(ostringstream& out,
@@ -1136,9 +1134,9 @@
string cap_name) {
(void)type;
(void)cap_name;
- indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << endl;
+ indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << '\n';
indent_up();
- indent(out) << "return this." << field_name << ";" << endl;
+ indent(out) << "return this." << field_name << ";" << '\n';
indent_down();
}
@@ -1148,13 +1146,13 @@
string cap_name) {
(void)type;
(void)cap_name;
- indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << endl;
+ indent(out) << "case " << upcase_string(field_name) << "_FIELD_ID:" << '\n';
indent_up();
- indent(out) << "if (value == null) {" << endl;
- indent(out) << " unset" << get_cap_name(field_name) << "();" << endl;
- indent(out) << "} else {" << endl;
- indent(out) << " this." << field_name << " = value;" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "if (value == null) {" << '\n';
+ indent(out) << " unset" << get_cap_name(field_name) << "();" << '\n';
+ indent(out) << "} else {" << '\n';
+ indent(out) << " this." << field_name << " = value;" << '\n';
+ indent(out) << "}" << '\n' << '\n';
indent_down();
}
@@ -1181,39 +1179,39 @@
}
// create the setter
- indent(out) << "public function setFieldValue(fieldID : Int, value : Dynamic) : Void {" << endl;
+ indent(out) << "public function setFieldValue(fieldID : Int, value : Dynamic) : Void {" << '\n';
indent_up();
if (fields.size() > 0) {
- indent(out) << "switch (fieldID) {" << endl;
+ indent(out) << "switch (fieldID) {" << '\n';
out << setter_stream.str();
- indent(out) << "default:" << endl;
- indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n';
+ indent(out) << "}" << '\n';
} else {
- indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
+ indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// create the getter
- indent(out) << "public function getFieldValue(fieldID : Int) : Dynamic {" << endl;
+ indent(out) << "public function getFieldValue(fieldID : Int) : Dynamic {" << '\n';
indent_up();
if (fields.size() > 0) {
- indent(out) << "switch (fieldID) {" << endl;
+ indent(out) << "switch (fieldID) {" << '\n';
out << getter_stream.str();
- indent(out) << "default:" << endl;
- indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n';
+ indent(out) << "}" << '\n';
} else {
- indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
+ indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// Creates a generic isSet method that takes the field number as argument
@@ -1223,29 +1221,29 @@
// create the isSet method
indent(out) << "// Returns true if field corresponding to fieldID is set (has been assigned a "
- "value) and false otherwise" << endl;
- indent(out) << "public function isSet(fieldID : Int) : Bool {" << endl;
+ "value) and false otherwise" << '\n';
+ indent(out) << "public function isSet(fieldID : Int) : Bool {" << '\n';
indent_up();
if (fields.size() > 0) {
- indent(out) << "switch (fieldID) {" << endl;
+ indent(out) << "switch (fieldID) {" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* field = *f_iter;
- indent(out) << "case " << upcase_string(field->get_name()) << "_FIELD_ID:" << endl;
+ indent(out) << "case " << upcase_string(field->get_name()) << "_FIELD_ID:" << '\n';
indent_up();
- indent(out) << "return " << generate_isset_check(field) << ";" << endl;
+ indent(out) << "return " << generate_isset_check(field) << ";" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
- indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n';
+ indent(out) << "}" << '\n';
} else {
- indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
+ indent(out) << "throw new ArgumentError(\"Field \" + fieldID + \" doesn't exist!\");" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1265,48 +1263,48 @@
// Simple getter
generate_haxe_doc(out, field);
indent(out) << "public function get_" << field_name << "() : " << get_cap_name(type_name(type))
- << " {" << endl;
+ << " {" << '\n';
indent_up();
- indent(out) << "return this." << field_name << ";" << endl;
+ indent(out) << "return this." << field_name << ";" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// Simple setter
generate_haxe_doc(out, field);
indent(out) << "public function set_" << field_name << "(" << field_name << ":"
<< get_cap_name(type_name(type)) << ") : " << get_cap_name(type_name(type)) << " {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "this." << field_name << " = " << field_name << ";" << endl;
+ indent(out) << "this." << field_name << " = " << field_name << ";" << '\n';
generate_isset_set(out, field);
- indent(out) << "return this." << field_name << ";" << endl;
+ indent(out) << "return this." << field_name << ";" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// Unsetter
- indent(out) << "public function unset" << cap_name << "() : Void {" << endl;
+ indent(out) << "public function unset" << cap_name << "() : Void {" << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "this." << field_name << " = null;" << endl;
+ indent(out) << "this." << field_name << " = null;" << '\n';
} else {
- indent(out) << "this.__isset_" << field_name << " = false;" << endl;
+ indent(out) << "this.__isset_" << field_name << " = false;" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// isSet method
indent(out) << "// Returns true if field " << field_name
- << " is set (has been assigned a value) and false otherwise" << endl;
- indent(out) << "public function is" << get_cap_name("set") << cap_name << "() : Bool {" << endl;
+ << " is set (has been assigned a value) and false otherwise" << '\n';
+ indent(out) << "public function is" << get_cap_name("set") << cap_name << "() : Bool {" << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "return this." << field_name << " != null;" << endl;
+ indent(out) << "return this." << field_name << " != null;" << '\n';
} else {
- indent(out) << "return this.__isset_" << field_name << ";" << endl;
+ indent(out) << "return this.__isset_" << field_name << ";" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
}
@@ -1320,11 +1318,11 @@
if( is_override) {
out << "override ";
}
- out << "function toString() : String {" << endl;
+ out << "function toString() : String {" << '\n';
indent_up();
- out << indent() << "var ret : String = \"" << tstruct->get_name() << "(\";" << endl;
- out << indent() << "var first : Bool = true;" << endl << endl;
+ out << indent() << "var ret : String = \"" << tstruct->get_name() << "(\";" << '\n';
+ out << indent() << "var first : Bool = true;" << '\n' << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -1332,58 +1330,58 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
if (could_be_unset) {
- indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
+ indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n';
indent_up();
}
t_field* field = (*f_iter);
if (!first) {
- indent(out) << "if (!first) ret += \", \";" << endl;
+ indent(out) << "if (!first) ret += \", \";" << '\n';
}
- indent(out) << "ret += \"" << (*f_iter)->get_name() << ":\";" << endl;
+ indent(out) << "ret += \"" << (*f_iter)->get_name() << ":\";" << '\n';
bool can_be_null = type_can_be_null(field->get_type());
if (can_be_null) {
- indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << endl;
- indent(out) << " ret += \"null\";" << endl;
- indent(out) << "} else {" << endl;
+ indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << '\n';
+ indent(out) << " ret += \"null\";" << '\n';
+ indent(out) << "} else {" << '\n';
indent_up();
}
if (field->get_type()->is_binary()) {
- indent(out) << " ret += \"BINARY\";" << endl;
+ indent(out) << " ret += \"BINARY\";" << '\n';
} else if (field->get_type()->is_enum()) {
indent(out) << "var " << field->get_name()
<< "_name : String = " << get_cap_name(get_enum_class_name(field->get_type()))
- << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];" << endl;
- indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
- indent(out) << " ret += " << field->get_name() << "_name;" << endl;
- indent(out) << " ret += \" (\";" << endl;
- indent(out) << "}" << endl;
- indent(out) << "ret += this." << field->get_name() << ";" << endl;
- indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
- indent(out) << " ret += \")\";" << endl;
- indent(out) << "}" << endl;
+ << ".VALUES_TO_NAMES[this." << (*f_iter)->get_name() << "];" << '\n';
+ indent(out) << "if (" << field->get_name() << "_name != null) {" << '\n';
+ indent(out) << " ret += " << field->get_name() << "_name;" << '\n';
+ indent(out) << " ret += \" (\";" << '\n';
+ indent(out) << "}" << '\n';
+ indent(out) << "ret += this." << field->get_name() << ";" << '\n';
+ indent(out) << "if (" << field->get_name() << "_name != null) {" << '\n';
+ indent(out) << " ret += \")\";" << '\n';
+ indent(out) << "}" << '\n';
} else {
- indent(out) << "ret += this." << (*f_iter)->get_name() << ";" << endl;
+ indent(out) << "ret += this." << (*f_iter)->get_name() << ";" << '\n';
}
if (can_be_null) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- indent(out) << "first = false;" << endl;
+ indent(out) << "first = false;" << '\n';
if (could_be_unset) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
first = false;
}
- out << indent() << "ret += \")\";" << endl << indent() << "return ret;" << endl;
+ out << indent() << "ret += \")\";" << '\n' << indent() << "return ret;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1397,7 +1395,7 @@
vector<t_field*>::const_iterator f_iter;
// Static Map with fieldID -> FieldMetaData mappings
- indent(out) << "inline static var metaDataMap : IntMap = new IntMap();" << endl;
+ indent(out) << "inline static var metaDataMap : IntMap = new IntMap();" << '\n';
if (fields.size() > 0) {
// Populate map
@@ -1419,7 +1417,7 @@
// Create value meta data
generate_field_value_meta_data(out, field->get_type());
- out << ");" << endl;
+ out << ");" << '\n';
}
scope_down(out);
}
@@ -1484,7 +1482,7 @@
}
void t_haxe_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) {
- out << endl;
+ out << '\n';
indent_up();
indent_up();
if (type->is_struct()) {
@@ -1527,20 +1525,20 @@
string f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "_service.hx";
f_service_.open(f_service_name.c_str());
- f_service_ << autogen_comment() << haxe_package() << ";" << endl;
+ f_service_ << autogen_comment() << haxe_package() << ";" << '\n';
- f_service_ << endl << haxe_type_imports() << haxe_thrift_imports()
+ f_service_ << '\n' << haxe_type_imports() << haxe_thrift_imports()
<< haxe_thrift_gen_imports(tservice);
if (tservice->get_extends() != nullptr) {
t_type* parent = tservice->get_extends();
string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe"));
if (!parent_namespace.empty() && parent_namespace != package_name_) {
- f_service_ << "import " << get_cap_name(type_name(parent)) << "_service;" << endl;
+ f_service_ << "import " << get_cap_name(type_name(parent)) << "_service;" << '\n';
}
}
- f_service_ << endl;
+ f_service_ << '\n';
generate_service_interface(tservice,false);
f_service_.close();
@@ -1549,20 +1547,20 @@
f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + ".hx";
f_service_.open(f_service_name.c_str());
- f_service_ << autogen_comment() << haxe_package() << ";" << endl;
+ f_service_ << autogen_comment() << haxe_package() << ";" << '\n';
- f_service_ << endl << haxe_type_imports() << haxe_thrift_imports()
+ f_service_ << '\n' << haxe_type_imports() << haxe_thrift_imports()
<< haxe_thrift_gen_imports(tservice);
if (tservice->get_extends() != nullptr) {
t_type* parent = tservice->get_extends();
string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe"));
if (!parent_namespace.empty() && parent_namespace != package_name_) {
- f_service_ << "import " << get_cap_name(type_name(parent)) << ";" << endl;
+ f_service_ << "import " << get_cap_name(type_name(parent)) << ";" << '\n';
}
}
- f_service_ << endl;
+ f_service_ << '\n';
generate_service_interface(tservice,true);
f_service_.close();
@@ -1571,18 +1569,18 @@
f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "Impl.hx";
f_service_.open(f_service_name.c_str());
- f_service_ << autogen_comment() << haxe_package() << ";" << endl << endl << haxe_type_imports()
- << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice) << endl;
+ f_service_ << autogen_comment() << haxe_package() << ";" << '\n' << '\n' << haxe_type_imports()
+ << haxe_thrift_imports() << haxe_thrift_gen_imports(tservice) << '\n';
if (tservice->get_extends() != nullptr) {
t_type* parent = tservice->get_extends();
string parent_namespace = make_package_name( parent->get_program()->get_namespace("haxe"));
if (!parent_namespace.empty() && parent_namespace != package_name_) {
- f_service_ << "import " << get_cap_name(type_name(parent)) << "Impl;" << endl;
+ f_service_ << "import " << get_cap_name(type_name(parent)) << "Impl;" << '\n';
}
}
- f_service_ << endl;
+ f_service_ << '\n';
generate_service_client(tservice);
f_service_.close();
@@ -1594,17 +1592,17 @@
f_service_name = package_dir_ + "/" + get_cap_name(service_name_) + "Processor.hx";
f_service_.open(f_service_name.c_str());
- f_service_ << autogen_comment() << haxe_package() << ";" << endl
- << endl
+ f_service_ << autogen_comment() << haxe_package() << ";" << '\n'
+ << '\n'
<< haxe_type_imports()
- << haxe_thrift_imports()
- << haxe_thrift_gen_imports(tservice)
- << endl;
+ << haxe_thrift_imports()
+ << haxe_thrift_gen_imports(tservice)
+ << '\n';
if (!package_name_.empty()) {
- f_service_ << "import " << package_name_ << ".*;" << endl;
- f_service_ << "import " << package_name_ << "." << get_cap_name(service_name_).c_str() << "Impl;" << endl;
- f_service_ << endl;
+ f_service_ << "import " << package_name_ << ".*;" << '\n';
+ f_service_ << "import " << package_name_ << "." << get_cap_name(service_name_).c_str() << "Impl;" << '\n';
+ f_service_ << '\n';
}
generate_service_server(tservice);
@@ -1668,9 +1666,9 @@
bool is_interface) {
if (is_interface) {
generate_deprecation_attribute(f_service_, tfunction, true);
- indent(f_service_) << function_signature_normal(tfunction) << ";" << endl << endl;
+ indent(f_service_) << function_signature_normal(tfunction) << ";" << '\n' << '\n';
} else {
- indent(f_service_) << "public " << function_signature_normal(tfunction) << " {" << endl;
+ indent(f_service_) << "public " << function_signature_normal(tfunction) << " {" << '\n';
}
}
@@ -1683,15 +1681,15 @@
bool is_interface) {
if (!tfunction->is_oneway()) {
std::string on_success_impl = generate_service_method_onsuccess(tfunction, false, false);
- indent(f_service_) << "// function onError(Dynamic) : Void;" << endl;
- indent(f_service_) << "// function " << on_success_impl.c_str() << ";" << endl;
+ indent(f_service_) << "// function onError(Dynamic) : Void;" << '\n';
+ indent(f_service_) << "// function " << on_success_impl.c_str() << ";" << '\n';
}
if (is_interface) {
generate_deprecation_attribute(f_service_, tfunction, false);
- indent(f_service_) << function_signature_combined(tfunction) << ";" << endl << endl;
+ indent(f_service_) << function_signature_combined(tfunction) << ";" << '\n' << '\n';
} else {
- indent(f_service_) << "public " << function_signature_combined(tfunction) << " {" << endl;
+ indent(f_service_) << "public " << function_signature_combined(tfunction) << " {" << '\n';
}
}
@@ -1738,7 +1736,7 @@
}
}
- out << endl;
+ out << '\n';
}
}
@@ -1762,14 +1760,14 @@
generate_rtti_decoration(f_service_);
generate_macro_decoration(f_service_);
f_service_ << indent() << "interface " << get_cap_name(service_name_) << cbk_postfix << extends_iface << " {"
- << endl << endl;
+ << '\n' << '\n';
indent_up();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_haxe_doc(f_service_, *f_iter);
generate_service_method_signature(*f_iter, true, combined);
}
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -1778,7 +1776,7 @@
* @param tservice The service
*/
void t_haxe_generator::generate_service_helpers(t_service* tservice) {
- f_service_ << endl << endl;
+ f_service_ << '\n' << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1804,44 +1802,44 @@
generate_rtti_decoration(f_service_);
// build macro is inherited from interface
indent(f_service_) << "class " << get_cap_name(service_name_) << "Impl" << extends_client
- << " implements " << get_cap_name(service_name_) << " {" << endl << endl;
+ << " implements " << get_cap_name(service_name_) << " {" << '\n' << '\n';
indent_up();
- indent(f_service_) << "public function new( iprot : TProtocol, oprot : TProtocol = null)" << endl;
+ indent(f_service_) << "public function new( iprot : TProtocol, oprot : TProtocol = null)" << '\n';
scope_up(f_service_);
if (extends.empty()) {
- f_service_ << indent() << "iprot_ = iprot;" << endl;
- f_service_ << indent() << "if (oprot == null) {" << endl;
+ f_service_ << indent() << "iprot_ = iprot;" << '\n';
+ f_service_ << indent() << "if (oprot == null) {" << '\n';
indent_up();
- f_service_ << indent() << "oprot_ = iprot;" << endl;
+ f_service_ << indent() << "oprot_ = iprot;" << '\n';
indent_down();
- f_service_ << indent() << "} else {" << endl;
+ f_service_ << indent() << "} else {" << '\n';
indent_up();
- f_service_ << indent() << "oprot_ = oprot;" << endl;
+ f_service_ << indent() << "oprot_ = oprot;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "}" << '\n';
} else {
- f_service_ << indent() << "super(iprot, oprot);" << endl;
+ f_service_ << indent() << "super(iprot, oprot);" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
if (extends.empty()) {
- f_service_ << indent() << "private var iprot_ : TProtocol;" << endl << indent()
- << "private var oprot_ : TProtocol;" << endl << indent()
- << "private var seqid_ : Int;" << endl << endl;
+ f_service_ << indent() << "private var iprot_ : TProtocol;" << '\n' << indent()
+ << "private var oprot_ : TProtocol;" << '\n' << indent()
+ << "private var seqid_ : Int;" << '\n' << '\n';
- indent(f_service_) << "public function getInputProtocol() : TProtocol" << endl;
+ indent(f_service_) << "public function getInputProtocol() : TProtocol" << '\n';
scope_up(f_service_);
- indent(f_service_) << "return this.iprot_;" << endl;
+ indent(f_service_) << "return this.iprot_;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
- indent(f_service_) << "public function getOutputProtocol() : TProtocol" << endl;
+ indent(f_service_) << "public function getOutputProtocol() : TProtocol" << '\n';
scope_up(f_service_);
- indent(f_service_) << "return this.oprot_;" << endl;
+ indent(f_service_) << "return this.oprot_;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
// Generate client method implementations
@@ -1866,140 +1864,140 @@
string args = tmp("args");
string calltype = (*f_iter)->is_oneway() ? "ONEWAY" : "CALL";
f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname
- << "\", TMessageType." << calltype << ", seqid_));" << endl << indent()
- << "var " << args << " : " << argsname << " = new " << argsname << "();" << endl;
+ << "\", TMessageType." << calltype << ", seqid_));" << '\n' << indent()
+ << "var " << args << " : " << argsname << " = new " << argsname << "();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << args << "." << (*fld_iter)->get_name() << " = "
- << (*fld_iter)->get_name() << ";" << endl;
+ << (*fld_iter)->get_name() << ";" << '\n';
}
- f_service_ << indent() << args << ".write(oprot_);" << endl << indent()
- << "oprot_.writeMessageEnd();" << endl;
+ f_service_ << indent() << args << ".write(oprot_);" << '\n' << indent()
+ << "oprot_.writeMessageEnd();" << '\n';
string retval = tmp("retval");
if (!((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) {
f_service_ << indent() << "var " << retval << " : " << type_name((*f_iter)->get_returntype())
- << " = " << render_default_value_for_type((*f_iter)->get_returntype(),true)
- << ";" << endl;
+ << " = " << render_default_value_for_type((*f_iter)->get_returntype(),true)
+ << ";" << '\n';
}
if ((*f_iter)->is_oneway()) {
- f_service_ << indent() << "oprot_.getTransport().flush();" << endl;
+ f_service_ << indent() << "oprot_.getTransport().flush();" << '\n';
} else {
- indent(f_service_) << "oprot_.getTransport().flush(function(error:Dynamic) : Void {" << endl;
+ indent(f_service_) << "oprot_.getTransport().flush(function(error:Dynamic) : Void {" << '\n';
indent_up();
- indent(f_service_) << "try {" << endl;
+ indent(f_service_) << "try {" << '\n';
indent_up();
string appex = tmp("appex");
- indent(f_service_) << "var " << appex << " : TApplicationException;" << endl;
+ indent(f_service_) << "var " << appex << " : TApplicationException;" << '\n';
string resultname = get_cap_name((*f_iter)->get_name() + "_result");
- indent(f_service_) << "if (error != null) {" << endl;
+ indent(f_service_) << "if (error != null) {" << '\n';
indent_up();
- indent(f_service_) << "if (onError == null)" << endl;
+ indent(f_service_) << "if (onError == null)" << '\n';
indent_up();
- indent(f_service_) << "throw error;" << endl;
+ indent(f_service_) << "throw error;" << '\n';
indent_down();
- indent(f_service_) << "onError(error);" << endl;
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "onError(error);" << '\n';
+ indent(f_service_) << "return;" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
string msg = tmp("msg");
- indent(f_service_) << "var " << msg << " : TMessage = iprot_.readMessageBegin();" << endl;
- indent(f_service_) << "if (" << msg << ".type == TMessageType.EXCEPTION) {" << endl;
+ indent(f_service_) << "var " << msg << " : TMessage = iprot_.readMessageBegin();" << '\n';
+ indent(f_service_) << "if (" << msg << ".type == TMessageType.EXCEPTION) {" << '\n';
indent_up();
- indent(f_service_) << appex << " = TApplicationException.read(iprot_);" << endl;
- indent(f_service_) << "iprot_.readMessageEnd();" << endl;
- indent(f_service_) << "if (onError == null)" << endl;
+ indent(f_service_) << appex << " = TApplicationException.read(iprot_);" << '\n';
+ indent(f_service_) << "iprot_.readMessageEnd();" << '\n';
+ indent(f_service_) << "if (onError == null)" << '\n';
indent_up();
- indent(f_service_) << "throw " << appex << ";" << endl;
+ indent(f_service_) << "throw " << appex << ";" << '\n';
indent_down();
- indent(f_service_) << "onError(" << appex << ");" << endl;
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "onError(" << appex << ");" << '\n';
+ indent(f_service_) << "return;" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
string result = tmp("result");
- indent(f_service_) << "var " << result << " : " << resultname << " = new " << resultname << "();" << endl;
- indent(f_service_) << "" << result << ".read(iprot_);" << endl;
- indent(f_service_) << "iprot_.readMessageEnd();" << endl;
+ indent(f_service_) << "var " << result << " : " << resultname << " = new " << resultname << "();" << '\n';
+ indent(f_service_) << "" << result << ".read(iprot_);" << '\n';
+ indent(f_service_) << "iprot_.readMessageEnd();" << '\n';
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "if (" << result << "." << generate_isset_check("success") << ") {" << endl;
+ indent(f_service_) << "if (" << result << "." << generate_isset_check("success") << ") {" << '\n';
indent_up();
- indent(f_service_) << "if (onSuccess != null)" << endl;
+ indent(f_service_) << "if (onSuccess != null)" << '\n';
indent_up();
- indent(f_service_) << "onSuccess(" << result << ".success);" << endl;
+ indent(f_service_) << "onSuccess(" << result << ".success);" << '\n';
indent_down();
- indent(f_service_) << retval << " = " << result << ".success;" << endl;
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << retval << " = " << result << ".success;" << '\n';
+ indent(f_service_) << "return;" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- indent(f_service_) << "if (" << result << "." << (*x_iter)->get_name() << " != null) {" << endl;
+ indent(f_service_) << "if (" << result << "." << (*x_iter)->get_name() << " != null) {" << '\n';
indent_up();
- indent(f_service_) << "if (onError == null)" << endl;
+ indent(f_service_) << "if (onError == null)" << '\n';
indent_up();
- indent(f_service_) << "throw " << result << "." << (*x_iter)->get_name() << ";" << endl;
+ indent(f_service_) << "throw " << result << "." << (*x_iter)->get_name() << ";" << '\n';
indent_down();
- indent(f_service_) << "onError(" << result << "." << (*x_iter)->get_name() << ");" << endl;
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "onError(" << result << "." << (*x_iter)->get_name() << ");" << '\n';
+ indent(f_service_) << "return;" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
// If you get here it's an exception, unless a void function
if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "if (onSuccess != null)" << endl;
+ indent(f_service_) << "if (onSuccess != null)" << '\n';
indent_up();
- indent(f_service_) << "onSuccess();" << endl;
+ indent(f_service_) << "onSuccess();" << '\n';
indent_down();
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
} else {
indent(f_service_) << appex << " = new TApplicationException("
<< "TApplicationException.MISSING_RESULT,"
- << "\"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
- indent(f_service_) << "if (onError == null)" << endl;
+ << "\"" << (*f_iter)->get_name() << " failed: unknown result\");" << '\n';
+ indent(f_service_) << "if (onError == null)" << '\n';
indent_up();
- indent(f_service_) << "throw " << appex << ";" << endl;
+ indent(f_service_) << "throw " << appex << ";" << '\n';
indent_down();
- indent(f_service_) << "onError(" << appex << ");" << endl;
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "onError(" << appex << ");" << '\n';
+ indent(f_service_) << "return;" << '\n';
}
indent_down();
- indent(f_service_) << endl;
- indent(f_service_) << "} catch( e : TException) {" << endl;
+ indent(f_service_) << '\n';
+ indent(f_service_) << "} catch( e : TException) {" << '\n';
indent_up();
- indent(f_service_) << "if (onError == null)" << endl;
+ indent(f_service_) << "if (onError == null)" << '\n';
indent_up();
- indent(f_service_) << "throw e;" << endl;
+ indent(f_service_) << "throw e;" << '\n';
indent_down();
- indent(f_service_) << "onError(e);" << endl;
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "onError(e);" << '\n';
+ indent(f_service_) << "return;" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
indent_down();
- indent(f_service_) << "});" << endl << endl;
+ indent(f_service_) << "});" << '\n' << '\n';
}
if (!((*f_iter)->is_oneway() || (*f_iter)->get_returntype()->is_void())) {
- f_service_ << indent() << "return " << retval << ";" << endl;
+ f_service_ << indent() << "return " << retval << ";" << '\n';
}
// Close function
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
}
/**
@@ -2024,35 +2022,35 @@
generate_rtti_decoration(f_service_);
generate_macro_decoration(f_service_);
indent(f_service_) << "class " << get_cap_name(service_name_) << "Processor" << extends_processor
- << " implements TProcessor {" << endl << endl;
+ << " implements TProcessor {" << '\n' << '\n';
indent_up();
f_service_ << indent() << "private var " << get_cap_name(service_name_)
- << "_iface_ : " << get_cap_name(service_name_) << "_service;" << endl;
+ << "_iface_ : " << get_cap_name(service_name_) << "_service;" << '\n';
if (extends.empty()) {
f_service_ << indent()
<< "private var PROCESS_MAP = new StringMap< Int->TProtocol->TProtocol->Void >();"
- << endl;
+ << '\n';
}
- f_service_ << endl;
+ f_service_ << '\n';
indent(f_service_) << "public function new( iface : " << get_cap_name(service_name_) << "_service)"
- << endl;
+ << '\n';
scope_up(f_service_);
if (!extends.empty()) {
- f_service_ << indent() << "super(iface);" << endl;
+ f_service_ << indent() << "super(iface);" << '\n';
}
- f_service_ << indent() << get_cap_name(service_name_) << "_iface_ = iface;" << endl;
+ f_service_ << indent() << get_cap_name(service_name_) << "_iface_ = iface;" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
f_service_ << indent() << "PROCESS_MAP.set(\"" << (*f_iter)->get_name() << "\", "
- << (*f_iter)->get_name() << "());" << endl;
+ << (*f_iter)->get_name() << "());" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the server implementation
string override = "";
@@ -2061,31 +2059,31 @@
}
indent(f_service_) << override
<< "public function process( iprot : TProtocol, oprot : TProtocol) : Bool"
- << endl;
+ << '\n';
scope_up(f_service_);
- f_service_ << indent() << "var msg : TMessage = iprot.readMessageBegin();" << endl;
+ f_service_ << indent() << "var msg : TMessage = iprot.readMessageBegin();" << '\n';
// TODO(mcslee): validate message, was the seqid etc. legit?
f_service_
- << indent() << "var fn = PROCESS_MAP.get(msg.name);" << endl
- << indent() << "if (fn == null) {" << endl
- << indent() << " TProtocolUtil.skip(iprot, TType.STRUCT);" << endl
- << indent() << " iprot.readMessageEnd();" << endl
+ << indent() << "var fn = PROCESS_MAP.get(msg.name);" << '\n'
+ << indent() << "if (fn == null) {" << '\n'
+ << indent() << " TProtocolUtil.skip(iprot, TType.STRUCT);" << '\n'
+ << indent() << " iprot.readMessageEnd();" << '\n'
<< indent() << " var appex = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "
- << "\"Invalid method name: '\"+msg.name+\"'\");" << endl
- << indent() << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl
- << indent() << " appex.write(oprot);" << endl << indent() << " oprot.writeMessageEnd();" << endl
- << indent() << " oprot.getTransport().flush();" << endl
- << indent() << " return true;" << endl << indent() << "}" << endl
- << indent() << "fn( msg.seqid, iprot, oprot);" << endl
+ << "\"Invalid method name: '\"+msg.name+\"'\");" << '\n'
+ << indent() << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << '\n'
+ << indent() << " appex.write(oprot);" << '\n' << indent() << " oprot.writeMessageEnd();" << '\n'
+ << indent() << " oprot.getTransport().flush();" << '\n'
+ << indent() << " return true;" << '\n' << indent() << "}" << '\n'
+ << indent() << "fn( msg.seqid, iprot, oprot);" << '\n'
;
- f_service_ << indent() << "return true;" << endl;
+ f_service_ << indent() << "return true;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -2093,7 +2091,7 @@
}
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
/**
@@ -2132,20 +2130,20 @@
(void)tservice;
// Open class
indent(f_service_) << "private function " << tfunction->get_name()
- << "() : Int->TProtocol->TProtocol->Void {" << endl;
+ << "() : Int->TProtocol->TProtocol->Void {" << '\n';
indent_up();
// Open function
indent(f_service_) << "return function( seqid : Int, iprot : TProtocol, oprot : TProtocol) : Void"
- << endl;
+ << '\n';
scope_up(f_service_);
string argsname = get_cap_name(tfunction->get_name() + "_args");
string resultname = get_cap_name(tfunction->get_name() + "_result");
- f_service_ << indent() << "var args : " << argsname << " = new " << argsname << "();" << endl
- << indent() << "args.read(iprot);" << endl << indent() << "iprot.readMessageEnd();"
- << endl;
+ f_service_ << indent() << "var args : " << argsname << " = new " << argsname << "();" << '\n'
+ << indent() << "args.read(iprot);" << '\n' << indent() << "iprot.readMessageEnd();"
+ << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -2153,11 +2151,11 @@
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "var result : " << resultname << " = new " << resultname << "();" << endl;
+ f_service_ << indent() << "var result : " << resultname << " = new " << resultname << "();" << '\n';
}
// Try block for any function to catch (defined or undefined) exceptions
- f_service_ << indent() << "try {" << endl;
+ f_service_ << indent() << "try {" << '\n';
indent_up();
@@ -2182,7 +2180,7 @@
}
f_service_ << "args." << (*f_iter)->get_name();
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
indent_down();
f_service_ << indent() << "}";
@@ -2190,11 +2188,11 @@
// catch exceptions defined in the IDL
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << (*x_iter)->get_name() << ":"
- << get_cap_name(type_name((*x_iter)->get_type(), false, false)) << ") {" << endl;
+ << get_cap_name(type_name((*x_iter)->get_type(), false, false)) << ") {" << '\n';
if (!tfunction->is_oneway()) {
indent_up();
f_service_ << indent() << "result." << (*x_iter)->get_name() << " = "
- << (*x_iter)->get_name() << ";" << endl;
+ << (*x_iter)->get_name() << ";" << '\n';
indent_down();
f_service_ << indent() << "}";
} else {
@@ -2205,45 +2203,45 @@
// always catch all exceptions to prevent from service denial
string appex = tmp("appex");
- f_service_ << " catch (th : Dynamic) {" << endl;
+ f_service_ << " catch (th : Dynamic) {" << '\n';
indent_up();
- indent(f_service_) << "trace(\"Internal error processing " << tfunction->get_name() << "\", th);" << endl;
+ indent(f_service_) << "trace(\"Internal error processing " << tfunction->get_name() << "\", th);" << '\n';
if (!tfunction->is_oneway()) {
indent(f_service_) << "var appex = new TApplicationException(TApplicationException.INTERNAL_ERROR, "
- "\"Internal error processing " << tfunction->get_name() << "\");" << endl;
+ "\"Internal error processing " << tfunction->get_name() << "\");" << '\n';
indent(f_service_) << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.EXCEPTION, seqid));" << endl;
- indent(f_service_) << "appex.write(oprot);" << endl;
- indent(f_service_) << "oprot.writeMessageEnd();" << endl;
- indent(f_service_) << "oprot.getTransport().flush();" << endl;
+ << "\", TMessageType.EXCEPTION, seqid));" << '\n';
+ indent(f_service_) << "appex.write(oprot);" << '\n';
+ indent(f_service_) << "oprot.writeMessageEnd();" << '\n';
+ indent(f_service_) << "oprot.getTransport().flush();" << '\n';
}
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "}" << '\n';
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- f_service_ << indent() << "return;" << endl;
+ f_service_ << indent() << "return;" << '\n';
scope_down(f_service_);
// Close class
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
return;
}
f_service_ << indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.REPLY, seqid));" << endl << indent() << "result.write(oprot);"
- << endl << indent() << "oprot.writeMessageEnd();" << endl << indent()
- << "oprot.getTransport().flush();" << endl;
+ << "\", TMessageType.REPLY, seqid));" << '\n' << indent() << "result.write(oprot);"
+ << '\n' << indent() << "oprot.writeMessageEnd();" << '\n' << indent()
+ << "oprot.getTransport().flush();" << '\n';
// Close function
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Close class
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -2309,7 +2307,7 @@
} else if (type->is_enum()) {
out << "readI32();";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
tfield->get_name().c_str(),
@@ -2323,8 +2321,8 @@
void t_haxe_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
- out << indent() << prefix << " = new " << get_cap_name(type_name(tstruct)) << "();" << endl
- << indent() << prefix << ".read(iprot);" << endl;
+ out << indent() << prefix << " = new " << get_cap_name(type_name(tstruct)) << "();" << '\n'
+ << indent() << prefix << ".read(iprot);" << '\n';
}
/**
@@ -2345,21 +2343,21 @@
// Declare variables, read header
if (ttype->is_map()) {
- indent(out) << "var " << obj << " = iprot.readMapBegin();" << endl;
+ indent(out) << "var " << obj << " = iprot.readMapBegin();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "var " << obj << " = iprot.readSetBegin();" << endl;
+ indent(out) << "var " << obj << " = iprot.readSetBegin();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "var " << obj << " = iprot.readListBegin();" << endl;
+ indent(out) << "var " << obj << " = iprot.readListBegin();" << '\n';
}
indent(out) << prefix << " = new " << type_name(ttype, false, true)
// size the collection correctly
<< "("
- << ");" << endl;
+ << ");" << '\n';
// For loop iterates over elements
string i = tmp("_i");
- indent(out) << "for( " << i << " in 0 ... " << obj << ".size)" << endl;
+ indent(out) << "for( " << i << " in 0 ... " << obj << ".size)" << '\n';
scope_up(out);
@@ -2375,11 +2373,11 @@
// Read container end
if (ttype->is_map()) {
- indent(out) << "iprot.readMapEnd();" << endl;
+ indent(out) << "iprot.readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "iprot.readSetEnd();" << endl;
+ indent(out) << "iprot.readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "iprot.readListEnd();" << endl;
+ indent(out) << "iprot.readListEnd();" << '\n';
}
scope_down(out);
@@ -2394,13 +2392,13 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- indent(out) << declare_field(&fkey) << endl;
- indent(out) << declare_field(&fval) << endl;
+ indent(out) << declare_field(&fkey) << '\n';
+ indent(out) << declare_field(&fval) << '\n';
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
- indent(out) << prefix << ".set( " << key << ", " << val << ");" << endl;
+ indent(out) << prefix << ".set( " << key << ", " << val << ");" << '\n';
}
/**
@@ -2410,11 +2408,11 @@
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".add(" << elem << ");" << endl;
+ indent(out) << prefix << ".add(" << elem << ");" << '\n';
}
/**
@@ -2426,11 +2424,11 @@
string elem = tmp("_elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".add(" << elem << ");" << endl;
+ indent(out) << prefix << ".add(" << elem << ");" << '\n';
}
/**
@@ -2496,7 +2494,7 @@
} else if (type->is_enum()) {
out << "writeI32(" << name << ");";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
prefix.c_str(),
@@ -2513,7 +2511,7 @@
*/
void t_haxe_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- out << indent() << prefix << ".write(oprot);" << endl;
+ out << indent() << prefix << ".write(oprot);" << '\n';
}
/**
@@ -2527,30 +2525,30 @@
if (ttype->is_map()) {
string iter = tmp("_key");
string counter = tmp("_sizeCounter");
- indent(out) << "var " << counter << " : Int = 0;" << endl;
- indent(out) << "for( " << iter << " in " << prefix << ") {" << endl;
- indent(out) << " " << counter << +"++;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "var " << counter << " : Int = 0;" << '\n';
+ indent(out) << "for( " << iter << " in " << prefix << ") {" << '\n';
+ indent(out) << " " << counter << +"++;" << '\n';
+ indent(out) << "}" << '\n';
indent(out) << "oprot.writeMapBegin(new TMap(" << type_to_enum(((t_map*)ttype)->get_key_type())
<< ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << counter << "));"
- << endl;
+ << '\n';
} else if (ttype->is_set()) {
indent(out) << "oprot.writeSetBegin(new TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type())
- << ", " << prefix << ".size));" << endl;
+ << ", " << prefix << ".size));" << '\n';
} else if (ttype->is_list()) {
indent(out) << "oprot.writeListBegin(new TList("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".length));"
- << endl;
+ << '\n';
}
string iter = tmp("elem");
if (ttype->is_map()) {
- indent(out) << "for( " << iter << " in " << prefix << ".keys())" << endl;
+ indent(out) << "for( " << iter << " in " << prefix << ".keys())" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "for( " << iter << " in " << prefix << ".toArray())" << endl;
+ indent(out) << "for( " << iter << " in " << prefix << ".toArray())" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "for( " << iter << " in " << prefix << ")" << endl;
+ indent(out) << "for( " << iter << " in " << prefix << ")" << '\n';
}
scope_up(out);
@@ -2566,11 +2564,11 @@
scope_down(out);
if (ttype->is_map()) {
- indent(out) << "oprot.writeMapEnd();" << endl;
+ indent(out) << "oprot.writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "oprot.writeSetEnd();" << endl;
+ indent(out) << "oprot.writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "oprot.writeListEnd();" << endl;
+ indent(out) << "oprot.writeListEnd();" << '\n';
}
}
@@ -3006,7 +3004,7 @@
*/
void t_haxe_generator::generate_rtti_decoration(ostream& out) {
if (rtti_) {
- out << "@:rtti" << endl;
+ out << "@:rtti" << '\n';
}
}
@@ -3015,10 +3013,10 @@
*/
void t_haxe_generator::generate_macro_decoration(ostream& out) {
if (!buildmacro_.empty()) {
- out << "#if ! macro" << endl;
- out << "@:build( " << buildmacro_ << ")" << endl; // current class/interface
- out << "@:autoBuild( " << buildmacro_ << ")" << endl; // inherited classes/interfaces
- out << "#end" << endl;
+ out << "#if ! macro" << '\n';
+ out << "@:build( " << buildmacro_ << ")" << '\n'; // current class/interface
+ out << "@:autoBuild( " << buildmacro_ << ")" << '\n'; // inherited classes/interfaces
+ out << "#end" << '\n';
}
}
@@ -3061,7 +3059,7 @@
void t_haxe_generator::generate_isset_set(ostream& out, t_field* field) {
if (!type_can_be_null(field->get_type())) {
- indent(out) << "this.__isset_" << field->get_name() << " = true;" << endl;
+ indent(out) << "this.__isset_" << field->get_name() << " = true;" << '\n';
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_html_generator.cc b/compiler/cpp/src/thrift/generate/t_html_generator.cc
index 15a0401..637cd88 100644
--- a/compiler/cpp/src/thrift/generate/t_html_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_html_generator.cc
@@ -38,8 +38,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
enum input_type { INPUT_UNKNOWN, INPUT_UTF8, INPUT_PLAIN };
/**
@@ -129,9 +127,9 @@
void t_html_generator::generate_program_toc() {
f_out_ << "<table class=\"table-bordered table-striped "
"table-condensed\"><thead><tr><th>Module</th><th>Services</th>"
- << "<th>Data types</th><th>Constants</th></tr></thead><tbody>" << endl;
+ << "<th>Data types</th><th>Constants</th></tr></thead><tbody>" << '\n';
generate_program_toc_row(program_);
- f_out_ << "</tbody></table>" << endl;
+ f_out_ << "</tbody></table>" << '\n';
}
/**
@@ -159,15 +157,15 @@
*/
void t_html_generator::generate_program_toc_row(t_program* tprog) {
string fname = tprog->get_name() + ".html";
- f_out_ << "<tr>" << endl << "<td>" << tprog->get_name() << "</td><td>";
+ f_out_ << "<tr>" << '\n' << "<td>" << tprog->get_name() << "</td><td>";
if (!tprog->get_services().empty()) {
vector<t_service*> services = tprog->get_services();
vector<t_service*>::iterator sv_iter;
for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) {
string name = get_service_name(*sv_iter);
f_out_ << "<a href=\"" << make_file_link(fname) << "#Svc_" << name << "\">" << name
- << "</a><br/>" << endl;
- f_out_ << "<ul>" << endl;
+ << "</a><br/>" << '\n';
+ f_out_ << "<ul>" << '\n';
map<string, string> fn_html;
vector<t_function*> functions = (*sv_iter)->get_functions();
vector<t_function*>::iterator fn_iter;
@@ -178,12 +176,12 @@
fn_html.insert(pair<string, string>(fn_name, html));
}
for (auto & html_iter : fn_html) {
- f_out_ << html_iter.second << endl;
+ f_out_ << html_iter.second << '\n';
}
- f_out_ << "</ul>" << endl;
+ f_out_ << "</ul>" << '\n';
}
}
- f_out_ << "</td>" << endl << "<td>";
+ f_out_ << "</td>" << '\n' << "<td>";
map<string, string> data_types;
if (!tprog->get_enums().empty()) {
vector<t_enum*> enums = tprog->get_enums();
@@ -191,7 +189,7 @@
for (en_iter = enums.begin(); en_iter != enums.end(); ++en_iter) {
string name = (*en_iter)->get_name();
// f_out_ << "<a href=\"" << make_file_link(fname) << "#Enum_" << name << "\">" << name
- // << "</a><br/>" << endl;
+ // << "</a><br/>" << '\n';
string html = "<a href=\"" + make_file_link(fname) + "#Enum_" + name + "\">" + name + "</a>";
data_types.insert(pair<string, string>(name, html));
}
@@ -202,7 +200,7 @@
for (td_iter = typedefs.begin(); td_iter != typedefs.end(); ++td_iter) {
string name = (*td_iter)->get_symbolic();
// f_out_ << "<a href=\"" << make_file_link(fname) << "#Typedef_" << name << "\">" << name
- // << "</a><br/>" << endl;
+ // << "</a><br/>" << '\n';
string html = "<a href=\"" + make_file_link(fname) + "#Typedef_" + name + "\">" + name
+ "</a>";
data_types.insert(pair<string, string>(name, html));
@@ -214,16 +212,16 @@
for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) {
string name = (*o_iter)->get_name();
// f_out_ << "<a href=\"" << make_file_link(fname) << "#Struct_" << name << "\">" << name
- //<< "</a><br/>" << endl;
+ //<< "</a><br/>" << '\n';
string html = "<a href=\"" + make_file_link(fname) + "#Struct_" + name + "\">" + name
+ "</a>";
data_types.insert(pair<string, string>(name, html));
}
}
for (auto & data_type : data_types) {
- f_out_ << data_type.second << "<br/>" << endl;
+ f_out_ << data_type.second << "<br/>" << '\n';
}
- f_out_ << "</td>" << endl << "<td>";
+ f_out_ << "</td>" << '\n' << "<td>";
if (!tprog->get_consts().empty()) {
map<string, string> const_html;
vector<t_const*> consts = tprog->get_consts();
@@ -235,10 +233,10 @@
const_html.insert(pair<string, string>(name, html));
}
for (auto & con_iter : const_html) {
- f_out_ << con_iter.second << "<br/>" << endl;
+ f_out_ << con_iter.second << "<br/>" << '\n';
}
}
- f_out_ << "</td>" << endl << "</tr>";
+ f_out_ << "</td>" << '\n' << "</tr>";
}
/**
@@ -251,30 +249,30 @@
current_file_ = program_->get_name() + ".html";
string fname = get_out_dir() + current_file_;
f_out_.open(fname.c_str());
- f_out_ << "<!DOCTYPE html>" << endl;
- f_out_ << "<html lang=\"en\">" << endl;
- f_out_ << "<head>" << endl;
- f_out_ << "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />" << endl;
+ f_out_ << "<!DOCTYPE html>" << '\n';
+ f_out_ << "<html lang=\"en\">" << '\n';
+ f_out_ << "<head>" << '\n';
+ f_out_ << "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />" << '\n';
generate_style_tag();
- f_out_ << "<title>Thrift module: " << program_->get_name() << "</title></head><body>" << endl
- << "<div class=\"container-fluid\">" << endl
- << "<h1>Thrift module: " << program_->get_name() << "</h1>" << endl;
+ f_out_ << "<title>Thrift module: " << program_->get_name() << "</title></head><body>" << '\n'
+ << "<div class=\"container-fluid\">" << '\n'
+ << "<h1>Thrift module: " << program_->get_name() << "</h1>" << '\n';
print_doc(program_);
generate_program_toc();
if (!program_->get_consts().empty()) {
- f_out_ << "<hr/><h2 id=\"Constants\">Constants</h2>" << endl;
+ f_out_ << "<hr/><h2 id=\"Constants\">Constants</h2>" << '\n';
vector<t_const*> consts = program_->get_consts();
f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
- f_out_ << "<thead><tr><th>Constant</th><th>Type</th><th>Value</th></tr></thead><tbody>" << endl;
+ f_out_ << "<thead><tr><th>Constant</th><th>Type</th><th>Value</th></tr></thead><tbody>" << '\n';
generate_consts(consts);
f_out_ << "</tbody></table>";
}
if (!program_->get_enums().empty()) {
- f_out_ << "<hr/><h2 id=\"Enumerations\">Enumerations</h2>" << endl;
+ f_out_ << "<hr/><h2 id=\"Enumerations\">Enumerations</h2>" << '\n';
// Generate enums
vector<t_enum*> enums = program_->get_enums();
vector<t_enum*>::iterator en_iter;
@@ -284,7 +282,7 @@
}
if (!program_->get_typedefs().empty()) {
- f_out_ << "<hr/><h2 id=\"Typedefs\">Type declarations</h2>" << endl;
+ f_out_ << "<hr/><h2 id=\"Typedefs\">Type declarations</h2>" << '\n';
// Generate typedefs
vector<t_typedef*> typedefs = program_->get_typedefs();
vector<t_typedef*>::iterator td_iter;
@@ -294,7 +292,7 @@
}
if (!program_->get_objects().empty()) {
- f_out_ << "<hr/><h2 id=\"Structs\">Data structures</h2>" << endl;
+ f_out_ << "<hr/><h2 id=\"Structs\">Data structures</h2>" << '\n';
// Generate structs and exceptions in declared order
vector<t_struct*> objects = program_->get_objects();
vector<t_struct*>::iterator o_iter;
@@ -308,7 +306,7 @@
}
if (!program_->get_services().empty()) {
- f_out_ << "<hr/><h2 id=\"Services\">Services</h2>" << endl;
+ f_out_ << "<hr/><h2 id=\"Services\">Services</h2>" << '\n';
// Generate services
vector<t_service*> services = program_->get_services();
vector<t_service*>::iterator sv_iter;
@@ -318,7 +316,7 @@
}
}
- f_out_ << "</div></body></html>" << endl;
+ f_out_ << "</div></body></html>" << '\n';
f_out_.close();
generate_index();
@@ -332,17 +330,17 @@
current_file_ = "index.html";
string index_fname = get_out_dir() + current_file_;
f_out_.open(index_fname.c_str());
- f_out_ << "<!DOCTYPE html>" << endl << "<html lang=\"en\"><head>" << endl;
+ f_out_ << "<!DOCTYPE html>" << '\n' << "<html lang=\"en\"><head>" << '\n';
generate_style_tag();
- f_out_ << "<title>All Thrift declarations</title></head><body>" << endl
- << "<div class=\"container-fluid\">" << endl << "<h1>All Thrift declarations</h1>" << endl;
+ f_out_ << "<title>All Thrift declarations</title></head><body>" << '\n'
+ << "<div class=\"container-fluid\">" << '\n' << "<h1>All Thrift declarations</h1>" << '\n';
f_out_ << "<table class=\"table-bordered table-striped "
"table-condensed\"><thead><tr><th>Module</th><th>Services</th><th>Data types</th>"
- << "<th>Constants</th></tr></thead><tbody>" << endl;
+ << "<th>Constants</th></tr></thead><tbody>" << '\n';
vector<t_program*> programs;
generate_program_toc_rows(program_, programs);
- f_out_ << "</tbody></table>" << endl;
- f_out_ << "</div></body></html>" << endl;
+ f_out_ << "</tbody></table>" << '\n';
+ f_out_ << "</div></body></html>" << '\n';
f_out_.close();
}
@@ -357,17 +355,17 @@
}
void t_html_generator::generate_css_content(std::ostream& f_target) {
- f_target << BOOTSTRAP_CSS() << endl;
- f_target << "/* Auto-generated CSS for generated Thrift docs */" << endl;
- f_target << "h3, h4 { margin-bottom: 6px; }" << endl;
+ f_target << BOOTSTRAP_CSS() << '\n';
+ f_target << "/* Auto-generated CSS for generated Thrift docs */" << '\n';
+ f_target << "h3, h4 { margin-bottom: 6px; }" << '\n';
f_target << "div.definition { border: 1px solid #CCC; margin-bottom: 10px; padding: 10px; }"
- << endl;
- f_target << "div.extends { margin: -0.5em 0 1em 5em }" << endl;
- f_target << "td { vertical-align: top; }" << endl;
- f_target << "table { empty-cells: show; }" << endl;
- f_target << "code { line-height: 20px; }" << endl;
+ << '\n';
+ f_target << "div.extends { margin: -0.5em 0 1em 5em }" << '\n';
+ f_target << "td { vertical-align: top; }" << '\n';
+ f_target << "table { empty-cells: show; }" << '\n';
+ f_target << "code { line-height: 20px; }" << '\n';
f_target << ".table-bordered th, .table-bordered td { border-bottom: 1px solid #DDDDDD; }"
- << endl;
+ << '\n';
}
/**
@@ -377,11 +375,11 @@
*/
void t_html_generator::generate_style_tag() {
if (!standalone_) {
- f_out_ << "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>" << endl;
+ f_out_ << "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>" << '\n';
} else {
- f_out_ << "<style type=\"text/css\"/><!--" << endl;
+ f_out_ << "<style type=\"text/css\"/><!--" << '\n';
generate_css_content(f_out_);
- f_out_ << "--></style>" << endl;
+ f_out_ << "--></style>" << '\n';
}
}
@@ -856,14 +854,14 @@
if (has_docs) {
arg_iter = args.begin();
f_out_ << "<br/><h4 id=\"Parameters_" << service_name_ << "_" << tfunction->get_name()
- << "\">Parameters</h4>" << endl;
+ << "\">Parameters</h4>" << '\n';
f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
f_out_ << "<thead><tr><th>Name</th><th>Description</th></tr></thead><tbody>";
for (; arg_iter != args.end(); arg_iter++) {
f_out_ << "<tr><td>" << (*arg_iter)->get_name();
f_out_ << "</td><td>";
f_out_ << escape_html((*arg_iter)->get_doc());
- f_out_ << "</td></tr>" << endl;
+ f_out_ << "</td></tr>" << '\n';
}
f_out_ << "</tbody></table>";
}
@@ -880,14 +878,14 @@
if (has_docs) {
ex_iter = excepts.begin();
f_out_ << "<br/><h4 id=\"Exceptions_" << service_name_ << "_" << tfunction->get_name()
- << "\">Exceptions</h4>" << endl;
+ << "\">Exceptions</h4>" << '\n';
f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
f_out_ << "<thead><tr><th>Type</th><th>Description</th></tr></thead><tbody>";
for (; ex_iter != excepts.end(); ex_iter++) {
f_out_ << "<tr><td>" << (*ex_iter)->get_type()->get_name();
f_out_ << "</td><td>";
f_out_ << escape_html((*ex_iter)->get_doc());
- f_out_ << "</td></tr>" << endl;
+ f_out_ << "</td></tr>" << '\n';
}
f_out_ << "</tbody></table>";
}
@@ -902,12 +900,12 @@
void t_html_generator::generate_typedef(t_typedef* ttypedef) {
string name = ttypedef->get_name();
f_out_ << "<div class=\"definition\">";
- f_out_ << "<h3 id=\"Typedef_" << name << "\">Typedef: " << name << "</h3>" << endl;
+ f_out_ << "<h3 id=\"Typedef_" << name << "\">Typedef: " << name << "</h3>" << '\n';
f_out_ << "<p><strong>Base type:</strong> ";
print_type(ttypedef->get_type());
- f_out_ << "</p>" << endl;
+ f_out_ << "</p>" << '\n';
print_doc(ttypedef);
- f_out_ << "</div>" << endl;
+ f_out_ << "</div>" << '\n';
}
/**
@@ -918,21 +916,21 @@
void t_html_generator::generate_enum(t_enum* tenum) {
string name = tenum->get_name();
f_out_ << "<div class=\"definition\">";
- f_out_ << "<h3 id=\"Enum_" << name << "\">Enumeration: " << name << "</h3>" << endl;
+ f_out_ << "<h3 id=\"Enum_" << name << "\">Enumeration: " << name << "</h3>" << '\n';
print_doc(tenum);
vector<t_enum_value*> values = tenum->get_constants();
vector<t_enum_value*>::iterator val_iter;
- f_out_ << "<br/><table class=\"table-bordered table-striped table-condensed\">" << endl;
+ f_out_ << "<br/><table class=\"table-bordered table-striped table-condensed\">" << '\n';
for (val_iter = values.begin(); val_iter != values.end(); ++val_iter) {
f_out_ << "<tr><td><code>";
f_out_ << (*val_iter)->get_name();
f_out_ << "</code></td><td><code>";
f_out_ << (*val_iter)->get_value();
- f_out_ << "</code></td><td>" << endl;
+ f_out_ << "</code></td><td>" << '\n';
print_doc((*val_iter));
- f_out_ << "</td></tr>" << endl;
+ f_out_ << "</td></tr>" << '\n';
}
- f_out_ << "</table></div>" << endl;
+ f_out_ << "</table></div>" << '\n';
}
/**
@@ -968,12 +966,12 @@
} else {
f_out_ << "Struct: ";
}
- f_out_ << name << "</h3>" << endl;
+ f_out_ << name << "</h3>" << '\n';
vector<t_field*> members = tstruct->get_members();
vector<t_field*>::iterator mem_iter = members.begin();
f_out_ << "<table class=\"table-bordered table-striped table-condensed\">";
f_out_ << "<thead><tr><th>Key</th><th>Field</th><th>Type</th><th>Description</th><th>Requiredness</"
- "th><th>Default value</th></tr></thead><tbody>" << endl;
+ "th><th>Default value</th></tr></thead><tbody>" << '\n';
for (; mem_iter != members.end(); mem_iter++) {
f_out_ << "<tr><td>" << (*mem_iter)->get_key() << "</td><td>";
f_out_ << (*mem_iter)->get_name();
@@ -996,7 +994,7 @@
print_const_value((*mem_iter)->get_type(), default_val);
f_out_ << "</code>";
}
- f_out_ << "</td></tr>" << endl;
+ f_out_ << "</td></tr>" << '\n';
}
f_out_ << "</tbody></table><br/>";
print_doc(tstruct);
@@ -1018,7 +1016,7 @@
* @param tservice The service definition
*/
void t_html_generator::generate_service(t_service* tservice) {
- f_out_ << "<h3 id=\"Svc_" << service_name_ << "\">Service: " << service_name_ << "</h3>" << endl;
+ f_out_ << "<h3 id=\"Svc_" << service_name_ << "\">Service: " << service_name_ << "</h3>" << '\n';
if (tservice->get_extends()) {
f_out_ << "<div class=\"extends\"><em>extends</em> ";
@@ -1032,7 +1030,7 @@
string fn_name = (*fn_iter)->get_name();
f_out_ << "<div class=\"definition\">";
f_out_ << "<h4 id=\"Fn_" << service_name_ << "_" << fn_name << "\">Function: " << service_name_
- << "." << fn_name << "</h4>" << endl;
+ << "." << fn_name << "</h4>" << '\n';
f_out_ << "<pre>";
std::string::size_type offset = print_type((*fn_iter)->get_returntype());
bool first = true;
@@ -1042,7 +1040,7 @@
vector<t_field*>::iterator arg_iter = args.begin();
for (; arg_iter != args.end(); arg_iter++) {
if (!first) {
- f_out_ << "," << endl;
+ f_out_ << "," << '\n';
for (std::string::size_type i = 0; i < offset; ++i) {
f_out_ << " ";
}
@@ -1055,7 +1053,7 @@
print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
}
}
- f_out_ << ")" << endl;
+ f_out_ << ")" << '\n';
first = true;
vector<t_field*> excepts = (*fn_iter)->get_xceptions()->get_members();
vector<t_field*>::iterator ex_iter = excepts.begin();
@@ -1068,7 +1066,7 @@
first = false;
print_type((*ex_iter)->get_type());
}
- f_out_ << endl;
+ f_out_ << '\n';
}
f_out_ << "</pre>";
print_doc(*fn_iter);
diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc
index 1985a3d..e81744e 100644
--- a/compiler/cpp/src/thrift/generate/t_java_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc
@@ -45,8 +45,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
static const string thrift_option_class = "org.apache.thrift.Option";
static const string jdk_option_class = "java.util.Optional";
@@ -511,8 +509,7 @@
}
string t_java_generator::java_suppressions() {
- return "@SuppressWarnings({\"cast\", \"rawtypes\", \"serial\", \"unchecked\", \"unused\"})"
- + endl;
+ return "@SuppressWarnings({\"cast\", \"rawtypes\", \"serial\", \"unchecked\", \"unused\"})\n";
}
string t_java_generator::java_nullable_annotation() {
@@ -567,7 +564,7 @@
f_enum.open(f_enum_name.c_str());
// Comment and package it
- f_enum << autogen_comment() << java_package() << endl;
+ f_enum << autogen_comment() << java_package() << '\n';
generate_java_doc(f_enum, tenum);
@@ -576,7 +573,7 @@
}
if (is_deprecated) {
- indent(f_enum) << "@Deprecated" << endl;
+ indent(f_enum) << "@Deprecated" << '\n';
}
indent(f_enum) << "public enum " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
scope_up(f_enum);
@@ -590,62 +587,62 @@
if (first) {
first = false;
} else {
- f_enum << "," << endl;
+ f_enum << "," << '\n';
}
generate_java_doc(f_enum, *c_iter);
if (this->is_deprecated((*c_iter)->annotations_)) {
- indent(f_enum) << "@Deprecated" << endl;
+ indent(f_enum) << "@Deprecated" << '\n';
}
indent(f_enum) << (*c_iter)->get_name() << "(" << value << ")";
}
- f_enum << ";" << endl << endl;
+ f_enum << ";" << '\n' << '\n';
// Field for thriftCode
- indent(f_enum) << "private final int value;" << endl << endl;
+ indent(f_enum) << "private final int value;" << '\n' << '\n';
- indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << endl;
- indent(f_enum) << " this.value = value;" << endl;
- indent(f_enum) << "}" << endl << endl;
+ indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << '\n';
+ indent(f_enum) << " this.value = value;" << '\n';
+ indent(f_enum) << "}" << '\n' << '\n';
- indent(f_enum) << "/**" << endl;
+ indent(f_enum) << "/**" << '\n';
indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL."
- << endl;
- indent(f_enum) << " */" << endl;
- indent(f_enum) << java_override_annotation() << endl;
- indent(f_enum) << "public int getValue() {" << endl;
- indent(f_enum) << " return value;" << endl;
- indent(f_enum) << "}" << endl << endl;
+ << '\n';
+ indent(f_enum) << " */" << '\n';
+ indent(f_enum) << java_override_annotation() << '\n';
+ indent(f_enum) << "public int getValue() {" << '\n';
+ indent(f_enum) << " return value;" << '\n';
+ indent(f_enum) << "}" << '\n' << '\n';
- indent(f_enum) << "/**" << endl;
+ indent(f_enum) << "/**" << '\n';
indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL."
- << endl;
- indent(f_enum) << " * @return null if the value is not found." << endl;
- indent(f_enum) << " */" << endl;
- indent(f_enum) << java_nullable_annotation() << endl;
- indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl;
+ << '\n';
+ indent(f_enum) << " * @return null if the value is not found." << '\n';
+ indent(f_enum) << " */" << '\n';
+ indent(f_enum) << java_nullable_annotation() << '\n';
+ indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << '\n';
indent_up();
- indent(f_enum) << "switch (value) {" << endl;
+ indent(f_enum) << "switch (value) {" << '\n';
indent_up();
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
- indent(f_enum) << "case " << value << ":" << endl;
- indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << endl;
+ indent(f_enum) << "case " << value << ":" << '\n';
+ indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << '\n';
}
- indent(f_enum) << "default:" << endl;
- indent(f_enum) << " return null;" << endl;
+ indent(f_enum) << "default:" << '\n';
+ indent(f_enum) << " return null;" << '\n';
indent_down();
- indent(f_enum) << "}" << endl;
+ indent(f_enum) << "}" << '\n';
indent_down();
- indent(f_enum) << "}" << endl;
+ indent(f_enum) << "}" << '\n';
scope_down(f_enum);
@@ -667,8 +664,8 @@
// Print header
f_consts << autogen_comment() << java_package() << java_suppressions();
- f_consts << "public class " << make_valid_java_identifier(program_name_) << "Constants {" << endl
- << endl;
+ f_consts << "public class " << make_valid_java_identifier(program_name_) << "Constants {" << '\n'
+ << '\n';
indent_up();
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -677,7 +674,7 @@
(*c_iter)->get_value(), false);
}
indent_down();
- indent(f_consts) << "}" << endl;
+ indent(f_consts) << "}" << '\n';
f_consts.close();
}
@@ -700,9 +697,9 @@
}
if (type->is_base_type()) {
string v2 = render_const_value(out, type, value);
- out << name << " = " << v2 << ";" << endl << endl;
+ out << name << " = " << v2 << ";" << '\n' << '\n';
} else if (type->is_enum()) {
- out << name << " = " << render_const_value(out, type, value) << ";" << endl << endl;
+ out << name << " = " << render_const_value(out, type, value) << ";" << '\n' << '\n';
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& unsorted_fields = ((t_struct*)type)->get_members();
vector<t_field*> fields = unsorted_fields;
@@ -710,9 +707,9 @@
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
- out << name << " = new " << type_name(type, false, true) << "();" << endl;
+ out << name << " = new " << type_name(type, false, true) << "();" << '\n';
if (!in_static) {
- indent(out) << "static {" << endl;
+ indent(out) << "static {" << '\n';
indent_up();
}
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
@@ -728,22 +725,22 @@
string val = render_const_value(out, field_type, v_iter->second);
indent(out) << name << ".";
std::string cap_name = get_cap_name(v_iter->first->get_string());
- out << "set" << cap_name << "(" << val << ");" << endl;
+ out << "set" << cap_name << "(" << val << ");" << '\n';
}
if (!in_static) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << endl;
+ out << '\n';
} else if (type->is_map()) {
std::string constructor_args;
if (is_enum_map(type)) {
constructor_args = inner_enum_type_name(type);
}
out << name << " = new " << type_name(type, false, true) << "(" << constructor_args << ");"
- << endl;
+ << '\n';
if (!in_static) {
- indent(out) << "static {" << endl;
+ indent(out) << "static {" << '\n';
indent_up();
}
t_type* ktype = ((t_map*)type)->get_key_type();
@@ -753,22 +750,22 @@
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, ktype, v_iter->first);
string val = render_const_value(out, vtype, v_iter->second);
- indent(out) << name << ".put(" << key << ", " << val << ");" << endl;
+ indent(out) << name << ".put(" << key << ", " << val << ");" << '\n';
}
if (!in_static) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << endl;
+ out << '\n';
} else if (type->is_list() || type->is_set()) {
if (is_enum_set(type)) {
out << name << " = " << type_name(type, false, true, true) << ".noneOf("
- << inner_enum_type_name(type) << ");" << endl;
+ << inner_enum_type_name(type) << ");" << '\n';
} else {
- out << name << " = new " << type_name(type, false, true) << "();" << endl;
+ out << name << " = new " << type_name(type, false, true) << "();" << '\n';
}
if (!in_static) {
- indent(out) << "static {" << endl;
+ indent(out) << "static {" << '\n';
indent_up();
}
t_type* etype;
@@ -781,13 +778,13 @@
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string val = render_const_value(out, etype, *v_iter);
- indent(out) << name << ".add(" << val << ");" << endl;
+ indent(out) << name << ".add(" << val << ");" << '\n';
}
if (!in_static) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << endl;
+ out << '\n';
} else {
throw "compiler error: no const of type " + type->get_name();
}
@@ -916,7 +913,7 @@
}
if (is_deprecated) {
- indent(f_struct) << "@Deprecated" << endl;
+ indent(f_struct) << "@Deprecated" << '\n';
}
indent(f_struct) << "public " << (is_final ? "final " : "") << "class " << make_valid_java_identifier(tstruct->get_name())
<< " extends org.apache.thrift.TUnion<" << make_valid_java_identifier(tstruct->get_name()) << ", "
@@ -927,49 +924,49 @@
generate_struct_desc(f_struct, tstruct);
generate_field_descs(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_field_name_constants(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_java_meta_data_map(f_struct, tstruct);
generate_union_constructor(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_abstract_methods(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_java_struct_field_by_id(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_getters_and_setters(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_is_set_methods(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_comparisons(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_hashcode(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_java_struct_write_object(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_java_struct_read_object(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
scope_down(f_struct);
@@ -980,63 +977,63 @@
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
- indent(out) << "public " << type_name(tstruct) << "() {" << endl;
+ indent(out) << "public " << type_name(tstruct) << "() {" << '\n';
indent_up();
bool default_value = false;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* type = get_true_type((*m_iter)->get_type());
if ((*m_iter)->get_value() != nullptr) {
indent(out) << "super(_Fields." << constant_name((*m_iter)->get_name()) << ", "
- << render_const_value(out, type, (*m_iter)->get_value()) << ");" << endl;
+ << render_const_value(out, type, (*m_iter)->get_value()) << ");" << '\n';
default_value = true;
break;
}
}
if (default_value == false) {
- indent(out) << "super();" << endl;
+ indent(out) << "super();" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
indent(out) << "public " << type_name(tstruct) << "(_Fields setField, java.lang.Object value) {"
- << endl;
- indent(out) << " super(setField, value);" << endl;
- indent(out) << "}" << endl << endl;
+ << '\n';
+ indent(out) << " super(setField, value);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
indent(out) << "public " << type_name(tstruct)
<< "(" << type_name(tstruct) << " other) {"
- << endl;
- indent(out) << " super(other);" << endl;
- indent(out) << "}" << endl;
+ << '\n';
+ indent(out) << " super(other);" << '\n';
+ indent(out) << "}" << '\n';
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << endl;
- indent(out) << " return new " << tstruct->get_name() << "(this);" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << '\n';
+ indent(out) << " return new " << tstruct->get_name() << "(this);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
// generate "constructors" for each field
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* type = (*m_iter)->get_type();
indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "("
- << type_name(type) << " value) {" << endl;
- indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl;
- indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << endl;
- indent(out) << " return x;" << endl;
- indent(out) << "}" << endl << endl;
+ << type_name(type) << " value) {" << '\n';
+ indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << '\n';
+ indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << '\n';
+ indent(out) << " return x;" << '\n';
+ indent(out) << "}" << '\n' << '\n';
if (type->is_binary()) {
indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name()
- << "(byte[] value) {" << endl;
+ << "(byte[] value) {" << '\n';
indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();"
- << endl;
+ << '\n';
indent(out) << " x.set" << get_cap_name((*m_iter)->get_name());
if (unsafe_binaries_) {
- indent(out) << "(java.nio.ByteBuffer.wrap(value));" << endl;
+ indent(out) << "(java.nio.ByteBuffer.wrap(value));" << '\n';
} else {
- indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << endl;
+ indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << '\n';
}
- indent(out) << " return x;" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << " return x;" << '\n';
+ indent(out) << "}" << '\n' << '\n';
}
}
}
@@ -1050,7 +1047,7 @@
if (first) {
first = false;
} else {
- out << endl;
+ out << '\n';
}
t_field* field = (*m_iter);
@@ -1061,95 +1058,95 @@
generate_java_doc(out, field);
if (type->is_binary()) {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
- indent(out) << "public byte[] get" << cap_name << "() {" << endl;
+ indent(out) << "public byte[] get" << cap_name << "() {" << '\n';
indent(out) << " set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize(buffer"
- << get_cap_name("for") << cap_name << "()));" << endl;
+ << get_cap_name("for") << cap_name << "()));" << '\n';
indent(out) << " java.nio.ByteBuffer b = buffer" << get_cap_name("for") << cap_name << "();"
- << endl;
- indent(out) << " return b == null ? null : b.array();" << endl;
- indent(out) << "}" << endl;
+ << '\n';
+ indent(out) << " return b == null ? null : b.array();" << '\n';
+ indent(out) << "}" << '\n';
- out << endl;
+ out << '\n';
indent(out) << "public java.nio.ByteBuffer buffer" << get_cap_name("for")
- << get_cap_name(field->get_name()) << "() {" << endl;
+ << get_cap_name(field->get_name()) << "() {" << '\n';
indent(out) << " if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {"
- << endl;
+ << '\n';
if (unsafe_binaries_) {
- indent(out) << " return (java.nio.ByteBuffer)getFieldValue();" << endl;
+ indent(out) << " return (java.nio.ByteBuffer)getFieldValue();" << '\n';
} else {
indent(out)
<< " return "
"org.apache.thrift.TBaseHelper.copyBinary((java.nio.ByteBuffer)getFieldValue());"
- << endl;
+ << '\n';
}
- indent(out) << " } else {" << endl;
+ indent(out) << " } else {" << '\n';
indent(out) << " throw new java.lang.RuntimeException(\"Cannot get field '"
<< field->get_name()
<< "' because union is currently set to \" + getFieldDesc(getSetField()).name);"
- << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl;
+ << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n';
} else {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public " << type_name(field->get_type()) << " get"
- << get_cap_name(field->get_name()) << "() {" << endl;
+ << get_cap_name(field->get_name()) << "() {" << '\n';
indent(out) << " if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {"
- << endl;
+ << '\n';
indent(out) << " return (" << type_name(field->get_type(), true) << ")getFieldValue();"
- << endl;
- indent(out) << " } else {" << endl;
+ << '\n';
+ indent(out) << " } else {" << '\n';
indent(out) << " throw new java.lang.RuntimeException(\"Cannot get field '"
<< field->get_name()
<< "' because union is currently set to \" + getFieldDesc(getSetField()).name);"
- << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl;
+ << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n';
}
- out << endl;
+ out << '\n';
generate_java_doc(out, field);
if (type->is_binary()) {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public void set" << get_cap_name(field->get_name()) << "(byte[] value) {"
- << endl;
+ << '\n';
indent(out) << " set" << get_cap_name(field->get_name());
if (unsafe_binaries_) {
- indent(out) << "(java.nio.ByteBuffer.wrap(value));" << endl;
+ indent(out) << "(java.nio.ByteBuffer.wrap(value));" << '\n';
} else {
- indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << endl;
+ indent(out) << "(java.nio.ByteBuffer.wrap(value.clone()));" << '\n';
}
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
- out << endl;
+ out << '\n';
}
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public void set" << get_cap_name(field->get_name()) << "("
- << type_name(field->get_type()) << " value) {" << endl;
+ << type_name(field->get_type()) << " value) {" << '\n';
- indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << endl;
+ indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << '\n';
if (type_can_be_null(field->get_type())) {
indent(out) << " value_ = java.util.Objects.requireNonNull(value,\""
- << "_Fields." << constant_name(field->get_name()) << "\");" << endl;
+ << "_Fields." << constant_name(field->get_name()) << "\");" << '\n';
} else {
- indent(out) << " value_ = value;" << endl;
+ indent(out) << " value_ = value;" << '\n';
}
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
@@ -1162,49 +1159,49 @@
if (first) {
first = false;
} else {
- out << endl;
+ out << '\n';
}
std::string field_name = (*m_iter)->get_name();
indent(out) << "public boolean is" << get_cap_name("set") << get_cap_name(field_name) << "() {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "return setField_ == _Fields." << constant_name(field_name) << ";" << endl;
+ indent(out) << "return setField_ == _Fields." << constant_name(field_name) << ";" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
}
void t_java_generator::generate_union_abstract_methods(ostream& out, t_struct* tstruct) {
generate_check_type(out, tstruct);
- out << endl;
+ out << '\n';
generate_standard_scheme_read_value(out, tstruct);
- out << endl;
+ out << '\n';
generate_standard_scheme_write_value(out, tstruct);
- out << endl;
+ out << '\n';
generate_tuple_scheme_read_value(out, tstruct);
- out << endl;
+ out << '\n';
generate_tuple_scheme_write_value(out, tstruct);
- out << endl;
+ out << '\n';
generate_get_field_desc(out, tstruct);
- out << endl;
+ out << '\n';
generate_get_struct_desc(out, tstruct);
- out << endl;
- indent(out) << java_override_annotation() << endl;
- indent(out) << "protected _Fields enumForId(short id) {" << endl;
- indent(out) << " return _Fields.findByThriftIdOrThrow(id);" << endl;
- indent(out) << "}" << endl;
+ out << '\n';
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "protected _Fields enumForId(short id) {" << '\n';
+ indent(out) << " return _Fields.findByThriftIdOrThrow(id);" << '\n';
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_check_type(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "protected void checkType(_Fields setField, java.lang.Object value) throws "
"java.lang.ClassCastException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "switch (setField) {" << endl;
+ indent(out) << "switch (setField) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -1213,42 +1210,42 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent(out) << " if (value instanceof " << type_name(field->get_type(), true, false, true)
- << ") {" << endl;
- indent(out) << " break;" << endl;
- indent(out) << " }" << endl;
+ << ") {" << '\n';
+ indent(out) << " break;" << '\n';
+ indent(out) << " }" << '\n';
indent(out) << " throw new java.lang.ClassCastException(\"Was expecting value of type "
<< type_name(field->get_type(), true, false) << " for field '" << field->get_name()
- << "', but got \" + value.getClass().getSimpleName());" << endl;
+ << "', but got \" + value.getClass().getSimpleName());" << '\n';
// do the real check here
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out) << " throw new java.lang.IllegalArgumentException(\"Unknown field id \" + setField);"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_standard_scheme_read_value(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out)
<< "protected java.lang.Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol "
"iprot, org.apache.thrift.protocol.TField field) throws "
"org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << endl;
- indent(out) << "if (setField != null) {" << endl;
+ indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << '\n';
+ indent(out) << "if (setField != null) {" << '\n';
indent_up();
- indent(out) << "switch (setField) {" << endl;
+ indent(out) << "switch (setField) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -1257,53 +1254,53 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent_up();
indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {"
- << endl;
+ << '\n';
indent_up();
indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";"
- << endl;
+ << '\n';
generate_deserialize_field(out, field, "");
- indent(out) << "return " << field->get_name() << ";" << endl;
+ indent(out) << "return " << field->get_name() << ";" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
- indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl;
- indent(out) << " return null;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "} else {" << '\n';
+ indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << '\n';
+ indent(out) << " return null;" << '\n';
+ indent(out) << "}" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out)
<< " throw new java.lang.IllegalStateException(\"setField wasn't null, but didn't match any "
"of the case statements!\");"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
- indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl;
- indent(out) << "return null;" << endl;
+ indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << '\n';
+ indent(out) << "return null;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_standard_scheme_write_value(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol "
"oprot) throws org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "switch (setField_) {" << endl;
+ indent(out) << "switch (setField_) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -1312,42 +1309,42 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent_up();
indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = ("
- << type_name(field->get_type(), true, false) << ")value_;" << endl;
+ << type_name(field->get_type(), true, false) << ")value_;" << '\n';
generate_serialize_field(out, field);
- indent(out) << "return;" << endl;
+ indent(out) << "return;" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out)
<< " throw new java.lang.IllegalStateException(\"Cannot write union with unknown field \" + "
"setField_);"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_tuple_scheme_read_value(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out)
<< "protected java.lang.Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol "
"iprot, short fieldID) throws org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "_Fields setField = _Fields.findByThriftId(fieldID);" << endl;
- indent(out) << "if (setField != null) {" << endl;
+ indent(out) << "_Fields setField = _Fields.findByThriftId(fieldID);" << '\n';
+ indent(out) << "if (setField != null) {" << '\n';
indent_up();
- indent(out) << "switch (setField) {" << endl;
+ indent(out) << "switch (setField) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -1356,45 +1353,45 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent_up();
indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";"
- << endl;
+ << '\n';
generate_deserialize_field(out, field, "");
- indent(out) << "return " << field->get_name() << ";" << endl;
+ indent(out) << "return " << field->get_name() << ";" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out)
<< " throw new java.lang.IllegalStateException(\"setField wasn't null, but didn't match any "
"of the case statements!\");"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
indent(out) << "throw new org.apache.thrift.protocol.TProtocolException(\"Couldn't find a field "
"with field id \" + fieldID);"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_tuple_scheme_write_value(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) "
"throws org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "switch (setField_) {" << endl;
+ indent(out) << "switch (setField_) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -1403,119 +1400,119 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent_up();
indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = ("
- << type_name(field->get_type(), true, false) << ")value_;" << endl;
+ << type_name(field->get_type(), true, false) << ")value_;" << '\n';
generate_serialize_field(out, field);
- indent(out) << "return;" << endl;
+ indent(out) << "return;" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out)
<< " throw new java.lang.IllegalStateException(\"Cannot write union with unknown field \" + "
"setField_);"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_get_field_desc(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {"
- << endl;
+ << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
- indent(out) << "switch (setField) {" << endl;
+ indent(out) << "switch (setField) {" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
- indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
+ indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << '\n';
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out) << " throw new java.lang.IllegalArgumentException(\"Unknown field id \" + setField);"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_get_struct_desc(ostream& out, t_struct* tstruct) {
(void)tstruct;
- indent(out) << java_override_annotation() << endl;
- indent(out) << "protected org.apache.thrift.protocol.TStruct getStructDesc() {" << endl;
- indent(out) << " return STRUCT_DESC;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "protected org.apache.thrift.protocol.TStruct getStructDesc() {" << '\n';
+ indent(out) << " return STRUCT_DESC;" << '\n';
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_union_comparisons(ostream& out, t_struct* tstruct) {
// equality
- indent(out) << "public boolean equals(java.lang.Object other) {" << endl;
- indent(out) << " if (other instanceof " << make_valid_java_identifier(tstruct->get_name()) << ") {" << endl;
- indent(out) << " return equals((" << make_valid_java_identifier(tstruct->get_name()) << ")other);" << endl;
- indent(out) << " } else {" << endl;
- indent(out) << " return false;" << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "public boolean equals(java.lang.Object other) {" << '\n';
+ indent(out) << " if (other instanceof " << make_valid_java_identifier(tstruct->get_name()) << ") {" << '\n';
+ indent(out) << " return equals((" << make_valid_java_identifier(tstruct->get_name()) << ")other);" << '\n';
+ indent(out) << " } else {" << '\n';
+ indent(out) << " return false;" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n';
- out << endl;
+ out << '\n';
- indent(out) << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " other) {" << endl;
+ indent(out) << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " other) {" << '\n';
indent(out) << " return other != null && getSetField() == other.getSetField() && "
"getFieldValue().equals(other.getFieldValue());"
- << endl;
- indent(out) << "}" << endl;
- out << endl;
+ << '\n';
+ indent(out) << "}" << '\n';
+ out << '\n';
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n';
indent(out) << " int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), "
"other.getSetField());"
- << endl;
- indent(out) << " if (lastComparison == 0) {" << endl;
+ << '\n';
+ indent(out) << " if (lastComparison == 0) {" << '\n';
indent(out) << " return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), "
"other.getFieldValue());"
- << endl;
- indent(out) << " }" << endl;
- indent(out) << " return lastComparison;" << endl;
- indent(out) << "}" << endl;
- out << endl;
+ << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << " return lastComparison;" << '\n';
+ indent(out) << "}" << '\n';
+ out << '\n';
}
void t_java_generator::generate_union_hashcode(ostream& out, t_struct* tstruct) {
(void)tstruct;
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public int hashCode() {" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public int hashCode() {" << '\n';
indent(out)
<< " java.util.List<java.lang.Object> list = new java.util.ArrayList<java.lang.Object>();"
- << endl;
- indent(out) << " list.add(this.getClass().getName());" << endl;
- indent(out) << " org.apache.thrift.TFieldIdEnum setField = getSetField();" << endl;
- indent(out) << " if (setField != null) {" << endl;
- indent(out) << " list.add(setField.getThriftFieldId());" << endl;
- indent(out) << " java.lang.Object value = getFieldValue();" << endl;
- indent(out) << " if (value instanceof org.apache.thrift.TEnum) {" << endl;
- indent(out) << " list.add(((org.apache.thrift.TEnum)getFieldValue()).getValue());" << endl;
- indent(out) << " } else {" << endl;
- indent(out) << " list.add(value);" << endl;
- indent(out) << " }" << endl;
- indent(out) << " }" << endl;
- indent(out) << " return list.hashCode();" << endl;
+ << '\n';
+ indent(out) << " list.add(this.getClass().getName());" << '\n';
+ indent(out) << " org.apache.thrift.TFieldIdEnum setField = getSetField();" << '\n';
+ indent(out) << " if (setField != null) {" << '\n';
+ indent(out) << " list.add(setField.getThriftFieldId());" << '\n';
+ indent(out) << " java.lang.Object value = getFieldValue();" << '\n';
+ indent(out) << " if (value instanceof org.apache.thrift.TEnum) {" << '\n';
+ indent(out) << " list.add(((org.apache.thrift.TEnum)getFieldValue()).getValue());" << '\n';
+ indent(out) << " } else {" << '\n';
+ indent(out) << " list.add(value);" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << " return list.hashCode();" << '\n';
indent(out) << "}";
}
@@ -1545,7 +1542,7 @@
}
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public " << (is_final ? "final " : "") << (in_class ? "static " : "") << "class "
<< make_valid_java_identifier(tstruct->get_name()) << " ";
@@ -1571,15 +1568,15 @@
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
- out << endl;
+ out << '\n';
generate_field_descs(out, tstruct);
- out << endl;
+ out << '\n';
generate_scheme_map(out, tstruct);
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (bean_style_ || private_members_) {
@@ -1588,10 +1585,10 @@
generate_java_doc(out, *m_iter);
indent(out) << "public ";
}
- out << declare_field(*m_iter, false, true) << endl;
+ out << declare_field(*m_iter, false, true) << '\n';
}
- out << endl;
+ out << '\n';
if (android_style_) {
generate_java_struct_parcelable(out, tstruct);
@@ -1601,9 +1598,9 @@
// isset data
if (members.size() > 0) {
- out << endl;
+ out << '\n';
- indent(out) << "// isset id assignments" << endl;
+ indent(out) << "// isset id assignments" << '\n';
int i = 0;
int optionals = 0;
@@ -1613,7 +1610,7 @@
}
if (!type_can_be_null((*m_iter)->get_type())) {
indent(out) << "private static final int " << isset_field_id(*m_iter) << " = " << i << ";"
- << endl;
+ << '\n';
i++;
}
}
@@ -1623,11 +1620,11 @@
case ISSET_NONE:
break;
case ISSET_PRIMITIVE:
- indent(out) << "private " << primitiveType << " __isset_bitfield = 0;" << endl;
+ indent(out) << "private " << primitiveType << " __isset_bitfield = 0;" << '\n';
break;
case ISSET_BITSET:
indent(out) << "private java.util.BitSet __isset_bit_vector = new java.util.BitSet(" << i
- << ");" << endl;
+ << ");" << '\n';
break;
}
@@ -1638,7 +1635,7 @@
output_string = output_string + "_Fields." + constant_name((*m_iter)->get_name()) + ",";
}
}
- indent(out) << output_string.substr(0, output_string.length() - 1) << "};" << endl;
+ indent(out) << output_string.substr(0, output_string.length() - 1) << "};" << '\n';
}
}
@@ -1647,7 +1644,7 @@
bool all_optional_members = true;
// Default constructor
- indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "() {" << endl;
+ indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "() {" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
@@ -1660,27 +1657,27 @@
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
if (!members.empty() && !all_optional_members) {
// Full constructor for all fields
- indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "(" << endl;
+ indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << "(" << '\n';
indent_up();
bool first = true;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
if (!first) {
- out << "," << endl;
+ out << "," << '\n';
}
first = false;
indent(out) << type_name((*m_iter)->get_type()) << " " << make_valid_java_identifier((*m_iter)->get_name());
}
}
- out << ")" << endl;
+ out << ")" << '\n';
indent_down();
- indent(out) << "{" << endl;
+ indent(out) << "{" << '\n';
indent_up();
- indent(out) << "this();" << endl;
+ indent(out) << "this();" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
t_type* type = get_true_type((*m_iter)->get_type());
@@ -1688,44 +1685,44 @@
if (unsafe_binaries_) {
indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name())
<< " = " << make_valid_java_identifier((*m_iter)->get_name()) << ";"
- << endl;
+ << '\n';
} else {
indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name())
<< " = org.apache.thrift.TBaseHelper.copyBinary("
<< make_valid_java_identifier((*m_iter)->get_name())
- << ");" << endl;
+ << ");" << '\n';
}
} else {
indent(out) << "this." << make_valid_java_identifier((*m_iter)->get_name()) << " = "
<< make_valid_java_identifier((*m_iter)->get_name()) << ";"
- << endl;
+ << '\n';
}
generate_isset_set(out, (*m_iter), "");
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// copy constructor
- indent(out) << "/**" << endl;
- indent(out) << " * Performs a deep copy on <i>other</i>." << endl;
- indent(out) << " */" << endl;
+ indent(out) << "/**" << '\n';
+ indent(out) << " * Performs a deep copy on <i>other</i>." << '\n';
+ indent(out) << " */" << '\n';
indent(out) << "public " << make_valid_java_identifier(tstruct->get_name())
<< "(" << make_valid_java_identifier(tstruct->get_name()) << " other) {"
- << endl;
+ << '\n';
indent_up();
switch (needs_isset(tstruct)) {
case ISSET_NONE:
break;
case ISSET_PRIMITIVE:
- indent(out) << "__isset_bitfield = other.__isset_bitfield;" << endl;
+ indent(out) << "__isset_bitfield = other.__isset_bitfield;" << '\n';
break;
case ISSET_BITSET:
- indent(out) << "__isset_bit_vector.clear();" << endl;
- indent(out) << "__isset_bit_vector.or(other.__isset_bit_vector);" << endl;
+ indent(out) << "__isset_bit_vector.clear();" << '\n';
+ indent(out) << "__isset_bit_vector.or(other.__isset_bit_vector);" << '\n';
break;
}
@@ -1736,33 +1733,33 @@
bool can_be_null = type_can_be_null(type);
if (can_be_null) {
- indent(out) << "if (other." << generate_isset_check(field) << ") {" << endl;
+ indent(out) << "if (other." << generate_isset_check(field) << ") {" << '\n';
indent_up();
}
if (type->is_container()) {
generate_deep_copy_container(out, "other", field_name, "__this__" + field_name, type);
- indent(out) << "this." << make_valid_java_identifier(field_name) << " = __this__" << field_name << ";" << endl;
+ indent(out) << "this." << make_valid_java_identifier(field_name) << " = __this__" << field_name << ";" << '\n';
} else {
indent(out) << "this." << make_valid_java_identifier(field_name) << " = ";
generate_deep_copy_non_container(out, "other." + make_valid_java_identifier(field_name), field_name, type);
- out << ";" << endl;
+ out << ";" << '\n';
}
if (can_be_null) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// clone method, so that you can deep copy an object when you don't know its class.
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << endl;
- indent(out) << " return new " << make_valid_java_identifier(tstruct->get_name()) << "(this);" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public " << make_valid_java_identifier(tstruct->get_name()) << " deepCopy() {" << '\n';
+ indent(out) << " return new " << make_valid_java_identifier(tstruct->get_name()) << "(this);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
generate_java_struct_clear(out, tstruct);
@@ -1791,7 +1788,7 @@
generate_java_scheme_lookup(out);
scope_down(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1803,30 +1800,30 @@
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
- out << indent() << java_override_annotation() << endl
- << indent() << "public void writeToParcel(android.os.Parcel out, int flags) {" << endl;
+ out << indent() << java_override_annotation() << '\n'
+ << indent() << "public void writeToParcel(android.os.Parcel out, int flags) {" << '\n';
indent_up();
string bitsetPrimitiveType = "";
switch (needs_isset(tstruct, &bitsetPrimitiveType)) {
case ISSET_NONE:
break;
case ISSET_PRIMITIVE:
- indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl;
+ indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << '\n';
if (bitsetPrimitiveType == "byte") {
- indent(out) << "out.writeByte(__isset_bitfield);" << endl;
+ indent(out) << "out.writeByte(__isset_bitfield);" << '\n';
} else if (bitsetPrimitiveType == "short") {
- indent(out) << "out.writeInt(new Short(__isset_bitfield).intValue());" << endl;
+ indent(out) << "out.writeInt(new Short(__isset_bitfield).intValue());" << '\n';
} else if (bitsetPrimitiveType == "int") {
- indent(out) << "out.writeInt(__isset_bitfield);" << endl;
+ indent(out) << "out.writeInt(__isset_bitfield);" << '\n';
} else if (bitsetPrimitiveType == "long") {
- indent(out) << "out.writeLong(__isset_bitfield);" << endl;
+ indent(out) << "out.writeLong(__isset_bitfield);" << '\n';
}
- out << endl;
+ out << '\n';
break;
case ISSET_BITSET:
- indent(out) << "//BitSet" << endl;
- indent(out) << "out.writeSerializable(__isset_bit_vector);" << endl;
- out << endl;
+ indent(out) << "//BitSet" << '\n';
+ indent(out) << "out.writeSerializable(__isset_bit_vector);" << '\n';
+ out << '\n';
break;
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1834,54 +1831,54 @@
string name = (*m_iter)->get_name();
if (t->is_struct()) {
- indent(out) << "out.writeParcelable(" << name << ", flags);" << endl;
+ indent(out) << "out.writeParcelable(" << name << ", flags);" << '\n';
} else if (type_name(t) == "float") {
- indent(out) << "out.writeFloat(" << name << ");" << endl;
+ indent(out) << "out.writeFloat(" << name << ");" << '\n';
} else if (t->is_enum()) {
indent(out) << "out.writeInt(" << name << " != null ? " << name << ".getValue() : -1);"
- << endl;
+ << '\n';
} else if (t->is_list()) {
if (((t_list*)t)->get_elem_type()->get_true_type()->is_struct()) {
- indent(out) << "out.writeTypedList(" << name << ");" << endl;
+ indent(out) << "out.writeTypedList(" << name << ");" << '\n';
} else {
- indent(out) << "out.writeList(" << name << ");" << endl;
+ indent(out) << "out.writeList(" << name << ");" << '\n';
}
} else if (t->is_map()) {
- indent(out) << "out.writeMap(" << name << ");" << endl;
+ indent(out) << "out.writeMap(" << name << ");" << '\n';
} else if (t->is_base_type()) {
if (t->is_binary()) {
- indent(out) << "out.writeInt(" << name << "!=null ? 1 : 0);" << endl;
- indent(out) << "if(" << name << " != null) { " << endl;
+ indent(out) << "out.writeInt(" << name << "!=null ? 1 : 0);" << '\n';
+ indent(out) << "if(" << name << " != null) { " << '\n';
indent_up();
indent(out) << "out.writeByteArray(" << name << ".array(), " << name << ".position() + "
<< name << ".arrayOffset(), " << name << ".limit() - " << name
- << ".position() );" << endl;
+ << ".position() );" << '\n';
scope_down(out);
} else {
switch (((t_base_type*)t)->get_base()) {
case t_base_type::TYPE_I16:
- indent(out) << "out.writeInt(new Short(" << name << ").intValue());" << endl;
+ indent(out) << "out.writeInt(new Short(" << name << ").intValue());" << '\n';
break;
case t_base_type::TYPE_UUID:
- indent(out) << "out.writeUuid(" << name << ");" << endl;
+ indent(out) << "out.writeUuid(" << name << ");" << '\n';
break;
case t_base_type::TYPE_I32:
- indent(out) << "out.writeInt(" << name << ");" << endl;
+ indent(out) << "out.writeInt(" << name << ");" << '\n';
break;
case t_base_type::TYPE_I64:
- indent(out) << "out.writeLong(" << name << ");" << endl;
+ indent(out) << "out.writeLong(" << name << ");" << '\n';
break;
case t_base_type::TYPE_BOOL:
- indent(out) << "out.writeInt(" << name << " ? 1 : 0);" << endl;
+ indent(out) << "out.writeInt(" << name << " ? 1 : 0);" << '\n';
break;
case t_base_type::TYPE_I8:
- indent(out) << "out.writeByte(" << name << ");" << endl;
+ indent(out) << "out.writeByte(" << name << ");" << '\n';
break;
case t_base_type::TYPE_DOUBLE:
- indent(out) << "out.writeDouble(" << name << ");" << endl;
+ indent(out) << "out.writeDouble(" << name << ");" << '\n';
break;
case t_base_type::TYPE_STRING:
- indent(out) << "out.writeString(" << name << ");" << endl;
+ indent(out) << "out.writeString(" << name << ");" << '\n';
break;
case t_base_type::TYPE_VOID:
break;
@@ -1892,38 +1889,38 @@
}
}
scope_down(out);
- out << endl;
+ out << '\n';
- out << indent() << java_override_annotation() << endl
- << indent() << "public int describeContents() {" << endl;
+ out << indent() << java_override_annotation() << '\n'
+ << indent() << "public int describeContents() {" << '\n';
indent_up();
- out << indent() << "return 0;" << endl;
+ out << indent() << "return 0;" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
- indent(out) << "public " << tname << "(android.os.Parcel in) {" << endl;
+ indent(out) << "public " << tname << "(android.os.Parcel in) {" << '\n';
indent_up();
// read in the required bitfield
switch (needs_isset(tstruct, &bitsetPrimitiveType)) {
case ISSET_NONE:
break;
case ISSET_PRIMITIVE:
- indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << endl;
+ indent(out) << "//primitive bitfield of type: " << bitsetPrimitiveType << '\n';
if (bitsetPrimitiveType == "byte") {
- indent(out) << "__isset_bitfield = in.readByte();" << endl;
+ indent(out) << "__isset_bitfield = in.readByte();" << '\n';
} else if (bitsetPrimitiveType == "short") {
- indent(out) << "__isset_bitfield = (short) in.readInt();" << endl;
+ indent(out) << "__isset_bitfield = (short) in.readInt();" << '\n';
} else if (bitsetPrimitiveType == "int") {
- indent(out) << "__isset_bitfield = in.readInt();" << endl;
+ indent(out) << "__isset_bitfield = in.readInt();" << '\n';
} else if (bitsetPrimitiveType == "long") {
- indent(out) << "__isset_bitfield = in.readLong();" << endl;
+ indent(out) << "__isset_bitfield = in.readLong();" << '\n';
}
- out << endl;
+ out << '\n';
break;
case ISSET_BITSET:
- indent(out) << "//BitSet" << endl;
- indent(out) << "__isset_bit_vector = (java.util.BitSet) in.readSerializable();" << endl;
- out << endl;
+ indent(out) << "//BitSet" << '\n';
+ indent(out) << "__isset_bit_vector = (java.util.BitSet) in.readSerializable();" << '\n';
+ out << '\n';
break;
}
// read all the fields
@@ -1934,57 +1931,57 @@
if (t->is_struct()) {
indent(out) << prefix << "= in.readParcelable(" << tname << ".class.getClassLoader());"
- << endl;
+ << '\n';
} else if (t->is_enum()) {
- indent(out) << prefix << " = " << type_name(t) << ".findByValue(in.readInt());" << endl;
+ indent(out) << prefix << " = " << type_name(t) << ".findByValue(in.readInt());" << '\n';
} else if (t->is_list()) {
t_list* list = (t_list*)t;
- indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl;
+ indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << '\n';
if (list->get_elem_type()->get_true_type()->is_struct()) {
indent(out) << "in.readTypedList(" << prefix << ", " << type_name(list->get_elem_type())
- << ".CREATOR);" << endl;
+ << ".CREATOR);" << '\n';
} else {
indent(out) << "in.readList(" << prefix << ", " << tname << ".class.getClassLoader());"
- << endl;
+ << '\n';
}
} else if (t->is_map()) {
- indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << endl;
+ indent(out) << prefix << " = new " << type_name(t, false, true) << "();" << '\n';
indent(out) << " in.readMap(" << prefix << ", " << tname << ".class.getClassLoader());"
- << endl;
+ << '\n';
} else if (type_name(t) == "float") {
- indent(out) << prefix << " = in.readFloat();" << endl;
+ indent(out) << prefix << " = in.readFloat();" << '\n';
} else if (t->is_base_type()) {
t_base_type* bt = (t_base_type*)t;
if (bt->is_binary()) {
- indent(out) << "if(in.readInt()==1) {" << endl;
+ indent(out) << "if(in.readInt()==1) {" << '\n';
indent_up();
- indent(out) << prefix << " = java.nio.ByteBuffer.wrap(in.createByteArray());" << endl;
+ indent(out) << prefix << " = java.nio.ByteBuffer.wrap(in.createByteArray());" << '\n';
scope_down(out);
} else {
switch (bt->get_base()) {
case t_base_type::TYPE_I8:
- indent(out) << prefix << " = in.readByte();" << endl;
+ indent(out) << prefix << " = in.readByte();" << '\n';
break;
case t_base_type::TYPE_I16:
- indent(out) << prefix << " = (short) in.readInt();" << endl;
+ indent(out) << prefix << " = (short) in.readInt();" << '\n';
break;
case t_base_type::TYPE_I32:
- indent(out) << prefix << " = in.readInt();" << endl;
+ indent(out) << prefix << " = in.readInt();" << '\n';
break;
case t_base_type::TYPE_I64:
- indent(out) << prefix << " = in.readLong();" << endl;
+ indent(out) << prefix << " = in.readLong();" << '\n';
break;
case t_base_type::TYPE_UUID:
- indent(out) << prefix << " = in.readUuid();" << endl;
+ indent(out) << prefix << " = in.readUuid();" << '\n';
break;
case t_base_type::TYPE_BOOL:
- indent(out) << prefix << " = (in.readInt()==1);" << endl;
+ indent(out) << prefix << " = (in.readInt()==1);" << '\n';
break;
case t_base_type::TYPE_DOUBLE:
- indent(out) << prefix << " = in.readDouble();" << endl;
+ indent(out) << prefix << " = in.readDouble();" << '\n';
break;
case t_base_type::TYPE_STRING:
- indent(out) << prefix << "= in.readString();" << endl;
+ indent(out) << prefix << "= in.readString();" << '\n';
break;
case t_base_type::TYPE_VOID:
break;
@@ -1996,29 +1993,29 @@
}
scope_down(out);
- out << endl;
+ out << '\n';
indent(out) << "public static final android.os.Parcelable.Creator<" << tname
- << "> CREATOR = new android.os.Parcelable.Creator<" << tname << ">() {" << endl;
+ << "> CREATOR = new android.os.Parcelable.Creator<" << tname << ">() {" << '\n';
indent_up();
- indent(out) << java_override_annotation() << endl
- << indent() << "public " << tname << "[] newArray(int size) {" << endl;
+ indent(out) << java_override_annotation() << '\n'
+ << indent() << "public " << tname << "[] newArray(int size) {" << '\n';
indent_up();
- indent(out) << "return new " << tname << "[size];" << endl;
+ indent(out) << "return new " << tname << "[size];" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
- indent(out) << java_override_annotation() << endl
+ indent(out) << java_override_annotation() << '\n'
<< indent() << "public " << tname << " createFromParcel(android.os.Parcel in) {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "return new " << tname << "(in);" << endl;
+ indent(out) << "return new " << tname << "(in);" << '\n';
scope_down(out);
indent_down();
- indent(out) << "};" << endl;
- out << endl;
+ indent(out) << "};" << '\n';
+ out << '\n';
}
/**
@@ -2027,26 +2024,26 @@
* @param tstruct The struct definition
*/
void t_java_generator::generate_java_struct_equality(ostream& out, t_struct* tstruct) {
- out << indent() << java_override_annotation() << endl
- << indent() << "public boolean equals(java.lang.Object that) {" << endl;
+ out << indent() << java_override_annotation() << '\n'
+ << indent() << "public boolean equals(java.lang.Object that) {" << '\n';
indent_up();
- out << indent() << "if (that instanceof " << make_valid_java_identifier(tstruct->get_name()) << ")" << endl
- << indent() << " return this.equals((" << make_valid_java_identifier(tstruct->get_name()) << ")that);" << endl
- << indent() << "return false;" << endl;
+ out << indent() << "if (that instanceof " << make_valid_java_identifier(tstruct->get_name()) << ")" << '\n'
+ << indent() << " return this.equals((" << make_valid_java_identifier(tstruct->get_name()) << ")that);" << '\n'
+ << indent() << "return false;" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
- out << indent() << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " that) {" << endl;
+ out << indent() << "public boolean equals(" << make_valid_java_identifier(tstruct->get_name()) << " that) {" << '\n';
indent_up();
- out << indent() << "if (that == null)" << endl
- << indent() << " return false;" << endl
- << indent() << "if (this == that)" << endl
- << indent() << " return true;" << endl;
+ out << indent() << "if (that == null)" << '\n'
+ << indent() << " return false;" << '\n'
+ << indent() << "if (this == that)" << '\n'
+ << indent() << " return true;" << '\n';
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- out << endl;
+ out << '\n';
t_type* t = get_true_type((*m_iter)->get_type());
// Most existing Thrift code does not use isset or optional/required,
@@ -2064,14 +2061,14 @@
that_present += " && that." + generate_isset_check(*m_iter);
}
- out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << endl
- << indent() << "boolean that_present_" << name << " = " << that_present << ";" << endl
+ out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << '\n'
+ << indent() << "boolean that_present_" << name << " = " << that_present << ";" << '\n'
<< indent() << "if ("
- << "this_present_" << name << " || that_present_" << name << ") {" << endl;
+ << "this_present_" << name << " || that_present_" << name << ") {" << '\n';
indent_up();
out << indent() << "if (!("
- << "this_present_" << name << " && that_present_" << name << "))" << endl
- << indent() << " return false;" << endl;
+ << "this_present_" << name << " && that_present_" << name << "))" << '\n'
+ << indent() << " return false;" << '\n';
if (t->is_binary()) {
unequal = "!this." + make_valid_java_identifier(name) + ".equals(that." + make_valid_java_identifier(name) + ")";
@@ -2081,25 +2078,25 @@
unequal = "this." + make_valid_java_identifier(name) + " != that." + make_valid_java_identifier(name);
}
- out << indent() << "if (" << unequal << ")" << endl << indent() << " return false;" << endl;
+ out << indent() << "if (" << unequal << ")" << '\n' << indent() << " return false;" << '\n';
scope_down(out);
}
- out << endl;
- indent(out) << "return true;" << endl;
+ out << '\n';
+ indent(out) << "return true;" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
const int MUL = 8191; // HashCode multiplier
const int B_YES = 131071;
const int B_NO = 524287;
- out << indent() << java_override_annotation() << endl
- << indent() << "public int hashCode() {" << endl;
+ out << indent() << java_override_annotation() << '\n'
+ << indent() << "public int hashCode() {" << '\n';
indent_up();
- indent(out) << "int hashCode = 1;" << endl;
+ indent(out) << "int hashCode = 1;" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- out << endl;
+ out << '\n';
t_type* t = get_true_type((*m_iter)->get_type());
bool is_optional = (*m_iter)->get_req() == t_field::T_OPTIONAL;
@@ -2108,37 +2105,37 @@
if (is_optional || can_be_null) {
indent(out) << "hashCode = hashCode * " << MUL << " + ((" << generate_isset_check(*m_iter)
- << ") ? " << B_YES << " : " << B_NO << ");" << endl;
+ << ") ? " << B_YES << " : " << B_NO << ");" << '\n';
}
if (is_optional || can_be_null) {
- indent(out) << "if (" + generate_isset_check(*m_iter) + ")" << endl;
+ indent(out) << "if (" + generate_isset_check(*m_iter) + ")" << '\n';
indent_up();
}
if (t->is_enum()) {
- indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".getValue();" << endl;
+ indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".getValue();" << '\n';
} else if (t->is_base_type()) {
switch (((t_base_type*)t)->get_base()) {
case t_base_type::TYPE_STRING:
case t_base_type::TYPE_UUID:
- indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << endl;
+ indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << '\n';
break;
case t_base_type::TYPE_BOOL:
indent(out) << "hashCode = hashCode * " << MUL << " + ((" << name << ") ? " << B_YES
- << " : " << B_NO << ");" << endl;
+ << " : " << B_NO << ");" << '\n';
break;
case t_base_type::TYPE_I8:
- indent(out) << "hashCode = hashCode * " << MUL << " + (int) (" << name << ");" << endl;
+ indent(out) << "hashCode = hashCode * " << MUL << " + (int) (" << name << ");" << '\n';
break;
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
- indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ";" << endl;
+ indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ";" << '\n';
break;
case t_base_type::TYPE_I64:
case t_base_type::TYPE_DOUBLE:
indent(out) << "hashCode = hashCode * " << MUL
- << " + org.apache.thrift.TBaseHelper.hashCode(" << name << ");" << endl;
+ << " + org.apache.thrift.TBaseHelper.hashCode(" << name << ");" << '\n';
break;
case t_base_type::TYPE_VOID:
throw std::logic_error("compiler error: a struct field cannot be void");
@@ -2147,7 +2144,7 @@
+ t_base_type::t_base_name(((t_base_type*)t)->get_base()));
}
} else {
- indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << endl;
+ indent(out) << "hashCode = hashCode * " << MUL << " + " << name << ".hashCode();" << '\n';
}
if (is_optional || can_be_null) {
@@ -2155,49 +2152,49 @@
}
}
- out << endl;
- indent(out) << "return hashCode;" << endl;
+ out << '\n';
+ indent(out) << "return hashCode;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
void t_java_generator::generate_java_struct_compare_to(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n';
indent_up();
- indent(out) << "if (!getClass().equals(other.getClass())) {" << endl;
- indent(out) << " return getClass().getName().compareTo(other.getClass().getName());" << endl;
- indent(out) << "}" << endl;
- out << endl;
+ indent(out) << "if (!getClass().equals(other.getClass())) {" << '\n';
+ indent(out) << " return getClass().getName().compareTo(other.getClass().getName());" << '\n';
+ indent(out) << "}" << '\n';
+ out << '\n';
- indent(out) << "int lastComparison = 0;" << endl;
- out << endl;
+ indent(out) << "int lastComparison = 0;" << '\n';
+ out << '\n';
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = *m_iter;
indent(out) << "lastComparison = java.lang.Boolean.compare(" << generate_isset_check(field)
- << ", other." << generate_isset_check(field) << ");" << endl;
- indent(out) << "if (lastComparison != 0) {" << endl;
- indent(out) << " return lastComparison;" << endl;
- indent(out) << "}" << endl;
+ << ", other." << generate_isset_check(field) << ");" << '\n';
+ indent(out) << "if (lastComparison != 0) {" << '\n';
+ indent(out) << " return lastComparison;" << '\n';
+ indent(out) << "}" << '\n';
- indent(out) << "if (" << generate_isset_check(field) << ") {" << endl;
+ indent(out) << "if (" << generate_isset_check(field) << ") {" << '\n';
indent(out) << " lastComparison = org.apache.thrift.TBaseHelper.compareTo(this."
<< make_valid_java_identifier(field->get_name())
- << ", other." << make_valid_java_identifier(field->get_name()) << ");" << endl;
- indent(out) << " if (lastComparison != 0) {" << endl;
- indent(out) << " return lastComparison;" << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl;
+ << ", other." << make_valid_java_identifier(field->get_name()) << ");" << '\n';
+ indent(out) << " if (lastComparison != 0) {" << '\n';
+ indent(out) << " return lastComparison;" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n';
}
- indent(out) << "return 0;" << endl;
+ indent(out) << "return 0;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -2206,63 +2203,63 @@
* @param tstruct The struct definition
*/
void t_java_generator::generate_java_struct_reader(ostream& out, t_struct* /*tstruct*/) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "public void read(org.apache.thrift.protocol.TProtocol iprot) throws "
"org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "scheme(iprot).read(iprot, this);" << endl;
+ indent(out) << "scheme(iprot).read(iprot, this);" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// generates java method to perform various checks
// (e.g. check that all required fields are set)
void t_java_generator::generate_java_validator(ostream& out, t_struct* tstruct) {
- indent(out) << "public void validate() throws org.apache.thrift.TException {" << endl;
+ indent(out) << "public void validate() throws org.apache.thrift.TException {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- out << indent() << "// check for required fields" << endl;
+ out << indent() << "// check for required fields" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
if (bean_style_) {
- out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl
+ out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << '\n'
<< indent()
<< " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '"
- << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl
- << indent() << "}" << endl
- << endl;
+ << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << '\n'
+ << indent() << "}" << '\n'
+ << '\n';
} else {
if (type_can_be_null((*f_iter)->get_type())) {
- indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl;
+ indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << '\n';
indent(out)
<< " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '"
- << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
- indent(out) << "}" << endl;
+ << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << '\n';
+ indent(out) << "}" << '\n';
} else {
indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name()
<< "' because it's a primitive and you chose the non-beans generator."
- << endl;
+ << '\n';
}
}
}
}
- out << indent() << "// check for sub-struct validity" << endl;
+ out << indent() << "// check for sub-struct validity" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_type* type = get_true_type((*f_iter)->get_type());
if (type->is_struct() && !((t_struct*)type)->is_union()) {
- out << indent() << "if (" << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << endl;
- out << indent() << " " << make_valid_java_identifier((*f_iter)->get_name()) << ".validate();" << endl;
- out << indent() << "}" << endl;
+ out << indent() << "if (" << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << '\n';
+ out << indent() << " " << make_valid_java_identifier((*f_iter)->get_name()) << ".validate();" << '\n';
+ out << indent() << "}" << '\n';
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -2271,15 +2268,15 @@
* @param tstruct The struct definition
*/
void t_java_generator::generate_java_struct_writer(ostream& out, t_struct* /*tstruct*/) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws "
"org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "scheme(oprot).write(oprot, this);" << endl;
+ indent(out) << "scheme(oprot).write(oprot, this);" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -2294,30 +2291,30 @@
(void)tstruct;
indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws "
"org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "scheme(oprot).write(oprot, this);" << endl;
+ indent(out) << "scheme(oprot).write(oprot, this);" << '\n';
indent_down();
- indent(out) << " }" << endl << endl;
+ indent(out) << " }" << '\n' << '\n';
}
void t_java_generator::generate_java_struct_field_by_id(ostream& out, t_struct* tstruct) {
(void)tstruct;
- indent(out) << java_nullable_annotation() << endl;
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public _Fields fieldForId(int fieldId) {" << endl;
- indent(out) << " return _Fields.findByThriftId(fieldId);" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << java_nullable_annotation() << '\n';
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public _Fields fieldForId(int fieldId) {" << '\n';
+ indent(out) << " return _Fields.findByThriftId(fieldId);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
}
void t_java_generator::generate_reflection_getters(ostringstream& out,
t_type* type,
string field_name,
string cap_name) {
- indent(out) << "case " << constant_name(field_name) << ":" << endl;
+ indent(out) << "case " << constant_name(field_name) << ":" << '\n';
indent_up();
- indent(out) << "return " << (type->is_bool() ? "is" : "get") << cap_name << "();" << endl << endl;
+ indent(out) << "return " << (type->is_bool() ? "is" : "get") << cap_name << "();" << '\n' << '\n';
indent_down();
}
@@ -2326,24 +2323,24 @@
string field_name,
string cap_name) {
const bool is_binary = type->is_binary();
- indent(out) << "case " << constant_name(field_name) << ":" << endl;
+ indent(out) << "case " << constant_name(field_name) << ":" << '\n';
indent_up();
- indent(out) << "if (value == null) {" << endl;
- indent(out) << " unset" << get_cap_name(field_name) << "();" << endl;
- indent(out) << "} else {" << endl;
+ indent(out) << "if (value == null) {" << '\n';
+ indent(out) << " unset" << get_cap_name(field_name) << "();" << '\n';
+ indent(out) << "} else {" << '\n';
if (is_binary) {
indent_up();
- indent(out) << "if (value instanceof byte[]) {" << endl;
- indent(out) << " set" << cap_name << "((byte[])value);" << endl;
- indent(out) << "} else {" << endl;
+ indent(out) << "if (value instanceof byte[]) {" << '\n';
+ indent(out) << " set" << cap_name << "((byte[])value);" << '\n';
+ indent(out) << "} else {" << '\n';
}
- indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << endl;
+ indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << '\n';
if (is_binary) {
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
}
- indent(out) << "}" << endl;
- indent(out) << "break;" << endl << endl;
+ indent(out) << "}" << '\n';
+ indent(out) << "break;" << '\n' << '\n';
indent_down();
}
@@ -2370,25 +2367,25 @@
// create the setter
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "public void setFieldValue(_Fields field, " << java_nullable_annotation()
- << " java.lang.Object value) {" << endl;
- indent(out) << " switch (field) {" << endl;
+ << " java.lang.Object value) {" << '\n';
+ indent(out) << " switch (field) {" << '\n';
out << setter_stream.str();
- indent(out) << " }" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n' << '\n';
// create the getter
- indent(out) << java_nullable_annotation() << endl;
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public java.lang.Object getFieldValue(_Fields field) {" << endl;
+ indent(out) << java_nullable_annotation() << '\n';
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public java.lang.Object getFieldValue(_Fields field) {" << '\n';
indent_up();
- indent(out) << "switch (field) {" << endl;
+ indent(out) << "switch (field) {" << '\n';
out << getter_stream.str();
- indent(out) << "}" << endl;
- indent(out) << "throw new java.lang.IllegalStateException();" << endl;
+ indent(out) << "}" << '\n';
+ indent(out) << "throw new java.lang.IllegalStateException();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// Creates a generic isSet method that takes the field number as argument
@@ -2399,28 +2396,28 @@
// create the isSet method
indent(out) << "/** Returns true if field corresponding to fieldID is set (has been assigned a "
"value) and false otherwise */"
- << endl;
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public boolean isSet(_Fields field) {" << endl;
+ << '\n';
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public boolean isSet(_Fields field) {" << '\n';
indent_up();
- indent(out) << "if (field == null) {" << endl;
- indent(out) << " throw new java.lang.IllegalArgumentException();" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "if (field == null) {" << '\n';
+ indent(out) << " throw new java.lang.IllegalArgumentException();" << '\n';
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << "switch (field) {" << endl;
+ indent(out) << "switch (field) {" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* field = *f_iter;
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent_up();
- indent(out) << "return " << generate_isset_check(field) << ";" << endl;
+ indent(out) << "return " << generate_isset_check(field) << ";" << '\n';
indent_down();
}
- indent(out) << "}" << endl;
- indent(out) << "throw new java.lang.IllegalStateException();" << endl;
+ indent(out) << "}" << '\n';
+ indent(out) << "throw new java.lang.IllegalStateException();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -2445,7 +2442,7 @@
// Method to return the size of the collection
if (optional) {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
if (use_jdk8_option_type_) {
@@ -2454,20 +2451,20 @@
indent(out) << "public " << thrift_option_class << "<Integer> get" << cap_name;
}
- out << get_cap_name("size() {") << endl;
+ out << get_cap_name("size() {") << '\n';
indent_up();
- indent(out) << "if (this." << field_name << " == null) {" << endl;
+ indent(out) << "if (this." << field_name << " == null) {" << '\n';
indent_up();
if (use_jdk8_option_type_) {
- indent(out) << "return " << jdk_option_class << ".empty();" << endl;
+ indent(out) << "return " << jdk_option_class << ".empty();" << '\n';
} else {
- indent(out) << "return " << thrift_option_class << ".none();" << endl;
+ indent(out) << "return " << thrift_option_class << ".none();" << '\n';
}
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
if (use_jdk8_option_type_) {
@@ -2475,24 +2472,24 @@
} else {
indent(out) << "return " << thrift_option_class << ".some(this.";
}
- out << field_name << ".size());" << endl;
+ out << field_name << ".size());" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public int get" << cap_name;
- out << get_cap_name("size() {") << endl;
+ out << get_cap_name("size() {") << '\n';
indent_up();
indent(out) << "return (this." << field_name << " == null) ? 0 : "
- << "this." << field_name << ".size();" << endl;
+ << "this." << field_name << ".size();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
}
@@ -2507,7 +2504,7 @@
// Iterator getter for sets and lists
if (optional) {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
if (use_jdk8_option_type_) {
@@ -2518,20 +2515,20 @@
out << "java.util.Iterator<" << type_name(element_type, true, false) << ">> get"
<< cap_name;
- out << get_cap_name("iterator() {") << endl;
+ out << get_cap_name("iterator() {") << '\n';
indent_up();
- indent(out) << "if (this." << field_name << " == null) {" << endl;
+ indent(out) << "if (this." << field_name << " == null) {" << '\n';
indent_up();
if (use_jdk8_option_type_) {
- indent(out) << "return " << jdk_option_class << ".empty();" << endl;
+ indent(out) << "return " << jdk_option_class << ".empty();" << '\n';
} else {
- indent(out) << "return " << thrift_option_class << ".none();" << endl;
+ indent(out) << "return " << thrift_option_class << ".none();" << '\n';
}
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
if (use_jdk8_option_type_) {
@@ -2539,104 +2536,104 @@
} else {
indent(out) << "return " << thrift_option_class << ".some(this.";
}
- out << field_name << ".iterator());" << endl;
+ out << field_name << ".iterator());" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
- indent(out) << java_nullable_annotation() << endl;
+ indent(out) << java_nullable_annotation() << '\n';
indent(out) << "public java.util.Iterator<" << type_name(element_type, true, false)
<< "> get" << cap_name;
- out << get_cap_name("iterator() {") << endl;
+ out << get_cap_name("iterator() {") << '\n';
indent_up();
indent(out) << "return (this." << field_name << " == null) ? null : "
- << "this." << field_name << ".iterator();" << endl;
+ << "this." << field_name << ".iterator();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// Add to set or list, create if the set/list is null
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public void add" << get_cap_name("to");
- out << cap_name << "(" << type_name(element_type) << " elem) {" << endl;
+ out << cap_name << "(" << type_name(element_type) << " elem) {" << '\n';
indent_up();
- indent(out) << "if (this." << field_name << " == null) {" << endl;
+ indent(out) << "if (this." << field_name << " == null) {" << '\n';
indent_up();
indent(out) << "this." << field_name;
if (is_enum_set(type)) {
out << " = " << type_name(type, false, true, true) << ".noneOf("
- << inner_enum_type_name(type) << ");" << endl;
+ << inner_enum_type_name(type) << ");" << '\n';
} else {
- out << " = new " << type_name(type, false, true) << "();" << endl;
+ out << " = new " << type_name(type, false, true) << "();" << '\n';
}
indent_down();
- indent(out) << "}" << endl;
- indent(out) << "this." << field_name << ".add(elem);" << endl;
+ indent(out) << "}" << '\n';
+ indent(out) << "this." << field_name << ".add(elem);" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else if (type->is_map()) {
// Put to map
t_type* key_type = ((t_map*)type)->get_key_type();
t_type* val_type = ((t_map*)type)->get_val_type();
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public void put" << get_cap_name("to");
out << cap_name << "(" << type_name(key_type) << " key, " << type_name(val_type) << " val) {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "if (this." << field_name << " == null) {" << endl;
+ indent(out) << "if (this." << field_name << " == null) {" << '\n';
indent_up();
std::string constructor_args;
if (is_enum_map(type)) {
constructor_args = inner_enum_type_name(type);
}
indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "("
- << constructor_args << ");" << endl;
+ << constructor_args << ");" << '\n';
indent_down();
- indent(out) << "}" << endl;
- indent(out) << "this." << field_name << ".put(key, val);" << endl;
+ indent(out) << "}" << '\n';
+ indent(out) << "this." << field_name << ".put(key, val);" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// Simple getter
generate_java_doc(out, field);
if (type->is_binary()) {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
- indent(out) << "public byte[] get" << cap_name << "() {" << endl;
+ indent(out) << "public byte[] get" << cap_name << "() {" << '\n';
indent(out) << " set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize("
- << field_name << "));" << endl;
+ << field_name << "));" << '\n';
indent(out) << " return " << field_name << " == null ? null : " << field_name << ".array();"
- << endl;
- indent(out) << "}" << endl << endl;
+ << '\n';
+ indent(out) << "}" << '\n' << '\n';
indent(out) << "public java.nio.ByteBuffer buffer" << get_cap_name("for") << cap_name
- << "() {" << endl;
+ << "() {" << '\n';
if (unsafe_binaries_) {
- indent(out) << " return " << field_name << ";" << endl;
+ indent(out) << " return " << field_name << ";" << '\n';
} else {
indent(out) << " return org.apache.thrift.TBaseHelper.copyBinary(" << field_name << ");"
- << endl;
+ << '\n';
}
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else {
if (optional) {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
if (use_jdk8_option_type_) {
@@ -2650,10 +2647,10 @@
} else {
out << " get";
}
- out << cap_name << "() {" << endl;
+ out << cap_name << "() {" << '\n';
indent_up();
- indent(out) << "if (this.isSet" << cap_name << "()) {" << endl;
+ indent(out) << "if (this.isSet" << cap_name << "()) {" << '\n';
indent_up();
if (use_jdk8_option_type_) {
@@ -2661,28 +2658,28 @@
} else {
indent(out) << "return " << thrift_option_class << ".some(this.";
}
- out << field_name << ");" << endl;
+ out << field_name << ");" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
if (use_jdk8_option_type_) {
- indent(out) << "return " << jdk_option_class << ".empty();" << endl;
+ indent(out) << "return " << jdk_option_class << ".empty();" << '\n';
} else {
- indent(out) << "return " << thrift_option_class << ".none();" << endl;
+ indent(out) << "return " << thrift_option_class << ".none();" << '\n';
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
if (type_can_be_null(type)) {
- indent(out) << java_nullable_annotation() << endl;
+ indent(out) << java_nullable_annotation() << '\n';
}
indent(out) << "public " << type_name(type);
if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
@@ -2690,11 +2687,11 @@
} else {
out << " get";
}
- out << cap_name << "() {" << endl;
+ out << cap_name << "() {" << '\n';
indent_up();
- indent(out) << "return this." << make_valid_java_identifier(field_name) << ";" << endl;
+ indent(out) << "return this." << make_valid_java_identifier(field_name) << ";" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
}
@@ -2702,7 +2699,7 @@
generate_java_doc(out, field);
if (type->is_binary()) {
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public ";
if (bean_style_) {
@@ -2710,23 +2707,23 @@
} else {
out << type_name(tstruct);
}
- out << " set" << cap_name << "(byte[] " << make_valid_java_identifier(field_name) << ") {" << endl;
+ out << " set" << cap_name << "(byte[] " << make_valid_java_identifier(field_name) << ") {" << '\n';
indent(out) << " this." << make_valid_java_identifier(field_name) << " = " << make_valid_java_identifier(field_name)
<< " == null ? (java.nio.ByteBuffer)null";
if (unsafe_binaries_) {
- indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ");" << endl;
+ indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ");" << '\n';
} else {
- indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ".clone());" << endl;
+ indent(out) << " : java.nio.ByteBuffer.wrap(" << make_valid_java_identifier(field_name) << ".clone());" << '\n';
}
if (!bean_style_) {
- indent(out) << " return this;" << endl;
+ indent(out) << " return this;" << '\n';
}
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public ";
if (bean_style_) {
@@ -2737,7 +2734,7 @@
out << " set" << cap_name << "("
<< (type_can_be_null(type) ? (java_nullable_annotation() + " ") : "")
<< type_name(type)
- << " " << make_valid_java_identifier(field_name) << ") {" << endl;
+ << " " << make_valid_java_identifier(field_name) << ") {" << '\n';
indent_up();
indent(out) << "this." << make_valid_java_identifier(field_name) << " = ";
if (type->is_binary() && !unsafe_binaries_) {
@@ -2745,70 +2742,70 @@
} else {
out << make_valid_java_identifier(field_name);
}
- out << ";" << endl;
+ out << ";" << '\n';
generate_isset_set(out, field, "");
if (!bean_style_) {
- indent(out) << "return this;" << endl;
+ indent(out) << "return this;" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// Unsetter
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
- indent(out) << "public void unset" << cap_name << "() {" << endl;
+ indent(out) << "public void unset" << cap_name << "() {" << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "this." << make_valid_java_identifier(field_name) << " = null;" << endl;
+ indent(out) << "this." << make_valid_java_identifier(field_name) << " = null;" << '\n';
} else if (issetType == ISSET_PRIMITIVE) {
indent(out)
<< "__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, "
- << isset_field_id(field) << ");" << endl;
+ << isset_field_id(field) << ");" << '\n';
} else {
- indent(out) << "__isset_bit_vector.clear(" << isset_field_id(field) << ");" << endl;
+ indent(out) << "__isset_bit_vector.clear(" << isset_field_id(field) << ");" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// isSet method
indent(out) << "/** Returns true if field " << field_name
- << " is set (has been assigned a value) and false otherwise */" << endl;
+ << " is set (has been assigned a value) and false otherwise */" << '\n';
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
- indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << endl;
+ indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "return this." << make_valid_java_identifier(field_name) << " != null;" << endl;
+ indent(out) << "return this." << make_valid_java_identifier(field_name) << " != null;" << '\n';
} else if (issetType == ISSET_PRIMITIVE) {
indent(out) << "return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, "
- << isset_field_id(field) << ");" << endl;
+ << isset_field_id(field) << ");" << '\n';
} else {
- indent(out) << "return __isset_bit_vector.get(" << isset_field_id(field) << ");" << endl;
+ indent(out) << "return __isset_bit_vector.get(" << isset_field_id(field) << ");" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
if (is_deprecated) {
- indent(out) << "@Deprecated" << endl;
+ indent(out) << "@Deprecated" << '\n';
}
indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {"
- << endl;
+ << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "if (!value) {" << endl;
- indent(out) << " this." << make_valid_java_identifier(field_name) << " = null;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "if (!value) {" << '\n';
+ indent(out) << " this." << make_valid_java_identifier(field_name) << " = null;" << '\n';
+ indent(out) << "}" << '\n';
} else if (issetType == ISSET_PRIMITIVE) {
indent(out) << "__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, "
- << isset_field_id(field) << ", value);" << endl;
+ << isset_field_id(field) << ", value);" << '\n';
} else {
- indent(out) << "__isset_bit_vector.set(" << isset_field_id(field) << ", value);" << endl;
+ indent(out) << "__isset_bit_vector.set(" << isset_field_id(field) << ", value);" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
}
@@ -2818,13 +2815,13 @@
* @param tstruct The struct definition
*/
void t_java_generator::generate_java_struct_tostring(ostream& out, t_struct* tstruct) {
- out << indent() << java_override_annotation() << endl
- << indent() << "public java.lang.String toString() {" << endl;
+ out << indent() << java_override_annotation() << '\n'
+ << indent() << "public java.lang.String toString() {" << '\n';
indent_up();
out << indent() << "java.lang.StringBuilder sb = new java.lang.StringBuilder(\""
- << tstruct->get_name() << "(\");" << endl;
- out << indent() << "boolean first = true;" << endl << endl;
+ << tstruct->get_name() << "(\");" << '\n';
+ out << indent() << "boolean first = true;" << '\n' << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -2832,55 +2829,55 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
if (could_be_unset) {
- indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
+ indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n';
indent_up();
}
t_field* field = (*f_iter);
if (!first) {
- indent(out) << "if (!first) sb.append(\", \");" << endl;
+ indent(out) << "if (!first) sb.append(\", \");" << '\n';
}
- indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << endl;
+ indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << '\n';
bool can_be_null = type_can_be_null(field->get_type());
if (can_be_null) {
- indent(out) << "if (this." << make_valid_java_identifier((*f_iter)->get_name()) << " == null) {" << endl;
- indent(out) << " sb.append(\"null\");" << endl;
- indent(out) << "} else {" << endl;
+ indent(out) << "if (this." << make_valid_java_identifier((*f_iter)->get_name()) << " == null) {" << '\n';
+ indent(out) << " sb.append(\"null\");" << '\n';
+ indent(out) << "} else {" << '\n';
indent_up();
}
if (get_true_type(field->get_type())->is_binary()) {
indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << make_valid_java_identifier(field->get_name()) << ", sb);"
- << endl;
+ << '\n';
} else if ((field->get_type()->is_set())
&& (get_true_type(((t_set*)field->get_type())->get_elem_type())->is_binary())) {
indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << make_valid_java_identifier(field->get_name()) << ", sb);"
- << endl;
+ << '\n';
} else if ((field->get_type()->is_list())
&& (get_true_type(((t_list*)field->get_type())->get_elem_type())->is_binary())) {
indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << make_valid_java_identifier(field->get_name()) << ", sb);"
- << endl;
+ << '\n';
} else {
- indent(out) << "sb.append(this." << make_valid_java_identifier((*f_iter)->get_name()) << ");" << endl;
+ indent(out) << "sb.append(this." << make_valid_java_identifier((*f_iter)->get_name()) << ");" << '\n';
}
if (can_be_null) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- indent(out) << "first = false;" << endl;
+ indent(out) << "first = false;" << '\n';
if (could_be_unset) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
first = false;
}
- out << indent() << "sb.append(\")\");" << endl << indent() << "return sb.toString();" << endl;
+ out << indent() << "sb.append(\")\");" << '\n' << indent() << "return sb.toString();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -2896,14 +2893,14 @@
// Static Map with fieldID -> org.apache.thrift.meta_data.FieldMetaData mappings
indent(out) << "public static final java.util.Map<_Fields, "
"org.apache.thrift.meta_data.FieldMetaData> metaDataMap;"
- << endl;
- indent(out) << "static {" << endl;
+ << '\n';
+ indent(out) << "static {" << '\n';
indent_up();
indent(out)
<< "java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new "
"java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);"
- << endl;
+ << '\n';
// Populate map
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -2928,15 +2925,15 @@
if (annotations_as_metadata_) {
generate_metadata_for_field_annotations(out, field);
}
- out << "));" << endl;
+ out << "));" << '\n';
}
- indent(out) << "metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);" << endl;
+ indent(out) << "metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);" << '\n';
indent(out) << "org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap("
- << type_name(tstruct) << ".class, metaDataMap);" << endl;
+ << type_name(tstruct) << ".class, metaDataMap);" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -3003,19 +3000,19 @@
if (field->annotations_.size() == 0) {
return;
}
- out << ", " << endl;
+ out << ", " << '\n';
indent_up();
indent_up();
indent(out) << "java.util.stream.Stream.<java.util.Map.Entry<java.lang.String, "
"java.lang.String>>builder()"
- << endl;
+ << '\n';
indent_up();
indent_up();
for (auto& annotation : field->annotations_) {
indent(out) << ".add(new java.util.AbstractMap.SimpleImmutableEntry<>(\"" + annotation.first
+ "\", \"" + annotation.second.back() + "\"))"
- << endl;
+ << '\n';
}
indent(out) << ".build().collect(java.util.stream.Collectors.toMap(java.util.Map.Entry::getKey, "
"java.util.Map.Entry::getValue))";
@@ -3028,7 +3025,7 @@
void t_java_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) {
t_type* ttype = get_true_type(type);
- out << endl;
+ out << '\n';
indent_up();
indent_up();
if (ttype->is_struct() || ttype->is_xception()) {
@@ -3093,7 +3090,7 @@
generate_javax_generated_annotation(f_service_);
}
f_service_ << java_suppressions();
- f_service_ << "public class " << make_valid_java_identifier(service_name_) << " {" << endl << endl;
+ f_service_ << "public class " << make_valid_java_identifier(service_name_) << " {" << '\n' << '\n';
indent_up();
// Generate the three main parts of the service
@@ -3112,7 +3109,7 @@
generate_service_helpers(tservice);
indent_down();
- f_service_ << "}" << endl;
+ f_service_ << "}" << '\n';
f_service_.close();
}
@@ -3130,16 +3127,16 @@
}
generate_java_doc(f_service_, tservice);
- f_service_ << indent() << "public interface Iface" << extends_iface << " {" << endl << endl;
+ f_service_ << indent() << "public interface Iface" << extends_iface << " {" << '\n' << '\n';
indent_up();
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_java_doc(f_service_, *f_iter);
- indent(f_service_) << "public " << function_signature(*f_iter) << ";" << endl << endl;
+ indent(f_service_) << "public " << function_signature(*f_iter) << ";" << '\n' << '\n';
}
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
void t_java_generator::generate_service_async_interface(t_service* tservice) {
@@ -3150,17 +3147,17 @@
extends_iface = " extends " + extends + ".AsyncIface";
}
- f_service_ << indent() << "public interface AsyncIface" << extends_iface << " {" << endl << endl;
+ f_service_ << indent() << "public interface AsyncIface" << extends_iface << " {" << '\n' << '\n';
indent_up();
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
indent(f_service_) << "public " << function_signature_async(*f_iter, true)
- << " throws org.apache.thrift.TException;" << endl
- << endl;
+ << " throws org.apache.thrift.TException;" << '\n'
+ << '\n';
}
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
void t_java_generator::generate_service_future_interface(t_service* tservice) {
@@ -3171,15 +3168,15 @@
extends_iface = " extends " + extends + " .FutureIface";
}
- f_service_ << indent() << "public interface FutureIface" << extends_iface << " {" << endl << endl;
+ f_service_ << indent() << "public interface FutureIface" << extends_iface << " {" << '\n' << '\n';
indent_up();
for (auto tfunc : tservice->get_functions()) {
indent(f_service_) << "public " << function_signature_future(tfunc)
- << " throws org.apache.thrift.TException;" << endl
- << endl;
+ << " throws org.apache.thrift.TException;" << '\n'
+ << '\n';
}
scope_down(f_service_);
- f_service_ << endl << endl;
+ f_service_ << '\n' << '\n';
}
/**
@@ -3209,43 +3206,43 @@
}
indent(f_service_) << "public static class Client extends " << extends_client
- << " implements Iface {" << endl;
+ << " implements Iface {" << '\n';
indent_up();
indent(f_service_)
<< "public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {"
- << endl;
+ << '\n';
indent_up();
- indent(f_service_) << "public Factory() {}" << endl;
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << "public Factory() {}" << '\n';
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public Client getClient(org.apache.thrift.protocol.TProtocol prot) {"
- << endl;
+ << '\n';
indent_up();
- indent(f_service_) << "return new Client(prot);" << endl;
+ indent(f_service_) << "return new Client(prot);" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << "}" << '\n';
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public Client getClient(org.apache.thrift.protocol.TProtocol iprot, "
"org.apache.thrift.protocol.TProtocol oprot) {"
- << endl;
+ << '\n';
indent_up();
- indent(f_service_) << "return new Client(iprot, oprot);" << endl;
+ indent(f_service_) << "return new Client(iprot, oprot);" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << "public Client(org.apache.thrift.protocol.TProtocol prot)" << endl;
+ indent(f_service_) << "public Client(org.apache.thrift.protocol.TProtocol prot)" << '\n';
scope_up(f_service_);
- indent(f_service_) << "super(prot, prot);" << endl;
+ indent(f_service_) << "super(prot, prot);" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
indent(f_service_) << "public Client(org.apache.thrift.protocol.TProtocol iprot, "
"org.apache.thrift.protocol.TProtocol oprot) {"
- << endl;
- indent(f_service_) << " super(iprot, oprot);" << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << " super(iprot, oprot);" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
// Generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -3260,8 +3257,8 @@
}
// Open function
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public " << function_signature(*f_iter) << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public " << function_signature(*f_iter) << '\n';
scope_up(f_service_);
indent(f_service_) << "send" << sep << javaname << "(";
@@ -3280,17 +3277,17 @@
}
f_service_ << make_valid_java_identifier((*fld_iter)->get_name());
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
- f_service_ << "recv" << sep << javaname << "();" << endl;
+ f_service_ << "recv" << sep << javaname << "();" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
t_function send_function(g_type_void, string("send") + sep + javaname,
(*f_iter)->get_arglist());
@@ -3298,22 +3295,22 @@
string argsname = (*f_iter)->get_name() + "_args";
// Open function
- indent(f_service_) << "public " << function_signature(&send_function) << endl;
+ indent(f_service_) << "public " << function_signature(&send_function) << '\n';
scope_up(f_service_);
// Serialize the request
- indent(f_service_) << argsname << " args = new " << argsname << "();" << endl;
+ indent(f_service_) << argsname << " args = new " << argsname << "();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
indent(f_service_) << "args.set" << get_cap_name((*fld_iter)->get_name()) << "("
- << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << endl;
+ << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << '\n';
}
const string sendBaseName = (*f_iter)->is_oneway() ? "sendBaseOneway" : "sendBase";
- indent(f_service_) << sendBaseName << "(\"" << funname << "\", args);" << endl;
+ indent(f_service_) << sendBaseName << "(\"" << funname << "\", args);" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
if (!(*f_iter)->is_oneway()) {
string resultname = (*f_iter)->get_name() + "_result";
@@ -3322,47 +3319,47 @@
t_function recv_function((*f_iter)->get_returntype(), string("recv") + sep + javaname,
&noargs, (*f_iter)->get_xceptions());
// Open function
- indent(f_service_) << "public " << function_signature(&recv_function) << endl;
+ indent(f_service_) << "public " << function_signature(&recv_function) << '\n';
scope_up(f_service_);
- f_service_ << indent() << resultname << " result = new " << resultname << "();" << endl
- << indent() << "receiveBase(result, \"" << funname << "\");" << endl;
+ f_service_ << indent() << resultname << " result = new " << resultname << "();" << '\n'
+ << indent() << "receiveBase(result, \"" << funname << "\");" << '\n';
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl
- << indent() << " return result.success;" << endl
- << indent() << "}" << endl;
+ f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << '\n'
+ << indent() << " return result.success;" << '\n'
+ << indent() << "}" << '\n';
}
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- f_service_ << indent() << "if (result." << make_valid_java_identifier((*x_iter)->get_name()) << " != null) {" << endl
- << indent() << " throw result." << make_valid_java_identifier((*x_iter)->get_name()) << ";" << endl
- << indent() << "}" << endl;
+ f_service_ << indent() << "if (result." << make_valid_java_identifier((*x_iter)->get_name()) << " != null) {" << '\n'
+ << indent() << " throw result." << make_valid_java_identifier((*x_iter)->get_name()) << ";" << '\n'
+ << indent() << "}" << '\n';
}
// If you get here it's an exception, unless a void function
if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
} else {
f_service_ << indent()
<< "throw new "
"org.apache.thrift.TApplicationException(org.apache.thrift."
"TApplicationException.MISSING_RESULT, \""
- << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+ << (*f_iter)->get_name() << " failed: unknown result\");" << '\n';
}
// Close function
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
}
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
}
void t_java_generator::generate_service_future_client(t_service* tservice) {
@@ -3373,13 +3370,13 @@
static string adapter_class = "org.apache.thrift.async.AsyncMethodFutureAdapter";
indent(f_service_) << "public static class FutureClient " << extends_client
- << "implements FutureIface {" << endl;
+ << "implements FutureIface {" << '\n';
indent_up();
- indent(f_service_) << "public FutureClient(AsyncIface delegate) {" << endl;
+ indent(f_service_) << "public FutureClient(AsyncIface delegate) {" << '\n';
indent_up();
- indent(f_service_) << "this.delegate = delegate;" << endl;
+ indent(f_service_) << "this.delegate = delegate;" << '\n';
scope_down(f_service_);
- indent(f_service_) << "private final AsyncIface delegate;" << endl;
+ indent(f_service_) << "private final AsyncIface delegate;" << '\n';
for (auto tfunc : tservice->get_functions()) {
string funname = tfunc->get_name();
string sep = "_";
@@ -3396,23 +3393,23 @@
string args_name = funname + "_args";
string result_name = funname + "_result";
- indent(f_service_) << "@Override" << endl;
+ indent(f_service_) << "@Override" << '\n';
indent(f_service_) << "public " << function_signature_future(tfunc)
- << " throws org.apache.thrift.TException {" << endl;
+ << " throws org.apache.thrift.TException {" << '\n';
indent_up();
auto adapter = tmp("asyncMethodFutureAdapter");
indent(f_service_) << adapter_class << "<" << ret_type_name << "> " << adapter << " = "
- << adapter_class << ".<" << ret_type_name << ">create();" << endl;
+ << adapter_class << ".<" << ret_type_name << ">create();" << '\n';
bool empty_args = tfunc->get_arglist()->get_members().empty();
indent(f_service_) << "delegate." << get_rpc_method_name(funname) << "("
<< argument_list(tfunc->get_arglist(), false) << (empty_args ? "" : ", ")
- << adapter << ");" << endl;
- indent(f_service_) << "return " << adapter << ".getFuture();" << endl;
+ << adapter << ");" << '\n';
+ indent(f_service_) << "return " << adapter << ".getFuture();" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
void t_java_generator::generate_service_async_client(t_service* tservice) {
@@ -3422,41 +3419,41 @@
}
indent(f_service_) << "public static class AsyncClient extends " << extends_client
- << " implements AsyncIface {" << endl;
+ << " implements AsyncIface {" << '\n';
indent_up();
// Factory method
indent(f_service_) << "public static class Factory implements "
"org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {"
- << endl;
+ << '\n';
indent(f_service_) << " private org.apache.thrift.async.TAsyncClientManager clientManager;"
- << endl;
+ << '\n';
indent(f_service_) << " private org.apache.thrift.protocol.TProtocolFactory protocolFactory;"
- << endl;
+ << '\n';
indent(f_service_) << " public Factory(org.apache.thrift.async.TAsyncClientManager "
"clientManager, org.apache.thrift.protocol.TProtocolFactory "
"protocolFactory) {"
- << endl;
- indent(f_service_) << " this.clientManager = clientManager;" << endl;
- indent(f_service_) << " this.protocolFactory = protocolFactory;" << endl;
- indent(f_service_) << " }" << endl;
- indent(f_service_) << java_override_annotation() << endl;
+ << '\n';
+ indent(f_service_) << " this.clientManager = clientManager;" << '\n';
+ indent(f_service_) << " this.protocolFactory = protocolFactory;" << '\n';
+ indent(f_service_) << " }" << '\n';
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << " public AsyncClient "
"getAsyncClient(org.apache.thrift.transport.TNonblockingTransport "
"transport) {"
- << endl;
+ << '\n';
indent(f_service_) << " return new AsyncClient(protocolFactory, clientManager, transport);"
- << endl;
- indent(f_service_) << " }" << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << " }" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
indent(f_service_) << "public AsyncClient(org.apache.thrift.protocol.TProtocolFactory "
"protocolFactory, org.apache.thrift.async.TAsyncClientManager "
"clientManager, org.apache.thrift.transport.TNonblockingTransport "
"transport) {"
- << endl;
- indent(f_service_) << " super(protocolFactory, clientManager, transport);" << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << " super(protocolFactory, clientManager, transport);" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
// Generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -3479,35 +3476,35 @@
string result_name = (*f_iter)->get_name() + "_result";
// Main method body
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public " << function_signature_async(*f_iter, false)
- << " throws org.apache.thrift.TException {" << endl;
- indent(f_service_) << " checkReady();" << endl;
+ << " throws org.apache.thrift.TException {" << '\n';
+ indent(f_service_) << " checkReady();" << '\n';
indent(f_service_) << " " << funclassname << " method_call = new " + funclassname + "("
<< async_argument_list(*f_iter, arg_struct, ret_type)
- << ", this, ___protocolFactory, ___transport);" << endl;
- indent(f_service_) << " this.___currentMethod = method_call;" << endl;
- indent(f_service_) << " ___manager.call(method_call);" << endl;
- indent(f_service_) << "}" << endl;
+ << ", this, ___protocolFactory, ___transport);" << '\n';
+ indent(f_service_) << " this.___currentMethod = method_call;" << '\n';
+ indent(f_service_) << " ___manager.call(method_call);" << '\n';
+ indent(f_service_) << "}" << '\n';
- f_service_ << endl;
+ f_service_ << '\n';
// TAsyncMethod object for this function call
indent(f_service_) << "public static class " + funclassname
+ " extends org.apache.thrift.async.TAsyncMethodCall<"
+ type_name((*f_iter)->get_returntype(), true) + "> {"
- << endl;
+ << '\n';
indent_up();
// Member variables
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
indent(f_service_) << "private " + type_name((*fld_iter)->get_type()) + " "
+ make_valid_java_identifier((*fld_iter)->get_name()) + ";"
- << endl;
+ << '\n';
}
// NOTE since we use a new Client instance to deserialize, let's keep seqid to 0 for now
- // indent(f_service_) << "private int seqid;" << endl << endl;
+ // indent(f_service_) << "private int seqid;" << '\n' << '\n';
// Constructor
indent(f_service_) << "public " + funclassname + "("
@@ -3516,22 +3513,22 @@
"org.apache.thrift.protocol.TProtocolFactory protocolFactory, "
"org.apache.thrift.transport.TNonblockingTransport transport) throws "
"org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent(f_service_) << " super(client, protocolFactory, transport, resultHandler, "
- << ((*f_iter)->is_oneway() ? "true" : "false") << ");" << endl;
+ << ((*f_iter)->is_oneway() ? "true" : "false") << ");" << '\n';
// Assign member variables
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
indent(f_service_) << " this." + make_valid_java_identifier((*fld_iter)->get_name()) + " = " + make_valid_java_identifier((*fld_iter)->get_name())
+ ";"
- << endl;
+ << '\n';
}
- indent(f_service_) << "}" << endl << endl;
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public void write_args(org.apache.thrift.protocol.TProtocol prot) "
"throws org.apache.thrift.TException {"
- << endl;
+ << '\n';
indent_up();
// Serialize request
@@ -3539,68 +3536,68 @@
f_service_ << indent() << "prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(\""
<< funname << "\", org.apache.thrift.protocol."
<< ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") << ", 0));"
- << endl
- << indent() << args_name << " args = new " << args_name << "();" << endl;
+ << '\n'
+ << indent() << args_name << " args = new " << args_name << "();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "("
- << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << endl;
+ << make_valid_java_identifier((*fld_iter)->get_name()) << ");" << '\n';
}
- f_service_ << indent() << "args.write(prot);" << endl
- << indent() << "prot.writeMessageEnd();" << endl;
+ f_service_ << indent() << "args.write(prot);" << '\n'
+ << indent() << "prot.writeMessageEnd();" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
// Return method
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public " + type_name(ret_type, true) + " getResult() throws ";
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << type_name((*x_iter)->get_type(), false, false) + ", ";
}
- f_service_ << "org.apache.thrift.TException {" << endl;
+ f_service_ << "org.apache.thrift.TException {" << '\n';
indent_up();
f_service_
<< indent()
<< "if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {"
- << endl
+ << '\n'
<< indent() << " throw new java.lang.IllegalStateException(\"Method call not finished!\");"
- << endl
- << indent() << "}" << endl
+ << '\n'
+ << indent() << "}" << '\n'
<< indent()
<< "org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new "
"org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());"
- << endl
+ << '\n'
<< indent()
<< "org.apache.thrift.protocol.TProtocol prot = "
"client.getProtocolFactory().getProtocol(memoryTransport);"
- << endl;
+ << '\n';
indent(f_service_);
if (ret_type->is_void()) { // NB: Includes oneways which always return void.
if (!(*f_iter)->is_oneway()) {
- f_service_ << "(new Client(prot)).recv" + sep + javaname + "();" << endl;
+ f_service_ << "(new Client(prot)).recv" + sep + javaname + "();" << '\n';
indent(f_service_);
}
- f_service_ << "return null;" << endl;
+ f_service_ << "return null;" << '\n';
} else {
- f_service_ << "return (new Client(prot)).recv" + sep + javaname + "();" << endl;
+ f_service_ << "return (new Client(prot)).recv" + sep + javaname + "();" << '\n';
}
// Close function
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
// Close class
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
// Close AsyncClient
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
/**
@@ -3625,26 +3622,26 @@
// Generate the header portion
indent(f_service_) << "public static class Processor<I extends Iface> extends "
- << extends_processor << " implements org.apache.thrift.TProcessor {" << endl;
+ << extends_processor << " implements org.apache.thrift.TProcessor {" << '\n';
indent_up();
indent(f_service_) << "private static final org.slf4j.Logger _LOGGER = "
"org.slf4j.LoggerFactory.getLogger(Processor.class.getName());"
- << endl;
+ << '\n';
- indent(f_service_) << "public Processor(I iface) {" << endl;
+ indent(f_service_) << "public Processor(I iface) {" << '\n';
indent(f_service_) << " super(iface, getProcessMap(new java.util.HashMap<java.lang.String, "
"org.apache.thrift.ProcessFunction<I, ? extends "
"org.apache.thrift.TBase, ? extends org.apache.thrift.TBase>>()));"
- << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
indent(f_service_) << "protected Processor(I iface, java.util.Map<java.lang.String, "
"org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase, ? "
"extends org.apache.thrift.TBase>> processMap) {"
- << endl;
- indent(f_service_) << " super(iface, getProcessMap(processMap));" << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << " super(iface, getProcessMap(processMap));" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
indent(f_service_) << "private static <I extends Iface> java.util.Map<java.lang.String, "
"org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase, "
@@ -3652,15 +3649,15 @@
"getProcessMap(java.util.Map<java.lang.String, "
"org.apache.thrift.ProcessFunction<I, ? extends "
" org.apache.thrift.TBase, ? extends org.apache.thrift.TBase>> processMap) {"
- << endl;
+ << '\n';
indent_up();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
indent(f_service_) << "processMap.put(\"" << (*f_iter)->get_name() << "\", new "
- << make_valid_java_identifier((*f_iter)->get_name()) << "());" << endl;
+ << make_valid_java_identifier((*f_iter)->get_name()) << "());" << '\n';
}
- indent(f_service_) << "return processMap;" << endl;
+ indent(f_service_) << "return processMap;" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -3668,7 +3665,7 @@
}
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
/**
@@ -3693,26 +3690,26 @@
// Generate the header portion
indent(f_service_) << "public static class AsyncProcessor<I extends AsyncIface> extends "
- << extends_processor << " {" << endl;
+ << extends_processor << " {" << '\n';
indent_up();
indent(f_service_) << "private static final org.slf4j.Logger _LOGGER = "
"org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());"
- << endl;
+ << '\n';
- indent(f_service_) << "public AsyncProcessor(I iface) {" << endl;
+ indent(f_service_) << "public AsyncProcessor(I iface) {" << '\n';
indent(f_service_) << " super(iface, getProcessMap(new java.util.HashMap<java.lang.String, "
"org.apache.thrift.AsyncProcessFunction<I, ? extends "
"org.apache.thrift.TBase, ?, ? extends org.apache.thrift.TBase>>()));"
- << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
indent(f_service_) << "protected AsyncProcessor(I iface, java.util.Map<java.lang.String, "
"org.apache.thrift.AsyncProcessFunction<I, ? extends "
"org.apache.thrift.TBase, ?, ? extends org.apache.thrift.TBase>> processMap) {"
- << endl;
- indent(f_service_) << " super(iface, getProcessMap(processMap));" << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << " super(iface, getProcessMap(processMap));" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
indent(f_service_)
<< "private static <I extends AsyncIface> java.util.Map<java.lang.String, "
@@ -3720,15 +3717,15 @@
"org.apache.thrift.TBase, ?, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<java.lang.String, "
"org.apache.thrift.AsyncProcessFunction<I, ? extends "
"org.apache.thrift.TBase, ?, ? extends org.apache.thrift.TBase>> processMap) {"
- << endl;
+ << '\n';
indent_up();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
indent(f_service_) << "processMap.put(\"" << (*f_iter)->get_name() << "\", new "
- << make_valid_java_identifier((*f_iter)->get_name()) << "());" << endl;
+ << make_valid_java_identifier((*f_iter)->get_name()) << "());" << '\n';
}
- indent(f_service_) << "return processMap;" << endl;
+ indent(f_service_) << "return processMap;" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -3736,7 +3733,7 @@
}
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
/**
@@ -3784,101 +3781,101 @@
// Open class
indent(f_service_) << "public static class " << make_valid_java_identifier(tfunction->get_name())
<< "<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, "
- << argsname << ", " << resulttype << ", " << resultname << "> {" << endl;
+ << argsname << ", " << resulttype << ", " << resultname << "> {" << '\n';
indent_up();
- indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << endl;
- indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << endl;
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << '\n';
+ indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << '\n';
if (tfunction->is_oneway()) {
- indent(f_service_) << " return null;" << endl;
+ indent(f_service_) << " return null;" << '\n';
}
else {
- indent(f_service_) << " return new " << resultname << "();" << endl;
+ indent(f_service_) << " return new " << resultname << "();" << '\n';
}
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << endl;
- indent(f_service_) << " return new " << argsname << "();" << endl;
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << '\n';
+ indent(f_service_) << " return new " << argsname << "();" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public org.apache.thrift.async.AsyncMethodCallback<" << resulttype
<< "> getResultHandler(final "
"org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, "
"final int seqid) {"
- << endl;
+ << '\n';
indent_up();
- indent(f_service_) << "final org.apache.thrift.AsyncProcessFunction fcall = this;" << endl;
+ indent(f_service_) << "final org.apache.thrift.AsyncProcessFunction fcall = this;" << '\n';
indent(f_service_) << "return new org.apache.thrift.async.AsyncMethodCallback<" << resulttype
- << ">() { " << endl;
+ << ">() { " << '\n';
indent_up();
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public void onComplete(" << resulttype << " o) {" << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public void onComplete(" << resulttype << " o) {" << '\n';
indent_up();
if (!tfunction->is_oneway()) {
- indent(f_service_) << resultname << " result = new " << resultname << "();" << endl;
+ indent(f_service_) << resultname << " result = new " << resultname << "();" << '\n';
if (!tfunction->get_returntype()->is_void()) {
- indent(f_service_) << "result.success = o;" << endl;
+ indent(f_service_) << "result.success = o;" << '\n';
// Set isset on success field
if (!type_can_be_null(tfunction->get_returntype())) {
indent(f_service_) << "result.set" << get_cap_name("success") << get_cap_name("isSet")
- << "(true);" << endl;
+ << "(true);" << '\n';
}
}
- indent(f_service_) << "try {" << endl;
+ indent(f_service_) << "try {" << '\n';
indent(f_service_)
<< " fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);"
- << endl;
- indent(f_service_) << "} catch (org.apache.thrift.transport.TTransportException e) {" << endl;
+ << '\n';
+ indent(f_service_) << "} catch (org.apache.thrift.transport.TTransportException e) {" << '\n';
indent_up();
f_service_ << indent()
<< "_LOGGER.error(\"TTransportException writing to internal frame buffer\", e);"
- << endl
- << indent() << "fb.close();" << endl;
+ << '\n'
+ << indent() << "fb.close();" << '\n';
indent_down();
- indent(f_service_) << "} catch (java.lang.Exception e) {" << endl;
+ indent(f_service_) << "} catch (java.lang.Exception e) {" << '\n';
indent_up();
f_service_ << indent() << "_LOGGER.error(\"Exception writing to internal frame buffer\", e);"
- << endl
- << indent() << "onError(e);" << endl;
+ << '\n'
+ << indent() << "onError(e);" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
}
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public void onError(java.lang.Exception e) {" << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public void onError(java.lang.Exception e) {" << '\n';
indent_up();
if (tfunction->is_oneway()) {
indent(f_service_) << "if (e instanceof org.apache.thrift.transport.TTransportException) {"
- << endl;
+ << '\n';
indent_up();
- f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << endl
- << indent() << "fb.close();" << endl;
+ f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << '\n'
+ << indent() << "fb.close();" << '\n';
indent_down();
- indent(f_service_) << "} else {" << endl;
+ indent(f_service_) << "} else {" << '\n';
indent_up();
- f_service_ << indent() << "_LOGGER.error(\"Exception inside oneway handler\", e);" << endl;
+ f_service_ << indent() << "_LOGGER.error(\"Exception inside oneway handler\", e);" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;" << endl;
- indent(f_service_) << "org.apache.thrift.TSerializable msg;" << endl;
- indent(f_service_) << resultname << " result = new " << resultname << "();" << endl;
+ indent(f_service_) << "byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;" << '\n';
+ indent(f_service_) << "org.apache.thrift.TSerializable msg;" << '\n';
+ indent(f_service_) << resultname << " result = new " << resultname << "();" << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -3890,66 +3887,66 @@
f_service_ << indent();
string type = type_name((*x_iter)->get_type(), false, false);
string name = (*x_iter)->get_name();
- f_service_ << "if (e instanceof " << type << ") {" << endl;
+ f_service_ << "if (e instanceof " << type << ") {" << '\n';
indent_up();
- f_service_ << indent() << "result." << make_valid_java_identifier(name) << " = (" << type << ") e;" << endl
+ f_service_ << indent() << "result." << make_valid_java_identifier(name) << " = (" << type << ") e;" << '\n'
<< indent() << "result.set" << get_cap_name(name) << get_cap_name("isSet")
- << "(true);" << endl
- << indent() << "msg = result;" << endl;
+ << "(true);" << '\n'
+ << indent() << "msg = result;" << '\n';
indent_down();
indent(f_service_) << "} else ";
}
} else {
indent(f_service_);
}
- f_service_ << "if (e instanceof org.apache.thrift.transport.TTransportException) {" << endl;
+ f_service_ << "if (e instanceof org.apache.thrift.transport.TTransportException) {" << '\n';
indent_up();
- f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << endl
- << indent() << "fb.close();" << endl
- << indent() << "return;" << endl;
+ f_service_ << indent() << "_LOGGER.error(\"TTransportException inside handler\", e);" << '\n'
+ << indent() << "fb.close();" << '\n'
+ << indent() << "return;" << '\n';
indent_down();
indent(f_service_) << "} else if (e instanceof org.apache.thrift.TApplicationException) {"
- << endl;
+ << '\n';
indent_up();
- f_service_ << indent() << "_LOGGER.error(\"TApplicationException inside handler\", e);" << endl
- << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << endl
- << indent() << "msg = (org.apache.thrift.TApplicationException)e;" << endl;
+ f_service_ << indent() << "_LOGGER.error(\"TApplicationException inside handler\", e);" << '\n'
+ << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << '\n'
+ << indent() << "msg = (org.apache.thrift.TApplicationException)e;" << '\n';
indent_down();
- indent(f_service_) << "} else {" << endl;
+ indent(f_service_) << "} else {" << '\n';
indent_up();
- f_service_ << indent() << "_LOGGER.error(\"Exception inside handler\", e);" << endl
- << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << endl
+ f_service_ << indent() << "_LOGGER.error(\"Exception inside handler\", e);" << '\n'
+ << indent() << "msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;" << '\n'
<< indent()
<< "msg = new "
"org.apache.thrift.TApplicationException(org.apache.thrift."
"TApplicationException.INTERNAL_ERROR, e.getMessage());"
- << endl;
+ << '\n';
indent_down();
- f_service_ << indent() << "}" << endl
- << indent() << "try {" << endl
- << indent() << " fcall.sendResponse(fb,msg,msgType,seqid);" << endl
- << indent() << "} catch (java.lang.Exception ex) {" << endl
+ f_service_ << indent() << "}" << '\n'
+ << indent() << "try {" << '\n'
+ << indent() << " fcall.sendResponse(fb,msg,msgType,seqid);" << '\n'
+ << indent() << "} catch (java.lang.Exception ex) {" << '\n'
<< indent() << " _LOGGER.error(\"Exception writing to internal frame buffer\", ex);"
- << endl
- << indent() << " fb.close();" << endl
- << indent() << "}" << endl;
+ << '\n'
+ << indent() << " fb.close();" << '\n'
+ << indent() << "}" << '\n';
}
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
indent_down();
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public boolean isOneway() {" << endl;
- indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << endl;
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public boolean isOneway() {" << '\n';
+ indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public void start(I iface, " << argsname
<< " args, org.apache.thrift.async.AsyncMethodCallback<" << resulttype
- << "> resultHandler) throws org.apache.thrift.TException {" << endl;
+ << "> resultHandler) throws org.apache.thrift.TException {" << '\n';
indent_up();
// Generate the function call
@@ -3971,17 +3968,17 @@
if (!first)
f_service_ << ",";
f_service_ << "resultHandler";
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
indent_down();
indent(f_service_) << "}";
// Close function
- f_service_ << endl;
+ f_service_ << '\n';
// Close class
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -4000,45 +3997,45 @@
// Open class
indent(f_service_) << "public static class " << make_valid_java_identifier(tfunction->get_name())
<< "<I extends Iface> extends org.apache.thrift.ProcessFunction<I, "
- << argsname << ", " << resultname << "> {" << endl;
+ << argsname << ", " << resultname << "> {" << '\n';
indent_up();
- indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << endl;
- indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << endl;
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "public " << make_valid_java_identifier(tfunction->get_name()) << "() {" << '\n';
+ indent(f_service_) << " super(\"" << tfunction->get_name() << "\");" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << endl;
- indent(f_service_) << " return new " << argsname << "();" << endl;
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public " << argsname << " getEmptyArgsInstance() {" << '\n';
+ indent(f_service_) << " return new " << argsname << "();" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public boolean isOneway() {" << endl;
- indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << endl;
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public boolean isOneway() {" << '\n';
+ indent(f_service_) << " return " << ((tfunction->is_oneway()) ? "true" : "false") << ";" << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "protected boolean rethrowUnhandledExceptions() {" << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "protected boolean rethrowUnhandledExceptions() {" << '\n';
indent(f_service_) << " return " << ((rethrow_unhandled_exceptions_) ? "true" : "false") << ";"
- << endl;
- indent(f_service_) << "}" << endl << endl;
+ << '\n';
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
- indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
+ indent(f_service_) << "public " << resultname << " getEmptyResultInstance() {" << '\n';
if (tfunction->is_oneway()) {
- indent(f_service_) << " return null;" << endl;
+ indent(f_service_) << " return null;" << '\n';
}
else {
- indent(f_service_) << " return new " << resultname << "();" << endl;
+ indent(f_service_) << " return new " << resultname << "();" << '\n';
}
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
- indent(f_service_) << java_override_annotation() << endl;
+ indent(f_service_) << java_override_annotation() << '\n';
indent(f_service_) << "public " << resultname << " getResult(I iface, " << argsname
- << " args) throws org.apache.thrift.TException {" << endl;
+ << " args) throws org.apache.thrift.TException {" << '\n';
indent_up();
if (!tfunction->is_oneway()) {
- indent(f_service_) << resultname << " result = getEmptyResultInstance();" << endl;
+ indent(f_service_) << resultname << " result = getEmptyResultInstance();" << '\n';
}
t_struct* xs = tfunction->get_xceptions();
@@ -4047,7 +4044,7 @@
// Try block for a function with exceptions
if (xceptions.size() > 0) {
- f_service_ << indent() << "try {" << endl;
+ f_service_ << indent() << "try {" << '\n';
indent_up();
}
@@ -4070,13 +4067,13 @@
}
f_service_ << "args." << make_valid_java_identifier((*f_iter)->get_name());
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
// Set isset on success field
if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()
&& !type_can_be_null(tfunction->get_returntype())) {
indent(f_service_) << "result.set" << get_cap_name("success") << get_cap_name("isSet")
- << "(true);" << endl;
+ << "(true);" << '\n';
}
if (!tfunction->is_oneway() && xceptions.size() > 0) {
@@ -4084,34 +4081,34 @@
f_service_ << indent() << "}";
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " "
- << make_valid_java_identifier((*x_iter)->get_name()) << ") {" << endl;
+ << make_valid_java_identifier((*x_iter)->get_name()) << ") {" << '\n';
if (!tfunction->is_oneway()) {
indent_up();
f_service_ << indent() << "result." << make_valid_java_identifier((*x_iter)->get_name()) << " = "
- << make_valid_java_identifier((*x_iter)->get_name()) << ";" << endl;
+ << make_valid_java_identifier((*x_iter)->get_name()) << ";" << '\n';
indent_down();
f_service_ << indent() << "}";
} else {
f_service_ << "}";
}
}
- f_service_ << endl;
+ f_service_ << '\n';
}
if (tfunction->is_oneway()) {
- indent(f_service_) << "return null;" << endl;
+ indent(f_service_) << "return null;" << '\n';
} else {
- indent(f_service_) << "return result;" << endl;
+ indent(f_service_) << "return result;" << '\n';
}
indent_down();
indent(f_service_) << "}";
// Close function
- f_service_ << endl;
+ f_service_ << '\n';
// Close class
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -4175,12 +4172,12 @@
default:
throw "compiler error: no Java name for base type " + t_base_type::t_base_name(tbase);
}
- out << endl;
+ out << '\n';
} else if (type->is_enum()) {
indent(out) << name << " = "
<< type_name(tfield->get_type(), true, false, false, true)
+ ".findByValue(iprot.readI32());"
- << endl;
+ << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n", tfield->get_name().c_str(),
type_name(type).c_str());
@@ -4193,15 +4190,15 @@
void t_java_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
if (reuse_objects_) {
- indent(out) << "if (" << prefix << " == null) {" << endl;
+ indent(out) << "if (" << prefix << " == null) {" << '\n';
indent_up();
}
- indent(out) << prefix << " = new " << type_name(tstruct) << "();" << endl;
+ indent(out) << prefix << " = new " << type_name(tstruct) << "();" << '\n';
if (reuse_objects_) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- indent(out) << prefix << ".read(iprot);" << endl;
+ indent(out) << prefix << ".read(iprot);" << '\n';
}
/**
@@ -4228,31 +4225,31 @@
// Declare variables, read header
if (ttype->is_map()) {
indent(out) << "org.apache.thrift.protocol.TMap " << obj << " = iprot.readMapBegin();"
- << endl;
+ << '\n';
} else if (ttype->is_set()) {
indent(out) << "org.apache.thrift.protocol.TSet " << obj << " = iprot.readSetBegin();"
- << endl;
+ << '\n';
} else if (ttype->is_list()) {
indent(out) << "org.apache.thrift.protocol.TList " << obj << " = iprot.readListBegin();"
- << endl;
+ << '\n';
}
} else {
// Declare variables, read header
if (ttype->is_map()) {
indent(out) << "org.apache.thrift.protocol.TMap " << obj << " = iprot.readMapBegin("
<< type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
- << type_to_enum(((t_map*)ttype)->get_val_type()) << "); " << endl;
+ << type_to_enum(((t_map*)ttype)->get_val_type()) << "); " << '\n';
} else if (ttype->is_set()) {
indent(out) << "org.apache.thrift.protocol.TSet " << obj << " = iprot.readSetBegin("
- << type_to_enum(((t_set*)ttype)->get_elem_type()) << ");" << endl;
+ << type_to_enum(((t_set*)ttype)->get_elem_type()) << ");" << '\n';
} else if (ttype->is_list()) {
indent(out) << "org.apache.thrift.protocol.TList " << obj << " = iprot.readListBegin("
- << type_to_enum(((t_list*)ttype)->get_elem_type()) << ");" << endl;
+ << type_to_enum(((t_list*)ttype)->get_elem_type()) << ");" << '\n';
}
}
if (reuse_objects_) {
- indent(out) << "if (" << prefix << " == null) {" << endl;
+ indent(out) << "if (" << prefix << " == null) {" << '\n';
indent_up();
}
@@ -4264,18 +4261,18 @@
// construct the collection correctly i.e. with appropriate size/type
if (is_enum_set(ttype) || is_enum_map(ttype)) {
- out << "(" << inner_enum_type_name(ttype) << ");" << endl;
+ out << "(" << inner_enum_type_name(ttype) << ");" << '\n';
} else if (sorted_containers_ && (ttype->is_map() || ttype->is_set())) {
// TreeSet and TreeMap don't have any constructor which takes a capacity as an argument
- out << "();" << endl;
+ out << "();" << '\n';
} else {
out << "(" << (ttype->is_list() ? "" : "2*") << obj << ".size"
- << ");" << endl;
+ << ");" << '\n';
}
if (reuse_objects_) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
if (ttype->is_map()) {
@@ -4291,11 +4288,11 @@
if (has_metadata) {
// Read container end
if (ttype->is_map()) {
- indent(out) << "iprot.readMapEnd();" << endl;
+ indent(out) << "iprot.readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "iprot.readSetEnd();" << endl;
+ indent(out) << "iprot.readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "iprot.readListEnd();" << endl;
+ indent(out) << "iprot.readListEnd();" << '\n';
}
}
scope_down(out);
@@ -4314,14 +4311,14 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- indent(out) << declare_field(&fkey, reuse_objects_, false) << endl;
- indent(out) << declare_field(&fval, reuse_objects_, false) << endl;
+ indent(out) << declare_field(&fkey, reuse_objects_, false) << '\n';
+ indent(out) << declare_field(&fval, reuse_objects_, false) << '\n';
// For loop iterates over elements
string i = tmp("_i");
indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size"
<< "; "
- << "++" << i << ")" << endl;
+ << "++" << i << ")" << '\n';
scope_up(out);
@@ -4329,22 +4326,22 @@
generate_deserialize_field(out, &fval, "", has_metadata);
if (get_true_type(fkey.get_type())->is_enum()) {
- indent(out) << "if (" << key << " != null)" << endl;
+ indent(out) << "if (" << key << " != null)" << '\n';
scope_up(out);
}
- indent(out) << prefix << ".put(" << key << ", " << val << ");" << endl;
+ indent(out) << prefix << ".put(" << key << ", " << val << ");" << '\n';
if (get_true_type(fkey.get_type())->is_enum()) {
scope_down(out);
}
if (reuse_objects_ && !get_true_type(fkey.get_type())->is_base_type()) {
- indent(out) << key << " = null;" << endl;
+ indent(out) << key << " = null;" << '\n';
}
if (reuse_objects_ && !get_true_type(fval.get_type())->is_base_type()) {
- indent(out) << val << " = null;" << endl;
+ indent(out) << val << " = null;" << '\n';
}
}
@@ -4359,30 +4356,30 @@
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << declare_field(&felem, reuse_objects_, false) << endl;
+ indent(out) << declare_field(&felem, reuse_objects_, false) << '\n';
// For loop iterates over elements
string i = tmp("_i");
indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size"
<< "; "
- << "++" << i << ")" << endl;
+ << "++" << i << ")" << '\n';
scope_up(out);
generate_deserialize_field(out, &felem, "", has_metadata);
if (get_true_type(felem.get_type())->is_enum()) {
- indent(out) << "if (" << elem << " != null)" << endl;
+ indent(out) << "if (" << elem << " != null)" << '\n';
scope_up(out);
}
- indent(out) << prefix << ".add(" << elem << ");" << endl;
+ indent(out) << prefix << ".add(" << elem << ");" << '\n';
if (get_true_type(felem.get_type())->is_enum()) {
scope_down(out);
}
if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) {
- indent(out) << elem << " = null;" << endl;
+ indent(out) << elem << " = null;" << '\n';
}
}
@@ -4397,30 +4394,30 @@
string elem = tmp("_elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << declare_field(&felem, reuse_objects_, false) << endl;
+ indent(out) << declare_field(&felem, reuse_objects_, false) << '\n';
// For loop iterates over elements
string i = tmp("_i");
indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size"
<< "; "
- << "++" << i << ")" << endl;
+ << "++" << i << ")" << '\n';
scope_up(out);
generate_deserialize_field(out, &felem, "", has_metadata);
if (get_true_type(felem.get_type())->is_enum()) {
- indent(out) << "if (" << elem << " != null)" << endl;
+ indent(out) << "if (" << elem << " != null)" << '\n';
scope_up(out);
}
- indent(out) << prefix << ".add(" << elem << ");" << endl;
+ indent(out) << prefix << ".add(" << elem << ");" << '\n';
if (get_true_type(felem.get_type())->is_enum()) {
scope_down(out);
}
if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) {
- indent(out) << elem << " = null;" << endl;
+ indent(out) << elem << " = null;" << '\n';
}
}
@@ -4446,7 +4443,7 @@
} else if (type->is_container()) {
generate_serialize_container(out, type, prefix + make_valid_java_identifier(tfield->get_name()) + postfix, has_metadata);
} else if (type->is_enum()) {
- indent(out) << "oprot.writeI32(" << prefix + make_valid_java_identifier(tfield->get_name()) + postfix << ".getValue());" << endl;
+ indent(out) << "oprot.writeI32(" << prefix + make_valid_java_identifier(tfield->get_name()) + postfix << ".getValue());" << '\n';
} else if (type->is_base_type()) {
string name = prefix + make_valid_java_identifier(tfield->get_name()) + postfix;
indent(out) << "oprot.";
@@ -4491,7 +4488,7 @@
} else if (type->is_enum()) {
out << "writeI32(struct." << name << ");";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s%s' TYPE '%s'\n", prefix.c_str(),
tfield->get_name().c_str(), postfix.c_str(), type_name(type).c_str());
@@ -4506,7 +4503,7 @@
*/
void t_java_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- out << indent() << prefix << ".write(oprot);" << endl;
+ out << indent() << prefix << ".write(oprot);" << '\n';
}
/**
@@ -4526,18 +4523,18 @@
indent(out) << "oprot.writeMapBegin(new org.apache.thrift.protocol.TMap("
<< type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix << ".size()));"
- << endl;
+ << '\n';
} else if (ttype->is_set()) {
indent(out) << "oprot.writeSetBegin(new org.apache.thrift.protocol.TSet("
<< type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << prefix
- << ".size()));" << endl;
+ << ".size()));" << '\n';
} else if (ttype->is_list()) {
indent(out) << "oprot.writeListBegin(new org.apache.thrift.protocol.TList("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix
- << ".size()));" << endl;
+ << ".size()));" << '\n';
}
} else {
- indent(out) << "oprot.writeI32(" << prefix << ".size());" << endl;
+ indent(out) << "oprot.writeI32(" << prefix << ".size());" << '\n';
}
string iter = tmp("_iter");
@@ -4554,7 +4551,7 @@
<< prefix << ")";
}
- out << endl;
+ out << '\n';
scope_up(out);
if (ttype->is_map()) {
generate_serialize_map_element(out, (t_map*)ttype, iter, prefix, has_metadata);
@@ -4567,11 +4564,11 @@
if (has_metadata) {
if (ttype->is_map()) {
- indent(out) << "oprot.writeMapEnd();" << endl;
+ indent(out) << "oprot.writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "oprot.writeSetEnd();" << endl;
+ indent(out) << "oprot.writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "oprot.writeListEnd();" << endl;
+ indent(out) << "oprot.writeListEnd();" << '\n';
}
}
@@ -5101,7 +5098,7 @@
// deep copy of base types can be done much more efficiently than iterating over all the
// elements manually
indent(out) << type_name(type, true, false) << " " << result_name << " = new "
- << type_name(container, false, true) << "(" << source_name << ");" << endl;
+ << type_name(container, false, true) << "(" << source_name << ");" << '\n';
return;
}
@@ -5116,10 +5113,10 @@
if (is_enum_set(container)) {
indent(out) << type_name(type, true, false) << " " << result_name << " = "
<< type_name(container, false, true, true) << ".noneOf(" << constructor_args << ");"
- << endl;
+ << '\n';
} else {
indent(out) << type_name(type, true, false) << " " << result_name << " = new "
- << type_name(container, false, true) << "(" << constructor_args << ");" << endl;
+ << type_name(container, false, true) << "(" << constructor_args << ");" << '\n';
}
std::string iterator_element_name = source_name_p1 + "_element";
@@ -5131,17 +5128,17 @@
indent(out) << "for (java.util.Map.Entry<" << type_name(key_type, true, false) << ", "
<< type_name(val_type, true, false) << "> " << iterator_element_name << " : "
- << source_name << ".entrySet()) {" << endl;
+ << source_name << ".entrySet()) {" << '\n';
indent_up();
- out << endl;
+ out << '\n';
indent(out) << type_name(key_type, true, false) << " " << iterator_element_name
- << "_key = " << iterator_element_name << ".getKey();" << endl;
+ << "_key = " << iterator_element_name << ".getKey();" << '\n';
indent(out) << type_name(val_type, true, false) << " " << iterator_element_name
- << "_value = " << iterator_element_name << ".getValue();" << endl;
+ << "_value = " << iterator_element_name << ".getValue();" << '\n';
- out << endl;
+ out << '\n';
if (key_type->is_container()) {
generate_deep_copy_container(out, iterator_element_name + "_key", "",
@@ -5150,10 +5147,10 @@
indent(out) << type_name(key_type, true, false) << " " << result_element_name << "_key = ";
generate_deep_copy_non_container(out, iterator_element_name + "_key",
result_element_name + "_key", key_type);
- out << ";" << endl;
+ out << ";" << '\n';
}
- out << endl;
+ out << '\n';
if (val_type->is_container()) {
generate_deep_copy_container(out, iterator_element_name + "_value", "",
@@ -5162,16 +5159,16 @@
indent(out) << type_name(val_type, true, false) << " " << result_element_name << "_value = ";
generate_deep_copy_non_container(out, iterator_element_name + "_value",
result_element_name + "_value", val_type);
- out << ";" << endl;
+ out << ";" << '\n';
}
- out << endl;
+ out << '\n';
indent(out) << result_name << ".put(" << result_element_name << "_key, " << result_element_name
- << "_value);" << endl;
+ << "_value);" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
} else {
t_type* elem_type;
@@ -5183,32 +5180,32 @@
}
indent(out) << "for (" << type_name(elem_type, true, false) << " " << iterator_element_name
- << " : " << source_name << ") {" << endl;
+ << " : " << source_name << ") {" << '\n';
indent_up();
if (elem_type->is_container()) {
// recursive deep copy
generate_deep_copy_container(out, iterator_element_name, "", result_element_name, elem_type);
- indent(out) << result_name << ".add(" << result_element_name << ");" << endl;
+ indent(out) << result_name << ".add(" << result_element_name << ");" << '\n';
} else {
// iterative copy
if (elem_type->is_binary()) {
indent(out) << "java.nio.ByteBuffer temp_binary_element = ";
generate_deep_copy_non_container(out, iterator_element_name, "temp_binary_element",
elem_type);
- out << ";" << endl;
- indent(out) << result_name << ".add(temp_binary_element);" << endl;
+ out << ";" << '\n';
+ indent(out) << result_name << ".add(temp_binary_element);" << '\n';
} else {
indent(out) << result_name << ".add(";
generate_deep_copy_non_container(out, iterator_element_name, result_name, elem_type);
- out << ");" << endl;
+ out << ");" << '\n';
}
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
@@ -5245,14 +5242,14 @@
void t_java_generator::generate_isset_set(ostream& out, t_field* field, string prefix) {
if (!type_can_be_null(field->get_type())) {
indent(out) << prefix << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet")
- << "(true);" << endl;
+ << "(true);" << '\n';
}
}
void t_java_generator::generate_struct_desc(ostream& out, t_struct* tstruct) {
indent(out) << "private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new "
"org.apache.thrift.protocol.TStruct(\""
- << tstruct->get_name() << "\");" << endl;
+ << tstruct->get_name() << "\");" << '\n';
}
void t_java_generator::generate_field_descs(ostream& out, t_struct* tstruct) {
@@ -5264,24 +5261,24 @@
<< constant_name((*m_iter)->get_name())
<< "_FIELD_DESC = new org.apache.thrift.protocol.TField(\"" << (*m_iter)->get_name()
<< "\", " << type_to_enum((*m_iter)->get_type()) << ", "
- << "(short)" << (*m_iter)->get_key() << ");" << endl;
+ << "(short)" << (*m_iter)->get_key() << ");" << '\n';
}
}
void t_java_generator::generate_scheme_map(ostream& out, t_struct* tstruct) {
indent(out) << "private static final org.apache.thrift.scheme.SchemeFactory "
"STANDARD_SCHEME_FACTORY = new "
- << tstruct->get_name() << "StandardSchemeFactory();" << endl;
+ << tstruct->get_name() << "StandardSchemeFactory();" << '\n';
indent(out)
<< "private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new "
- << tstruct->get_name() << "TupleSchemeFactory();" << endl;
+ << tstruct->get_name() << "TupleSchemeFactory();" << '\n';
}
void t_java_generator::generate_field_name_constants(ostream& out, t_struct* tstruct) {
indent(out) << "/** The set of fields this struct contains, along with convenience methods for "
"finding and manipulating them. */"
- << endl;
- indent(out) << "public enum _Fields implements org.apache.thrift.TFieldIdEnum {" << endl;
+ << '\n';
+ indent(out) << "public enum _Fields implements org.apache.thrift.TFieldIdEnum {" << '\n';
indent_up();
bool first = true;
@@ -5289,7 +5286,7 @@
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (!first) {
- out << "," << endl;
+ out << "," << '\n';
}
first = false;
generate_java_doc(out, *m_iter);
@@ -5297,87 +5294,87 @@
<< ", \"" << (*m_iter)->get_name() << "\")";
}
- out << ";" << endl << endl;
+ out << ";" << '\n' << '\n';
indent(out) << "private static final java.util.Map<java.lang.String, _Fields> byName = new "
"java.util.HashMap<java.lang.String, _Fields>();"
- << endl;
- out << endl;
+ << '\n';
+ out << '\n';
- indent(out) << "static {" << endl;
- indent(out) << " for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {" << endl;
- indent(out) << " byName.put(field.getFieldName(), field);" << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "static {" << '\n';
+ indent(out) << " for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {" << '\n';
+ indent(out) << " byName.put(field.getFieldName(), field);" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << "/**" << endl;
+ indent(out) << "/**" << '\n';
indent(out) << " * Find the _Fields constant that matches fieldId, or null if its not found."
- << endl;
- indent(out) << " */" << endl;
- indent(out) << java_nullable_annotation() << endl;
- indent(out) << "public static _Fields findByThriftId(int fieldId) {" << endl;
+ << '\n';
+ indent(out) << " */" << '\n';
+ indent(out) << java_nullable_annotation() << '\n';
+ indent(out) << "public static _Fields findByThriftId(int fieldId) {" << '\n';
indent_up();
- indent(out) << "switch(fieldId) {" << endl;
+ indent(out) << "switch(fieldId) {" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
indent(out) << "case " << (*m_iter)->get_key() << ": // "
- << constant_name((*m_iter)->get_name()) << endl;
- indent(out) << " return " << constant_name((*m_iter)->get_name()) << ";" << endl;
+ << constant_name((*m_iter)->get_name()) << '\n';
+ indent(out) << " return " << constant_name((*m_iter)->get_name()) << ";" << '\n';
}
- indent(out) << "default:" << endl;
- indent(out) << " return null;" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " return null;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << "/**" << endl;
- indent(out) << " * Find the _Fields constant that matches fieldId, throwing an exception" << endl;
- indent(out) << " * if it is not found." << endl;
- indent(out) << " */" << endl;
- indent(out) << "public static _Fields findByThriftIdOrThrow(int fieldId) {" << endl;
- indent(out) << " _Fields fields = findByThriftId(fieldId);" << endl;
+ indent(out) << "/**" << '\n';
+ indent(out) << " * Find the _Fields constant that matches fieldId, throwing an exception" << '\n';
+ indent(out) << " * if it is not found." << '\n';
+ indent(out) << " */" << '\n';
+ indent(out) << "public static _Fields findByThriftIdOrThrow(int fieldId) {" << '\n';
+ indent(out) << " _Fields fields = findByThriftId(fieldId);" << '\n';
indent(out) << " if (fields == null) throw new java.lang.IllegalArgumentException(\"Field \" + "
"fieldId + "
"\" doesn't exist!\");"
- << endl;
- indent(out) << " return fields;" << endl;
- indent(out) << "}" << endl << endl;
+ << '\n';
+ indent(out) << " return fields;" << '\n';
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << "/**" << endl;
+ indent(out) << "/**" << '\n';
indent(out) << " * Find the _Fields constant that matches name, or null if its not found."
- << endl;
- indent(out) << " */" << endl;
- indent(out) << java_nullable_annotation() << endl;
- indent(out) << "public static _Fields findByName(java.lang.String name) {" << endl;
- indent(out) << " return byName.get(name);" << endl;
- indent(out) << "}" << endl << endl;
+ << '\n';
+ indent(out) << " */" << '\n';
+ indent(out) << java_nullable_annotation() << '\n';
+ indent(out) << "public static _Fields findByName(java.lang.String name) {" << '\n';
+ indent(out) << " return byName.get(name);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << "private final short _thriftId;" << endl;
- indent(out) << "private final java.lang.String _fieldName;" << endl << endl;
+ indent(out) << "private final short _thriftId;" << '\n';
+ indent(out) << "private final java.lang.String _fieldName;" << '\n' << '\n';
- indent(out) << "_Fields(short thriftId, java.lang.String fieldName) {" << endl;
- indent(out) << " _thriftId = thriftId;" << endl;
- indent(out) << " _fieldName = fieldName;" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "_Fields(short thriftId, java.lang.String fieldName) {" << '\n';
+ indent(out) << " _thriftId = thriftId;" << '\n';
+ indent(out) << " _fieldName = fieldName;" << '\n';
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public short getThriftFieldId() {" << endl;
- indent(out) << " return _thriftId;" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public short getThriftFieldId() {" << '\n';
+ indent(out) << " return _thriftId;" << '\n';
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public java.lang.String getFieldName() {" << endl;
- indent(out) << " return _fieldName;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public java.lang.String getFieldName() {" << '\n';
+ indent(out) << " return _fieldName;" << '\n';
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
t_java_generator::isset_type t_java_generator::needs_isset(t_struct* tstruct,
@@ -5411,8 +5408,8 @@
}
void t_java_generator::generate_java_struct_clear(std::ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public void clear() {" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public void clear() {" << '\n';
indent_up();
for (auto field : tstruct->get_members()) {
@@ -5425,13 +5422,13 @@
if (type_can_be_null(t)) {
if (reuse_objects_ && (t->is_container() || t->is_struct())) {
- indent(out) << "if (this." << make_valid_java_identifier(field->get_name()) << " != null) {" << endl;
+ indent(out) << "if (this." << make_valid_java_identifier(field->get_name()) << " != null) {" << '\n';
indent_up();
- indent(out) << "this." << make_valid_java_identifier(field->get_name()) << ".clear();" << endl;
+ indent(out) << "this." << make_valid_java_identifier(field->get_name()) << ".clear();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
} else {
- indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = null;" << endl;
+ indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = null;" << '\n';
}
continue;
}
@@ -5439,7 +5436,7 @@
// must be a base type
// means it also needs to be explicitly unset
indent(out) << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet") << "(false);"
- << endl;
+ << '\n';
t_base_type* base_type = (t_base_type*)t;
switch (base_type->get_base()) {
@@ -5447,13 +5444,13 @@
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
case t_base_type::TYPE_I64:
- indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0;" << endl;
+ indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0;" << '\n';
break;
case t_base_type::TYPE_DOUBLE:
- indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0.0;" << endl;
+ indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = 0.0;" << '\n';
break;
case t_base_type::TYPE_BOOL:
- indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = false;" << endl;
+ indent(out) << "this." << make_valid_java_identifier(field->get_name()) << " = false;" << '\n';
break;
default:
throw "unsupported type: " + base_type->get_name() + " for field " + field->get_name();
@@ -5461,7 +5458,7 @@
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// generates java method to serialize (in the Java sense) the object
@@ -5469,24 +5466,24 @@
(void)tstruct;
indent(out)
<< "private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {"
- << endl;
- indent(out) << " try {" << endl;
+ << '\n';
+ indent(out) << " try {" << '\n';
indent(out) << " write(new org.apache.thrift.protocol.TCompactProtocol(new "
"org.apache.thrift.transport.TIOStreamTransport(out)));"
- << endl;
- indent(out) << " } catch (org.apache.thrift.TException te) {" << endl;
+ << '\n';
+ indent(out) << " } catch (org.apache.thrift.TException te) {" << '\n';
indent(out) << " throw new java.io.IOException(te" << (android_legacy_ ? ".getMessage()" : "")
- << ");" << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl << endl;
+ << ");" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n' << '\n';
}
// generates java method to serialize (in the Java sense) the object
void t_java_generator::generate_java_struct_read_object(ostream& out, t_struct* tstruct) {
indent(out) << "private void readObject(java.io.ObjectInputStream in) throws "
"java.io.IOException, java.lang.ClassNotFoundException {"
- << endl;
- indent(out) << " try {" << endl;
+ << '\n';
+ indent(out) << " try {" << '\n';
if (!tstruct->is_union()) {
switch (needs_isset(tstruct)) {
case ISSET_NONE:
@@ -5494,174 +5491,174 @@
case ISSET_PRIMITIVE:
indent(out) << " // it doesn't seem like you should have to do this, but java "
"serialization is wacky, and doesn't call the default constructor."
- << endl;
- indent(out) << " __isset_bitfield = 0;" << endl;
+ << '\n';
+ indent(out) << " __isset_bitfield = 0;" << '\n';
break;
case ISSET_BITSET:
indent(out) << " // it doesn't seem like you should have to do this, but java "
"serialization is wacky, and doesn't call the default constructor."
- << endl;
- indent(out) << " __isset_bit_vector = new java.util.BitSet(1);" << endl;
+ << '\n';
+ indent(out) << " __isset_bit_vector = new java.util.BitSet(1);" << '\n';
break;
}
}
indent(out) << " read(new org.apache.thrift.protocol.TCompactProtocol(new "
"org.apache.thrift.transport.TIOStreamTransport(in)));"
- << endl;
- indent(out) << " } catch (org.apache.thrift.TException te) {" << endl;
+ << '\n';
+ indent(out) << " } catch (org.apache.thrift.TException te) {" << '\n';
indent(out) << " throw new java.io.IOException(te" << (android_legacy_ ? ".getMessage()" : "")
- << ");" << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl << endl;
+ << ");" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n' << '\n';
}
void t_java_generator::generate_standard_reader(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "public void read(org.apache.thrift.protocol.TProtocol iprot, "
- << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl;
+ << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
// Declare stack tmp variables and read struct header
- out << indent() << "org.apache.thrift.protocol.TField schemeField;" << endl
- << indent() << "iprot.readStructBegin();" << endl;
+ out << indent() << "org.apache.thrift.protocol.TField schemeField;" << '\n'
+ << indent() << "iprot.readStructBegin();" << '\n';
// Loop over reading in fields
- indent(out) << "while (true)" << endl;
+ indent(out) << "while (true)" << '\n';
scope_up(out);
// Read beginning field marker
- indent(out) << "schemeField = iprot.readFieldBegin();" << endl;
+ indent(out) << "schemeField = iprot.readFieldBegin();" << '\n';
// Check for field STOP marker and break
- indent(out) << "if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { " << endl;
+ indent(out) << "if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { " << '\n';
indent_up();
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
// Switch statement on the field we are reading
- indent(out) << "switch (schemeField.id) {" << endl;
+ indent(out) << "switch (schemeField.id) {" << '\n';
indent_up();
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent(out) << "case " << (*f_iter)->get_key() << ": // "
- << constant_name((*f_iter)->get_name()) << endl;
+ << constant_name((*f_iter)->get_name()) << '\n';
indent_up();
indent(out) << "if (schemeField.type == " << type_to_enum((*f_iter)->get_type()) << ") {"
- << endl;
+ << '\n';
indent_up();
generate_deserialize_field(out, *f_iter, "struct.", true);
indent(out) << "struct."
<< "set" << get_cap_name((*f_iter)->get_name()) << get_cap_name("isSet")
- << "(true);" << endl;
+ << "(true);" << '\n';
indent_down();
- out << indent() << "} else { " << endl
+ out << indent() << "} else { " << '\n'
<< indent() << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);"
- << endl
- << indent() << "}" << endl
- << indent() << "break;" << endl;
+ << '\n'
+ << indent() << "}" << '\n'
+ << indent() << "break;" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
// Read field end marker
- indent(out) << "iprot.readFieldEnd();" << endl;
+ indent(out) << "iprot.readFieldEnd();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
- out << indent() << "iprot.readStructEnd();" << endl;
+ out << indent() << "iprot.readStructEnd();" << '\n';
// in non-beans style, check for required fields of primitive type
// (which can be checked here but not in the general validate method)
if (!bean_style_) {
- out << endl
+ out << '\n'
<< indent()
<< "// check for required fields of primitive type, which can't be "
"checked in the validate method"
- << endl;
+ << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
- out << indent() << "if (!struct." << generate_isset_check(*f_iter) << ") {" << endl
+ out << indent() << "if (!struct." << generate_isset_check(*f_iter) << ") {" << '\n'
<< indent()
<< " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '"
<< (*f_iter)->get_name()
- << "' was not found in serialized data! Struct: \" + toString());" << endl
- << indent() << "}" << endl;
+ << "' was not found in serialized data! Struct: \" + toString());" << '\n'
+ << indent() << "}" << '\n';
}
}
}
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "struct.validate();" << endl;
+ indent(out) << "struct.validate();" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
void t_java_generator::generate_standard_writer(ostream& out, t_struct* tstruct, bool is_result) {
indent_up();
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "public void write(org.apache.thrift.protocol.TProtocol oprot, "
- << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl;
+ << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "struct.validate();" << endl << endl;
+ indent(out) << "struct.validate();" << '\n' << '\n';
- indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
+ indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool null_allowed = type_can_be_null((*f_iter)->get_type());
if (null_allowed) {
- out << indent() << "if (struct." << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << endl;
+ out << indent() << "if (struct." << make_valid_java_identifier((*f_iter)->get_name()) << " != null) {" << '\n';
indent_up();
}
bool optional = ((*f_iter)->get_req() == t_field::T_OPTIONAL) || (is_result && !null_allowed);
if (optional) {
indent(out) << "if ("
- << "struct." << generate_isset_check((*f_iter)) << ") {" << endl;
+ << "struct." << generate_isset_check((*f_iter)) << ") {" << '\n';
indent_up();
}
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
+ << "_FIELD_DESC);" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "struct.", "", true);
// Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
+ indent(out) << "oprot.writeFieldEnd();" << '\n';
if (optional) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
if (null_allowed) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
// Write the struct map
- out << indent() << "oprot.writeFieldStop();" << endl
- << indent() << "oprot.writeStructEnd();" << endl;
+ out << indent() << "oprot.writeFieldStop();" << '\n'
+ << indent() << "oprot.writeStructEnd();" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
indent_down();
}
@@ -5670,38 +5667,38 @@
bool is_result) {
indent(out) << "private static class " << tstruct->get_name()
<< "StandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public " << tstruct->get_name() << "StandardScheme getScheme() {" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public " << tstruct->get_name() << "StandardScheme getScheme() {" << '\n';
indent_up();
- indent(out) << "return new " << tstruct->get_name() << "StandardScheme();" << endl;
+ indent(out) << "return new " << tstruct->get_name() << "StandardScheme();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
out << indent() << "private static class " << tstruct->get_name()
<< "StandardScheme extends org.apache.thrift.scheme.StandardScheme<" << make_valid_java_identifier(tstruct->get_name())
- << "> {" << endl
- << endl;
+ << "> {" << '\n'
+ << '\n';
indent_up();
generate_standard_reader(out, tstruct);
indent_down();
- out << endl;
+ out << '\n';
generate_standard_writer(out, tstruct, is_result);
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_java_generator::generate_java_struct_tuple_reader(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "public void read(org.apache.thrift.protocol.TProtocol prot, "
- << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl;
+ << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n';
indent_up();
indent(out) << "org.apache.thrift.protocol.TTupleProtocol iprot = "
"(org.apache.thrift.protocol.TTupleProtocol) prot;"
- << endl;
+ << '\n';
int optional_count = 0;
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -5713,39 +5710,39 @@
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
generate_deserialize_field(out, (*f_iter), "struct.", false);
indent(out) << "struct.set" << get_cap_name((*f_iter)->get_name()) << get_cap_name("isSet")
- << "(true);" << endl;
+ << "(true);" << '\n';
}
}
if (optional_count > 0) {
indent(out) << "java.util.BitSet incoming = iprot.readBitSet(" << optional_count << ");"
- << endl;
+ << '\n';
int i = 0;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_OPTIONAL
|| (*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) {
- indent(out) << "if (incoming.get(" << i << ")) {" << endl;
+ indent(out) << "if (incoming.get(" << i << ")) {" << '\n';
indent_up();
generate_deserialize_field(out, (*f_iter), "struct.", false);
indent(out) << "struct.set" << get_cap_name((*f_iter)->get_name()) << get_cap_name("isSet")
- << "(true);" << endl;
+ << "(true);" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
i++;
}
}
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_java_struct_tuple_writer(ostream& out, t_struct* tstruct) {
- indent(out) << java_override_annotation() << endl;
+ indent(out) << java_override_annotation() << '\n';
indent(out) << "public void write(org.apache.thrift.protocol.TProtocol prot, "
- << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << endl;
+ << make_valid_java_identifier(tstruct->get_name()) << " struct) throws org.apache.thrift.TException {" << '\n';
indent_up();
indent(out) << "org.apache.thrift.protocol.TTupleProtocol oprot = "
"(org.apache.thrift.protocol.TTupleProtocol) prot;"
- << endl;
+ << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -5762,70 +5759,70 @@
}
}
if (has_optional) {
- indent(out) << "java.util.BitSet optionals = new java.util.BitSet();" << endl;
+ indent(out) << "java.util.BitSet optionals = new java.util.BitSet();" << '\n';
int i = 0;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_OPTIONAL
|| (*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) {
- indent(out) << "if (struct." << generate_isset_check((*f_iter)) << ") {" << endl;
+ indent(out) << "if (struct." << generate_isset_check((*f_iter)) << ") {" << '\n';
indent_up();
- indent(out) << "optionals.set(" << i << ");" << endl;
+ indent(out) << "optionals.set(" << i << ");" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
i++;
}
}
- indent(out) << "oprot.writeBitSet(optionals, " << optional_count << ");" << endl;
+ indent(out) << "oprot.writeBitSet(optionals, " << optional_count << ");" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_OPTIONAL
|| (*f_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) {
- indent(out) << "if (struct." << generate_isset_check(*f_iter) << ") {" << endl;
+ indent(out) << "if (struct." << generate_isset_check(*f_iter) << ") {" << '\n';
indent_up();
generate_serialize_field(out, (*f_iter), "struct.", "", false);
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_java_struct_tuple_scheme(ostream& out, t_struct* tstruct) {
indent(out) << "private static class " << tstruct->get_name()
- << "TupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {" << endl;
+ << "TupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {" << '\n';
indent_up();
- indent(out) << java_override_annotation() << endl;
- indent(out) << "public " << tstruct->get_name() << "TupleScheme getScheme() {" << endl;
+ indent(out) << java_override_annotation() << '\n';
+ indent(out) << "public " << tstruct->get_name() << "TupleScheme getScheme() {" << '\n';
indent_up();
- indent(out) << "return new " << tstruct->get_name() << "TupleScheme();" << endl;
+ indent(out) << "return new " << tstruct->get_name() << "TupleScheme();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
out << indent() << "private static class " << tstruct->get_name()
<< "TupleScheme extends org.apache.thrift.scheme.TupleScheme<" << make_valid_java_identifier(tstruct->get_name()) << "> {"
- << endl
- << endl;
+ << '\n'
+ << '\n';
indent_up();
generate_java_struct_tuple_writer(out, tstruct);
- out << endl;
+ out << '\n';
generate_java_struct_tuple_reader(out, tstruct);
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_java_generator::generate_java_scheme_lookup(ostream& out) {
indent(out) << "private static <S extends org.apache.thrift.scheme.IScheme> S scheme("
- << "org.apache.thrift.protocol.TProtocol proto) {" << endl;
+ << "org.apache.thrift.protocol.TProtocol proto) {" << '\n';
indent_up();
indent(out) << "return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) "
<< "? STANDARD_SCHEME_FACTORY "
<< ": TUPLE_SCHEME_FACTORY"
- << ").getScheme();" << endl;
+ << ").getScheme();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_java_generator::generate_javax_generated_annotation(ostream& out) {
@@ -5838,11 +5835,11 @@
}
if (undated_generated_annotations_) {
- out << ")" << endl;
+ out << ")" << '\n';
} else {
indent(out) << ", date = \"" << (now->tm_year + 1900) << "-" << setfill('0') << setw(2)
<< (now->tm_mon + 1) << "-" << setfill('0') << setw(2) << now->tm_mday << "\")"
- << endl;
+ << '\n';
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_javame_generator.cc b/compiler/cpp/src/thrift/generate/t_javame_generator.cc
index d8d9056..e2c3a39 100644
--- a/compiler/cpp/src/thrift/generate/t_javame_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_javame_generator.cc
@@ -37,8 +37,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* Java code generator.
*
@@ -339,7 +337,7 @@
generate_java_doc(f_enum, tenum);
indent(f_enum) << "public class " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
scope_up(f_enum);
- f_enum << endl;
+ f_enum << '\n';
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
@@ -347,53 +345,53 @@
int value = (*c_iter)->get_value();
generate_java_doc(f_enum, *c_iter);
indent(f_enum) << "public static final " << tenum->get_name() << " " << (*c_iter)->get_name()
- << " = new " << tenum->get_name() << "(" << value << ");" << endl;
+ << " = new " << tenum->get_name() << "(" << value << ");" << '\n';
}
- f_enum << endl;
+ f_enum << '\n';
// Field for thriftCode
- indent(f_enum) << "private final int value;" << endl << endl;
+ indent(f_enum) << "private final int value;" << '\n' << '\n';
- indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << endl;
- indent(f_enum) << " this.value = value;" << endl;
- indent(f_enum) << "}" << endl << endl;
+ indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << '\n';
+ indent(f_enum) << " this.value = value;" << '\n';
+ indent(f_enum) << "}" << '\n' << '\n';
- indent(f_enum) << "/**" << endl;
+ indent(f_enum) << "/**" << '\n';
indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL."
- << endl;
- indent(f_enum) << " */" << endl;
- indent(f_enum) << "public int getValue() {" << endl;
- indent(f_enum) << " return value;" << endl;
- indent(f_enum) << "}" << endl << endl;
+ << '\n';
+ indent(f_enum) << " */" << '\n';
+ indent(f_enum) << "public int getValue() {" << '\n';
+ indent(f_enum) << " return value;" << '\n';
+ indent(f_enum) << "}" << '\n' << '\n';
- indent(f_enum) << "/**" << endl;
+ indent(f_enum) << "/**" << '\n';
indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL."
- << endl;
- indent(f_enum) << " * @return null if the value is not found." << endl;
- indent(f_enum) << " */" << endl;
- indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl;
+ << '\n';
+ indent(f_enum) << " * @return null if the value is not found." << '\n';
+ indent(f_enum) << " */" << '\n';
+ indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << '\n';
indent_up();
- indent(f_enum) << "switch (value) {" << endl;
+ indent(f_enum) << "switch (value) {" << '\n';
indent_up();
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
- indent(f_enum) << "case " << value << ":" << endl;
- indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << endl;
+ indent(f_enum) << "case " << value << ":" << '\n';
+ indent(f_enum) << " return " << (*c_iter)->get_name() << ";" << '\n';
}
- indent(f_enum) << "default:" << endl;
- indent(f_enum) << " return null;" << endl;
+ indent(f_enum) << "default:" << '\n';
+ indent(f_enum) << " return null;" << '\n';
indent_down();
- indent(f_enum) << "}" << endl;
+ indent(f_enum) << "}" << '\n';
indent_down();
- indent(f_enum) << "}" << endl;
+ indent(f_enum) << "}" << '\n';
scope_down(f_enum);
@@ -415,7 +413,7 @@
// Print header
f_consts << autogen_comment() << java_package() << java_type_imports();
- f_consts << "public class " << program_name_ << "Constants {" << endl << endl;
+ f_consts << "public class " << program_name_ << "Constants {" << '\n' << '\n';
indent_up();
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -426,7 +424,7 @@
false);
}
indent_down();
- indent(f_consts) << "}" << endl;
+ indent(f_consts) << "}" << '\n';
f_consts.close();
}
@@ -449,17 +447,17 @@
}
if (type->is_base_type()) {
string v2 = render_const_value(out, name, type, value);
- out << name << " = " << v2 << ";" << endl << endl;
+ out << name << " = " << v2 << ";" << '\n' << '\n';
} else if (type->is_enum()) {
- out << name << " = " << render_const_value(out, name, type, value) << ";" << endl << endl;
+ out << name << " = " << render_const_value(out, name, type, value) << ";" << '\n' << '\n';
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
- out << name << " = new " << type_name(type, false, true) << "();" << endl;
+ out << name << " = new " << type_name(type, false, true) << "();" << '\n';
if (!in_static) {
- indent(out) << "static {" << endl;
+ indent(out) << "static {" << '\n';
indent_up();
}
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
@@ -475,17 +473,17 @@
string val = render_const_value(out, name, field_type, v_iter->second);
indent(out) << name << ".";
std::string cap_name = get_cap_name(v_iter->first->get_string());
- out << "set" << cap_name << "(" << val << ");" << endl;
+ out << "set" << cap_name << "(" << val << ");" << '\n';
}
if (!in_static) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << endl;
+ out << '\n';
} else if (type->is_map()) {
- out << name << " = new " << type_name(type, false, true) << "();" << endl;
+ out << name << " = new " << type_name(type, false, true) << "();" << '\n';
if (!in_static) {
- indent(out) << "static {" << endl;
+ indent(out) << "static {" << '\n';
indent_up();
}
t_type* ktype = ((t_map*)type)->get_key_type();
@@ -496,17 +494,17 @@
string key = render_const_value(out, name, ktype, v_iter->first);
string val = render_const_value(out, name, vtype, v_iter->second);
indent(out) << name << ".put(" << box_type(ktype, key) << ", " << box_type(vtype, val) << ");"
- << endl;
+ << '\n';
}
if (!in_static) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << endl;
+ out << '\n';
} else if (type->is_list() || type->is_set()) {
- out << name << " = new " << type_name(type, false, true) << "();" << endl;
+ out << name << " = new " << type_name(type, false, true) << "();" << '\n';
if (!in_static) {
- indent(out) << "static {" << endl;
+ indent(out) << "static {" << '\n';
indent_up();
}
t_type* etype;
@@ -520,17 +518,17 @@
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string val = render_const_value(out, name, etype, *v_iter);
if (type->is_list()) {
- indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << endl;
+ indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << '\n';
} else {
indent(out) << name << ".put(" << box_type(etype, val) << ", " << box_type(etype, val)
- << ");" << endl;
+ << ");" << '\n';
}
}
if (!in_static) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << endl;
+ out << '\n';
} else {
throw "compiler error: no const of type " + type->get_name();
}
@@ -673,27 +671,27 @@
generate_struct_desc(f_struct, tstruct);
generate_field_descs(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_constructor(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_abstract_methods(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_getters_and_setters(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_comparisons(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
generate_union_hashcode(f_struct, tstruct);
- f_struct << endl;
+ f_struct << '\n';
scope_down(f_struct);
@@ -701,33 +699,33 @@
}
void t_javame_generator::generate_union_constructor(ostream& out, t_struct* tstruct) {
- indent(out) << "public " << type_name(tstruct) << "() {" << endl;
- indent(out) << " super();" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "public " << type_name(tstruct) << "() {" << '\n';
+ indent(out) << " super();" << '\n';
+ indent(out) << "}" << '\n' << '\n';
- indent(out) << "public " << type_name(tstruct) << "(_Fields setField, Object value) {" << endl;
- indent(out) << " super(setField, value);" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "public " << type_name(tstruct) << "(_Fields setField, Object value) {" << '\n';
+ indent(out) << " super(setField, value);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {"
- << endl;
- indent(out) << " super(other);" << endl;
- indent(out) << "}" << endl;
+ << '\n';
+ indent(out) << " super(other);" << '\n';
+ indent(out) << "}" << '\n';
- indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << endl;
- indent(out) << " return new " << tstruct->get_name() << "(this);" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << '\n';
+ indent(out) << " return new " << tstruct->get_name() << "(this);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
// generate "constructors" for each field
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "("
- << type_name((*m_iter)->get_type()) << " value) {" << endl;
- indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl;
- indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << endl;
- indent(out) << " return x;" << endl;
- indent(out) << "}" << endl << endl;
+ << type_name((*m_iter)->get_type()) << " value) {" << '\n';
+ indent(out) << " " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << '\n';
+ indent(out) << " x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << '\n';
+ indent(out) << " return x;" << '\n';
+ indent(out) << "}" << '\n' << '\n';
}
}
@@ -740,59 +738,59 @@
if (first) {
first = false;
} else {
- out << endl;
+ out << '\n';
}
t_field* field = (*m_iter);
generate_java_doc(out, field);
indent(out) << "public " << type_name(field->get_type()) << " get"
- << get_cap_name(field->get_name()) << "() {" << endl;
+ << get_cap_name(field->get_name()) << "() {" << '\n';
indent(out) << " if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {"
- << endl;
+ << '\n';
indent(out) << " return (" << type_name(field->get_type(), true) << ")getFieldValue();"
- << endl;
- indent(out) << " } else {" << endl;
+ << '\n';
+ indent(out) << " } else {" << '\n';
indent(out) << " throw new RuntimeException(\"Cannot get field '" << field->get_name()
<< "' because union is currently set to \" + getFieldDesc(getSetField()).name);"
- << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl;
+ << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n';
- out << endl;
+ out << '\n';
generate_java_doc(out, field);
indent(out) << "public void set" << get_cap_name(field->get_name()) << "("
- << type_name(field->get_type()) << " value) {" << endl;
+ << type_name(field->get_type()) << " value) {" << '\n';
if (type_can_be_null(field->get_type())) {
- indent(out) << " if (value == null) throw new NullPointerException();" << endl;
+ indent(out) << " if (value == null) throw new NullPointerException();" << '\n';
}
- indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << endl;
- indent(out) << " value_ = value;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << " setField_ = _Fields." << constant_name(field->get_name()) << ";" << '\n';
+ indent(out) << " value_ = value;" << '\n';
+ indent(out) << "}" << '\n';
}
}
void t_javame_generator::generate_union_abstract_methods(ostream& out, t_struct* tstruct) {
generate_check_type(out, tstruct);
- out << endl;
+ out << '\n';
generate_read_value(out, tstruct);
- out << endl;
+ out << '\n';
generate_write_value(out, tstruct);
- out << endl;
+ out << '\n';
generate_get_field_desc(out, tstruct);
- out << endl;
+ out << '\n';
generate_get_struct_desc(out, tstruct);
- out << endl;
+ out << '\n';
}
void t_javame_generator::generate_check_type(ostream& out, t_struct* tstruct) {
indent(out)
<< "protected void checkType(_Fields setField, Object value) throws ClassCastException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "switch (setField) {" << endl;
+ indent(out) << "switch (setField) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -801,37 +799,37 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent(out) << " if (value instanceof " << type_name(field->get_type(), true, false, true)
- << ") {" << endl;
- indent(out) << " break;" << endl;
- indent(out) << " }" << endl;
+ << ") {" << '\n';
+ indent(out) << " break;" << '\n';
+ indent(out) << " }" << '\n';
indent(out) << " throw new ClassCastException(\"Was expecting value of type "
<< type_name(field->get_type(), true, false) << " for field '" << field->get_name()
- << "', but got \" + value.getClass().getSimpleName());" << endl;
+ << "', but got \" + value.getClass().getSimpleName());" << '\n';
// do the real check here
}
- indent(out) << "default:" << endl;
- indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_javame_generator::generate_read_value(ostream& out, t_struct* tstruct) {
indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << endl;
- indent(out) << "if (setField != null) {" << endl;
+ indent(out) << "_Fields setField = _Fields.findByThriftId(field.id);" << '\n';
+ indent(out) << "if (setField != null) {" << '\n';
indent_up();
- indent(out) << "switch (setField) {" << endl;
+ indent(out) << "switch (setField) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -840,48 +838,48 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent_up();
indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {"
- << endl;
+ << '\n';
indent_up();
indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";"
- << endl;
+ << '\n';
generate_deserialize_field(out, field, "");
- indent(out) << "return " << field->get_name() << ";" << endl;
+ indent(out) << "return " << field->get_name() << ";" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
- indent(out) << " TProtocolUtil.skip(iprot, field.type);" << endl;
- indent(out) << " return null;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "} else {" << '\n';
+ indent(out) << " TProtocolUtil.skip(iprot, field.type);" << '\n';
+ indent(out) << " return null;" << '\n';
+ indent(out) << "}" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out) << " throw new IllegalStateException(\"setField wasn't null, but didn't match any "
- "of the case statements!\");" << endl;
+ "of the case statements!\");" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
- indent(out) << "TProtocolUtil.skip(iprot, field.type);" << endl;
- indent(out) << "return null;" << endl;
+ indent(out) << "TProtocolUtil.skip(iprot, field.type);" << '\n';
+ indent(out) << "return null;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_javame_generator::generate_write_value(ostream& out, t_struct* tstruct) {
- indent(out) << "protected void writeValue(TProtocol oprot) throws TException {" << endl;
+ indent(out) << "protected void writeValue(TProtocol oprot) throws TException {" << '\n';
indent_up();
- indent(out) << "switch (setField_) {" << endl;
+ indent(out) << "switch (setField_) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -890,100 +888,100 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
indent_up();
indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = ("
- << type_name(field->get_type(), true, false) << ")value_;" << endl;
+ << type_name(field->get_type(), true, false) << ")value_;" << '\n';
generate_serialize_field(out, field, "");
- indent(out) << "return;" << endl;
+ indent(out) << "return;" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent(out) << " throw new IllegalStateException(\"Cannot write union with unknown field \" + "
- "setField_);" << endl;
+ "setField_);" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_javame_generator::generate_get_field_desc(ostream& out, t_struct* tstruct) {
- indent(out) << "protected TField getFieldDesc(_Fields setField) {" << endl;
+ indent(out) << "protected TField getFieldDesc(_Fields setField) {" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
- indent(out) << "switch (setField) {" << endl;
+ indent(out) << "switch (setField) {" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = (*m_iter);
- indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
- indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << endl;
+ indent(out) << "case " << constant_name(field->get_name()) << ":" << '\n';
+ indent(out) << " return " << constant_name(field->get_name()) << "_FIELD_DESC;" << '\n';
}
- indent(out) << "default:" << endl;
- indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " throw new IllegalArgumentException(\"Unknown field id \" + setField);" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_javame_generator::generate_get_struct_desc(ostream& out, t_struct* tstruct) {
(void)tstruct;
- indent(out) << "protected TStruct getStructDesc() {" << endl;
- indent(out) << " return STRUCT_DESC;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "protected TStruct getStructDesc() {" << '\n';
+ indent(out) << " return STRUCT_DESC;" << '\n';
+ indent(out) << "}" << '\n';
}
void t_javame_generator::generate_union_comparisons(ostream& out, t_struct* tstruct) {
// equality
- indent(out) << "public boolean equals(Object other) {" << endl;
- indent(out) << " if (other instanceof " << tstruct->get_name() << ") {" << endl;
- indent(out) << " return equals((" << tstruct->get_name() << ")other);" << endl;
- indent(out) << " } else {" << endl;
- indent(out) << " return false;" << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "public boolean equals(Object other) {" << '\n';
+ indent(out) << " if (other instanceof " << tstruct->get_name() << ") {" << '\n';
+ indent(out) << " return equals((" << tstruct->get_name() << ")other);" << '\n';
+ indent(out) << " } else {" << '\n';
+ indent(out) << " return false;" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n';
- out << endl;
+ out << '\n';
- indent(out) << "public boolean equals(" << tstruct->get_name() << " other) {" << endl;
+ indent(out) << "public boolean equals(" << tstruct->get_name() << " other) {" << '\n';
indent(out) << " return other != null && getSetField() == other.getSetField() && "
- "getFieldValue().equals(other.getFieldValue());" << endl;
- indent(out) << "}" << endl;
- out << endl;
+ "getFieldValue().equals(other.getFieldValue());" << '\n';
+ indent(out) << "}" << '\n';
+ out << '\n';
- indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
+ indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n';
indent(out) << " int lastComparison = TBaseHelper.compareTo(getSetField(), other.getSetField());"
- << endl;
- indent(out) << " if (lastComparison == 0) {" << endl;
+ << '\n';
+ indent(out) << " if (lastComparison == 0) {" << '\n';
indent(out) << " return TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());"
- << endl;
- indent(out) << " }" << endl;
- indent(out) << " return lastComparison;" << endl;
- indent(out) << "}" << endl;
- out << endl;
+ << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << " return lastComparison;" << '\n';
+ indent(out) << "}" << '\n';
+ out << '\n';
}
void t_javame_generator::generate_union_hashcode(ostream& out, t_struct* tstruct) {
(void)tstruct;
- indent(out) << "/**" << endl;
+ indent(out) << "/**" << '\n';
indent(out)
<< " * If you'd like this to perform more respectably, use the hashcode generator option."
- << endl;
- indent(out) << " */" << endl;
- indent(out) << "public int hashCode() {" << endl;
- indent(out) << " return 0;" << endl;
- indent(out) << "}" << endl;
+ << '\n';
+ indent(out) << " */" << '\n';
+ indent(out) << "public int hashCode() {" << '\n';
+ indent(out) << " return 0;" << '\n';
+ indent(out) << "}" << '\n';
}
/**
@@ -1021,43 +1019,43 @@
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
- out << endl;
+ out << '\n';
generate_field_descs(out, tstruct);
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
indent(out) << "private ";
- out << declare_field(*m_iter, false) << endl;
+ out << declare_field(*m_iter, false) << '\n';
}
// isset data
if (members.size() > 0) {
- out << endl;
+ out << '\n';
- indent(out) << "// isset id assignments" << endl;
+ indent(out) << "// isset id assignments" << '\n';
int i = 0;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (!type_can_be_null((*m_iter)->get_type())) {
indent(out) << "private static final int " << isset_field_id(*m_iter) << " = " << i << ";"
- << endl;
+ << '\n';
i++;
}
}
if (i > 0) {
- indent(out) << "private boolean[] __isset_vector = new boolean[" << i << "];" << endl;
+ indent(out) << "private boolean[] __isset_vector = new boolean[" << i << "];" << '\n';
}
- out << endl;
+ out << '\n';
}
bool all_optional_members = true;
// Default constructor
- indent(out) << "public " << tstruct->get_name() << "() {" << endl;
+ indent(out) << "public " << tstruct->get_name() << "() {" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
@@ -1074,49 +1072,49 @@
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
if (!members.empty() && !all_optional_members) {
// Full constructor for all fields
- indent(out) << "public " << tstruct->get_name() << "(" << endl;
+ indent(out) << "public " << tstruct->get_name() << "(" << '\n';
indent_up();
bool first = true;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
if (!first) {
- out << "," << endl;
+ out << "," << '\n';
}
first = false;
indent(out) << type_name((*m_iter)->get_type()) << " " << (*m_iter)->get_name();
}
}
- out << ")" << endl;
+ out << ")" << '\n';
indent_down();
- indent(out) << "{" << endl;
+ indent(out) << "{" << '\n';
indent_up();
- indent(out) << "this();" << endl;
+ indent(out) << "this();" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
indent(out) << "this." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << ";"
- << endl;
+ << '\n';
generate_isset_set(out, (*m_iter));
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// copy constructor
- indent(out) << "/**" << endl;
- indent(out) << " * Performs a deep copy on <i>other</i>." << endl;
- indent(out) << " */" << endl;
+ indent(out) << "/**" << '\n';
+ indent(out) << " * Performs a deep copy on <i>other</i>." << '\n';
+ indent(out) << " */" << '\n';
indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {"
- << endl;
+ << '\n';
indent_up();
if (has_bit_vector(tstruct)) {
indent(out) << "System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, "
- "other.__isset_vector.length);" << endl;
+ "other.__isset_vector.length);" << '\n';
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1126,32 +1124,32 @@
bool can_be_null = type_can_be_null(type);
if (can_be_null) {
- indent(out) << "if (other." << generate_isset_check(field) << ") {" << endl;
+ indent(out) << "if (other." << generate_isset_check(field) << ") {" << '\n';
indent_up();
}
if (type->is_container()) {
generate_deep_copy_container(out, "other", field_name, "__this__" + field_name, type);
- indent(out) << "this." << field_name << " = __this__" << field_name << ";" << endl;
+ indent(out) << "this." << field_name << " = __this__" << field_name << ";" << '\n';
} else {
indent(out) << "this." << field_name << " = ";
generate_deep_copy_non_container(out, "other." + field_name, field_name, type);
- out << ";" << endl;
+ out << ";" << '\n';
}
if (can_be_null) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// clone method, so that you can deep copy an object when you don't know its class.
- indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << endl;
- indent(out) << " return new " << tstruct->get_name() << "(this);" << endl;
- indent(out) << "}" << endl << endl;
+ indent(out) << "public " << tstruct->get_name() << " deepCopy() {" << '\n';
+ indent(out) << " return new " << tstruct->get_name() << "(this);" << '\n';
+ indent(out) << "}" << '\n' << '\n';
generate_java_struct_clear(out, tstruct);
@@ -1170,7 +1168,7 @@
generate_java_struct_tostring(out, tstruct);
generate_java_validator(out, tstruct);
scope_down(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1179,24 +1177,24 @@
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_equality(ostream& out, t_struct* tstruct) {
- out << indent() << "public boolean equals(Object that) {" << endl;
+ out << indent() << "public boolean equals(Object that) {" << '\n';
indent_up();
- out << indent() << "if (that == null)" << endl << indent() << " return false;" << endl
- << indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl << indent()
- << " return this.equals((" << tstruct->get_name() << ")that);" << endl << indent()
- << "return false;" << endl;
+ out << indent() << "if (that == null)" << '\n' << indent() << " return false;" << '\n'
+ << indent() << "if (that instanceof " << tstruct->get_name() << ")" << '\n' << indent()
+ << " return this.equals((" << tstruct->get_name() << ")that);" << '\n' << indent()
+ << "return false;" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
- out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
+ out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << '\n';
indent_up();
- out << indent() << "if (that == null)" << endl << indent() << " return false;" << endl
- << indent() << "if (this == that)" << endl << indent() << " return true;" << endl;
+ out << indent() << "if (that == null)" << '\n' << indent() << " return false;" << '\n'
+ << indent() << "if (this == that)" << '\n' << indent() << " return true;" << '\n';
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- out << endl;
+ out << '\n';
t_type* t = get_true_type((*m_iter)->get_type());
// Most existing Thrift code does not use isset or optional/required,
@@ -1214,14 +1212,14 @@
that_present += " && that." + generate_isset_check(*m_iter);
}
- out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << endl
- << indent() << "boolean that_present_" << name << " = " << that_present << ";" << endl
+ out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << '\n'
+ << indent() << "boolean that_present_" << name << " = " << that_present << ";" << '\n'
<< indent() << "if ("
- << "this_present_" << name << " || that_present_" << name << ") {" << endl;
+ << "this_present_" << name << " || that_present_" << name << ") {" << '\n';
indent_up();
out << indent() << "if (!("
- << "this_present_" << name << " && that_present_" << name << "))" << endl << indent()
- << " return false;" << endl;
+ << "this_present_" << name << " && that_present_" << name << "))" << '\n' << indent()
+ << " return false;" << '\n';
if (t->is_binary()) {
unequal = "TBaseHelper.compareTo(this." + name + ", that." + name + ") != 0";
@@ -1231,66 +1229,66 @@
unequal = "this." + name + " != that." + name;
}
- out << indent() << "if (" << unequal << ")" << endl << indent() << " return false;" << endl;
+ out << indent() << "if (" << unequal << ")" << '\n' << indent() << " return false;" << '\n';
scope_down(out);
}
- out << endl;
- indent(out) << "return true;" << endl;
+ out << '\n';
+ indent(out) << "return true;" << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
- out << indent() << "public int hashCode() {" << endl;
+ out << indent() << "public int hashCode() {" << '\n';
indent_up();
- indent(out) << "return 0;" << endl;
+ indent(out) << "return 0;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
void t_javame_generator::generate_java_struct_compare_to(ostream& out, t_struct* tstruct) {
- indent(out) << "public int compareTo(Object otherObject) {" << endl;
- // indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
+ indent(out) << "public int compareTo(Object otherObject) {" << '\n';
+ // indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << '\n';
indent_up();
- indent(out) << "if (!getClass().equals(otherObject.getClass())) {" << endl;
+ indent(out) << "if (!getClass().equals(otherObject.getClass())) {" << '\n';
indent(out) << " return getClass().getName().compareTo(otherObject.getClass().getName());"
- << endl;
- indent(out) << "}" << endl;
- out << endl;
+ << '\n';
+ indent(out) << "}" << '\n';
+ out << '\n';
indent(out) << type_name(tstruct) << " other = (" << type_name(tstruct) << ")otherObject;";
- indent(out) << "int lastComparison = 0;" << endl;
- out << endl;
+ indent(out) << "int lastComparison = 0;" << '\n';
+ out << '\n';
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* field = *m_iter;
indent(out) << "lastComparison = TBaseHelper.compareTo(" << generate_isset_check(field)
- << ", other." << generate_isset_check(field) << ");" << endl;
- indent(out) << "if (lastComparison != 0) {" << endl;
- indent(out) << " return lastComparison;" << endl;
- indent(out) << "}" << endl;
+ << ", other." << generate_isset_check(field) << ");" << '\n';
+ indent(out) << "if (lastComparison != 0) {" << '\n';
+ indent(out) << " return lastComparison;" << '\n';
+ indent(out) << "}" << '\n';
- indent(out) << "if (" << generate_isset_check(field) << ") {" << endl;
+ indent(out) << "if (" << generate_isset_check(field) << ") {" << '\n';
if (field->get_type()->is_struct() || field->get_type()->is_xception()) {
indent(out) << " lastComparison = this." << field->get_name() << ".compareTo(other."
- << field->get_name() << ");" << endl;
+ << field->get_name() << ");" << '\n';
} else {
indent(out) << " lastComparison = TBaseHelper.compareTo(this." << field->get_name()
- << ", other." << field->get_name() << ");" << endl;
+ << ", other." << field->get_name() << ");" << '\n';
}
- indent(out) << " if (lastComparison != 0) {" << endl;
- indent(out) << " return lastComparison;" << endl;
- indent(out) << " }" << endl;
- indent(out) << "}" << endl;
+ indent(out) << " if (lastComparison != 0) {" << '\n';
+ indent(out) << " return lastComparison;" << '\n';
+ indent(out) << " }" << '\n';
+ indent(out) << "}" << '\n';
}
- indent(out) << "return 0;" << endl;
+ indent(out) << "return 0;" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1299,91 +1297,91 @@
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_reader(ostream& out, t_struct* tstruct) {
- out << indent() << "public void read(TProtocol iprot) throws TException {" << endl;
+ out << indent() << "public void read(TProtocol iprot) throws TException {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
// Declare stack tmp variables and read struct header
- out << indent() << "TField field;" << endl << indent() << "iprot.readStructBegin();" << endl;
+ out << indent() << "TField field;" << '\n' << indent() << "iprot.readStructBegin();" << '\n';
// Loop over reading in fields
- indent(out) << "while (true)" << endl;
+ indent(out) << "while (true)" << '\n';
scope_up(out);
// Read beginning field marker
- indent(out) << "field = iprot.readFieldBegin();" << endl;
+ indent(out) << "field = iprot.readFieldBegin();" << '\n';
// Check for field STOP marker and break
- indent(out) << "if (field.type == TType.STOP) { " << endl;
+ indent(out) << "if (field.type == TType.STOP) { " << '\n';
indent_up();
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
// Switch statement on the field we are reading
- indent(out) << "switch (field.id) {" << endl;
+ indent(out) << "switch (field.id) {" << '\n';
indent_up();
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent(out) << "case " << (*f_iter)->get_key() << ": // "
- << constant_name((*f_iter)->get_name()) << endl;
+ << constant_name((*f_iter)->get_name()) << '\n';
indent_up();
- indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+ indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n';
indent_up();
generate_deserialize_field(out, *f_iter, "this.");
generate_isset_set(out, *f_iter);
indent_down();
- out << indent() << "} else { " << endl << indent() << " TProtocolUtil.skip(iprot, field.type);"
- << endl << indent() << "}" << endl << indent() << "break;" << endl;
+ out << indent() << "} else { " << '\n' << indent() << " TProtocolUtil.skip(iprot, field.type);"
+ << '\n' << indent() << "}" << '\n' << indent() << "break;" << '\n';
indent_down();
}
- indent(out) << "default:" << endl;
- indent(out) << " TProtocolUtil.skip(iprot, field.type);" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " TProtocolUtil.skip(iprot, field.type);" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
// Read field end marker
- indent(out) << "iprot.readFieldEnd();" << endl;
+ indent(out) << "iprot.readFieldEnd();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
- out << indent() << "iprot.readStructEnd();" << endl;
+ out << indent() << "iprot.readStructEnd();" << '\n';
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl;
+ indent(out) << "validate();" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
// generates java method to perform various checks
// (e.g. check that all required fields are set)
void t_javame_generator::generate_java_validator(ostream& out, t_struct* tstruct) {
- indent(out) << "public void validate() throws TException {" << endl;
+ indent(out) << "public void validate() throws TException {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- out << indent() << "// check for required fields" << endl;
+ out << indent() << "// check for required fields" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
- out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl << indent()
+ out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << '\n' << indent()
<< " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name()
- << "' is unset! Struct:\" + toString());" << endl << indent() << "}" << endl << endl;
+ << "' is unset! Struct:\" + toString());" << '\n' << indent() << "}" << '\n' << '\n';
}
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1392,7 +1390,7 @@
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_writer(ostream& out, t_struct* tstruct) {
- out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
+ out << indent() << "public void write(TProtocol oprot) throws TException {" << '\n';
indent_up();
string name = tstruct->get_name();
@@ -1400,46 +1398,46 @@
vector<t_field*>::const_iterator f_iter;
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "validate();" << endl << endl;
+ indent(out) << "validate();" << '\n' << '\n';
- indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
+ indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool null_allowed = type_can_be_null((*f_iter)->get_type());
if (null_allowed) {
- out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
+ out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << '\n';
indent_up();
}
bool optional = (*f_iter)->get_req() == t_field::T_OPTIONAL;
if (optional) {
- indent(out) << "if (" << generate_isset_check((*f_iter)) << ") {" << endl;
+ indent(out) << "if (" << generate_isset_check((*f_iter)) << ") {" << '\n';
indent_up();
}
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
+ << "_FIELD_DESC);" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "this.");
// Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
+ indent(out) << "oprot.writeFieldEnd();" << '\n';
if (optional) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
if (null_allowed) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
// Write the struct map
- out << indent() << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();"
- << endl;
+ out << indent() << "oprot.writeFieldStop();" << '\n' << indent() << "oprot.writeStructEnd();"
+ << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
/**
@@ -1451,62 +1449,62 @@
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_result_writer(ostream& out, t_struct* tstruct) {
- out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
+ out << indent() << "public void write(TProtocol oprot) throws TException {" << '\n';
indent_up();
string name = tstruct->get_name();
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
+ indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << '\n';
bool first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (first) {
first = false;
- out << endl << indent() << "if ";
+ out << '\n' << indent() << "if ";
} else {
out << " else if ";
}
- out << "(this." << generate_isset_check(*f_iter) << ") {" << endl;
+ out << "(this." << generate_isset_check(*f_iter) << ") {" << '\n';
indent_up();
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
- << "_FIELD_DESC);" << endl;
+ << "_FIELD_DESC);" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "this.");
// Write field closer
- indent(out) << "oprot.writeFieldEnd();" << endl;
+ indent(out) << "oprot.writeFieldEnd();" << '\n';
indent_down();
indent(out) << "}";
}
// Write the struct map
- out << endl << indent() << "oprot.writeFieldStop();" << endl << indent()
- << "oprot.writeStructEnd();" << endl;
+ out << '\n' << indent() << "oprot.writeFieldStop();" << '\n' << indent()
+ << "oprot.writeStructEnd();" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_javame_generator::generate_reflection_getters(ostringstream& out,
t_type* type,
string field_name,
string cap_name) {
- indent(out) << "case " << constant_name(field_name) << ":" << endl;
+ indent(out) << "case " << constant_name(field_name) << ":" << '\n';
indent_up();
if (type->is_base_type() && !type->is_string()) {
t_base_type* base_type = (t_base_type*)type;
indent(out) << "return new " << type_name(type, true, false) << "("
- << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
+ << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << '\n' << '\n';
} else {
- indent(out) << "return get" << cap_name << "();" << endl << endl;
+ indent(out) << "return get" << cap_name << "();" << '\n' << '\n';
}
indent_down();
@@ -1516,14 +1514,14 @@
t_type* type,
string field_name,
string cap_name) {
- indent(out) << "case " << constant_name(field_name) << ":" << endl;
+ indent(out) << "case " << constant_name(field_name) << ":" << '\n';
indent_up();
- indent(out) << "if (value == null) {" << endl;
- indent(out) << " unset" << get_cap_name(field_name) << "();" << endl;
- indent(out) << "} else {" << endl;
- indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << endl;
- indent(out) << "}" << endl;
- indent(out) << "break;" << endl << endl;
+ indent(out) << "if (value == null) {" << '\n';
+ indent(out) << " unset" << get_cap_name(field_name) << "();" << '\n';
+ indent(out) << "} else {" << '\n';
+ indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << '\n';
+ indent(out) << "}" << '\n';
+ indent(out) << "break;" << '\n' << '\n';
indent_down();
}
@@ -1568,13 +1566,13 @@
if (type->is_container()) {
// Method to return the size of the collection
indent(out) << "public int get" << cap_name;
- out << get_cap_name("size() {") << endl;
+ out << get_cap_name("size() {") << '\n';
indent_up();
indent(out) << "return (this." << field_name << " == null) ? 0 : "
- << "this." << field_name << ".size();" << endl;
+ << "this." << field_name << ".size();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
if (type->is_set() || type->is_list()) {
@@ -1588,35 +1586,35 @@
// Iterator getter for sets and lists
indent(out) << "public Enumeration get" << cap_name;
- out << get_cap_name("Enumeration() {") << endl;
+ out << get_cap_name("Enumeration() {") << '\n';
indent_up();
indent(out) << "return (this." << field_name << " == null) ? null : "
- << "this." << field_name << ".elements();" << endl;
+ << "this." << field_name << ".elements();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// Add to set or list, create if the set/list is null
indent(out);
out << "public void add" << get_cap_name("to");
- out << cap_name << "(" << type_name(element_type) << " elem) {" << endl;
+ out << cap_name << "(" << type_name(element_type) << " elem) {" << '\n';
indent_up();
- indent(out) << "if (this." << field_name << " == null) {" << endl;
+ indent(out) << "if (this." << field_name << " == null) {" << '\n';
indent_up();
indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
if (type->is_set()) {
indent(out) << "this." << field_name << ".put(" << box_type(element_type, "elem") << ", "
- << box_type(element_type, "elem") << ");" << endl;
+ << box_type(element_type, "elem") << ");" << '\n';
} else {
indent(out) << "this." << field_name << ".addElement(" << box_type(element_type, "elem")
- << ");" << endl;
+ << ");" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else if (type->is_map()) {
// Put to map
@@ -1625,18 +1623,18 @@
indent(out);
out << "public void putTo" << cap_name << "(" << type_name(key_type, true) << " key, "
- << type_name(val_type, true) << " val) {" << endl;
+ << type_name(val_type, true) << " val) {" << '\n';
indent_up();
- indent(out) << "if (this." << field_name << " == null) {" << endl;
+ indent(out) << "if (this." << field_name << " == null) {" << '\n';
indent_up();
indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "}" << endl;
- indent(out) << "this." << field_name << ".put(key, val);" << endl;
+ indent(out) << "}" << '\n';
+ indent(out) << "this." << field_name << ".put(key, val);" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
// Simple getter
@@ -1647,60 +1645,60 @@
} else {
out << " get";
}
- out << cap_name << "() {" << endl;
+ out << cap_name << "() {" << '\n';
indent_up();
- indent(out) << "return this." << field_name << ";" << endl;
+ indent(out) << "return this." << field_name << ";" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// Simple setter
generate_java_doc(out, field);
indent(out) << "public ";
out << "void";
- out << " set" << cap_name << "(" << type_name(type) << " " << field_name << ") {" << endl;
+ out << " set" << cap_name << "(" << type_name(type) << " " << field_name << ") {" << '\n';
indent_up();
- indent(out) << "this." << field_name << " = " << field_name << ";" << endl;
+ indent(out) << "this." << field_name << " = " << field_name << ";" << '\n';
generate_isset_set(out, field);
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// Unsetter
- indent(out) << "public void unset" << cap_name << "() {" << endl;
+ indent(out) << "public void unset" << cap_name << "() {" << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "this." << field_name << " = null;" << endl;
+ indent(out) << "this." << field_name << " = null;" << '\n';
} else {
- indent(out) << "__isset_vector[" << isset_field_id(field) << "] = false;" << endl;
+ indent(out) << "__isset_vector[" << isset_field_id(field) << "] = false;" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
// isSet method
indent(out) << "/** Returns true if field " << field_name
- << " is set (has been assigned a value) and false otherwise */" << endl;
- indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << endl;
+ << " is set (has been assigned a value) and false otherwise */" << '\n';
+ indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "return this." << field_name << " != null;" << endl;
+ indent(out) << "return this." << field_name << " != null;" << '\n';
} else {
- indent(out) << "return __isset_vector[" << isset_field_id(field) << "];" << endl;
+ indent(out) << "return __isset_vector[" << isset_field_id(field) << "];" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {"
- << endl;
+ << '\n';
indent_up();
if (type_can_be_null(type)) {
- indent(out) << "if (!value) {" << endl;
- indent(out) << " this." << field_name << " = null;" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "if (!value) {" << '\n';
+ indent(out) << " this." << field_name << " = null;" << '\n';
+ indent(out) << "}" << '\n';
} else {
- indent(out) << "__isset_vector[" << isset_field_id(field) << "] = value;" << endl;
+ indent(out) << "__isset_vector[" << isset_field_id(field) << "] = value;" << '\n';
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
}
@@ -1710,12 +1708,12 @@
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_tostring(ostream& out, t_struct* tstruct) {
- out << indent() << "public String toString() {" << endl;
+ out << indent() << "public String toString() {" << '\n';
indent_up();
out << indent() << "StringBuffer sb = new StringBuffer(\"" << tstruct->get_name() << "(\");"
- << endl;
- out << indent() << "boolean first = true;" << endl << endl;
+ << '\n';
+ out << indent() << "boolean first = true;" << '\n' << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -1723,46 +1721,46 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
if (could_be_unset) {
- indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
+ indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << '\n';
indent_up();
}
t_field* field = (*f_iter);
if (!first) {
- indent(out) << "if (!first) sb.append(\", \");" << endl;
+ indent(out) << "if (!first) sb.append(\", \");" << '\n';
}
- indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << endl;
+ indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << '\n';
bool can_be_null = type_can_be_null(field->get_type());
if (can_be_null) {
- indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << endl;
- indent(out) << " sb.append(\"null\");" << endl;
- indent(out) << "} else {" << endl;
+ indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << '\n';
+ indent(out) << " sb.append(\"null\");" << '\n';
+ indent(out) << "} else {" << '\n';
indent_up();
}
if (field->get_type()->is_binary()) {
- indent(out) << "TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl;
+ indent(out) << "TBaseHelper.toString(this." << field->get_name() << ", sb);" << '\n';
} else {
- indent(out) << "sb.append(this." << (*f_iter)->get_name() << ");" << endl;
+ indent(out) << "sb.append(this." << (*f_iter)->get_name() << ");" << '\n';
}
if (can_be_null) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- indent(out) << "first = false;" << endl;
+ indent(out) << "first = false;" << '\n';
if (could_be_unset) {
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
first = false;
}
- out << indent() << "sb.append(\")\");" << endl << indent() << "return sb.toString();" << endl;
+ out << indent() << "sb.append(\")\");" << '\n' << indent() << "return sb.toString();" << '\n';
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
/**
@@ -1821,7 +1819,7 @@
}
void t_javame_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) {
- out << endl;
+ out << '\n';
indent_up();
indent_up();
if (type->is_struct() || type->is_xception()) {
@@ -1871,7 +1869,7 @@
f_service_ << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
- f_service_ << "public class " << service_name_ << " {" << endl << endl;
+ f_service_ << "public class " << service_name_ << " {" << '\n' << '\n';
indent_up();
// Generate the three main parts of the service
@@ -1881,7 +1879,7 @@
generate_service_helpers(tservice);
indent_down();
- f_service_ << "}" << endl;
+ f_service_ << "}" << '\n';
f_service_.close();
}
@@ -1892,7 +1890,7 @@
*/
void t_javame_generator::generate_primitive_service_interface(t_service* tservice) {
f_service_ << indent() << "public interface Iface extends " << service_name_ << "Iface { }"
- << endl << endl;
+ << '\n' << '\n';
string f_interface_name = package_dir_ + "/" + service_name_ + "Iface.java";
ofstream_with_content_based_conditional_update f_iface;
@@ -1905,15 +1903,15 @@
f_iface << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
generate_java_doc(f_iface, tservice);
- f_iface << "public interface " << service_name_ << "Iface" << extends_iface << " {" << endl
- << endl;
+ f_iface << "public interface " << service_name_ << "Iface" << extends_iface << " {" << '\n'
+ << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_java_doc(f_iface, *f_iter);
- f_iface << " public " << function_signature(*f_iter) << ";" << endl << endl;
+ f_iface << " public " << function_signature(*f_iter) << ";" << '\n' << '\n';
}
- f_iface << "}" << endl << endl;
+ f_iface << "}" << '\n' << '\n';
}
/**
@@ -1930,16 +1928,16 @@
}
generate_java_doc(f_service_, tservice);
- f_service_ << indent() << "public interface Iface" << extends_iface << " {" << endl << endl;
+ f_service_ << indent() << "public interface Iface" << extends_iface << " {" << '\n' << '\n';
indent_up();
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_java_doc(f_service_, *f_iter);
- indent(f_service_) << "public " << function_signature(*f_iter) << ";" << endl << endl;
+ indent(f_service_) << "public " << function_signature(*f_iter) << ";" << '\n' << '\n';
}
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -1971,41 +1969,41 @@
}
indent(f_service_) << "public static class Client" << extends_client
- << " implements TServiceClient, Iface {" << endl;
+ << " implements TServiceClient, Iface {" << '\n';
indent_up();
- indent(f_service_) << "public Client(TProtocol prot)" << endl;
+ indent(f_service_) << "public Client(TProtocol prot)" << '\n';
scope_up(f_service_);
- indent(f_service_) << "this(prot, prot);" << endl;
+ indent(f_service_) << "this(prot, prot);" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
- indent(f_service_) << "public Client(TProtocol iprot, TProtocol oprot)" << endl;
+ indent(f_service_) << "public Client(TProtocol iprot, TProtocol oprot)" << '\n';
scope_up(f_service_);
if (extends.empty()) {
- f_service_ << indent() << "iprot_ = iprot;" << endl << indent() << "oprot_ = oprot;" << endl;
+ f_service_ << indent() << "iprot_ = iprot;" << '\n' << indent() << "oprot_ = oprot;" << '\n';
} else {
- f_service_ << indent() << "super(iprot, oprot);" << endl;
+ f_service_ << indent() << "super(iprot, oprot);" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
if (extends.empty()) {
- f_service_ << indent() << "protected TProtocol iprot_;" << endl << indent()
- << "protected TProtocol oprot_;" << endl << endl << indent()
- << "protected int seqid_;" << endl << endl;
+ f_service_ << indent() << "protected TProtocol iprot_;" << '\n' << indent()
+ << "protected TProtocol oprot_;" << '\n' << '\n' << indent()
+ << "protected int seqid_;" << '\n' << '\n';
- indent(f_service_) << "public TProtocol getInputProtocol()" << endl;
+ indent(f_service_) << "public TProtocol getInputProtocol()" << '\n';
scope_up(f_service_);
- indent(f_service_) << "return this.iprot_;" << endl;
+ indent(f_service_) << "return this.iprot_;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
- indent(f_service_) << "public TProtocol getOutputProtocol()" << endl;
+ indent(f_service_) << "public TProtocol getOutputProtocol()" << '\n';
scope_up(f_service_);
- indent(f_service_) << "return this.oprot_;" << endl;
+ indent(f_service_) << "return this.oprot_;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
// Generate client method implementations
@@ -2015,7 +2013,7 @@
string funname = (*f_iter)->get_name();
// Open function
- indent(f_service_) << "public " << function_signature(*f_iter) << endl;
+ indent(f_service_) << "public " << function_signature(*f_iter) << '\n';
scope_up(f_service_);
indent(f_service_) << "send_" << funname << "(";
@@ -2034,17 +2032,17 @@
}
f_service_ << (*fld_iter)->get_name();
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
- f_service_ << "recv_" << funname << "();" << endl;
+ f_service_ << "recv_" << funname << "();" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
t_function send_function(g_type_void,
string("send_") + (*f_iter)->get_name(),
@@ -2053,26 +2051,26 @@
string argsname = (*f_iter)->get_name() + "_args";
// Open function
- indent(f_service_) << "public " << function_signature(&send_function) << endl;
+ indent(f_service_) << "public " << function_signature(&send_function) << '\n';
scope_up(f_service_);
// Serialize the request
f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", "
<< ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
- << ", ++seqid_));" << endl << indent() << argsname << " args = new " << argsname
- << "();" << endl;
+ << ", ++seqid_));" << '\n' << indent() << argsname << " args = new " << argsname
+ << "();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "("
- << (*fld_iter)->get_name() << ");" << endl;
+ << (*fld_iter)->get_name() << ");" << '\n';
}
- f_service_ << indent() << "args.write(oprot_);" << endl << indent()
- << "oprot_.writeMessageEnd();" << endl << indent()
- << "oprot_.getTransport().flush();" << endl;
+ f_service_ << indent() << "args.write(oprot_);" << '\n' << indent()
+ << "oprot_.writeMessageEnd();" << '\n' << indent()
+ << "oprot_.getTransport().flush();" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
if (!(*f_iter)->is_oneway()) {
string resultname = (*f_iter)->get_name() + "_result";
@@ -2083,53 +2081,53 @@
&noargs,
(*f_iter)->get_xceptions());
// Open function
- indent(f_service_) << "public " << function_signature(&recv_function) << endl;
+ indent(f_service_) << "public " << function_signature(&recv_function) << '\n';
scope_up(f_service_);
- f_service_ << indent() << "TMessage msg = iprot_.readMessageBegin();" << endl << indent()
- << "if (msg.type == TMessageType.EXCEPTION) {" << endl << indent()
- << " TApplicationException x = TApplicationException.read(iprot_);" << endl
- << indent() << " iprot_.readMessageEnd();" << endl << indent() << " throw x;"
- << endl << indent() << "}" << endl << indent() << "if (msg.seqid != seqid_) {"
- << endl << indent()
+ f_service_ << indent() << "TMessage msg = iprot_.readMessageBegin();" << '\n' << indent()
+ << "if (msg.type == TMessageType.EXCEPTION) {" << '\n' << indent()
+ << " TApplicationException x = TApplicationException.read(iprot_);" << '\n'
+ << indent() << " iprot_.readMessageEnd();" << '\n' << indent() << " throw x;"
+ << '\n' << indent() << "}" << '\n' << indent() << "if (msg.seqid != seqid_) {"
+ << '\n' << indent()
<< " throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, \""
- << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl
- << indent() << "}" << endl << indent() << resultname << " result = new "
- << resultname << "();" << endl << indent() << "result.read(iprot_);" << endl
- << indent() << "iprot_.readMessageEnd();" << endl;
+ << (*f_iter)->get_name() << " failed: out of sequence response\");" << '\n'
+ << indent() << "}" << '\n' << indent() << resultname << " result = new "
+ << resultname << "();" << '\n' << indent() << "result.read(iprot_);" << '\n'
+ << indent() << "iprot_.readMessageEnd();" << '\n';
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl
- << indent() << " return result.success;" << endl << indent() << "}" << endl;
+ f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << '\n'
+ << indent() << " return result.success;" << '\n' << indent() << "}" << '\n';
}
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl
- << indent() << " throw result." << (*x_iter)->get_name() << ";" << endl
- << indent() << "}" << endl;
+ f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << '\n'
+ << indent() << " throw result." << (*x_iter)->get_name() << ";" << '\n'
+ << indent() << "}" << '\n';
}
// If you get here it's an exception, unless a void function
if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
} else {
f_service_ << indent()
<< "throw new TApplicationException(TApplicationException.MISSING_RESULT, \""
- << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+ << (*f_iter)->get_name() << " failed: unknown result\");" << '\n';
}
// Close function
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
}
}
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
}
/**
@@ -2152,66 +2150,66 @@
// Generate the header portion
indent(f_service_) << "public static class Processor" << extends_processor
- << " implements TProcessor {" << endl;
+ << " implements TProcessor {" << '\n';
indent_up();
- indent(f_service_) << "public Processor(Iface iface)" << endl;
+ indent(f_service_) << "public Processor(Iface iface)" << '\n';
scope_up(f_service_);
if (!extends.empty()) {
- f_service_ << indent() << "super(iface);" << endl;
+ f_service_ << indent() << "super(iface);" << '\n';
}
- f_service_ << indent() << "iface_ = iface;" << endl;
+ f_service_ << indent() << "iface_ = iface;" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
f_service_ << indent() << "processMap_.put(\"" << (*f_iter)->get_name() << "\", new "
- << (*f_iter)->get_name() << "());" << endl;
+ << (*f_iter)->get_name() << "());" << '\n';
}
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
if (extends.empty()) {
f_service_
- << indent() << "protected static interface ProcessFunction {" << endl << indent()
+ << indent() << "protected static interface ProcessFunction {" << '\n' << indent()
<< " public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;"
- << endl << indent() << "}" << endl << endl;
+ << '\n' << indent() << "}" << '\n' << '\n';
}
- f_service_ << indent() << "private Iface iface_;" << endl;
+ f_service_ << indent() << "private Iface iface_;" << '\n';
if (extends.empty()) {
- f_service_ << indent() << "protected final Hashtable processMap_ = new Hashtable();" << endl;
+ f_service_ << indent() << "protected final Hashtable processMap_ = new Hashtable();" << '\n';
}
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the server implementation
indent(f_service_) << "public boolean process(TProtocol iprot, TProtocol oprot) throws TException"
- << endl;
+ << '\n';
scope_up(f_service_);
- f_service_ << indent() << "TMessage msg = iprot.readMessageBegin();" << endl;
+ f_service_ << indent() << "TMessage msg = iprot.readMessageBegin();" << '\n';
// TODO(mcslee): validate message, was the seqid etc. legit?
f_service_
- << indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << endl
- << indent() << "if (fn == null) {" << endl << indent()
- << " TProtocolUtil.skip(iprot, TType.STRUCT);" << endl << indent()
- << " iprot.readMessageEnd();" << endl << indent()
+ << indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << '\n'
+ << indent() << "if (fn == null) {" << '\n' << indent()
+ << " TProtocolUtil.skip(iprot, TType.STRUCT);" << '\n' << indent()
+ << " iprot.readMessageEnd();" << '\n' << indent()
<< " TApplicationException x = new "
"TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: "
- "'\"+msg.name+\"'\");" << endl << indent()
+ "'\"+msg.name+\"'\");" << '\n' << indent()
<< " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));"
- << endl << indent() << " x.write(oprot);" << endl << indent() << " oprot.writeMessageEnd();"
- << endl << indent() << " oprot.getTransport().flush();" << endl << indent()
- << " return true;" << endl << indent() << "}" << endl << indent()
- << "fn.process(msg.seqid, iprot, oprot);" << endl;
+ << '\n' << indent() << " x.write(oprot);" << '\n' << indent() << " oprot.writeMessageEnd();"
+ << '\n' << indent() << " oprot.getTransport().flush();" << '\n' << indent()
+ << " return true;" << '\n' << indent() << "}" << '\n' << indent()
+ << "fn.process(msg.seqid, iprot, oprot);" << '\n';
- f_service_ << indent() << "return true;" << endl;
+ f_service_ << indent() << "return true;" << '\n';
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -2219,7 +2217,7 @@
}
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
/**
@@ -2257,36 +2255,36 @@
(void)tservice;
// Open class
indent(f_service_) << "private class " << tfunction->get_name() << " implements ProcessFunction {"
- << endl;
+ << '\n';
indent_up();
// Open function
indent(f_service_)
<< "public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException"
- << endl;
+ << '\n';
scope_up(f_service_);
string argsname = tfunction->get_name() + "_args";
string resultname = tfunction->get_name() + "_result";
- f_service_ << indent() << argsname << " args = new " << argsname << "();" << endl << indent()
- << "try {" << endl;
+ f_service_ << indent() << argsname << " args = new " << argsname << "();" << '\n' << indent()
+ << "try {" << '\n';
indent_up();
- f_service_ << indent() << "args.read(iprot);" << endl;
+ f_service_ << indent() << "args.read(iprot);" << '\n';
indent_down();
- f_service_ << indent() << "} catch (TProtocolException e) {" << endl;
+ f_service_ << indent() << "} catch (TProtocolException e) {" << '\n';
indent_up();
- f_service_ << indent() << "iprot.readMessageEnd();" << endl << indent()
+ f_service_ << indent() << "iprot.readMessageEnd();" << '\n' << indent()
<< "TApplicationException x = new "
"TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());"
- << endl << indent() << "oprot.writeMessageBegin(new TMessage(\""
- << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl << indent()
- << "x.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();" << endl
- << indent() << "oprot.getTransport().flush();" << endl << indent() << "return;"
- << endl;
+ << '\n' << indent() << "oprot.writeMessageBegin(new TMessage(\""
+ << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << '\n' << indent()
+ << "x.write(oprot);" << '\n' << indent() << "oprot.writeMessageEnd();" << '\n'
+ << indent() << "oprot.getTransport().flush();" << '\n' << indent() << "return;"
+ << '\n';
indent_down();
- f_service_ << indent() << "}" << endl;
- f_service_ << indent() << "iprot.readMessageEnd();" << endl;
+ f_service_ << indent() << "}" << '\n';
+ f_service_ << indent() << "iprot.readMessageEnd();" << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -2294,12 +2292,12 @@
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
- f_service_ << indent() << resultname << " result = new " << resultname << "();" << endl;
+ f_service_ << indent() << resultname << " result = new " << resultname << "();" << '\n';
}
// Try block for a function with exceptions
if (xceptions.size() > 0) {
- f_service_ << indent() << "try {" << endl;
+ f_service_ << indent() << "try {" << '\n';
indent_up();
}
@@ -2322,13 +2320,13 @@
}
f_service_ << "args." << (*f_iter)->get_name();
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
// Set isset on success field
if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()
&& !type_can_be_null(tfunction->get_returntype())) {
f_service_ << indent() << "result.set" << get_cap_name("success") << get_cap_name("isSet")
- << "(true);" << endl;
+ << "(true);" << '\n';
}
if (!tfunction->is_oneway() && xceptions.size() > 0) {
@@ -2336,54 +2334,54 @@
f_service_ << indent() << "}";
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " "
- << (*x_iter)->get_name() << ") {" << endl;
+ << (*x_iter)->get_name() << ") {" << '\n';
if (!tfunction->is_oneway()) {
indent_up();
f_service_ << indent() << "result." << (*x_iter)->get_name() << " = "
- << (*x_iter)->get_name() << ";" << endl;
+ << (*x_iter)->get_name() << ";" << '\n';
indent_down();
f_service_ << indent() << "}";
} else {
f_service_ << "}";
}
}
- f_service_ << " catch (Throwable th) {" << endl;
+ f_service_ << " catch (Throwable th) {" << '\n';
indent_up();
f_service_ << indent() << "TApplicationException x = new "
"TApplicationException(TApplicationException.INTERNAL_ERROR, "
"\"Internal error processing " << tfunction->get_name() << "\");"
- << endl << indent() << "oprot.writeMessageBegin(new TMessage(\""
- << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl
- << indent() << "x.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();"
- << endl << indent() << "oprot.getTransport().flush();" << endl << indent()
- << "return;" << endl;
+ << '\n' << indent() << "oprot.writeMessageBegin(new TMessage(\""
+ << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << '\n'
+ << indent() << "x.write(oprot);" << '\n' << indent() << "oprot.writeMessageEnd();"
+ << '\n' << indent() << "oprot.getTransport().flush();" << '\n' << indent()
+ << "return;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "}" << '\n';
}
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- f_service_ << indent() << "return;" << endl;
+ f_service_ << indent() << "return;" << '\n';
scope_down(f_service_);
// Close class
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
return;
}
f_service_ << indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.REPLY, seqid));" << endl << indent() << "result.write(oprot);"
- << endl << indent() << "oprot.writeMessageEnd();" << endl << indent()
- << "oprot.getTransport().flush();" << endl;
+ << "\", TMessageType.REPLY, seqid));" << '\n' << indent() << "result.write(oprot);"
+ << '\n' << indent() << "oprot.writeMessageEnd();" << '\n' << indent()
+ << "oprot.getTransport().flush();" << '\n';
// Close function
scope_down(f_service_);
- f_service_ << endl;
+ f_service_ << '\n';
// Close class
indent_down();
- f_service_ << indent() << "}" << endl << endl;
+ f_service_ << indent() << "}" << '\n' << '\n';
}
/**
@@ -2441,11 +2439,11 @@
default:
throw "compiler error: no Java name for base type " + t_base_type::t_base_name(tbase);
}
- out << endl;
+ out << '\n';
} else if (type->is_enum()) {
indent(out) << name << " = "
<< type_name(tfield->get_type(), true, false) + ".findByValue(iprot.readI32());"
- << endl;
+ << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
tfield->get_name().c_str(),
@@ -2459,8 +2457,8 @@
void t_javame_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
- out << indent() << prefix << " = new " << type_name(tstruct) << "();" << endl << indent()
- << prefix << ".read(iprot);" << endl;
+ out << indent() << prefix << " = new " << type_name(tstruct) << "();" << '\n' << indent()
+ << prefix << ".read(iprot);" << '\n';
}
/**
@@ -2483,23 +2481,23 @@
// Declare variables, read header
if (ttype->is_map()) {
- indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << endl;
+ indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << endl;
+ indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "TList " << obj << " = iprot.readListBegin();" << endl;
+ indent(out) << "TList " << obj << " = iprot.readListBegin();" << '\n';
}
indent(out) << prefix << " = new " << type_name(ttype, false, true)
// size the collection correctly
<< "(" << (ttype->is_list() ? "" : "2*") << obj << ".size"
- << ");" << endl;
+ << ");" << '\n';
// For loop iterates over elements
string i = tmp("_i");
indent(out) << "for (int " << i << " = 0; " << i << " < " << obj << ".size"
<< "; "
- << "++" << i << ")" << endl;
+ << "++" << i << ")" << '\n';
scope_up(out);
@@ -2515,11 +2513,11 @@
// Read container end
if (ttype->is_map()) {
- indent(out) << "iprot.readMapEnd();" << endl;
+ indent(out) << "iprot.readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "iprot.readSetEnd();" << endl;
+ indent(out) << "iprot.readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "iprot.readListEnd();" << endl;
+ indent(out) << "iprot.readListEnd();" << '\n';
}
scope_down(out);
@@ -2536,14 +2534,14 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- indent(out) << declare_field(&fkey) << endl;
- indent(out) << declare_field(&fval) << endl;
+ indent(out) << declare_field(&fkey) << '\n';
+ indent(out) << declare_field(&fval) << '\n';
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
indent(out) << prefix << ".put(" << box_type(tmap->get_key_type(), key) << ", "
- << box_type(tmap->get_val_type(), val) << ");" << endl;
+ << box_type(tmap->get_val_type(), val) << ");" << '\n';
}
/**
@@ -2555,12 +2553,12 @@
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
indent(out) << prefix << ".put(" << box_type(tset->get_elem_type(), elem) << ", "
- << box_type(tset->get_elem_type(), elem) << ");" << endl;
+ << box_type(tset->get_elem_type(), elem) << ");" << '\n';
}
/**
@@ -2572,11 +2570,11 @@
string elem = tmp("_elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << declare_field(&felem) << endl;
+ indent(out) << declare_field(&felem) << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".addElement(" << box_type(tlist->get_elem_type(), elem) << ");" << endl;
+ indent(out) << prefix << ".addElement(" << box_type(tlist->get_elem_type(), elem) << ");" << '\n';
}
/**
@@ -2598,7 +2596,7 @@
} else if (type->is_container()) {
generate_serialize_container(out, type, prefix + tfield->get_name());
} else if (type->is_enum()) {
- indent(out) << "oprot.writeI32(" << prefix + tfield->get_name() << ".getValue());" << endl;
+ indent(out) << "oprot.writeI32(" << prefix + tfield->get_name() << ".getValue());" << '\n';
} else if (type->is_base_type()) {
string name = prefix + tfield->get_name();
indent(out) << "oprot.";
@@ -2640,7 +2638,7 @@
} else if (type->is_enum()) {
out << "writeI32(" << name << ");";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
prefix.c_str(),
@@ -2659,7 +2657,7 @@
t_struct* tstruct,
string prefix) {
(void)tstruct;
- out << indent() << prefix << ".write(oprot);" << endl;
+ out << indent() << prefix << ".write(oprot);" << '\n';
}
/**
@@ -2674,14 +2672,14 @@
if (ttype->is_map()) {
indent(out) << "oprot.writeMapBegin(new TMap(" << type_to_enum(((t_map*)ttype)->get_key_type())
<< ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix
- << ".size()));" << endl;
+ << ".size()));" << '\n';
} else if (ttype->is_set()) {
indent(out) << "oprot.writeSetBegin(new TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type())
- << ", " << prefix << ".size()));" << endl;
+ << ", " << prefix << ".size()));" << '\n';
} else if (ttype->is_list()) {
indent(out) << "oprot.writeListBegin(new TList("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".size()));"
- << endl;
+ << '\n';
}
string iter = tmp("_iter");
@@ -2692,7 +2690,7 @@
<< ".hasMoreElements(); ) ";
scope_up(out);
indent(out) << key_type << " " << iter << " = (" << key_type << ")" << enumer
- << ".nextElement();" << endl;
+ << ".nextElement();" << '\n';
} else if (ttype->is_set()) {
string enumer = iter + "_enum";
string ele_type = type_name(((t_list*)ttype)->get_elem_type(), true);
@@ -2700,7 +2698,7 @@
<< ".hasMoreElements(); ) ";
scope_up(out);
indent(out) << ele_type << " " << iter << " = (" << ele_type << ")" << enumer
- << ".nextElement();" << endl;
+ << ".nextElement();" << '\n';
} else if (ttype->is_list()) {
string enumer = iter + "_enum";
indent(out) << "for (Enumeration " << enumer << " = " << prefix << ".elements(); " << enumer
@@ -2708,7 +2706,7 @@
scope_up(out);
string ele_type = type_name(((t_list*)ttype)->get_elem_type(), true);
indent(out) << ele_type << " " << iter << " = (" << ele_type << ")" << enumer
- << ".nextElement();" << endl;
+ << ".nextElement();" << '\n';
}
if (ttype->is_map()) {
@@ -2721,11 +2719,11 @@
scope_down(out);
if (ttype->is_map()) {
- indent(out) << "oprot.writeMapEnd();" << endl;
+ indent(out) << "oprot.writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "oprot.writeSetEnd();" << endl;
+ indent(out) << "oprot.writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "oprot.writeListEnd();" << endl;
+ indent(out) << "oprot.writeListEnd();" << '\n';
}
scope_down(out);
@@ -3056,7 +3054,7 @@
source_name = source_name_p1 + "." + source_name_p2;
indent(out) << type_name(type, true, false) << " " << result_name << " = new "
- << type_name(container, false, true) << "();" << endl;
+ << type_name(container, false, true) << "();" << '\n';
std::string iterator_element_name = source_name_p1 + "_element";
std::string enumeration_name = source_name_p1 + "_enum";
@@ -3067,19 +3065,19 @@
t_type* val_type = ((t_map*)container)->get_val_type();
indent(out) << "for (Enumeration " << enumeration_name << " = " << source_name << ".keys(); "
- << enumeration_name << ".hasMoreElements(); ) {" << endl;
+ << enumeration_name << ".hasMoreElements(); ) {" << '\n';
indent_up();
- out << endl;
+ out << '\n';
indent(out) << type_name(key_type, true, false) << " " << iterator_element_name << "_key = ("
<< type_name(key_type, true, false) << ")" << enumeration_name << ".nextElement();"
- << endl;
+ << '\n';
indent(out) << type_name(val_type, true, false) << " " << iterator_element_name << "_value = ("
<< type_name(val_type, true, false) << ")" << source_name << ".get("
- << iterator_element_name << "_key);" << endl;
+ << iterator_element_name << "_key);" << '\n';
- out << endl;
+ out << '\n';
if (key_type->is_container()) {
generate_deep_copy_container(out,
@@ -3093,10 +3091,10 @@
iterator_element_name + "_key",
result_element_name + "_key",
key_type);
- out << ";" << endl;
+ out << ";" << '\n';
}
- out << endl;
+ out << '\n';
if (val_type->is_container()) {
generate_deep_copy_container(out,
@@ -3110,16 +3108,16 @@
iterator_element_name + "_value",
result_element_name + "_value",
val_type);
- out << ";" << endl;
+ out << ";" << '\n';
}
- out << endl;
+ out << '\n';
indent(out) << result_name << ".put(" << result_element_name << "_key, " << result_element_name
- << "_value);" << endl;
+ << "_value);" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
} else {
t_type* elem_type;
@@ -3131,19 +3129,19 @@
}
indent(out) << "for (Enumeration " << enumeration_name << " = " << source_name
- << ".elements(); " << enumeration_name << ".hasMoreElements(); ) {" << endl;
+ << ".elements(); " << enumeration_name << ".hasMoreElements(); ) {" << '\n';
indent_up();
indent(out) << type_name(elem_type, true, false) << " " << iterator_element_name << " = ("
<< type_name(elem_type, true, false) << ")" << enumeration_name << ".nextElement();"
- << endl;
+ << '\n';
if (elem_type->is_container()) {
// recursive deep copy
generate_deep_copy_container(out, iterator_element_name, "", result_element_name, elem_type);
if (elem_type->is_list()) {
- indent(out) << result_name << ".addElement(" << result_element_name << ");" << endl;
+ indent(out) << result_name << ".addElement(" << result_element_name << ");" << '\n';
} else {
indent(out) << result_name << ".put(" << result_element_name << ", " << result_element_name
- << ");" << endl;
+ << ");" << '\n';
}
} else {
// iterative copy
@@ -3153,22 +3151,22 @@
iterator_element_name,
"temp_binary_element",
elem_type);
- out << ";" << endl;
+ out << ";" << '\n';
if (elem_type->is_list()) {
- indent(out) << result_name << ".addElement(temp_binary_element);" << endl;
+ indent(out) << result_name << ".addElement(temp_binary_element);" << '\n';
} else {
- indent(out) << result_name << ".put(temp_binary_element, temp_binary_element);" << endl;
+ indent(out) << result_name << ".put(temp_binary_element, temp_binary_element);" << '\n';
}
} else {
indent(out) << result_name << ".addElement(";
generate_deep_copy_non_container(out, iterator_element_name, result_name, elem_type);
- out << ");" << endl;
+ out << ");" << '\n';
}
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
@@ -3179,7 +3177,7 @@
if (type->is_base_type() || type->is_enum() || type->is_typedef()) {
// binary fields need to be copied with System.arraycopy
if (type->is_binary()) {
- out << "new byte[" << source_name << ".length];" << endl;
+ out << "new byte[" << source_name << ".length];" << '\n';
indent(out) << "System.arraycopy(" << source_name << ", 0, " << dest_name << ", 0, "
<< source_name << ".length)";
}
@@ -3206,7 +3204,7 @@
void t_javame_generator::generate_isset_set(ostream& out, t_field* field) {
if (!type_can_be_null(field->get_type())) {
indent(out) << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet") << "(true);"
- << endl;
+ << '\n';
}
}
@@ -3221,7 +3219,7 @@
void t_javame_generator::generate_struct_desc(ostream& out, t_struct* tstruct) {
indent(out) << "private static final TStruct STRUCT_DESC = new TStruct(\"" << tstruct->get_name()
- << "\");" << endl;
+ << "\");" << '\n';
}
void t_javame_generator::generate_field_descs(ostream& out, t_struct* tstruct) {
@@ -3232,7 +3230,7 @@
indent(out) << "private static final TField " << constant_name((*m_iter)->get_name())
<< "_FIELD_DESC = new TField(\"" << (*m_iter)->get_name() << "\", "
<< type_to_enum((*m_iter)->get_type()) << ", "
- << "(short)" << (*m_iter)->get_key() << ");" << endl;
+ << "(short)" << (*m_iter)->get_key() << ");" << '\n';
}
}
@@ -3249,7 +3247,7 @@
}
void t_javame_generator::generate_java_struct_clear(std::ostream& out, t_struct* tstruct) {
- indent(out) << "public void clear() {" << endl;
+ indent(out) << "public void clear() {" << '\n';
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
@@ -3266,24 +3264,24 @@
true);
} else {
if (type_can_be_null(t)) {
- indent(out) << "this." << (*m_iter)->get_name() << " = null;" << endl;
+ indent(out) << "this." << (*m_iter)->get_name() << " = null;" << '\n';
} else {
// must be a base type
// means it also needs to be explicitly unset
indent(out) << "set" << get_cap_name((*m_iter)->get_name()) << get_cap_name("isSet")
- << "(false);" << endl;
+ << "(false);" << '\n';
switch (((t_base_type*)t)->get_base()) {
case t_base_type::TYPE_I8:
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
case t_base_type::TYPE_I64:
- indent(out) << "this." << (*m_iter)->get_name() << " = 0;" << endl;
+ indent(out) << "this." << (*m_iter)->get_name() << " = 0;" << '\n';
break;
case t_base_type::TYPE_DOUBLE:
- indent(out) << "this." << (*m_iter)->get_name() << " = 0.0;" << endl;
+ indent(out) << "this." << (*m_iter)->get_name() << " = 0.0;" << '\n';
break;
case t_base_type::TYPE_BOOL:
- indent(out) << "this." << (*m_iter)->get_name() << " = false;" << endl;
+ indent(out) << "this." << (*m_iter)->get_name() << " = false;" << '\n';
break;
default: // prevent gcc compiler warning
break;
@@ -3293,7 +3291,7 @@
}
indent_down();
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
std::string t_javame_generator::display_name() const {
diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc
index 0e8da59..dfc334b 100644
--- a/compiler/cpp/src/thrift/generate/t_js_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc
@@ -43,7 +43,6 @@
using std::unordered_map;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
static const string episode_file_name = "thrift.js.episode";
// largest consecutive integer representable by a double (2 ^ 53 - 1)
static const int64_t max_safe_integer = 0x1fffffffffffff;
@@ -339,17 +338,17 @@
* @return string The documentation
*/
string ts_print_doc(t_doc* tdoc) {
- string result = endl;
+ string result = "\n";
if (tdoc->has_doc()) {
std::stringstream doc(tdoc->get_doc());
string item;
- result += ts_indent() + "/**" + endl;
+ result += ts_indent() + "/**" + "\n";
while (std::getline(doc, item)) {
- result += ts_indent() + " * " + item + endl;
+ result += ts_indent() + " * " + item + "\n";
}
- result += ts_indent() + " */" + endl;
+ result += ts_indent() + " */" + "\n";
}
return result;
}
@@ -457,7 +456,7 @@
f_types_.open(f_types_name.c_str());
if (gen_episode_file_) {
const auto types_module = program_->get_name() + "_types";
- f_episode_ << types_module << ":" << thrift_package_output_directory_ << "/" << types_module << endl;
+ f_episode_ << types_module << ":" << thrift_package_output_directory_ << "/" << types_module << '\n';
}
if (gen_ts_) {
@@ -469,17 +468,17 @@
f_types_ << autogen_comment();
if ((gen_node_ || gen_es6_) && no_ns_) {
- f_types_ << "\"use strict\";" << endl << endl;
+ f_types_ << "\"use strict\";" << '\n' << '\n';
}
- f_types_ << js_includes() << endl << render_includes() << endl;
+ f_types_ << js_includes() << '\n' << render_includes() << '\n';
if (gen_ts_) {
- f_types_ts_ << autogen_comment() << ts_includes() << endl << render_ts_includes() << endl;
+ f_types_ts_ << autogen_comment() << ts_includes() << '\n' << render_ts_includes() << '\n';
}
if (gen_node_) {
- f_types_ << js_const_type_ << "ttypes = module.exports = {};" << endl;
+ f_types_ << js_const_type_ << "ttypes = module.exports = {};" << '\n';
}
string pns;
@@ -490,11 +489,11 @@
if (ns_pieces.size() > 0) {
for (size_t i = 0; i < ns_pieces.size(); ++i) {
pns += ((i == 0) ? "" : ".") + ns_pieces[i];
- f_types_ << "if (typeof " << pns << " === 'undefined') {" << endl;
- f_types_ << " " << pns << " = {};" << endl;
- f_types_ << "}" << endl;
- f_types_ << "" << "if (typeof module !== 'undefined' && module.exports) {" << endl;
- f_types_ << " module.exports." << pns << " = " << pns << ";" << endl << "}" << endl;
+ f_types_ << "if (typeof " << pns << " === 'undefined') {" << '\n';
+ f_types_ << " " << pns << " = {};" << '\n';
+ f_types_ << "}" << '\n';
+ f_types_ << "" << "if (typeof module !== 'undefined' && module.exports) {" << '\n';
+ f_types_ << " module.exports." << pns << " = " << pns << ";" << '\n' << "}" << '\n';
}
if (gen_ts_) {
ts_module_ = pns;
@@ -639,11 +638,11 @@
* @param tenum The enumeration
*/
void t_js_generator::generate_enum(t_enum* tenum) {
- f_types_ << js_type_namespace(tenum->get_program()) << tenum->get_name() << " = {" << endl;
+ f_types_ << js_type_namespace(tenum->get_program()) << tenum->get_name() << " = {" << '\n';
if (gen_ts_) {
f_types_ts_ << ts_print_doc(tenum) << ts_indent() << ts_declare() << "enum "
- << tenum->get_name() << " {" << endl;
+ << tenum->get_name() << " {" << '\n';
}
indent_up();
@@ -653,23 +652,23 @@
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
if (gen_ts_) {
- f_types_ts_ << ts_indent() << (*c_iter)->get_name() << " = " << value << "," << endl;
+ f_types_ts_ << ts_indent() << (*c_iter)->get_name() << " = " << value << "," << '\n';
// add 'value: key' in addition to 'key: value' for TypeScript enums
- f_types_ << indent() << "'" << value << "' : '" << (*c_iter)->get_name() << "'," << endl;
+ f_types_ << indent() << "'" << value << "' : '" << (*c_iter)->get_name() << "'," << '\n';
}
f_types_ << indent() << "'" << (*c_iter)->get_name() << "' : " << value;
if (c_iter != constants.end() - 1) {
f_types_ << ",";
}
- f_types_ << endl;
+ f_types_ << '\n';
}
indent_down();
- f_types_ << "};" << endl;
+ f_types_ << "};" << '\n';
if (gen_ts_) {
- f_types_ts_ << ts_indent() << "}" << endl;
+ f_types_ts_ << ts_indent() << "}" << '\n';
}
}
@@ -682,11 +681,11 @@
t_const_value* value = tconst->get_value();
f_types_ << js_type_namespace(program_) << name << " = ";
- f_types_ << render_const_value(type, value) << ";" << endl;
+ f_types_ << render_const_value(type, value) << ";" << '\n';
if (gen_ts_) {
f_types_ts_ << ts_print_doc(tconst) << ts_indent() << ts_declare() << js_const_type_ << name << ": "
- << ts_get_type(type) << ";" << endl;
+ << ts_get_type(type) << ";" << '\n';
}
}
@@ -755,24 +754,24 @@
}
if (v_iter != val.begin())
out << ",";
- out << endl << indent() << render_const_value(g_type_string, v_iter->first);
+ out << '\n' << indent() << render_const_value(g_type_string, v_iter->first);
out << " : ";
out << render_const_value(field_type, v_iter->second);
}
indent_down();
- out << endl << indent() << "})";
+ out << '\n' << indent() << "})";
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
if (v_iter != val.begin())
- out << "," << endl;
+ out << "," << '\n';
if (ktype->is_base_type() && ((t_base_type*)get_true_type(ktype))->get_base() == t_base_type::TYPE_I64){
out << indent() << "\"" << v_iter->first->get_integer() << "\"";
@@ -784,7 +783,7 @@
out << render_const_value(vtype, v_iter->second);
}
indent_down();
- out << endl << indent() << "}";
+ out << '\n' << indent() << "}";
} else if (type->is_list() || type->is_set()) {
t_type* etype;
if (type->is_list()) {
@@ -866,27 +865,27 @@
if (gen_ts_) {
f_types_ts_ << ts_print_doc(tstruct) << ts_indent() << ts_declare() << "class "
<< tstruct->get_name() << (is_exception ? " extends Thrift.TException" : "")
- << " {" << endl;
+ << " {" << '\n';
}
} else {
out << js_namespace(tstruct->get_program()) << tstruct->get_name();
if (gen_ts_) {
f_types_ts_ << ts_print_doc(tstruct) << ts_indent() << ts_declare() << "class "
<< tstruct->get_name() << (is_exception ? " extends Thrift.TException" : "")
- << " {" << endl;
+ << " {" << '\n';
}
}
if (gen_es6_) {
if (gen_node_ && is_exception) {
- out << " = class extends Thrift.TException {" << endl;
+ out << " = class extends Thrift.TException {" << '\n';
} else {
- out << " = class {" << endl;
+ out << " = class {" << '\n';
}
indent_up();
- indent(out) << "constructor(args) {" << endl;
+ indent(out) << "constructor(args) {" << '\n';
} else {
- out << " = function(args) {" << endl;
+ out << " = function(args) {" << '\n';
}
indent_up();
@@ -894,13 +893,13 @@
// Call super() method on inherited Error class
if (gen_node_ && is_exception) {
if (gen_es6_) {
- indent(out) << "super(args);" << endl;
+ indent(out) << "super(args);" << '\n';
} else {
indent(out) << "Thrift.TException.call(this, \"" << js_namespace(tstruct->get_program())
- << tstruct->get_name() << "\");" << endl;
+ << tstruct->get_name() << "\");" << '\n';
}
out << indent() << "this.name = \"" << js_namespace(tstruct->get_program())
- << tstruct->get_name() << "\";" << endl;
+ << tstruct->get_name() << "\";" << '\n';
}
// members with arguments
@@ -909,9 +908,9 @@
t_type* t = get_true_type((*m_iter)->get_type());
if ((*m_iter)->get_value() != nullptr && !(t->is_struct() || t->is_xception())) {
dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
- out << indent() << "this." << (*m_iter)->get_name() << " = " << dval << ";" << endl;
+ out << indent() << "this." << (*m_iter)->get_name() << " = " << dval << ";" << '\n';
} else {
- out << indent() << dval << ";" << endl;
+ out << indent() << dval << ";" << '\n';
}
if (gen_ts_) {
string ts_access = gen_node_ ? "public " : "";
@@ -919,11 +918,11 @@
// Special case. Exceptions derive from Error, and error has a non optional message field.
// Ignore the optional flag in this case, otherwise we will generate a incompatible field
- // in the eyes of typescript.
+ // in the eyes of typescript.
string optional_flag = is_exception && member_name == "message" ? "" : ts_get_req(*m_iter);
-
+
f_types_ts_ << ts_indent() << ts_access << member_name << optional_flag << ": "
- << ts_get_type((*m_iter)->get_type()) << ";" << endl;
+ << ts_get_type((*m_iter)->get_type()) << ";" << '\n';
}
}
@@ -934,7 +933,7 @@
t_type* t = get_true_type((*m_iter)->get_type());
if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) {
indent(out) << "this." << (*m_iter)->get_name() << " = "
- << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
+ << render_const_value(t, (*m_iter)->get_value()) << ";" << '\n';
}
}
@@ -943,28 +942,28 @@
t_type* t = get_true_type((*m_iter)->get_type());
if (t->is_xception()) {
out << indent() << "if (args instanceof " << js_type_namespace(t->get_program())
- << t->get_name() << ") {" << endl << indent() << indent() << "this."
- << (*m_iter)->get_name() << " = args;" << endl << indent() << indent() << "return;"
- << endl << indent() << "}" << endl;
+ << t->get_name() << ") {" << '\n' << indent() << indent() << "this."
+ << (*m_iter)->get_name() << " = args;" << '\n' << indent() << indent() << "return;"
+ << '\n' << indent() << "}" << '\n';
}
}
- indent(out) << "if (args) {" << endl;
+ indent(out) << "if (args) {" << '\n';
indent_up();
if (gen_ts_) {
- f_types_ts_ << endl << ts_indent() << "constructor(args?: { ";
+ f_types_ts_ << '\n' << ts_indent() << "constructor(args?: { ";
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- indent(out) << "if (args." << (*m_iter)->get_name() << " !== undefined && args." << (*m_iter)->get_name() << " !== null) {" << endl;
+ indent(out) << "if (args." << (*m_iter)->get_name() << " !== undefined && args." << (*m_iter)->get_name() << " !== null) {" << '\n';
indent_up();
indent(out) << "this." << (*m_iter)->get_name();
if (t->is_struct()) {
out << (" = new " + js_type_namespace(t->get_program()) + t->get_name() +
"(args."+(*m_iter)->get_name() +");");
- out << endl;
+ out << '\n';
} else if (t->is_container()) {
t_type* etype = get_contained_type(t);
string copyFunc = t->is_map() ? "Thrift.copyMap" : "Thrift.copyList";
@@ -993,53 +992,53 @@
out << (" = " + copyFunc + "(args." + (*m_iter)->get_name() +
", [" + type_list + "]);");
- out << endl;
+ out << '\n';
} else {
- out << " = args." << (*m_iter)->get_name() << ";" << endl;
+ out << " = args." << (*m_iter)->get_name() << ";" << '\n';
}
indent_down();
if (!(*m_iter)->get_req()) {
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent(out)
<< " throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, "
- "'Required field " << (*m_iter)->get_name() << " is unset!');" << endl;
+ "'Required field " << (*m_iter)->get_name() << " is unset!');" << '\n';
}
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
if (gen_ts_) {
f_types_ts_ << (*m_iter)->get_name() << ts_get_req(*m_iter) << ": "
<< ts_get_type((*m_iter)->get_type()) << "; ";
}
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (gen_ts_) {
- f_types_ts_ << "});" << endl;
+ f_types_ts_ << "});" << '\n';
}
}
// Done with constructor
indent_down();
if (gen_es6_) {
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else {
- indent(out) << "};" << endl;
+ indent(out) << "};" << '\n';
}
if (gen_ts_) {
- f_types_ts_ << ts_indent() << "}" << endl;
+ f_types_ts_ << ts_indent() << "}" << '\n';
}
if (!gen_es6_) {
if (is_exception) {
out << "Thrift.inherits(" << js_namespace(tstruct->get_program()) << tstruct->get_name()
- << ", Thrift.TException);" << endl;
+ << ", Thrift.TException);" << '\n';
out << js_namespace(tstruct->get_program()) << tstruct->get_name() << ".prototype.name = '"
- << tstruct->get_name() << "';" << endl;
+ << tstruct->get_name() << "';" << '\n';
} else {
// init prototype manually if we aren't using es6
out << js_namespace(tstruct->get_program()) << tstruct->get_name() << ".prototype = {};"
- << endl;
+ << '\n';
}
}
@@ -1050,7 +1049,7 @@
// Close out the class definition
if (gen_es6_) {
indent_down();
- indent(out) << "};" << endl;
+ indent(out) << "};" << '\n';
}
}
@@ -1062,84 +1061,84 @@
vector<t_field*>::const_iterator f_iter;
if (gen_es6_) {
- indent(out) << "read (input) {" << endl;
+ indent(out) << "read (input) {" << '\n';
} else {
indent(out) << js_namespace(tstruct->get_program()) << tstruct->get_name()
- << ".prototype.read = function(input) {" << endl;
+ << ".prototype.read = function(input) {" << '\n';
}
indent_up();
- indent(out) << "input.readStructBegin();" << endl;
+ indent(out) << "input.readStructBegin();" << '\n';
// Loop over reading in fields
- indent(out) << "while (true) {" << endl;
+ indent(out) << "while (true) {" << '\n';
indent_up();
- indent(out) << js_const_type_ << "ret = input.readFieldBegin();" << endl;
- indent(out) << js_const_type_ << "ftype = ret.ftype;" << endl;
+ indent(out) << js_const_type_ << "ret = input.readFieldBegin();" << '\n';
+ indent(out) << js_const_type_ << "ftype = ret.ftype;" << '\n';
if (!fields.empty()) {
- indent(out) << js_const_type_ << "fid = ret.fid;" << endl;
+ indent(out) << js_const_type_ << "fid = ret.fid;" << '\n';
}
// Check for field STOP marker and break
- indent(out) << "if (ftype == Thrift.Type.STOP) {" << endl;
+ indent(out) << "if (ftype == Thrift.Type.STOP) {" << '\n';
indent_up();
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
if (!fields.empty()) {
// Switch statement on the field we are reading
- indent(out) << "switch (fid) {" << endl;
+ indent(out) << "switch (fid) {" << '\n';
indent_up();
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
- indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+ indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n';
+ indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n';
indent_up();
generate_deserialize_field(out, *f_iter, "this.");
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
- indent(out) << " input.skip(ftype);" << endl;
+ indent(out) << " input.skip(ftype);" << '\n';
- out << indent() << "}" << endl << indent() << "break;" << endl;
+ out << indent() << "}" << '\n' << indent() << "break;" << '\n';
}
if (fields.size() == 1) {
// pseudo case to make jslint happy
- indent(out) << "case 0:" << endl;
- indent(out) << " input.skip(ftype);" << endl;
- indent(out) << " break;" << endl;
+ indent(out) << "case 0:" << '\n';
+ indent(out) << " input.skip(ftype);" << '\n';
+ indent(out) << " break;" << '\n';
}
// In the default case we skip the field
- indent(out) << "default:" << endl;
- indent(out) << " input.skip(ftype);" << endl;
+ indent(out) << "default:" << '\n';
+ indent(out) << " input.skip(ftype);" << '\n';
scope_down(out);
} else {
- indent(out) << "input.skip(ftype);" << endl;
+ indent(out) << "input.skip(ftype);" << '\n';
}
- indent(out) << "input.readFieldEnd();" << endl;
+ indent(out) << "input.readFieldEnd();" << '\n';
scope_down(out);
- indent(out) << "input.readStructEnd();" << endl;
+ indent(out) << "input.readStructEnd();" << '\n';
- indent(out) << "return;" << endl;
+ indent(out) << "return;" << '\n';
indent_down();
if (gen_es6_) {
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
} else {
- indent(out) << "};" << endl << endl;
+ indent(out) << "};" << '\n' << '\n';
}
}
@@ -1152,44 +1151,44 @@
vector<t_field*>::const_iterator f_iter;
if (gen_es6_) {
- indent(out) << "write (output) {" << endl;
+ indent(out) << "write (output) {" << '\n';
} else {
indent(out) << js_namespace(tstruct->get_program()) << tstruct->get_name()
- << ".prototype.write = function(output) {" << endl;
+ << ".prototype.write = function(output) {" << '\n';
}
indent_up();
- indent(out) << "output.writeStructBegin('" << name << "');" << endl;
+ indent(out) << "output.writeStructBegin('" << name << "');" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
out << indent() << "if (this." << (*f_iter)->get_name() << " !== null && this."
- << (*f_iter)->get_name() << " !== undefined) {" << endl;
+ << (*f_iter)->get_name() << " !== undefined) {" << '\n';
indent_up();
indent(out) << "output.writeFieldBegin("
<< "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
- << ", " << (*f_iter)->get_key() << ");" << endl;
+ << ", " << (*f_iter)->get_key() << ");" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "this.");
- indent(out) << "output.writeFieldEnd();" << endl;
+ indent(out) << "output.writeFieldEnd();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << indent() << "output.writeFieldStop();" << endl << indent() << "output.writeStructEnd();"
- << endl;
+ out << indent() << "output.writeFieldStop();" << '\n' << indent() << "output.writeStructEnd();"
+ << '\n';
- out << indent() << "return;" << endl;
+ out << indent() << "return;" << '\n';
indent_down();
if (gen_es6_) {
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
} else {
- out << indent() << "};" << endl << endl;
+ out << indent() << "};" << '\n' << '\n';
}
}
@@ -1202,7 +1201,7 @@
string f_service_name = get_out_dir() + service_name_ + ".js";
f_service_.open(f_service_name.c_str());
if (gen_episode_file_) {
- f_episode_ << service_name_ << ":" << thrift_package_output_directory_ << "/" << service_name_ << endl;
+ f_episode_ << service_name_ << ":" << thrift_package_output_directory_ << "/" << service_name_ << '\n';
}
if (gen_ts_) {
@@ -1213,58 +1212,58 @@
f_service_ << autogen_comment();
if ((gen_node_ || gen_es6_) && no_ns_) {
- f_service_ << "\"use strict\";" << endl << endl;
+ f_service_ << "\"use strict\";" << '\n' << '\n';
}
- f_service_ << js_includes() << endl << render_includes() << endl;
+ f_service_ << js_includes() << '\n' << render_includes() << '\n';
if (gen_ts_) {
if (tservice->get_extends() != nullptr) {
f_service_ts_ << "/// <reference path=\"" << tservice->get_extends()->get_name()
- << ".d.ts\" />" << endl;
+ << ".d.ts\" />" << '\n';
}
- f_service_ts_ << autogen_comment() << endl << ts_includes() << endl << render_ts_includes() << endl;
+ f_service_ts_ << autogen_comment() << '\n' << ts_includes() << '\n' << render_ts_includes() << '\n';
if (gen_node_) {
- f_service_ts_ << "import ttypes = require('./" + program_->get_name() + "_types');" << endl;
+ f_service_ts_ << "import ttypes = require('./" + program_->get_name() + "_types');" << '\n';
// Generate type aliases
// enum
vector<t_enum*> const& enums = program_->get_enums();
vector<t_enum*>::const_iterator e_iter;
for (e_iter = enums.begin(); e_iter != enums.end(); ++e_iter) {
f_service_ts_ << "import " << (*e_iter)->get_name() << " = ttypes."
- << js_namespace(program_) << (*e_iter)->get_name() << endl;
+ << js_namespace(program_) << (*e_iter)->get_name() << '\n';
}
// const
vector<t_const*> const& consts = program_->get_consts();
vector<t_const*>::const_iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
f_service_ts_ << "import " << (*c_iter)->get_name() << " = ttypes."
- << js_namespace(program_) << (*c_iter)->get_name() << endl;
+ << js_namespace(program_) << (*c_iter)->get_name() << '\n';
}
// exception
vector<t_struct*> const& exceptions = program_->get_xceptions();
vector<t_struct*>::const_iterator x_iter;
for (x_iter = exceptions.begin(); x_iter != exceptions.end(); ++x_iter) {
f_service_ts_ << "import " << (*x_iter)->get_name() << " = ttypes."
- << js_namespace(program_) << (*x_iter)->get_name() << endl;
+ << js_namespace(program_) << (*x_iter)->get_name() << '\n';
}
// structs
vector<t_struct*> const& structs = program_->get_structs();
vector<t_struct*>::const_iterator s_iter;
for (s_iter = structs.begin(); s_iter != structs.end(); ++s_iter) {
f_service_ts_ << "import " << (*s_iter)->get_name() << " = ttypes."
- << js_namespace(program_) << (*s_iter)->get_name() << endl;
+ << js_namespace(program_) << (*s_iter)->get_name() << '\n';
}
} else {
- f_service_ts_ << "import { " << program_->get_name() << " } from \"./" << program_->get_name() << "_types\";" << endl << endl;
+ f_service_ts_ << "import { " << program_->get_name() << " } from \"./" << program_->get_name() << "_types\";" << '\n' << '\n';
}
if (!ts_module_.empty()) {
if (gen_node_) {
f_service_ts_ << "declare module " << ts_module_ << " {";
} else {
- f_service_ts_ << "declare module \"./" << program_->get_name() << "_types\" {" << endl;
+ f_service_ts_ << "declare module \"./" << program_->get_name() << "_types\" {" << '\n';
indent_up();
- f_service_ts_ << ts_indent() << "module " << program_->get_name() << " {" << endl;
+ f_service_ts_ << ts_indent() << "module " << program_->get_name() << " {" << '\n';
indent_up();
}
}
@@ -1273,17 +1272,17 @@
if (gen_node_) {
if (tservice->get_extends() != nullptr) {
f_service_ << js_const_type_ << tservice->get_extends()->get_name() << " = require('./"
- << tservice->get_extends()->get_name() << "');" << endl << js_const_type_
+ << tservice->get_extends()->get_name() << "');" << '\n' << js_const_type_
<< tservice->get_extends()->get_name()
- << "Client = " << tservice->get_extends()->get_name() << ".Client;" << endl
+ << "Client = " << tservice->get_extends()->get_name() << ".Client;" << '\n'
<< js_const_type_ << tservice->get_extends()->get_name()
- << "Processor = " << tservice->get_extends()->get_name() << ".Processor;" << endl;
+ << "Processor = " << tservice->get_extends()->get_name() << ".Processor;" << '\n';
f_service_ts_ << "import " << tservice->get_extends()->get_name() << " = require('./"
- << tservice->get_extends()->get_name() << "');" << endl;
+ << tservice->get_extends()->get_name() << "');" << '\n';
}
- f_service_ << js_const_type_ << "ttypes = require('./" + program_->get_name() + "_types');" << endl;
+ f_service_ << js_const_type_ << "ttypes = require('./" + program_->get_name() + "_types');" << '\n';
}
generate_service_helpers(tservice);
@@ -1298,11 +1297,11 @@
if (gen_ts_) {
if (!ts_module_.empty()) {
if (gen_node_) {
- f_service_ts_ << "}" << endl;
+ f_service_ts_ << "}" << '\n';
} else {
indent_down();
- f_service_ts_ << ts_indent() << "}" << endl;
- f_service_ts_ << "}" << endl;
+ f_service_ts_ << ts_indent() << "}" << '\n';
+ f_service_ts_ << "}" << '\n';
}
}
f_service_ts_.close();
@@ -1322,18 +1321,18 @@
string prefix = has_js_namespace(tservice->get_program()) ? js_namespace(tservice->get_program()) : js_const_type_;
f_service_ << prefix << service_name_ << "Processor = " << "exports.Processor";
if (gen_ts_) {
- f_service_ts_ << endl << "declare class Processor ";
+ f_service_ts_ << '\n' << "declare class Processor ";
if (tservice->get_extends() != nullptr) {
f_service_ts_ << "extends " << tservice->get_extends()->get_name() << ".Processor ";
}
- f_service_ts_ << "{" << endl;
+ f_service_ts_ << "{" << '\n';
indent_up();
if(tservice->get_extends() == nullptr) {
- f_service_ts_ << ts_indent() << "private _handler: object;" << endl << endl;
+ f_service_ts_ << ts_indent() << "private _handler: object;" << '\n' << '\n';
}
- f_service_ts_ << ts_indent() << "constructor(handler: object);" << endl;
- f_service_ts_ << ts_indent() << "process(input: thrift.TProtocol, output: thrift.TProtocol): void;" << endl;
+ f_service_ts_ << ts_indent() << "constructor(handler: object);" << '\n';
+ f_service_ts_ << ts_indent() << "process(input: thrift.TProtocol, output: thrift.TProtocol): void;" << '\n';
indent_down();
}
} else {
@@ -1346,65 +1345,65 @@
// ES6 Constructor
if (gen_es6_) {
if (is_subclass_service) {
- f_service_ << " = class " << service_name_ << "Processor extends " << tservice->get_extends()->get_name() << "Processor {" << endl;
+ f_service_ << " = class " << service_name_ << "Processor extends " << tservice->get_extends()->get_name() << "Processor {" << '\n';
} else {
- f_service_ << " = class " << service_name_ << "Processor {" << endl;
+ f_service_ << " = class " << service_name_ << "Processor {" << '\n';
}
indent_up();
- indent(f_service_) << "constructor(handler) {" << endl;
+ indent(f_service_) << "constructor(handler) {" << '\n';
} else {
- f_service_ << " = function(handler) {" << endl;
+ f_service_ << " = function(handler) {" << '\n';
}
indent_up();
if (gen_es6_ && is_subclass_service) {
- indent(f_service_) << "super(handler);" << endl;
+ indent(f_service_) << "super(handler);" << '\n';
}
- indent(f_service_) << "this._handler = handler;" << endl;
+ indent(f_service_) << "this._handler = handler;" << '\n';
indent_down();
// Done with constructor
if (gen_es6_) {
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
}
// ES5 service inheritance
if (!gen_es6_ && is_subclass_service) {
indent(f_service_) << "Thrift.inherits(" << js_namespace(tservice->get_program())
<< service_name_ << "Processor, " << tservice->get_extends()->get_name()
- << "Processor);" << endl;
+ << "Processor);" << '\n';
}
// Generate the server implementation
if (gen_es6_) {
- indent(f_service_) << "process (input, output) {" << endl;
+ indent(f_service_) << "process (input, output) {" << '\n';
} else {
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
- << "Processor.prototype.process = function(input, output) {" << endl;
+ << "Processor.prototype.process = function(input, output) {" << '\n';
}
indent_up();
- indent(f_service_) << js_const_type_ << "r = input.readMessageBegin();" << endl << indent()
- << "if (this['process_' + r.fname]) {" << endl << indent()
- << " return this['process_' + r.fname].call(this, r.rseqid, input, output);" << endl
- << indent() << "} else {" << endl << indent() << " input.skip(Thrift.Type.STRUCT);"
- << endl << indent() << " input.readMessageEnd();" << endl << indent()
+ indent(f_service_) << js_const_type_ << "r = input.readMessageBegin();" << '\n' << indent()
+ << "if (this['process_' + r.fname]) {" << '\n' << indent()
+ << " return this['process_' + r.fname].call(this, r.rseqid, input, output);" << '\n'
+ << indent() << "} else {" << '\n' << indent() << " input.skip(Thrift.Type.STRUCT);"
+ << '\n' << indent() << " input.readMessageEnd();" << '\n' << indent()
<< " " << js_const_type_ << "x = new "
"Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, "
- "'Unknown function ' + r.fname);" << endl << indent()
+ "'Unknown function ' + r.fname);" << '\n' << indent()
<< " output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);"
- << endl << indent() << " x.write(output);" << endl << indent()
- << " output.writeMessageEnd();" << endl << indent() << " output.flush();" << endl
- << indent() << "}" << endl;
+ << '\n' << indent() << " x.write(output);" << '\n' << indent()
+ << " output.writeMessageEnd();" << '\n' << indent() << " output.flush();" << '\n'
+ << indent() << "}" << '\n';
indent_down();
if (gen_es6_) {
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
}
// Generate the process subfunctions
@@ -1415,10 +1414,10 @@
// Close off the processor class definition
if (gen_es6_) {
indent_down();
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
}
if (gen_node_ && gen_ts_) {
- f_service_ts_ << "}" << endl;
+ f_service_ts_ << "}" << '\n';
}
}
@@ -1429,15 +1428,15 @@
*/
void t_js_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
if (gen_es6_) {
- indent(f_service_) << "process_" + tfunction->get_name() + " (seqid, input, output) {" << endl;
+ indent(f_service_) << "process_" + tfunction->get_name() + " (seqid, input, output) {" << '\n';
} else {
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
<< "Processor.prototype.process_" + tfunction->get_name()
- + " = function(seqid, input, output) {" << endl;
+ + " = function(seqid, input, output) {" << '\n';
}
if (gen_ts_) {
indent_up();
- f_service_ts_ << ts_indent() << "process_" << tfunction->get_name() << "(seqid: number, input: thrift.TProtocol, output: thrift.TProtocol): void;" << endl;
+ f_service_ts_ << ts_indent() << "process_" << tfunction->get_name() << "(seqid: number, input: thrift.TProtocol, output: thrift.TProtocol): void;" << '\n';
indent_down();
}
@@ -1447,8 +1446,8 @@
string resultname = js_namespace(program_) + service_name_ + "_" + tfunction->get_name()
+ "_result";
- indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << endl << indent()
- << "args.read(input);" << endl << indent() << "input.readMessageEnd();" << endl;
+ indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << '\n' << indent()
+ << "args.read(input);" << '\n' << indent() << "input.readMessageEnd();" << '\n';
// Generate the function call
t_struct* arg_struct = tfunction->get_arglist();
@@ -1469,58 +1468,58 @@
f_service_ << "args." << (*f_iter)->get_name();
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
indent_down();
if (gen_es6_) {
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
}
return;
}
// Promise style invocation
indent(f_service_) << "if (this._handler." << tfunction->get_name()
- << ".length === " << fields.size() << ") {" << endl;
+ << ".length === " << fields.size() << ") {" << '\n';
indent_up();
if (gen_es6_) {
- indent(f_service_) << "new Promise((resolve) => resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << endl;
+ indent(f_service_) << "new Promise((resolve) => resolve(this._handler." << tfunction->get_name() << ".bind(this._handler)(" << '\n';
} else {
string maybeComma = (fields.size() > 0 ? "," : "");
indent(f_service_) << "Q.fcall(this._handler." << tfunction->get_name() << ".bind(this._handler)"
- << maybeComma << endl;
+ << maybeComma << '\n';
}
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
string maybeComma = (f_iter != fields.end() - 1 ? "," : "");
- indent(f_service_) << "args." << (*f_iter)->get_name() << maybeComma << endl;
+ indent(f_service_) << "args." << (*f_iter)->get_name() << maybeComma << '\n';
}
indent_down();
if (gen_es6_) {
- indent(f_service_) << "))).then(result => {" << endl;
+ indent(f_service_) << "))).then(result => {" << '\n';
} else {
- indent(f_service_) << ").then(function(result) {" << endl;
+ indent(f_service_) << ").then(function(result) {" << '\n';
}
indent_up();
- f_service_ << indent() << js_const_type_ << "result_obj = new " << resultname << "({success: result});" << endl
+ f_service_ << indent() << js_const_type_ << "result_obj = new " << resultname << "({success: result});" << '\n'
<< indent() << "output.writeMessageBegin(\"" << tfunction->get_name()
- << "\", Thrift.MessageType.REPLY, seqid);" << endl << indent()
- << "result_obj.write(output);" << endl << indent() << "output.writeMessageEnd();" << endl
- << indent() << "output.flush();" << endl;
+ << "\", Thrift.MessageType.REPLY, seqid);" << '\n' << indent()
+ << "result_obj.write(output);" << '\n' << indent() << "output.writeMessageEnd();" << '\n'
+ << indent() << "output.flush();" << '\n';
indent_down();
if (gen_es6_) {
- indent(f_service_) << "}).catch(err => {" << endl;
+ indent(f_service_) << "}).catch(err => {" << '\n';
} else {
- indent(f_service_) << "}).catch(function (err) {" << endl;
+ indent(f_service_) << "}).catch(function (err) {" << '\n';
}
indent_up();
- indent(f_service_) << js_let_type_ << "result;" << endl;
+ indent(f_service_) << js_let_type_ << "result;" << '\n';
bool has_exception = false;
t_struct* exceptions = tfunction->get_xceptions();
@@ -1542,36 +1541,36 @@
}
if (has_exception) {
- f_service_ << ") {" << endl;
+ f_service_ << ") {" << '\n';
indent_up();
- f_service_ << indent() << "result = new " << resultname << "(err);" << endl << indent()
+ f_service_ << indent() << "result = new " << resultname << "(err);" << '\n' << indent()
<< "output.writeMessageBegin(\"" << tfunction->get_name()
- << "\", Thrift.MessageType.REPLY, seqid);" << endl;
+ << "\", Thrift.MessageType.REPLY, seqid);" << '\n';
indent_down();
- indent(f_service_) << "} else {" << endl;
+ indent(f_service_) << "} else {" << '\n';
indent_up();
}
f_service_ << indent() << "result = new "
"Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN,"
- " err.message);" << endl << indent() << "output.writeMessageBegin(\""
- << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << endl;
+ " err.message);" << '\n' << indent() << "output.writeMessageBegin(\""
+ << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << '\n';
if (has_exception) {
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
}
- f_service_ << indent() << "result.write(output);" << endl << indent()
- << "output.writeMessageEnd();" << endl << indent() << "output.flush();" << endl;
+ f_service_ << indent() << "result.write(output);" << '\n' << indent()
+ << "output.writeMessageEnd();" << '\n' << indent() << "output.flush();" << '\n';
indent_down();
- indent(f_service_) << "});" << endl;
+ indent(f_service_) << "});" << '\n';
indent_down();
// End promise style invocation
// Callback style invocation
- indent(f_service_) << "} else {" << endl;
+ indent(f_service_) << "} else {" << '\n';
indent_up();
indent(f_service_) << "this._handler." << tfunction->get_name() << "(";
@@ -1580,12 +1579,12 @@
}
if (gen_es6_) {
- f_service_ << "(err, result) => {" << endl;
+ f_service_ << "(err, result) => {" << '\n';
} else {
- f_service_ << "function (err, result) {" << endl;
+ f_service_ << "function (err, result) {" << '\n';
}
indent_up();
- indent(f_service_) << js_let_type_ << "result_obj;" << endl;
+ indent(f_service_) << js_let_type_ << "result_obj;" << '\n';
indent(f_service_) << "if ((err === null || typeof err === 'undefined')";
if (has_exception) {
@@ -1597,35 +1596,35 @@
}
}
}
- f_service_ << ") {" << endl;
+ f_service_ << ") {" << '\n';
indent_up();
f_service_ << indent() << "result_obj = new " << resultname
- << "((err !== null || typeof err === 'undefined') ? err : {success: result});" << endl << indent()
+ << "((err !== null || typeof err === 'undefined') ? err : {success: result});" << '\n' << indent()
<< "output.writeMessageBegin(\"" << tfunction->get_name()
- << "\", Thrift.MessageType.REPLY, seqid);" << endl;
+ << "\", Thrift.MessageType.REPLY, seqid);" << '\n';
indent_down();
- indent(f_service_) << "} else {" << endl;
+ indent(f_service_) << "} else {" << '\n';
indent_up();
f_service_ << indent() << "result_obj = new "
"Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN,"
- " err.message);" << endl << indent() << "output.writeMessageBegin(\""
- << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << endl;
+ " err.message);" << '\n' << indent() << "output.writeMessageBegin(\""
+ << tfunction->get_name() << "\", Thrift.MessageType.EXCEPTION, seqid);" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl << indent() << "result_obj.write(output);" << endl << indent()
- << "output.writeMessageEnd();" << endl << indent() << "output.flush();" << endl;
+ f_service_ << indent() << "}" << '\n' << indent() << "result_obj.write(output);" << '\n' << indent()
+ << "output.writeMessageEnd();" << '\n' << indent() << "output.flush();" << '\n';
indent_down();
- indent(f_service_) << "});" << endl;
+ indent(f_service_) << "});" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
// End callback style invocation
indent_down();
if (gen_es6_) {
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
}
}
@@ -1642,7 +1641,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- f_service_ << "//HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+ f_service_ << "//HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
@@ -1712,7 +1711,7 @@
if (tservice->get_extends() != nullptr) {
f_service_ts_ << "extends " << tservice->get_extends()->get_name() << ".Client ";
}
- f_service_ts_ << "{" << endl;
+ f_service_ts_ << "{" << '\n';
}
} else {
f_service_ << js_namespace(tservice->get_program()) << service_name_
@@ -1723,7 +1722,7 @@
if (is_subclass_service) {
f_service_ts_ << "extends " << tservice->get_extends()->get_name() << "Client ";
}
- f_service_ts_ << "{" << endl;
+ f_service_ts_ << "{" << '\n';
}
}
@@ -1732,21 +1731,21 @@
if (is_subclass_service) {
f_service_ << " = class " << service_name_ << "Client extends " << js_namespace(tservice->get_extends()->get_program())
- << tservice->get_extends()->get_name() << "Client {" << endl;
+ << tservice->get_extends()->get_name() << "Client {" << '\n';
} else {
- f_service_ << " = class " << service_name_ << "Client {" << endl;
+ f_service_ << " = class " << service_name_ << "Client {" << '\n';
}
indent_up();
if (gen_node_) {
- indent(f_service_) << "constructor(output, pClass) {" << endl;
+ indent(f_service_) << "constructor(output, pClass) {" << '\n';
} else {
- indent(f_service_) << "constructor(input, output) {" << endl;
+ indent(f_service_) << "constructor(input, output) {" << '\n';
}
} else {
if (gen_node_) {
- f_service_ << " = function(output, pClass) {" << endl;
+ f_service_ << " = function(output, pClass) {" << '\n';
} else {
- f_service_ << " = function(input, output) {" << endl;
+ f_service_ << " = function(input, output) {" << '\n';
}
}
@@ -1754,65 +1753,65 @@
if (gen_node_) {
if (gen_es6_ && is_subclass_service) {
- indent(f_service_) << "super(output, pClass);" << endl;
+ indent(f_service_) << "super(output, pClass);" << '\n';
}
- indent(f_service_) << "this.output = output;" << endl;
- indent(f_service_) << "this.pClass = pClass;" << endl;
- indent(f_service_) << "this._seqid = 0;" << endl;
- indent(f_service_) << "this._reqs = {};" << endl;
+ indent(f_service_) << "this.output = output;" << '\n';
+ indent(f_service_) << "this.pClass = pClass;" << '\n';
+ indent(f_service_) << "this._seqid = 0;" << '\n';
+ indent(f_service_) << "this._reqs = {};" << '\n';
if (gen_ts_) {
if(!is_subclass_service) {
- f_service_ts_ << ts_indent() << "private output: thrift.TTransport;" << endl
- << ts_indent() << "private pClass: thrift.TProtocol;" << endl
- << ts_indent() << "private _seqid: number;" << endl
- << endl;
+ f_service_ts_ << ts_indent() << "private output: thrift.TTransport;" << '\n'
+ << ts_indent() << "private pClass: thrift.TProtocol;" << '\n'
+ << ts_indent() << "private _seqid: number;" << '\n'
+ << '\n';
}
f_service_ts_ << ts_indent() << "constructor(output: thrift.TTransport, pClass: { new(trans: thrift.TTransport): thrift.TProtocol });"
- << endl;
+ << '\n';
}
} else {
- indent(f_service_) << "this.input = input;" << endl;
- indent(f_service_) << "this.output = (!output) ? input : output;" << endl;
- indent(f_service_) << "this.seqid = 0;" << endl;
+ indent(f_service_) << "this.input = input;" << '\n';
+ indent(f_service_) << "this.output = (!output) ? input : output;" << '\n';
+ indent(f_service_) << "this.seqid = 0;" << '\n';
if (gen_ts_) {
- f_service_ts_ << ts_indent() << "input: Thrift.TJSONProtocol;" << endl << ts_indent()
- << "output: Thrift.TJSONProtocol;" << endl << ts_indent() << "seqid: number;"
- << endl << endl << ts_indent()
+ f_service_ts_ << ts_indent() << "input: Thrift.TJSONProtocol;" << '\n' << ts_indent()
+ << "output: Thrift.TJSONProtocol;" << '\n' << ts_indent() << "seqid: number;"
+ << '\n' << '\n' << ts_indent()
<< "constructor(input: Thrift.TJSONProtocol, output?: Thrift.TJSONProtocol);"
- << endl;
+ << '\n';
}
}
indent_down();
if (gen_es6_) {
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
if (is_subclass_service) {
indent(f_service_) << "Thrift.inherits(" << js_namespace(tservice->get_program())
<< service_name_ << "Client, "
<< js_namespace(tservice->get_extends()->get_program())
- << tservice->get_extends()->get_name() << "Client);" << endl;
+ << tservice->get_extends()->get_name() << "Client);" << '\n';
} else {
// init prototype
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
- << "Client.prototype = {};" << endl;
+ << "Client.prototype = {};" << '\n';
}
}
// utils for multiplexed services
if (gen_node_) {
if (gen_es6_) {
- indent(f_service_) << "seqid () { return this._seqid; }" << endl;
- indent(f_service_) << "new_seqid () { return this._seqid += 1; }" << endl;
+ indent(f_service_) << "seqid () { return this._seqid; }" << '\n';
+ indent(f_service_) << "new_seqid () { return this._seqid += 1; }" << '\n';
} else {
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
- << "Client.prototype.seqid = function() { return this._seqid; };" << endl
+ << "Client.prototype.seqid = function() { return this._seqid; };" << '\n'
<< js_namespace(tservice->get_program()) << service_name_
<< "Client.prototype.new_seqid = function() { return this._seqid += 1; };"
- << endl;
+ << '\n';
}
}
@@ -1827,144 +1826,144 @@
string arglist = argument_list(arg_struct);
// Open function
- f_service_ << endl;
+ f_service_ << '\n';
if (gen_es6_) {
- indent(f_service_) << funname << " (" << arglist << ") {" << endl;
+ indent(f_service_) << funname << " (" << arglist << ") {" << '\n';
} else {
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype."
- << function_signature(*f_iter, "", !gen_es6_) << " {" << endl;
+ << function_signature(*f_iter, "", !gen_es6_) << " {" << '\n';
}
indent_up();
if (gen_ts_) {
// function definition without callback
- f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, false) << endl;
+ f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, false) << '\n';
if (!gen_es6_) {
// overload with callback
- f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << endl;
+ f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << '\n';
} else {
// overload with callback
- f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << endl;
+ f_service_ts_ << ts_print_doc(*f_iter) << ts_indent() << ts_function_signature(*f_iter, true) << '\n';
}
}
if (gen_es6_ && gen_node_) {
- indent(f_service_) << "this._seqid = this.new_seqid();" << endl;
- indent(f_service_) << js_const_type_ << "self = this;" << endl << indent()
- << "return new Promise((resolve, reject) => {" << endl;
+ indent(f_service_) << "this._seqid = this.new_seqid();" << '\n';
+ indent(f_service_) << js_const_type_ << "self = this;" << '\n' << indent()
+ << "return new Promise((resolve, reject) => {" << '\n';
indent_up();
- indent(f_service_) << "self._reqs[self.seqid()] = (error, result) => {" << endl;
+ indent(f_service_) << "self._reqs[self.seqid()] = (error, result) => {" << '\n';
indent_up();
- indent(f_service_) << "return error ? reject(error) : resolve(result);" << endl;
+ indent(f_service_) << "return error ? reject(error) : resolve(result);" << '\n';
indent_down();
- indent(f_service_) << "};" << endl;
- indent(f_service_) << "self.send_" << funname << "(" << arglist << ");" << endl;
+ indent(f_service_) << "};" << '\n';
+ indent(f_service_) << "self.send_" << funname << "(" << arglist << ");" << '\n';
indent_down();
- indent(f_service_) << "});" << endl;
+ indent(f_service_) << "});" << '\n';
} else if (gen_node_) { // Node.js output ./gen-nodejs
- f_service_ << indent() << "this._seqid = this.new_seqid();" << endl << indent()
- << "if (callback === undefined) {" << endl;
+ f_service_ << indent() << "this._seqid = this.new_seqid();" << '\n' << indent()
+ << "if (callback === undefined) {" << '\n';
indent_up();
- f_service_ << indent() << js_const_type_ << "_defer = Q.defer();" << endl << indent()
- << "this._reqs[this.seqid()] = function(error, result) {" << endl;
+ f_service_ << indent() << js_const_type_ << "_defer = Q.defer();" << '\n' << indent()
+ << "this._reqs[this.seqid()] = function(error, result) {" << '\n';
indent_up();
- indent(f_service_) << "if (error) {" << endl;
+ indent(f_service_) << "if (error) {" << '\n';
indent_up();
- indent(f_service_) << "_defer.reject(error);" << endl;
+ indent(f_service_) << "_defer.reject(error);" << '\n';
indent_down();
- indent(f_service_) << "} else {" << endl;
+ indent(f_service_) << "} else {" << '\n';
indent_up();
- indent(f_service_) << "_defer.resolve(result);" << endl;
+ indent(f_service_) << "_defer.resolve(result);" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
indent_down();
- indent(f_service_) << "};" << endl;
- f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << endl
- << indent() << "return _defer.promise;" << endl;
+ indent(f_service_) << "};" << '\n';
+ f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << '\n'
+ << indent() << "return _defer.promise;" << '\n';
indent_down();
- indent(f_service_) << "} else {" << endl;
+ indent(f_service_) << "} else {" << '\n';
indent_up();
- f_service_ << indent() << "this._reqs[this.seqid()] = callback;" << endl << indent()
- << "this.send_" << funname << "(" << arglist << ");" << endl;
+ f_service_ << indent() << "this._reqs[this.seqid()] = callback;" << '\n' << indent()
+ << "this.send_" << funname << "(" << arglist << ");" << '\n';
indent_down();
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else if (gen_es6_) {
- f_service_ << indent() << js_const_type_ << "self = this;" << endl << indent()
- << "return new Promise((resolve, reject) => {" << endl;
+ f_service_ << indent() << js_const_type_ << "self = this;" << '\n' << indent()
+ << "return new Promise((resolve, reject) => {" << '\n';
indent_up();
f_service_ << indent() << "self.send_" << funname << "(" << arglist
- << (arglist.empty() ? "" : ", ") << "(error, result) => {" << endl;
+ << (arglist.empty() ? "" : ", ") << "(error, result) => {" << '\n';
indent_up();
- indent(f_service_) << "return error ? reject(error) : resolve(result);" << endl;
+ indent(f_service_) << "return error ? reject(error) : resolve(result);" << '\n';
indent_down();
- f_service_ << indent() << "});" << endl;
+ f_service_ << indent() << "});" << '\n';
indent_down();
- f_service_ << indent() << "});" << endl;
+ f_service_ << indent() << "});" << '\n';
} else if (gen_jquery_) { // jQuery output ./gen-js
- f_service_ << indent() << "if (callback === undefined) {" << endl;
+ f_service_ << indent() << "if (callback === undefined) {" << '\n';
indent_up();
- f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << endl;
+ f_service_ << indent() << "this.send_" << funname << "(" << arglist << ");" << '\n';
if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
- f_service_ << "this.recv_" << funname << "();" << endl;
+ f_service_ << "this.recv_" << funname << "();" << '\n';
}
indent_down();
- f_service_ << indent() << "} else {" << endl;
+ f_service_ << indent() << "} else {" << '\n';
indent_up();
f_service_ << indent() << js_const_type_ << "postData = this.send_" << funname << "(" << arglist
- << (arglist.empty() ? "" : ", ") << "true);" << endl;
- f_service_ << indent() << "return this.output.getTransport()" << endl;
+ << (arglist.empty() ? "" : ", ") << "true);" << '\n';
+ f_service_ << indent() << "return this.output.getTransport()" << '\n';
indent_up();
f_service_ << indent() << ".jqRequest(this, postData, arguments, this.recv_" << funname
- << ");" << endl;
+ << ");" << '\n';
indent_down();
indent_down();
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "}" << '\n';
} else { // Standard JavaScript ./gen-js
f_service_ << indent() << "this.send_" << funname << "(" << arglist
- << (arglist.empty() ? "" : ", ") << "callback); " << endl;
+ << (arglist.empty() ? "" : ", ") << "callback); " << '\n';
if (!(*f_iter)->is_oneway()) {
- f_service_ << indent() << "if (!callback) {" << endl;
+ f_service_ << indent() << "if (!callback) {" << '\n';
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << " return ";
}
- f_service_ << "this.recv_" << funname << "();" << endl;
- f_service_ << indent() << "}" << endl;
+ f_service_ << "this.recv_" << funname << "();" << '\n';
+ f_service_ << indent() << "}" << '\n';
}
}
indent_down();
if (gen_es6_) {
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
} else {
- indent(f_service_) << "};" << endl << endl;
+ indent(f_service_) << "};" << '\n' << '\n';
}
// Send function
if (gen_es6_) {
if (gen_node_) {
- indent(f_service_) << "send_" << funname << " (" << arglist << ") {" << endl;
+ indent(f_service_) << "send_" << funname << " (" << arglist << ") {" << '\n';
} else {
// ES6 js still uses callbacks here. Should refactor this to promise style later..
- indent(f_service_) << "send_" << funname << " (" << argument_list(arg_struct, true) << ") {" << endl;
+ indent(f_service_) << "send_" << funname << " (" << argument_list(arg_struct, true) << ") {" << '\n';
}
} else {
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_ << "Client.prototype.send_"
- << function_signature(*f_iter, "", !gen_node_) << " {" << endl;
+ << function_signature(*f_iter, "", !gen_node_) << " {" << '\n';
}
indent_up();
std::string outputVar;
if (gen_node_) {
- f_service_ << indent() << js_const_type_ << "output = new this.pClass(this.output);" << endl;
+ f_service_ << indent() << js_const_type_ << "output = new this.pClass(this.output);" << '\n';
outputVar = "output";
} else {
outputVar = "this.output";
@@ -1980,127 +1979,127 @@
// It is possible that a method argument is named "params", we need to ensure the locally
// generated identifier "params" is uniquely named
std::string params_identifier = this->next_identifier_name(fields, "params");
- f_service_ << indent() << js_const_type_ << params_identifier << " = {" << endl;
+ f_service_ << indent() << js_const_type_ << params_identifier << " = {" << '\n';
indent_up();
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
indent(f_service_) << (*fld_iter)->get_name() << ": " << (*fld_iter)->get_name();
if (fld_iter != fields.end()-1) {
- f_service_ << "," << endl;
+ f_service_ << "," << '\n';
} else {
- f_service_ << endl;
+ f_service_ << '\n';
}
}
indent_down();
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
// NOTE: "args" is a reserved keyword, so no need to generate a unique identifier
- indent(f_service_) << js_const_type_ << "args = new " << argsname << "(" << params_identifier << ");" << endl;
+ indent(f_service_) << js_const_type_ << "args = new " << argsname << "(" << params_identifier << ");" << '\n';
} else {
- indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << endl;
+ indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << '\n';
}
// Serialize the request header within try/catch
- indent(f_service_) << "try {" << endl;
+ indent(f_service_) << "try {" << '\n';
indent_up();
if (gen_node_) {
f_service_ << indent() << outputVar << ".writeMessageBegin('" << (*f_iter)->get_name()
- << "', " << messageType << ", this.seqid());" << endl;
+ << "', " << messageType << ", this.seqid());" << '\n';
} else {
f_service_ << indent() << outputVar << ".writeMessageBegin('" << (*f_iter)->get_name()
- << "', " << messageType << ", this.seqid);" << endl;
+ << "', " << messageType << ", this.seqid);" << '\n';
}
// Write to the stream
- f_service_ << indent() << "args.write(" << outputVar << ");" << endl << indent() << outputVar
- << ".writeMessageEnd();" << endl;
+ f_service_ << indent() << "args.write(" << outputVar << ");" << '\n' << indent() << outputVar
+ << ".writeMessageEnd();" << '\n';
if (gen_node_) {
if((*f_iter)->is_oneway()) {
- f_service_ << indent() << "this.output.flush();" << endl;
- f_service_ << indent() << js_const_type_ << "callback = this._reqs[this.seqid()] || function() {};" << endl;
- f_service_ << indent() << "delete this._reqs[this.seqid()];" << endl;
- f_service_ << indent() << "callback(null);" << endl;
+ f_service_ << indent() << "this.output.flush();" << '\n';
+ f_service_ << indent() << js_const_type_ << "callback = this._reqs[this.seqid()] || function() {};" << '\n';
+ f_service_ << indent() << "delete this._reqs[this.seqid()];" << '\n';
+ f_service_ << indent() << "callback(null);" << '\n';
} else {
- f_service_ << indent() << "return this.output.flush();" << endl;
+ f_service_ << indent() << "return this.output.flush();" << '\n';
}
} else {
if (gen_jquery_) {
- f_service_ << indent() << "return this.output.getTransport().flush(callback);" << endl;
+ f_service_ << indent() << "return this.output.getTransport().flush(callback);" << '\n';
} else if (gen_es6_) {
- f_service_ << indent() << js_const_type_ << "self = this;" << endl;
+ f_service_ << indent() << js_const_type_ << "self = this;" << '\n';
if((*f_iter)->is_oneway()) {
- f_service_ << indent() << "this.output.getTransport().flush(true, null);" << endl;
- f_service_ << indent() << "callback();" << endl;
+ f_service_ << indent() << "this.output.getTransport().flush(true, null);" << '\n';
+ f_service_ << indent() << "callback();" << '\n';
} else {
- f_service_ << indent() << "this.output.getTransport().flush(true, () => {" << endl;
+ f_service_ << indent() << "this.output.getTransport().flush(true, () => {" << '\n';
indent_up();
- f_service_ << indent() << js_let_type_ << "error = null, result = null;" << endl;
- f_service_ << indent() << "try {" << endl;
- f_service_ << indent() << " result = self.recv_" << funname << "();" << endl;
- f_service_ << indent() << "} catch (e) {" << endl;
- f_service_ << indent() << " error = e;" << endl;
- f_service_ << indent() << "}" << endl;
- f_service_ << indent() << "callback(error, result);" << endl;
+ f_service_ << indent() << js_let_type_ << "error = null, result = null;" << '\n';
+ f_service_ << indent() << "try {" << '\n';
+ f_service_ << indent() << " result = self.recv_" << funname << "();" << '\n';
+ f_service_ << indent() << "} catch (e) {" << '\n';
+ f_service_ << indent() << " error = e;" << '\n';
+ f_service_ << indent() << "}" << '\n';
+ f_service_ << indent() << "callback(error, result);" << '\n';
indent_down();
- f_service_ << indent() << "});" << endl;
+ f_service_ << indent() << "});" << '\n';
}
} else {
- f_service_ << indent() << "if (callback) {" << endl;
+ f_service_ << indent() << "if (callback) {" << '\n';
indent_up();
if((*f_iter)->is_oneway()) {
- f_service_ << indent() << "this.output.getTransport().flush(true, null);" << endl;
- f_service_ << indent() << "callback();" << endl;
+ f_service_ << indent() << "this.output.getTransport().flush(true, null);" << '\n';
+ f_service_ << indent() << "callback();" << '\n';
} else {
- f_service_ << indent() << js_const_type_ << "self = this;" << endl;
- f_service_ << indent() << "this.output.getTransport().flush(true, function() {" << endl;
+ f_service_ << indent() << js_const_type_ << "self = this;" << '\n';
+ f_service_ << indent() << "this.output.getTransport().flush(true, function() {" << '\n';
indent_up();
- f_service_ << indent() << js_let_type_ << "result = null;" << endl;
- f_service_ << indent() << "try {" << endl;
- f_service_ << indent() << " result = self.recv_" << funname << "();" << endl;
- f_service_ << indent() << "} catch (e) {" << endl;
- f_service_ << indent() << " result = e;" << endl;
- f_service_ << indent() << "}" << endl;
- f_service_ << indent() << "callback(result);" << endl;
+ f_service_ << indent() << js_let_type_ << "result = null;" << '\n';
+ f_service_ << indent() << "try {" << '\n';
+ f_service_ << indent() << " result = self.recv_" << funname << "();" << '\n';
+ f_service_ << indent() << "} catch (e) {" << '\n';
+ f_service_ << indent() << " result = e;" << '\n';
+ f_service_ << indent() << "}" << '\n';
+ f_service_ << indent() << "callback(result);" << '\n';
indent_down();
- f_service_ << indent() << "});" << endl;
+ f_service_ << indent() << "});" << '\n';
}
indent_down();
- f_service_ << indent() << "} else {" << endl;
- f_service_ << indent() << " return this.output.getTransport().flush();" << endl;
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "} else {" << '\n';
+ f_service_ << indent() << " return this.output.getTransport().flush();" << '\n';
+ f_service_ << indent() << "}" << '\n';
}
}
indent_down();
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "}" << '\n';
// Reset the transport and delete registered callback if there was a serialization error
- f_service_ << indent() << "catch (e) {" << endl;
+ f_service_ << indent() << "catch (e) {" << '\n';
indent_up();
if (gen_node_) {
- f_service_ << indent() << "delete this._reqs[this.seqid()];" << endl;
- f_service_ << indent() << "if (typeof " << outputVar << ".reset === 'function') {" << endl;
- f_service_ << indent() << " " << outputVar << ".reset();" << endl;
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "delete this._reqs[this.seqid()];" << '\n';
+ f_service_ << indent() << "if (typeof " << outputVar << ".reset === 'function') {" << '\n';
+ f_service_ << indent() << " " << outputVar << ".reset();" << '\n';
+ f_service_ << indent() << "}" << '\n';
} else {
- f_service_ << indent() << "if (typeof " << outputVar << ".getTransport().reset === 'function') {" << endl;
- f_service_ << indent() << " " << outputVar << ".getTransport().reset();" << endl;
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "if (typeof " << outputVar << ".getTransport().reset === 'function') {" << '\n';
+ f_service_ << indent() << " " << outputVar << ".getTransport().reset();" << '\n';
+ f_service_ << indent() << "}" << '\n';
}
- f_service_ << indent() << "throw e;" << endl;
+ f_service_ << indent() << "throw e;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "}" << '\n';
indent_down();
// Close send function
if (gen_es6_) {
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
}
// Receive function
@@ -2108,19 +2107,19 @@
std::string resultname = js_namespace(tservice->get_program()) + service_name_ + "_"
+ (*f_iter)->get_name() + "_result";
- f_service_ << endl;
+ f_service_ << '\n';
// Open receive function
if (gen_node_) {
if (gen_es6_) {
- indent(f_service_) << "recv_" << (*f_iter)->get_name() << " (input, mtype, rseqid) {" << endl;
+ indent(f_service_) << "recv_" << (*f_iter)->get_name() << " (input, mtype, rseqid) {" << '\n';
} else {
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
<< "Client.prototype.recv_" << (*f_iter)->get_name()
- << " = function(input,mtype,rseqid) {" << endl;
+ << " = function(input,mtype,rseqid) {" << '\n';
}
} else {
if (gen_es6_) {
- indent(f_service_) << "recv_" << (*f_iter)->get_name() << " () {" << endl;
+ indent(f_service_) << "recv_" << (*f_iter)->get_name() << " () {" << '\n';
} else {
t_struct noargs(program_);
@@ -2128,7 +2127,7 @@
string("recv_") + (*f_iter)->get_name(),
&noargs);
indent(f_service_) << js_namespace(tservice->get_program()) << service_name_
- << "Client.prototype." << function_signature(&recv_function) << " {" << endl;
+ << "Client.prototype." << function_signature(&recv_function) << " {" << '\n';
}
}
@@ -2142,68 +2141,68 @@
}
if (gen_node_) {
- f_service_ << indent() << js_const_type_ << "callback = this._reqs[rseqid] || function() {};" << endl
- << indent() << "delete this._reqs[rseqid];" << endl;
+ f_service_ << indent() << js_const_type_ << "callback = this._reqs[rseqid] || function() {};" << '\n'
+ << indent() << "delete this._reqs[rseqid];" << '\n';
} else {
- f_service_ << indent() << js_const_type_ << "ret = this.input.readMessageBegin();" << endl
- << indent() << js_const_type_ << "mtype = ret.mtype;" << endl;
+ f_service_ << indent() << js_const_type_ << "ret = this.input.readMessageBegin();" << '\n'
+ << indent() << js_const_type_ << "mtype = ret.mtype;" << '\n';
}
- f_service_ << indent() << "if (mtype == Thrift.MessageType.EXCEPTION) {" << endl;
+ f_service_ << indent() << "if (mtype == Thrift.MessageType.EXCEPTION) {" << '\n';
indent_up();
- f_service_ << indent() << js_const_type_ << "x = new Thrift.TApplicationException();" << endl
- << indent() << "x.read(" << inputVar << ");" << endl
- << indent() << inputVar << ".readMessageEnd();" << endl
- << indent() << render_recv_throw("x") << endl;
+ f_service_ << indent() << js_const_type_ << "x = new Thrift.TApplicationException();" << '\n'
+ << indent() << "x.read(" << inputVar << ");" << '\n'
+ << indent() << inputVar << ".readMessageEnd();" << '\n'
+ << indent() << render_recv_throw("x") << '\n';
scope_down(f_service_);
- f_service_ << indent() << js_const_type_ << "result = new " << resultname << "();" << endl << indent()
- << "result.read(" << inputVar << ");" << endl;
+ f_service_ << indent() << js_const_type_ << "result = new " << resultname << "();" << '\n' << indent()
+ << "result.read(" << inputVar << ");" << '\n';
- f_service_ << indent() << inputVar << ".readMessageEnd();" << endl << endl;
+ f_service_ << indent() << inputVar << ".readMessageEnd();" << '\n' << '\n';
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- f_service_ << indent() << "if (null !== result." << (*x_iter)->get_name() << ") {" << endl
+ f_service_ << indent() << "if (null !== result." << (*x_iter)->get_name() << ") {" << '\n'
<< indent() << " " << render_recv_throw("result." + (*x_iter)->get_name())
- << endl << indent() << "}" << endl;
+ << '\n' << indent() << "}" << '\n';
}
// Careful, only return result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "if (null !== result.success) {" << endl << indent() << " "
- << render_recv_return("result.success") << endl << indent() << "}" << endl;
+ f_service_ << indent() << "if (null !== result.success) {" << '\n' << indent() << " "
+ << render_recv_return("result.success") << '\n' << indent() << "}" << '\n';
f_service_ << indent()
<< render_recv_throw("'" + (*f_iter)->get_name() + " failed: unknown result'")
- << endl;
+ << '\n';
} else {
if (gen_node_) {
- indent(f_service_) << "callback(null);" << endl;
+ indent(f_service_) << "callback(null);" << '\n';
} else {
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
}
}
// Close receive function
indent_down();
if (gen_es6_) {
- indent(f_service_) << "}" << endl;
+ indent(f_service_) << "}" << '\n';
} else {
- indent(f_service_) << "};" << endl;
+ indent(f_service_) << "};" << '\n';
}
}
}
// Finish class definitions
if (gen_ts_) {
- f_service_ts_ << ts_indent() << "}" << endl;
+ f_service_ts_ << ts_indent() << "}" << '\n';
}
if (gen_es6_) {
indent_down();
- f_service_ << "};" << endl;
+ f_service_ << "};" << '\n';
}
}
@@ -2284,7 +2283,7 @@
out << ".value";
}
- out << ";" << endl;
+ out << ";" << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
tfield->get_name().c_str(),
@@ -2300,7 +2299,7 @@
*/
void t_js_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
out << indent() << prefix << " = new " << js_type_namespace(tstruct->get_program())
- << tstruct->get_name() << "();" << endl << indent() << prefix << ".read(input);" << endl;
+ << tstruct->get_name() << "();" << '\n' << indent() << prefix << ".read(input);" << '\n';
}
void t_js_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
@@ -2311,36 +2310,36 @@
// Declare variables, read header
if (ttype->is_map()) {
- out << indent() << prefix << " = {};" << endl;
+ out << indent() << prefix << " = {};" << '\n';
- out << indent() << js_const_type_ << rtmp3 << " = input.readMapBegin();" << endl;
- out << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << endl;
+ out << indent() << js_const_type_ << rtmp3 << " = input.readMapBegin();" << '\n';
+ out << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << '\n';
} else if (ttype->is_set()) {
- out << indent() << prefix << " = [];" << endl
- << indent() << js_const_type_ << rtmp3 << " = input.readSetBegin();" << endl
- << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << endl;
+ out << indent() << prefix << " = [];" << '\n'
+ << indent() << js_const_type_ << rtmp3 << " = input.readSetBegin();" << '\n'
+ << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << '\n';
} else if (ttype->is_list()) {
- out << indent() << prefix << " = [];" << endl
- << indent() << js_const_type_ << rtmp3 << " = input.readListBegin();" << endl
- << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << endl;
+ out << indent() << prefix << " = [];" << '\n'
+ << indent() << js_const_type_ << rtmp3 << " = input.readListBegin();" << '\n'
+ << indent() << js_const_type_ << size << " = " << rtmp3 << ".size || 0;" << '\n';
}
// For loop iterates over elements
string i = tmp("_i");
- indent(out) << "for (" << js_let_type_ << i << " = 0; " << i << " < " << size << "; ++" << i << ") {" << endl;
+ indent(out) << "for (" << js_let_type_ << i << " = 0; " << i << " < " << size << "; ++" << i << ") {" << '\n';
indent_up();
if (ttype->is_map()) {
if (!gen_node_) {
- out << indent() << "if (" << i << " > 0 ) {" << endl << indent()
- << " if (input.rstack.length > input.rpos[input.rpos.length -1] + 1) {" << endl
- << indent() << " input.rstack.pop();" << endl << indent() << " }" << endl << indent()
- << "}" << endl;
+ out << indent() << "if (" << i << " > 0 ) {" << '\n' << indent()
+ << " if (input.rstack.length > input.rpos[input.rpos.length -1] + 1) {" << '\n'
+ << indent() << " input.rstack.pop();" << '\n' << indent() << " }" << '\n' << indent()
+ << "}" << '\n';
}
generate_deserialize_map_element(out, (t_map*)ttype, prefix);
@@ -2354,11 +2353,11 @@
// Read container end
if (ttype->is_map()) {
- indent(out) << "input.readMapEnd();" << endl;
+ indent(out) << "input.readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "input.readSetEnd();" << endl;
+ indent(out) << "input.readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "input.readListEnd();" << endl;
+ indent(out) << "input.readListEnd();" << '\n';
}
}
@@ -2371,24 +2370,24 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- indent(out) << declare_field(&fkey, false, false) << ";" << endl;
- indent(out) << declare_field(&fval, false, false) << ";" << endl;
+ indent(out) << declare_field(&fkey, false, false) << ";" << '\n';
+ indent(out) << declare_field(&fval, false, false) << ";" << '\n';
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
- indent(out) << prefix << "[" << key << "] = " << val << ";" << endl;
+ indent(out) << prefix << "[" << key << "] = " << val << ";" << '\n';
}
void t_js_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
string elem = tmp("elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << js_let_type_ << elem << " = null;" << endl;
+ indent(out) << js_let_type_ << elem << " = null;" << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".push(" << elem << ");" << endl;
+ indent(out) << prefix << ".push(" << elem << ");" << '\n';
}
void t_js_generator::generate_deserialize_list_element(ostream& out,
@@ -2397,11 +2396,11 @@
string elem = tmp("elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << js_let_type_ << elem << " = null;" << endl;
+ indent(out) << js_let_type_ << elem << " = null;" << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".push(" << elem << ");" << endl;
+ indent(out) << prefix << ".push(" << elem << ");" << '\n';
}
/**
@@ -2465,7 +2464,7 @@
} else if (type->is_enum()) {
out << "writeI32(" << name << ")";
}
- out << ";" << endl;
+ out << ";" << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
@@ -2483,7 +2482,7 @@
*/
void t_js_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- indent(out) << prefix << ".write(output);" << endl;
+ indent(out) << prefix << ".write(output);" << '\n';
}
/**
@@ -2493,58 +2492,58 @@
if (ttype->is_map()) {
indent(out) << "output.writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "Thrift.objectLength(" << prefix << "));" << endl;
+ << "Thrift.objectLength(" << prefix << "));" << '\n';
} else if (ttype->is_set()) {
indent(out) << "output.writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
- << prefix << ".length);" << endl;
+ << prefix << ".length);" << '\n';
} else if (ttype->is_list()) {
indent(out) << "output.writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
- << ", " << prefix << ".length);" << endl;
+ << ", " << prefix << ".length);" << '\n';
}
if (ttype->is_map()) {
string kiter = tmp("kiter");
string viter = tmp("viter");
- indent(out) << "for (" << js_let_type_ << kiter << " in " << prefix << ") {" << endl;
+ indent(out) << "for (" << js_let_type_ << kiter << " in " << prefix << ") {" << '\n';
indent_up();
- indent(out) << "if (" << prefix << ".hasOwnProperty(" << kiter << ")) {" << endl;
+ indent(out) << "if (" << prefix << ".hasOwnProperty(" << kiter << ")) {" << '\n';
indent_up();
- indent(out) << js_let_type_ << viter << " = " << prefix << "[" << kiter << "];" << endl;
+ indent(out) << js_let_type_ << viter << " = " << prefix << "[" << kiter << "];" << '\n';
generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
scope_down(out);
scope_down(out);
} else if (ttype->is_set()) {
string iter = tmp("iter");
- indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << endl;
+ indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << '\n';
indent_up();
- indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << endl;
+ indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << '\n';
indent_up();
- indent(out) << iter << " = " << prefix << "[" << iter << "];" << endl;
+ indent(out) << iter << " = " << prefix << "[" << iter << "];" << '\n';
generate_serialize_set_element(out, (t_set*)ttype, iter);
scope_down(out);
scope_down(out);
} else if (ttype->is_list()) {
string iter = tmp("iter");
- indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << endl;
+ indent(out) << "for (" << js_let_type_ << iter << " in " << prefix << ") {" << '\n';
indent_up();
- indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << endl;
+ indent(out) << "if (" << prefix << ".hasOwnProperty(" << iter << ")) {" << '\n';
indent_up();
- indent(out) << iter << " = " << prefix << "[" << iter << "];" << endl;
+ indent(out) << iter << " = " << prefix << "[" << iter << "];" << '\n';
generate_serialize_list_element(out, (t_list*)ttype, iter);
scope_down(out);
scope_down(out);
}
if (ttype->is_map()) {
- indent(out) << "output.writeMapEnd();" << endl;
+ indent(out) << "output.writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "output.writeSetEnd();" << endl;
+ indent(out) << "output.writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "output.writeListEnd();" << endl;
+ indent(out) << "output.writeListEnd();" << '\n';
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_json_generator.cc b/compiler/cpp/src/thrift/generate/t_json_generator.cc
index e91d65a..3fb973a 100644
--- a/compiler/cpp/src/thrift/generate/t_json_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_json_generator.cc
@@ -42,8 +42,6 @@
using std::vector;
using std::stack;
-static const string endl = "\n";
-static const string quot = "\"";
static const bool NO_INDENT = false;
static const bool FORCE_STRING = true;
@@ -182,20 +180,20 @@
}
void t_json_generator::start_object(bool should_indent) {
- f_json_ << (should_indent ? indent() : "") << "{" << endl;
+ f_json_ << (should_indent ? indent() : "") << "{" << '\n';
indent_up();
comma_needed_.push(false);
}
void t_json_generator::start_array() {
- f_json_ << "[" << endl;
+ f_json_ << "[" << '\n';
indent_up();
comma_needed_.push(false);
}
void t_json_generator::write_comma_if_needed() {
if (comma_needed_.top()) {
- f_json_ << "," << endl;
+ f_json_ << "," << '\n';
}
}
@@ -230,14 +228,14 @@
void t_json_generator::end_object() {
indent_down();
- f_json_ << endl << indent() << "}";
+ f_json_ << '\n' << indent() << "}";
comma_needed_.pop();
}
void t_json_generator::end_array() {
indent_down();
if (comma_needed_.top()) {
- f_json_ << endl;
+ f_json_ << '\n';
}
indent(f_json_) << "]";
comma_needed_.pop();
@@ -296,7 +294,7 @@
}
void t_json_generator::close_generator() {
- f_json_ << endl;
+ f_json_ << '\n';
f_json_.close();
}
@@ -471,7 +469,7 @@
}
void t_json_generator::write_string(const string& value) {
- f_json_ << quot << escape_json_string(value) << quot;
+ f_json_ << '\"' << escape_json_string(value) << '\"';
}
void t_json_generator::write_const_value(t_const_value* value, bool should_force_string) {
@@ -537,7 +535,7 @@
}
string t_json_generator::json_str(const string& str) {
- return quot + escape_json_string(str) + quot;
+ return string("\"") + escape_json_string(str) + string("\"");
}
void t_json_generator::generate_constant(t_const* con) {
diff --git a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc
index 78917d9..2e81909 100644
--- a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc
@@ -45,8 +45,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
static const string KOTLIN_RESERVED_WORDS[] = {
"as", "as?", "break", "class", "continue", "do", "else",
"false", "for", "fun", "if", "in", "!in", "interface",
@@ -209,7 +207,7 @@
* Nothing in Kotlin generator
*/
void t_kotlin_generator::close_generator() {
- f_types_ << endl;
+ f_types_ << '\n';
f_types_.close();
}
@@ -222,7 +220,7 @@
*/
void t_kotlin_generator::generate_typedef(t_typedef* ttypedef) {
f_types_ << "typealias " << ttypedef->get_symbolic() << " = "
- << type_name(ttypedef->get_type(), true) << endl;
+ << type_name(ttypedef->get_type(), true) << '\n';
}
void t_kotlin_generator::generate_enum(t_enum* tenum) {
@@ -241,32 +239,32 @@
auto first = true;
auto enum_values = tenum->get_constants();
for (auto& enum_value : enum_values) {
- f_enum << (first ? "" : ",") << endl;
+ f_enum << (first ? "" : ",") << '\n';
first = false;
indent(f_enum) << enum_value->get_name() << "(" << enum_value->get_value() << ")";
}
if (first) {
indent(f_enum);
}
- f_enum << ";" << endl << endl;
- indent(f_enum) << "override fun getValue() = value" << endl << endl;
+ f_enum << ";" << '\n' << '\n';
+ indent(f_enum) << "override fun getValue() = value" << '\n' << '\n';
{
- indent(f_enum) << "companion object {" << endl;
+ indent(f_enum) << "companion object {" << '\n';
indent_up();
{
- indent(f_enum) << "@kotlin.jvm.JvmStatic" << endl;
+ indent(f_enum) << "@kotlin.jvm.JvmStatic" << '\n';
indent(f_enum) << "fun findByValue(i: kotlin.Int): " << kotlin_safe_name(tenum->get_name())
- << "? {" << endl;
+ << "? {" << '\n';
indent_up();
{
- indent(f_enum) << "return when (i) {" << endl;
+ indent(f_enum) << "return when (i) {" << '\n';
indent_up();
{
auto enum_values = tenum->get_constants();
for (auto& enum_value : enum_values) {
- indent(f_enum) << enum_value->get_value() << " -> " << enum_value->get_name() << endl;
+ indent(f_enum) << enum_value->get_value() << " -> " << enum_value->get_name() << '\n';
}
- indent(f_enum) << "else -> null" << endl;
+ indent(f_enum) << "else -> null" << '\n';
}
scope_down(f_enum);
}
@@ -322,7 +320,7 @@
} else {
// TODO
}
- f_types_ << endl;
+ f_types_ << '\n';
}
}
@@ -442,7 +440,7 @@
t_struct* tstruct) {
indent(out) << "enum class _Fields(private val thriftFieldId: kotlin.Short, private val "
"fieldName: kotlin.String) : org.apache.thrift.TFieldIdEnum {"
- << endl;
+ << '\n';
indent_up();
{
// fields
@@ -450,7 +448,7 @@
bool first = true;
for (auto& field : tstruct->get_members()) {
if (!first) {
- out << "," << endl;
+ out << "," << '\n';
}
first = false;
indent(out) << constant_name(field->get_name()) << "(" << field->get_key() << ", \""
@@ -459,49 +457,49 @@
if (first) {
indent(out);
}
- out << ";" << endl << endl;
+ out << ";" << '\n' << '\n';
}
// methods
- indent(out) << "override fun getThriftFieldId() = thriftFieldId" << endl << endl;
- indent(out) << "override fun getFieldName() = fieldName" << endl << endl;
+ indent(out) << "override fun getThriftFieldId() = thriftFieldId" << '\n' << '\n';
+ indent(out) << "override fun getFieldName() = fieldName" << '\n' << '\n';
// companion object
- indent(out) << "companion object {" << endl;
+ indent(out) << "companion object {" << '\n';
indent_up();
{
- indent(out) << "@kotlin.jvm.JvmStatic" << endl;
- indent(out) << "fun findByValue(value: kotlin.Int): _Fields? {" << endl;
+ indent(out) << "@kotlin.jvm.JvmStatic" << '\n';
+ indent(out) << "fun findByValue(value: kotlin.Int): _Fields? {" << '\n';
indent_up();
{
- indent(out) << "return when (value) {" << endl;
+ indent(out) << "return when (value) {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
- indent(out) << field->get_key() << " -> " << constant_name(field->get_name()) << endl;
+ indent(out) << field->get_key() << " -> " << constant_name(field->get_name()) << '\n';
}
- indent(out) << "else -> null" << endl;
+ indent(out) << "else -> null" << '\n';
}
scope_down(out);
}
scope_down(out);
}
- out << endl;
+ out << '\n';
{
- indent(out) << "@kotlin.jvm.JvmStatic" << endl;
- indent(out) << "fun findByName(name: kotlin.String): _Fields? {" << endl;
+ indent(out) << "@kotlin.jvm.JvmStatic" << '\n';
+ indent(out) << "fun findByName(name: kotlin.String): _Fields? {" << '\n';
indent_up();
{
- indent(out) << "return when (name) {" << endl;
+ indent(out) << "return when (name) {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
indent(out) << "\"" << field->get_name() << "\""
- << " -> " << constant_name(field->get_name()) << endl;
+ << " -> " << constant_name(field->get_name()) << '\n';
}
- indent(out) << "else -> null" << endl;
+ indent(out) << "else -> null" << '\n';
}
scope_down(out);
}
@@ -511,16 +509,16 @@
scope_down(out);
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_companion_object(std::ostream& out, t_struct* tstruct) {
- indent(out) << "companion object {" << endl;
+ indent(out) << "companion object {" << '\n';
indent_up();
{
indent(out) << "private val STRUCT_DESC: org.apache.thrift.protocol.TStruct = "
"org.apache.thrift.protocol.TStruct(\""
- << tstruct->get_name() << "\")" << endl;
+ << tstruct->get_name() << "\")" << '\n';
{
for (auto& field : tstruct->get_members()) {
// field desc
@@ -528,15 +526,15 @@
<< "_FIELD_DESC: org.apache.thrift.protocol.TField = "
"org.apache.thrift.protocol.TField(\""
<< field->get_name() << "\", " << type_to_enum(field->get_type()) << ", "
- << field->get_key() << ")" << endl;
+ << field->get_key() << ")" << '\n';
// field metadata
indent(out) << "private val " << constant_name(field->get_name())
<< "_FIELD_META_DATA: org.apache.thrift.meta_data.FieldMetaData = "
"org.apache.thrift.meta_data.FieldMetaData("
- << endl;
+ << '\n';
indent_up();
{
- indent(out) << '"' << field->get_name() << '"' << ',' << endl;
+ indent(out) << '"' << field->get_name() << '"' << ',' << '\n';
indent(out) << "org.apache.thrift.TFieldRequirementType.";
if (field->get_req() == t_field::T_REQUIRED) {
out << "REQUIRED";
@@ -545,12 +543,12 @@
} else {
out << "DEFAULT";
}
- out << ',' << endl;
+ out << ',' << '\n';
generate_field_value_meta_data(indent(out), field->get_type());
- out << ',' << endl;
+ out << ',' << '\n';
generate_metadata_for_field_annotations(indent(out), field);
}
- out << ")" << endl;
+ out << ")" << '\n';
indent_down();
}
}
@@ -558,23 +556,23 @@
// all fields in a map
indent(out)
<< "private val metadata: Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> = mapOf("
- << endl;
+ << '\n';
indent_up();
for (auto& field : tstruct->get_members()) {
indent(out) << "_Fields." << constant_name(field->get_name()) << " to "
- << constant_name(field->get_name()) << "_FIELD_META_DATA," << endl;
+ << constant_name(field->get_name()) << "_FIELD_META_DATA," << '\n';
}
indent_down();
- indent(out) << ")" << endl;
+ indent(out) << ")" << '\n';
- indent(out) << "init {" << endl;
+ indent(out) << "init {" << '\n';
indent_up();
indent(out) << "org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap("
- << tstruct->get_name() << "::class.java, metadata)" << endl;
+ << tstruct->get_name() << "::class.java, metadata)" << '\n';
scope_down(out);
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_metadata_for_field_annotations(std::ostream& out,
@@ -582,10 +580,10 @@
if (field->annotations_.size() == 0) {
out << "emptyMap()";
} else {
- out << "mapOf(" << endl;
+ out << "mapOf(" << '\n';
indent_up();
for (auto& annotation : field->annotations_) {
- indent(out) << "\"" + annotation.first + "\" to \"" + annotation.second.back() + "\"," << endl;
+ indent(out) << "\"" + annotation.first + "\" to \"" + annotation.second.back() + "\"," << '\n';
}
indent_down();
indent(out) << ")";
@@ -600,24 +598,24 @@
out << "StructMetaData(" << ttype_class << "STRUCT, " << type_name(type) << "::class.java";
} else if (type->is_container()) {
if (type->is_list()) {
- out << "ListMetaData(" << ttype_class << "LIST," << endl;
+ out << "ListMetaData(" << ttype_class << "LIST," << '\n';
indent_up();
t_type* elem_type = ((t_list*)type)->get_elem_type();
generate_field_value_meta_data(indent(out), elem_type);
indent_down();
} else if (type->is_set()) {
- out << "SetMetaData(" << ttype_class << "SET," << endl;
+ out << "SetMetaData(" << ttype_class << "SET," << '\n';
indent_up();
t_type* elem_type = ((t_set*)type)->get_elem_type();
generate_field_value_meta_data(indent(out), elem_type);
indent_down();
} else {
- out << "MapMetaData(" << ttype_class << "MAP," << endl;
+ out << "MapMetaData(" << ttype_class << "MAP," << '\n';
indent_up();
t_type* key_type = ((t_map*)type)->get_key_type();
t_type* val_type = ((t_map*)type)->get_val_type();
generate_field_value_meta_data(indent(out), key_type);
- out << "," << endl;
+ out << "," << '\n';
generate_field_value_meta_data(indent(out), val_type);
indent_down();
}
@@ -635,30 +633,30 @@
}
void t_kotlin_generator::generate_struct_method_deep_copy(std::ostream& out, t_struct* tstruct) {
- indent(out) << "override fun deepCopy(): " << tstruct->get_name() << " {" << endl;
+ indent(out) << "override fun deepCopy(): " << tstruct->get_name() << " {" << '\n';
indent_up();
{
- indent(out) << "return " << tstruct->get_name() << " (" << endl;
+ indent(out) << "return " << tstruct->get_name() << " (" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
- indent(out) << kotlin_safe_name(field->get_name()) << "," << endl;
+ indent(out) << kotlin_safe_name(field->get_name()) << "," << '\n';
}
}
indent_down();
- indent(out) << ")" << endl;
+ indent(out) << ")" << '\n';
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_compare_to(std::ostream& out, t_struct* tstruct) {
indent(out) << "override fun compareTo(other: " << tstruct->get_name() << "?): kotlin.Int {"
- << endl;
+ << '\n';
indent_up();
{
indent(out) << "val comparator = compareBy<" << tstruct->get_name()
- << "> { it::class.java.name }" << endl;
+ << "> { it::class.java.name }" << '\n';
indent_up();
for (auto& field : tstruct->get_members()) {
indent(out) << ".thenBy";
@@ -667,33 +665,33 @@
|| field_type->is_binary()) {
out << "(org.apache.thrift.TBaseHelper::compareTo)";
}
- out << " { it." << kotlin_safe_name(field->get_name()) << " } " << endl;
+ out << " { it." << kotlin_safe_name(field->get_name()) << " } " << '\n';
}
indent_down();
- indent(out) << "return nullsFirst(comparator).compare(this, other)" << endl;
+ indent(out) << "return nullsFirst(comparator).compare(this, other)" << '\n';
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_field_for_id(std::ostream& out,
t_struct* /*tstruct*/) {
- indent(out) << "override fun fieldForId(fieldId: kotlin.Int): _Fields {" << endl;
+ indent(out) << "override fun fieldForId(fieldId: kotlin.Int): _Fields {" << '\n';
indent_up();
{
indent(out) << "return _Fields.findByValue(fieldId) ?: throw "
"kotlin.IllegalArgumentException(\"invalid fieldId $fieldId\")"
- << endl;
+ << '\n';
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_is_set(std::ostream& out, t_struct* tstruct) {
- indent(out) << "override fun isSet(field: _Fields): kotlin.Boolean {" << endl;
+ indent(out) << "override fun isSet(field: _Fields): kotlin.Boolean {" << '\n';
indent_up();
{
- indent(out) << "return when (field) {" << endl;
+ indent(out) << "return when (field) {" << '\n';
indent_up();
{
auto members = tstruct->get_members();
@@ -705,67 +703,67 @@
} else {
out << "this." << kotlin_safe_name(field->get_name()) << " != null";
}
- out << endl;
+ out << '\n';
}
} else {
- indent(out) << "else -> false" << endl;
+ indent(out) << "else -> false" << '\n';
}
}
scope_down(out);
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_clear(std::ostream& out, t_struct* tstruct) {
- indent(out) << "override fun clear(): kotlin.Unit {" << endl;
+ indent(out) << "override fun clear(): kotlin.Unit {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
auto is_required = field->get_req() == t_field::T_REQUIRED;
indent(out) << (is_required ? "_" + field->get_name() : kotlin_safe_name(field->get_name()))
- << " = null" << endl;
+ << " = null" << '\n';
}
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_validate(std::ostream& out, t_struct* tstruct) {
- indent(out) << "@kotlin.jvm.Throws(org.apache.thrift.TException::class)" << endl;
- indent(out) << "fun validate(): kotlin.Unit {" << endl;
+ indent(out) << "@kotlin.jvm.Throws(org.apache.thrift.TException::class)" << '\n';
+ indent(out) << "fun validate(): kotlin.Unit {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
bool is_required = field->get_req() == t_field::T_REQUIRED;
if (is_required) {
- indent(out) << "if (_" << field->get_name() << " == null) {" << endl;
+ indent(out) << "if (_" << field->get_name() << " == null) {" << '\n';
indent_up();
{
indent(out) << "throw org.apache.thrift.TException(\"Required field `"
<< field->get_name()
<< "' is null, "
"struct is: $this\")"
- << endl;
+ << '\n';
}
scope_down(out);
}
}
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_set_field_value(std::ostream& out,
t_struct* tstruct) {
- indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << endl;
+ indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << '\n';
indent(out) << "override fun setFieldValue(field: _Fields, value: kotlin.Any?): kotlin.Unit {"
- << endl;
+ << '\n';
indent_up();
{
const vector<t_field*>& members = tstruct->get_members();
if (members.size() > 0) {
- indent(out) << "when (field) {" << endl;
+ indent(out) << "when (field) {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
@@ -773,155 +771,155 @@
indent(out) << "_Fields." << constant_name(field->get_name()) << " -> this."
<< (is_required ? "_" + field->get_name()
: kotlin_safe_name(field->get_name()))
- << " = value as " << type_name(field->get_type()) << "?" << endl;
+ << " = value as " << type_name(field->get_type()) << "?" << '\n';
}
}
scope_down(out);
} else {
- indent(out) << "return" << endl;
+ indent(out) << "return" << '\n';
}
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_get_field_value(std::ostream& out,
t_struct* tstruct) {
- indent(out) << "override fun getFieldValue(field: _Fields): kotlin.Any? {" << endl;
+ indent(out) << "override fun getFieldValue(field: _Fields): kotlin.Any? {" << '\n';
indent_up();
{
auto members = tstruct->get_members();
if (members.size() > 0) {
- indent(out) << "return when (field) {" << endl;
+ indent(out) << "return when (field) {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
indent(out) << "_Fields." << constant_name(field->get_name()) << " -> this."
- << kotlin_safe_name(field->get_name()) << endl;
+ << kotlin_safe_name(field->get_name()) << '\n';
}
}
scope_down(out);
} else {
- indent(out) << "return null" << endl;
+ indent(out) << "return null" << '\n';
}
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_read(std::ostream& out, t_struct* tstruct) {
indent(out) << "override fun read(iproto: org.apache.thrift.protocol.TProtocol): kotlin.Unit {"
- << endl;
+ << '\n';
indent_up();
{
indent(out)
<< "require(org.apache.thrift.scheme.StandardScheme::class.java == iproto.scheme) { "
"\"only standard scheme is "
"supported for now\" }"
- << endl;
- indent(out) << tstruct->get_name() << "StandardScheme.read(iproto, this)" << endl;
+ << '\n';
+ indent(out) << tstruct->get_name() << "StandardScheme.read(iproto, this)" << '\n';
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_method_write(std::ostream& out, t_struct* tstruct) {
indent(out) << "override fun write(oproto: org.apache.thrift.protocol.TProtocol): kotlin.Unit {"
- << endl;
+ << '\n';
indent_up();
{
indent(out)
<< "require(org.apache.thrift.scheme.StandardScheme::class.java == oproto.scheme) { "
"\"only standard scheme is "
"supported for now\" }"
- << endl;
- indent(out) << tstruct->get_name() << "StandardScheme.write(oproto, this)" << endl;
+ << '\n';
+ indent(out) << tstruct->get_name() << "StandardScheme.write(oproto, this)" << '\n';
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_standard_scheme_read(std::ostream& out,
t_struct* tstruct) {
indent(out) << "override fun read(iproto: org.apache.thrift.protocol.TProtocol, struct: "
- << tstruct->get_name() << ") {" << endl;
+ << tstruct->get_name() << ") {" << '\n';
indent_up();
{
- indent(out) << "iproto.apply {" << endl;
+ indent(out) << "iproto.apply {" << '\n';
indent_up();
{
- indent(out) << "readStruct {" << endl;
+ indent(out) << "readStruct {" << '\n';
indent_up();
{
- indent(out) << "var stopped = false" << endl;
- indent(out) << "while (!stopped) {" << endl;
+ indent(out) << "var stopped = false" << '\n';
+ indent(out) << "while (!stopped) {" << '\n';
indent_up();
{
- indent(out) << "stopped = readField {" << endl;
+ indent(out) << "stopped = readField {" << '\n';
indent_up();
{
indent(out) << "val skipNext = { "
"org.apache.thrift.protocol.TProtocolUtil.skip(iproto, it.type) }"
- << endl;
+ << '\n';
- indent(out) << "when (it.id.toInt()) {" << endl;
+ indent(out) << "when (it.id.toInt()) {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
- indent(out) << field->get_key() << " -> {" << endl;
+ indent(out) << field->get_key() << " -> {" << '\n';
indent_up();
{
indent(out) << "if (it.type == " << type_to_enum(field->get_type()) << ") {"
- << endl;
+ << '\n';
indent_up();
generate_deserialize_field(out, field, "struct.");
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
- indent(out) << "skipNext()" << endl;
+ indent(out) << "skipNext()" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
scope_down(out);
}
- indent(out) << "else -> skipNext()" << endl;
+ indent(out) << "else -> skipNext()" << '\n';
}
scope_down(out);
}
scope_down(out);
}
scope_down(out);
- indent(out) << "struct.validate()" << endl;
+ indent(out) << "struct.validate()" << '\n';
}
scope_down(out);
}
scope_down(out);
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_standard_scheme_write(std::ostream& out,
t_struct* tstruct) {
indent(out) << "override fun write(oproto: org.apache.thrift.protocol.TProtocol, struct: "
- << tstruct->get_name() << ") {" << endl;
+ << tstruct->get_name() << ") {" << '\n';
indent_up();
{
- indent(out) << "struct.validate()" << endl;
- indent(out) << "oproto.apply {" << endl;
+ indent(out) << "struct.validate()" << '\n';
+ indent(out) << "oproto.apply {" << '\n';
indent_up();
{
- indent(out) << "writeStruct(STRUCT_DESC) {" << endl;
+ indent(out) << "writeStruct(STRUCT_DESC) {" << '\n';
indent_up();
{
for (auto& field : tstruct->get_members()) {
auto is_required = field->get_req() == t_field::T_REQUIRED;
indent(out) << "struct." << kotlin_safe_name(field->get_name())
<< (is_required ? "" : "?") << ".let { "
- << kotlin_safe_name(field->get_name()) << " ->" << endl;
+ << kotlin_safe_name(field->get_name()) << " ->" << '\n';
indent_up();
{
indent(out) << "writeField(" << constant_name(field->get_name()) << "_FIELD_DESC) {"
- << endl;
+ << '\n';
indent_up();
generate_serialize_field(out, field);
scope_down(out);
@@ -929,36 +927,36 @@
scope_down(out);
}
}
- indent(out) << "writeFieldStop()" << endl;
+ indent(out) << "writeFieldStop()" << '\n';
scope_down(out);
}
scope_down(out);
}
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_struct_standard_scheme(std::ostream& out, t_struct* tstruct) {
indent(out) << "private object " << tstruct->get_name()
<< "StandardScheme : org.apache.thrift.scheme.StandardScheme<" << tstruct->get_name()
- << ">() {" << endl;
+ << ">() {" << '\n';
indent_up();
generate_struct_standard_scheme_read(out, tstruct);
generate_struct_standard_scheme_write(out, tstruct);
scope_down(out);
- out << endl;
+ out << '\n';
}
void t_kotlin_generator::generate_union_tuple_scheme(std::ostream& out, t_struct* /*tunion*/) {
indent(out) << "override fun tupleSchemeReadValue(iproto: org.apache.thrift.protocol.TProtocol, "
"fieldID: kotlin.Short) = throw kotlin.UnsupportedOperationException(\"only "
"standard scheme is supported for now\")"
- << endl;
+ << '\n';
indent(out)
<< "override fun tupleSchemeWriteValue(oproto: org.apache.thrift.protocol.TProtocol) = "
"throw kotlin.UnsupportedOperationException(\"only standard scheme is supported for "
"now\")"
- << endl;
+ << '\n';
}
void t_kotlin_generator::generate_union_standard_scheme(std::ostream& out, t_struct* tunion) {
@@ -970,61 +968,61 @@
indent(out)
<< "override fun standardSchemeReadValue(iproto: org.apache.thrift.protocol.TProtocol, "
"field: org.apache.thrift.protocol.TField): Any? ="
- << endl;
+ << '\n';
indent_up();
- indent(out) << "when (_Fields.findByValue(field.id.toInt())) {" << endl;
+ indent(out) << "when (_Fields.findByValue(field.id.toInt())) {" << '\n';
indent_up();
for (auto& member : tunion->get_members()) {
auto expect_type = type_name(member->get_type());
- indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << endl;
+ indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << '\n';
indent_up();
{
indent(out) << "if (field.type == " << constant_name(member->get_name())
- << "_FIELD_DESC.type) {" << endl;
+ << "_FIELD_DESC.type) {" << '\n';
indent_up();
- indent(out) << "iproto.run {" << endl;
+ indent(out) << "iproto.run {" << '\n';
indent_up();
indent(out);
generate_deserialize_value(out, member->get_type());
- out << endl;
+ out << '\n';
scope_down(out);
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
- indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << endl;
- indent(out) << "null" << endl;
+ indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << '\n';
+ indent(out) << "null" << '\n';
scope_down(out);
}
scope_down(out);
}
- indent(out) << "null -> {" << endl;
+ indent(out) << "null -> {" << '\n';
indent_up();
- indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << endl;
- indent(out) << "null" << endl;
+ indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iproto, field.type)" << '\n';
+ indent(out) << "null" << '\n';
scope_down(out);
scope_down(out);
indent_down();
}
void t_kotlin_generator::generate_union_standard_scheme_write(std::ostream& out, t_struct* tunion) {
- indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << endl;
+ indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << '\n';
indent(out)
<< "override fun standardSchemeWriteValue(oproto: org.apache.thrift.protocol.TProtocol) {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "when (setField_) {" << endl;
+ indent(out) << "when (setField_) {" << '\n';
indent_up();
for (auto& member : tunion->get_members()) {
- indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << endl;
+ indent(out) << "_Fields." << constant_name(member->get_name()) << " -> {" << '\n';
indent_up();
{
- indent(out) << "val it = value_ as " << type_name(member->get_type()) << endl;
- indent(out) << "oproto.apply {" << endl;
+ indent(out) << "val it = value_ as " << type_name(member->get_type()) << '\n';
+ indent(out) << "oproto.apply {" << '\n';
indent_up();
{
indent(out);
generate_serialize_value(out, member->get_type());
- out << endl;
+ out << '\n';
}
scope_down(out);
}
@@ -1032,7 +1030,7 @@
}
indent(out) << "null -> throw kotlin.IllegalStateException(\"Cannot write union with unknown "
"field $setField_\")"
- << endl;
+ << '\n';
scope_down(out);
scope_down(out);
}
@@ -1052,25 +1050,25 @@
}
auto union_class_name = kotlin_safe_name(tunion->get_name());
- { indent(out) << "override fun deepCopy() = " << union_class_name << "(this)" << endl; }
- { indent(out) << "override fun enumForId(id: kotlin.Short) = fieldForId(id.toInt())" << endl; }
- { indent(out) << "override fun getStructDesc() = STRUCT_DESC" << endl; }
+ { indent(out) << "override fun deepCopy() = " << union_class_name << "(this)" << '\n'; }
+ { indent(out) << "override fun enumForId(id: kotlin.Short) = fieldForId(id.toInt())" << '\n'; }
+ { indent(out) << "override fun getStructDesc() = STRUCT_DESC" << '\n'; }
{
- indent(out) << "override fun getFieldDesc(setField: _Fields) = when (setField) {" << endl;
+ indent(out) << "override fun getFieldDesc(setField: _Fields) = when (setField) {" << '\n';
indent_up();
for (auto& member : tunion->get_members()) {
indent(out) << "_Fields." << constant_name(member->get_name()) << " -> "
- << constant_name(member->get_name()) << "_FIELD_DESC" << endl;
+ << constant_name(member->get_name()) << "_FIELD_DESC" << '\n';
}
scope_down(out);
}
}
void t_kotlin_generator::generate_union_method_check_type(std::ostream& out, t_struct* tunion) {
- indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << endl;
- indent(out) << "override fun checkType(setField: _Fields, value: kotlin.Any?) {" << endl;
+ indent(out) << "@Suppress(\"UNCHECKED_CAST\")" << '\n';
+ indent(out) << "override fun checkType(setField: _Fields, value: kotlin.Any?) {" << '\n';
indent_up();
- indent(out) << "when (setField) {" << endl;
+ indent(out) << "when (setField) {" << '\n';
indent_up();
for (auto& member : tunion->get_members()) {
auto expect_type = type_name(member->get_type());
@@ -1078,7 +1076,7 @@
<< expect_type
<< " ?: throw kotlin.ClassCastException(\"Was expecting value of type `"
<< expect_type << "' for field `" << member->get_name()
- << "', but got ${value?.javaClass}\")" << endl;
+ << "', but got ${value?.javaClass}\")" << '\n';
}
scope_down(out);
scope_down(out);
@@ -1089,12 +1087,12 @@
string /*additional interface*/) {
auto union_class_name = kotlin_safe_name(tunion->get_name());
indent(out) << "class " << union_class_name << " : org.apache.thrift.TUnion<" << union_class_name
- << ", " << union_class_name << "._Fields> {" << endl;
+ << ", " << union_class_name << "._Fields> {" << '\n';
indent_up();
indent(out) << "constructor(setField: _Fields, value: kotlin.Any) : super(setField, value)"
- << endl;
- indent(out) << "constructor(other: " << union_class_name << ") : super(other)" << endl;
- indent(out) << "constructor() : super()" << endl;
+ << '\n';
+ indent(out) << "constructor(other: " << union_class_name << ") : super(other)" << '\n';
+ indent(out) << "constructor() : super()" << '\n';
generate_struct_field_name_constants(out, tunion);
generate_struct_companion_object(out, tunion);
@@ -1104,7 +1102,7 @@
generate_union_standard_scheme(out, tunion);
generate_union_tuple_scheme(out, tunion);
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_kotlin_generator::generate_struct_definition(std::ostream& out,
@@ -1123,7 +1121,7 @@
indent_up();
auto sep = "";
for (auto field : members) {
- out << sep << endl;
+ out << sep << '\n';
sep = ",";
generate_kdoc_comment(out, field);
auto is_required = field->get_req() == t_field::T_REQUIRED;
@@ -1141,7 +1139,7 @@
out << ": " << type_name(field->get_type()) << "? = null";
}
indent_down();
- out << endl;
+ out << '\n';
indent(out) << ") : ";
if (is_exception) {
out << "org.apache.thrift.TException(), ";
@@ -1150,7 +1148,7 @@
additional_interface = ", " + additional_interface;
}
out << "org.apache.thrift.TBase<" << tstruct->get_name() << ", " << tstruct->get_name()
- << "._Fields>" << additional_interface << " {" << endl;
+ << "._Fields>" << additional_interface << " {" << '\n';
indent_up();
@@ -1162,7 +1160,7 @@
out << "override ";
}
out << "val " << kotlin_safe_name(field->get_name()) << ": " << type_name(field->get_type())
- << " get() = _" + kotlin_safe_name(field->get_name()) << "!!" << endl;
+ << " get() = _" + kotlin_safe_name(field->get_name()) << "!!" << '\n';
}
}
@@ -1181,7 +1179,7 @@
generate_struct_method_write(out, tstruct);
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
string t_kotlin_generator::base_type_write_expression(t_base_type* tbase, string it) {
@@ -1286,7 +1284,7 @@
}
indent(out);
generate_serialize_value(out, type, kotlin_safe_name(tfield->get_name()));
- out << endl;
+ out << '\n';
}
/**
@@ -1305,7 +1303,7 @@
= prefix + (is_required ? "_" + tfield->get_name() : kotlin_safe_name(tfield->get_name()));
indent(out) << name << " = ";
generate_deserialize_value(out, type);
- out << endl;
+ out << '\n';
}
/**
@@ -1315,33 +1313,33 @@
if (ttype->is_map()) {
out << "writeMap(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << it << ") { (key, value) ->"
- << endl;
+ << '\n';
indent_up();
{
generate_serialize_value(indent(out), ((t_map*)ttype)->get_key_type(), "key");
- out << endl;
+ out << '\n';
generate_serialize_value(indent(out), ((t_map*)ttype)->get_val_type(), "value");
- out << endl;
+ out << '\n';
indent_down();
}
indent(out) << "}";
} else if (ttype->is_set()) {
out << "writeSet(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << it << ") {"
- << endl;
+ << '\n';
indent_up();
{
generate_serialize_value(indent(out), ((t_set*)ttype)->get_elem_type());
- out << endl;
+ out << '\n';
indent_down();
}
indent(out) << "}";
} else if (ttype->is_list()) {
out << "writeList(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << it << ") {"
- << endl;
+ << '\n';
{
indent_up();
generate_serialize_value(indent(out), ((t_list*)ttype)->get_elem_type());
- out << endl;
+ out << '\n';
indent_down();
}
indent(out) << "}";
@@ -1355,41 +1353,41 @@
*/
void t_kotlin_generator::generate_deserialize_container(ostream& out, t_type* ttype) {
if (ttype->is_map()) {
- out << "readMap { tmap ->" << endl;
+ out << "readMap { tmap ->" << '\n';
indent_up();
- indent(out) << "kotlin.collections.List(tmap.size) {" << endl;
+ indent(out) << "kotlin.collections.List(tmap.size) {" << '\n';
indent_up();
indent(out);
generate_deserialize_value(out, ((t_map*)ttype)->get_key_type());
out << " to ";
generate_deserialize_value(out, ((t_map*)ttype)->get_val_type());
- out << endl;
+ out << '\n';
indent_down();
- indent(out) << "}.associate { it }" << endl;
+ indent(out) << "}.associate { it }" << '\n';
indent_down();
indent(out) << "}";
} else if (ttype->is_set()) {
- out << "readSet { tset ->" << endl;
+ out << "readSet { tset ->" << '\n';
indent_up();
- indent(out) << "kotlin.collections.List(tset.size) {" << endl;
+ indent(out) << "kotlin.collections.List(tset.size) {" << '\n';
indent_up();
indent(out);
generate_deserialize_value(out, ((t_set*)ttype)->get_elem_type());
- out << endl;
+ out << '\n';
indent_down();
- indent(out) << "}.toSet()" << endl;
+ indent(out) << "}.toSet()" << '\n';
indent_down();
indent(out) << "}";
} else if (ttype->is_list()) {
- out << "readList { tlist ->" << endl;
+ out << "readList { tlist ->" << '\n';
indent_up();
- indent(out) << "kotlin.collections.List(tlist.size) {" << endl;
+ indent(out) << "kotlin.collections.List(tlist.size) {" << '\n';
indent_up();
indent(out);
generate_deserialize_value(out, ((t_list*)ttype)->get_elem_type());
- out << endl;
+ out << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
indent_down();
indent(out) << "}";
} else {
@@ -1419,14 +1417,14 @@
ofstream_with_content_based_conditional_update out;
out.open(f_service_name.c_str());
out << autogen_comment() << kotlin_package();
- out << "interface " << tservice->get_name() << " {" << endl;
+ out << "interface " << tservice->get_name() << " {" << '\n';
indent_up();
for (auto tfunc : tservice->get_functions()) {
generate_kdoc_comment(out, tfunc);
- indent(out) << function_signature(tfunc) << endl;
+ indent(out) << function_signature(tfunc) << '\n';
}
scope_down(out);
- out << endl << endl;
+ out << '\n' << '\n';
out.close();
}
@@ -1437,22 +1435,22 @@
out << autogen_comment() << warning_surpressions() << kotlin_package();
generate_docstring_comment(out, "/**\n", " * ",
"client implementation for [" + tservice->get_name() + "]", " */\n");
- indent(out) << "class " << tservice->get_name() << "Client(" << endl;
+ indent(out) << "class " << tservice->get_name() << "Client(" << '\n';
indent_up();
- indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << endl;
- indent(out) << "clientManager: org.apache.thrift.async.TAsyncClientManager," << endl;
- indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport" << endl;
+ indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << '\n';
+ indent(out) << "clientManager: org.apache.thrift.async.TAsyncClientManager," << '\n';
+ indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport" << '\n';
indent_down();
out << "): org.apache.thrift.async.TAsyncClient(protocolFactory, clientManager, transport), "
- << tservice->get_name() << " {" << endl
- << endl;
+ << tservice->get_name() << " {" << '\n'
+ << '\n';
indent_up();
{
- indent(out) << "private val seqId = java.util.concurrent.atomic.AtomicInteger()" << endl
- << endl;
+ indent(out) << "private val seqId = java.util.concurrent.atomic.AtomicInteger()" << '\n'
+ << '\n';
for (auto tfunc : tservice->get_functions()) {
- indent(out) << "override " << function_signature(tfunc) << " {" << endl;
+ indent(out) << "override " << function_signature(tfunc) << " {" << '\n';
indent_up();
{
string args_name = tservice->get_name() + "FunctionArgs." + tfunc->get_name() + "_args";
@@ -1465,16 +1463,16 @@
first = false;
out << tfield->get_name();
}
- out << ")" << endl;
- indent(out) << "return transformCallback {" << endl;
+ out << ")" << '\n';
+ indent(out) << "return transformCallback {" << '\n';
indent_up();
{
- indent(out) << "checkReady()" << endl;
+ indent(out) << "checkReady()" << '\n';
indent(out)
<< "___currentMethod = ProcessCall." << tfunc->get_name()
<< "Call(args, seqId.getAndIncrement(), this, ___protocolFactory, ___transport, it)"
- << endl;
- indent(out) << "___manager.call(___currentMethod)" << endl;
+ << '\n';
+ indent(out) << "___manager.call(___currentMethod)" << '\n';
}
scope_down(out);
}
@@ -1484,22 +1482,22 @@
indent(out) << "private suspend fun <R> "
"org.apache.thrift.async.TAsyncClient.transformCallback(action: "
"(org.apache.thrift.async.AsyncMethodCallback<R>) -> Unit): R {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "val deferred = kotlinx.coroutines.CompletableDeferred<R>()" << endl;
+ indent(out) << "val deferred = kotlinx.coroutines.CompletableDeferred<R>()" << '\n';
indent(out) << "val callback = object : org.apache.thrift.async.AsyncMethodCallback<R> {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "override fun onComplete(response: R) { deferred.complete(response) }" << endl;
+ indent(out) << "override fun onComplete(response: R) { deferred.complete(response) }" << '\n';
indent(out) << "override fun onError(exception: java.lang.Exception) { "
"deferred.completeExceptionally(exception) }"
- << endl;
+ << '\n';
scope_down(out);
- indent(out) << "action(callback)" << endl;
- indent(out) << "return deferred.await()" << endl;
+ indent(out) << "action(callback)" << '\n';
+ indent(out) << "return deferred.await()" << '\n';
scope_down(out);
- indent(out) << "sealed interface ProcessCall {" << endl;
+ indent(out) << "sealed interface ProcessCall {" << '\n';
indent_up();
for (auto tfunc : tservice->get_functions()) {
generate_client_call(out, tservice, tfunc);
@@ -1507,7 +1505,7 @@
scope_down(out);
}
scope_down(out);
- out << endl << endl;
+ out << '\n' << '\n';
out.close();
}
@@ -1518,74 +1516,74 @@
string funclassname = funname + "Call";
string rtype = type_name(tfunc->get_returntype(), true);
- indent(out) << "class " + funclassname + "(" << endl;
+ indent(out) << "class " + funclassname + "(" << '\n';
indent_up();
string args_name = tservice->get_name() + "FunctionArgs." + tfunc->get_name() + "_args";
- indent(out) << "val args: " << args_name << "," << endl;
- indent(out) << "val seqId: kotlin.Int," << endl;
- indent(out) << "client: org.apache.thrift.async.TAsyncClient," << endl;
- indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << endl;
- indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport," << endl;
+ indent(out) << "val args: " << args_name << "," << '\n';
+ indent(out) << "val seqId: kotlin.Int," << '\n';
+ indent(out) << "client: org.apache.thrift.async.TAsyncClient," << '\n';
+ indent(out) << "protocolFactory: org.apache.thrift.protocol.TProtocolFactory," << '\n';
+ indent(out) << "transport: org.apache.thrift.transport.TNonblockingTransport," << '\n';
indent(out) << "resultHandler: org.apache.thrift.async.AsyncMethodCallback<" << rtype << ">,"
- << endl;
+ << '\n';
indent_down();
indent(out) << ") : org.apache.thrift.async.TAsyncMethodCall<" << rtype
<< ">(client, protocolFactory, transport, resultHandler, "
- << (tfunc->is_oneway() ? "true" : "false") << "), ProcessCall {" << endl;
+ << (tfunc->is_oneway() ? "true" : "false") << "), ProcessCall {" << '\n';
indent_up();
indent(out) << "override fun write_args(protocol: org.apache.thrift.protocol.TProtocol) {"
- << endl;
+ << '\n';
indent_up();
indent(out) << "val marker = org.apache.thrift.protocol.TMessage(\"" << tfunc->get_name()
- << "\", org.apache.thrift.protocol.TMessageType.CALL, seqId)" << endl;
- indent(out) << "protocol.writeMessage(marker) { args.write(protocol) }" << endl;
+ << "\", org.apache.thrift.protocol.TMessageType.CALL, seqId)" << '\n';
+ indent(out) << "protocol.writeMessage(marker) { args.write(protocol) }" << '\n';
scope_down(out);
- indent(out) << "override fun getResult(): " << rtype << " {" << endl;
+ indent(out) << "override fun getResult(): " << rtype << " {" << '\n';
indent_up();
indent(out) << "check(state == org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { "
"\"Method call not finished!\" }"
- << endl;
+ << '\n';
indent(out) << "val memoryTransport = "
"org.apache.thrift.transport.TMemoryInputTransport(frameBuffer.array())"
- << endl;
- indent(out) << "val protocol = client.protocolFactory.getProtocol(memoryTransport)" << endl;
+ << '\n';
+ indent(out) << "val protocol = client.protocolFactory.getProtocol(memoryTransport)" << '\n';
if (tfunc->is_oneway()) {
- indent(out) << "// one way function, nothing to read" << endl;
+ indent(out) << "// one way function, nothing to read" << '\n';
} else {
- indent(out) << "return protocol.readMessage {" << endl;
+ indent(out) << "return protocol.readMessage {" << '\n';
indent_up();
{
- indent(out) << "if (it.type == org.apache.thrift.protocol.TMessageType.EXCEPTION) {" << endl;
+ indent(out) << "if (it.type == org.apache.thrift.protocol.TMessageType.EXCEPTION) {" << '\n';
indent_up();
indent(out) << "val ex = org.apache.thrift.TApplicationException().apply { read(protocol) }"
- << endl;
- indent(out) << "throw ex" << endl;
+ << '\n';
+ indent(out) << "throw ex" << '\n';
scope_down(out);
- indent(out) << "if (it.seqid != seqId) {" << endl;
+ indent(out) << "if (it.seqid != seqId) {" << '\n';
indent_up();
- indent(out) << "throw org.apache.thrift.TApplicationException(" << endl;
+ indent(out) << "throw org.apache.thrift.TApplicationException(" << '\n';
indent_up();
- indent(out) << "org.apache.thrift.TApplicationException.BAD_SEQUENCE_ID," << endl;
+ indent(out) << "org.apache.thrift.TApplicationException.BAD_SEQUENCE_ID," << '\n';
indent(out) << "\"" << funname
<< " failed: out of sequence response: expected $seqId but got ${it.seqid}\""
- << endl;
+ << '\n';
indent_down();
- indent(out) << ")" << endl;
+ indent(out) << ")" << '\n';
scope_down(out);
string result_name = tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result";
- indent(out) << "val result = " << result_name << "().apply { read(protocol) }" << endl;
+ indent(out) << "val result = " << result_name << "().apply { read(protocol) }" << '\n';
for (auto xception : tfunc->get_xceptions()->get_members()) {
- indent(out) << "result." << xception->get_name() << "?.let { throw it }" << endl;
+ indent(out) << "result." << xception->get_name() << "?.let { throw it }" << '\n';
}
if (!tfunc->get_returntype()->is_void()) {
indent(out)
<< "result.success ?: throw "
"org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException."
"MISSING_RESULT, \"returnString failed: unknown result\")"
- << endl;
+ << '\n';
}
}
scope_down(out);
@@ -1601,43 +1599,43 @@
out << autogen_comment() << warning_surpressions() << kotlin_package();
auto service_imports = {"import kotlinx.coroutines.future.future"};
for (auto service_import : service_imports) {
- out << service_import << endl;
+ out << service_import << '\n';
}
- out << endl;
+ out << '\n';
generate_docstring_comment(out, "/**\n", " * ",
"server implementation for [" + tservice->get_name() + "]", " */\n");
- indent(out) << "class " << tservice->get_name() << "Processor(" << endl;
+ indent(out) << "class " << tservice->get_name() << "Processor(" << '\n';
indent_up();
- indent(out) << "handler: " << tservice->get_name() << "," << endl;
- indent(out) << "private val scope: kotlinx.coroutines.CoroutineScope," << endl;
+ indent(out) << "handler: " << tservice->get_name() << "," << '\n';
+ indent(out) << "private val scope: kotlinx.coroutines.CoroutineScope," << '\n';
indent(out) << "private val processMap: kotlin.collections.Map<kotlin.String, "
"org.apache.thrift.AsyncProcessFunction<"
<< tservice->get_name()
<< ", out org.apache.thrift.TBase<*, "
"*>, out kotlin.Any, out org.apache.thrift.TBase<*, *>>> = mapOf("
- << endl;
+ << '\n';
indent_up();
{
for (auto tfunc : tservice->get_functions()) {
indent(out) << '"' << tfunc->get_name() << '"' << " to ProcessFunction." << tfunc->get_name()
- << "(scope)," << endl;
+ << "(scope)," << '\n';
}
}
indent_down();
- indent(out) << ")" << endl;
+ indent(out) << ")" << '\n';
indent_down();
out << "): org.apache.thrift.TBaseAsyncProcessor<" << tservice->get_name()
- << ">(handler, processMap) {" << endl;
+ << ">(handler, processMap) {" << '\n';
indent_up();
- indent(out) << "companion object {" << endl;
+ indent(out) << "companion object {" << '\n';
indent_up();
indent(out) << "internal val logger: org.slf4j.Logger = "
"org.slf4j.LoggerFactory.getLogger("
- << tservice->get_name() << "Processor::class.java)" << endl;
+ << tservice->get_name() << "Processor::class.java)" << '\n';
scope_down(out);
- indent(out) << "sealed interface ProcessFunction {" << endl;
+ indent(out) << "sealed interface ProcessFunction {" << '\n';
indent_up();
{
@@ -1647,7 +1645,7 @@
}
scope_down(out);
scope_down(out);
- out << endl << endl;
+ out << '\n' << '\n';
out.close();
}
@@ -1663,25 +1661,25 @@
"org.apache.thrift.AsyncProcessFunction<I, "
<< args_name << ", " << rtype << ", "
<< (tfunc->is_oneway() ? "org.apache.thrift.TBase<*, *>" : resultname)
- << ">(\"" << tfunc->get_name() << "\"), ProcessFunction {"
- << endl;
+ << ">(\"" << tfunc->get_name() << "\"), ProcessFunction {"
+ << '\n';
indent_up();
{
- indent(out) << "override fun isOneway() = " << (tfunc->is_oneway() ? "true" : "false") << endl;
- indent(out) << "override fun getEmptyArgsInstance() = " << args_name << "()" << endl;
+ indent(out) << "override fun isOneway() = " << (tfunc->is_oneway() ? "true" : "false") << '\n';
+ indent(out) << "override fun getEmptyArgsInstance() = " << args_name << "()" << '\n';
indent(out) << "override fun getEmptyResultInstance() = ";
if (tfunc->is_oneway()) {
- out << "null" << endl;
+ out << "null" << '\n';
}
else {
- out << resultname << "()" << endl;
+ out << resultname << "()" << '\n';
}
- indent(out) << endl;
+ indent(out) << '\n';
indent(out) << "override fun start(iface: I, args: " << args_name
<< ", resultHandler: org.apache.thrift.async.AsyncMethodCallback<" << rtype
- << ">) {" << endl;
+ << ">) {" << '\n';
indent_up();
- indent(out) << "scope.future {" << endl;
+ indent(out) << "scope.future {" << '\n';
indent_up();
indent(out) << "iface." << tfunc->get_name() << "(";
{
@@ -1696,18 +1694,18 @@
out << "args." << tfield->get_name() << "!!";
}
}
- out << ")" << endl;
+ out << ")" << '\n';
indent_down();
- indent(out) << "}.whenComplete { r, t ->" << endl;
+ indent(out) << "}.whenComplete { r, t ->" << '\n';
{
indent_up();
- indent(out) << "if (t != null) {" << endl;
+ indent(out) << "if (t != null) {" << '\n';
indent_up();
- indent(out) << "resultHandler.onError(t as java.lang.Exception)" << endl;
+ indent(out) << "resultHandler.onError(t as java.lang.Exception)" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
- indent(out) << "resultHandler.onComplete(r)" << endl;
+ indent(out) << "resultHandler.onComplete(r)" << '\n';
}
scope_down(out);
scope_down(out);
@@ -1716,106 +1714,106 @@
indent(out) << "override fun getResultHandler(fb: "
"org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer, seqid: "
"Int) ="
- << endl;
+ << '\n';
indent_up();
{
indent(out) << "object : org.apache.thrift.async.AsyncMethodCallback<" << rtype << ">{"
- << endl;
+ << '\n';
indent_up();
{
- indent(out) << "override fun onComplete(response: " << rtype << ") {" << endl;
+ indent(out) << "override fun onComplete(response: " << rtype << ") {" << '\n';
indent_up();
if (tfunc->is_oneway()) {
- indent(out) << "// one way function, no result handling" << endl;
+ indent(out) << "// one way function, no result handling" << '\n';
} else {
string result_name
= tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result";
- indent(out) << "val result = " << result_name << "()" << endl;
+ indent(out) << "val result = " << result_name << "()" << '\n';
if (!tfunc->get_returntype()->is_void()) {
- indent(out) << "result.success = response" << endl;
+ indent(out) << "result.success = response" << '\n';
}
- indent(out) << "try {" << endl;
+ indent(out) << "try {" << '\n';
indent_up();
indent(out)
<< "sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY, seqid)"
- << endl;
+ << '\n';
indent_down();
- indent(out) << "} catch (e: org.apache.thrift.transport.TTransportException) {" << endl;
+ indent(out) << "} catch (e: org.apache.thrift.transport.TTransportException) {" << '\n';
indent_up();
indent(out) << "logger.error(\"TTransportException writing to internal frame buffer\", e)"
- << endl;
- indent(out) << "fb.close()" << endl;
+ << '\n';
+ indent(out) << "fb.close()" << '\n';
indent_down();
- indent(out) << "} catch (e: Exception) {" << endl;
+ indent(out) << "} catch (e: Exception) {" << '\n';
indent_up();
- indent(out) << "logger.error(\"Exception writing to internal frame buffer\", e)" << endl;
- indent(out) << "onError(e)" << endl;
+ indent(out) << "logger.error(\"Exception writing to internal frame buffer\", e)" << '\n';
+ indent(out) << "onError(e)" << '\n';
scope_down(out);
}
scope_down(out);
}
{
- indent(out) << "override fun onError(exception: kotlin.Exception) {" << endl;
+ indent(out) << "override fun onError(exception: kotlin.Exception) {" << '\n';
indent_up();
if (tfunc->is_oneway()) {
indent(out) << "if (exception is org.apache.thrift.transport.TTransportException) {"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << endl;
- indent(out) << "fb.close()" << endl;
+ indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << '\n';
+ indent(out) << "fb.close()" << '\n';
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
indent_up();
- indent(out) << "logger.error(\"Exception inside oneway handler\", exception)" << endl;
+ indent(out) << "logger.error(\"Exception inside oneway handler\", exception)" << '\n';
scope_down(out);
} else {
- indent(out) << "val (msgType, msg) = when (exception) {" << endl;
+ indent(out) << "val (msgType, msg) = when (exception) {" << '\n';
indent_up();
auto xceptions = tfunc->get_xceptions()->get_members();
for (auto xception : xceptions) {
- indent(out) << "is " << type_name(xception->get_type()) << " -> {" << endl;
+ indent(out) << "is " << type_name(xception->get_type()) << " -> {" << '\n';
indent_up();
string result_name
= tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result";
- indent(out) << "val result = " << result_name << "()" << endl;
- indent(out) << "result." << xception->get_name() << " = exception" << endl;
- indent(out) << "org.apache.thrift.protocol.TMessageType.REPLY to result" << endl;
+ indent(out) << "val result = " << result_name << "()" << '\n';
+ indent(out) << "result." << xception->get_name() << " = exception" << '\n';
+ indent(out) << "org.apache.thrift.protocol.TMessageType.REPLY to result" << '\n';
scope_down(out);
}
- indent(out) << "is org.apache.thrift.transport.TTransportException -> {" << endl;
+ indent(out) << "is org.apache.thrift.transport.TTransportException -> {" << '\n';
indent_up();
- indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << endl;
- indent(out) << "fb.close()" << endl;
- indent(out) << "return" << endl;
+ indent(out) << "logger.error(\"TTransportException inside handler\", exception)" << '\n';
+ indent(out) << "fb.close()" << '\n';
+ indent(out) << "return" << '\n';
scope_down(out);
- indent(out) << "is org.apache.thrift.TApplicationException -> {" << endl;
+ indent(out) << "is org.apache.thrift.TApplicationException -> {" << '\n';
indent_up();
indent(out) << "logger.error(\"TApplicationException inside handler\", exception)"
- << endl;
- indent(out) << "org.apache.thrift.protocol.TMessageType.EXCEPTION to exception" << endl;
+ << '\n';
+ indent(out) << "org.apache.thrift.protocol.TMessageType.EXCEPTION to exception" << '\n';
scope_down(out);
- indent(out) << "else -> {" << endl;
+ indent(out) << "else -> {" << '\n';
indent_up();
- indent(out) << "logger.error(\"Exception inside handler\", exception)" << endl;
+ indent(out) << "logger.error(\"Exception inside handler\", exception)" << '\n';
indent(out) << "org.apache.thrift.protocol.TMessageType.EXCEPTION to "
"org.apache.thrift.TApplicationException(org.apache.thrift."
"TApplicationException.INTERNAL_ERROR, exception.message)"
- << endl;
+ << '\n';
scope_down(out);
scope_down(out);
- indent(out) << "try {" << endl;
+ indent(out) << "try {" << '\n';
indent_up();
- indent(out) << "sendResponse(fb, msg, msgType, seqid)" << endl;
+ indent(out) << "sendResponse(fb, msg, msgType, seqid)" << '\n';
indent_down();
- indent(out) << "} catch (ex: java.lang.Exception) {" << endl;
+ indent(out) << "} catch (ex: java.lang.Exception) {" << '\n';
indent_up();
- indent(out) << "logger.error(\"Exception writing to internal frame buffer\", ex)" << endl;
- indent(out) << "fb.close()" << endl;
+ indent(out) << "logger.error(\"Exception writing to internal frame buffer\", ex)" << '\n';
+ indent(out) << "fb.close()" << '\n';
scope_down(out);
}
@@ -1836,7 +1834,7 @@
generate_docstring_comment(out, "/**\n", " * ",
"function result for [" + tservice->get_name() + "]", " */\n");
- indent(out) << "sealed interface " << tservice->get_name() << "FunctionResult {" << endl;
+ indent(out) << "sealed interface " << tservice->get_name() << "FunctionResult {" << '\n';
indent_up();
for (auto func : tservice->get_functions()) {
if (func->is_oneway()) {
@@ -1863,12 +1861,12 @@
out << autogen_comment() << warning_surpressions() << kotlin_package();
generate_docstring_comment(out, "/**\n", " * ",
"function arguments for [" + tservice->get_name() + "]", " */\n");
- indent(out) << "sealed interface " << tservice->get_name() << "FunctionArgs {" << endl;
+ indent(out) << "sealed interface " << tservice->get_name() << "FunctionArgs {" << '\n';
indent_up();
for (auto func : tservice->get_functions()) {
t_struct* ts = func->get_arglist();
generate_struct_definition(out, ts, false, tservice->get_name() + "FunctionArgs");
- out << endl;
+ out << '\n';
}
scope_down(out);
out.close();
@@ -1972,7 +1970,7 @@
*/
string t_kotlin_generator::kotlin_package() {
if (!package_name_.empty()) {
- return string("package ") + package_name_ + endl + endl;
+ return string("package ") + package_name_ + "\n" + "\n";
}
return "";
}
@@ -1980,8 +1978,7 @@
string t_kotlin_generator::warning_surpressions() {
return "@file:Suppress(\"ClassName\", \"PropertyName\", \"RedundantUnitReturnType\", "
"\"NestedLambdaShadowedImplicitParameter\", "
- "\"RemoveRedundantQualifierName\")"
- + endl;
+ "\"RemoveRedundantQualifierName\")\n";
}
string t_kotlin_generator::constant_name(string name) {
diff --git a/compiler/cpp/src/thrift/generate/t_lua_generator.cc b/compiler/cpp/src/thrift/generate/t_lua_generator.cc
index 0dc7743..642dd9c 100644
--- a/compiler/cpp/src/thrift/generate/t_lua_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_lua_generator.cc
@@ -26,8 +26,6 @@
using std::vector;
using std::map;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* LUA code generator.
*
@@ -190,7 +188,7 @@
f_consts_ << autogen_comment() << lua_includes();
f_types_ << autogen_comment() << lua_includes();
if (gen_requires_) {
- f_types_ << endl << "require '" << cur_namespace << "constants'";
+ f_types_ << '\n' << "require '" << cur_namespace << "constants'";
}
}
@@ -207,7 +205,7 @@
if (ttypedef->get_type()->get_name().empty()) {
return;
}
- f_types_ << endl << endl << indent() << ttypedef->get_symbolic() << " = "
+ f_types_ << '\n' << '\n' << indent() << ttypedef->get_symbolic() << " = "
<< ttypedef->get_type()->get_name();
}
@@ -215,7 +213,7 @@
* Generates code for an enumerated type (table)
*/
void t_lua_generator::generate_enum(t_enum* tenum) {
- f_types_ << endl << endl << tenum->get_name() << " = {" << endl;
+ f_types_ << '\n' << '\n' << tenum->get_name() << " = {" << '\n';
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
@@ -227,7 +225,7 @@
if (c_iter != constants.end()) {
f_types_ << ",";
}
- f_types_ << endl;
+ f_types_ << '\n';
}
f_types_ << "}";
}
@@ -240,7 +238,7 @@
string name = tconst->get_name();
t_const_value* value = tconst->get_value();
- f_consts_ << endl << endl << name << " = ";
+ f_consts_ << '\n' << '\n' << name << " = ";
f_consts_ << render_const_value(type, value);
}
@@ -281,7 +279,7 @@
} else if (type->is_enum()) {
out << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
- out << type->get_name() << " = {" << endl;
+ out << type->get_name() << " = {" << '\n';
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
@@ -312,7 +310,7 @@
out << "}";
indent_down();
} else if (type->is_map()) {
- out << type->get_name() << "{" << endl;
+ out << type->get_name() << "{" << '\n';
indent_up();
t_type* ktype = ((t_map*)type)->get_key_type();
@@ -327,7 +325,7 @@
if (v_iter != val.end()) {
out << ",";
}
- out << endl;
+ out << '\n';
}
indent_down();
indent(out) << "}";
@@ -338,7 +336,7 @@
} else {
etype = ((t_set*)type)->get_elem_type();
}
- out << type->get_name() << " = {" << endl;
+ out << type->get_name() << " = {" << '\n';
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end();) {
@@ -351,7 +349,7 @@
}
++v_iter;
if (v_iter != val.end()) {
- out << "," << endl;
+ out << "," << '\n';
}
}
out << "}";
@@ -382,15 +380,15 @@
vector<t_field*>::const_iterator m_iter;
const vector<t_field*>& members = tstruct->get_members();
- indent(out) << endl << endl << tstruct->get_name();
+ indent(out) << '\n' << '\n' << tstruct->get_name();
if (is_exception) {
- out << " = TException:new{" << endl << indent() << " __type = '" << tstruct->get_name() << "'";
+ out << " = TException:new{" << '\n' << indent() << " __type = '" << tstruct->get_name() << "'";
if (members.size() > 0) {
out << ",";
}
- out << endl;
+ out << '\n';
} else {
- out << " = __TObject:new{" << endl;
+ out << " = __TObject:new{" << '\n';
}
indent_up();
for (m_iter = members.begin(); m_iter != members.end();) {
@@ -398,12 +396,12 @@
out << (*m_iter)->get_name();
++m_iter;
if (m_iter != members.end()) {
- out << "," << endl;
+ out << "," << '\n';
}
}
indent_down();
indent(out);
- out << endl << "}";
+ out << '\n' << "}";
generate_lua_struct_reader(out, tstruct);
generate_lua_struct_writer(out, tstruct);
@@ -417,48 +415,48 @@
vector<t_field*>::const_iterator f_iter;
// function
- indent(out) << endl << endl << "function " << tstruct->get_name() << ":read(iprot)" << endl;
+ indent(out) << '\n' << '\n' << "function " << tstruct->get_name() << ":read(iprot)" << '\n';
indent_up();
- indent(out) << "iprot:readStructBegin()" << endl;
+ indent(out) << "iprot:readStructBegin()" << '\n';
// while: Read in fields
- indent(out) << "while true do" << endl;
+ indent(out) << "while true do" << '\n';
indent_up();
// if: Check what to read
- indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << endl;
- indent(out) << "if ftype == TType.STOP then" << endl;
+ indent(out) << "local fname, ftype, fid = iprot:readFieldBegin()" << '\n';
+ indent(out) << "if ftype == TType.STOP then" << '\n';
indent_up();
- indent(out) << "break" << endl;
+ indent(out) << "break" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent_down();
- indent(out) << "elseif fid == " << (*f_iter)->get_key() << " then" << endl;
+ indent(out) << "elseif fid == " << (*f_iter)->get_key() << " then" << '\n';
indent_up();
- indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << " then" << endl;
+ indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << " then" << '\n';
indent_up();
// Read field contents
generate_deserialize_field(out, *f_iter, false, "self.");
indent_down();
- indent(out) << "else" << endl;
- indent(out) << " iprot:skip(ftype)" << endl;
- indent(out) << "end" << endl;
+ indent(out) << "else" << '\n';
+ indent(out) << " iprot:skip(ftype)" << '\n';
+ indent(out) << "end" << '\n';
}
// end if
indent_down();
- indent(out) << "else" << endl;
- indent(out) << " iprot:skip(ftype)" << endl;
- indent(out) << "end" << endl;
- indent(out) << "iprot:readFieldEnd()" << endl;
+ indent(out) << "else" << '\n';
+ indent(out) << " iprot:skip(ftype)" << '\n';
+ indent(out) << "end" << '\n';
+ indent(out) << "iprot:readFieldEnd()" << '\n';
// end while
indent_down();
- indent(out) << "end" << endl;
- indent(out) << "iprot:readStructEnd()" << endl;
+ indent(out) << "end" << '\n';
+ indent(out) << "iprot:readStructEnd()" << '\n';
// end function
indent_down();
@@ -474,28 +472,28 @@
vector<t_field*>::const_iterator f_iter;
// function
- indent(out) << endl << endl << "function " << tstruct->get_name() << ":write(oprot)" << endl;
+ indent(out) << '\n' << '\n' << "function " << tstruct->get_name() << ":write(oprot)" << '\n';
indent_up();
- indent(out) << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << endl;
+ indent(out) << "oprot:writeStructBegin('" << tstruct->get_name() << "')" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
// To check element of self whether nil or not.
// avoid the value(false) of BOOL is lost.
- indent(out) << "if self." << (*f_iter)->get_name() << " ~= nil then" << endl;
+ indent(out) << "if self." << (*f_iter)->get_name() << " ~= nil then" << '\n';
indent_up();
indent(out) << "oprot:writeFieldBegin('" << (*f_iter)->get_name() << "', "
<< type_to_enum((*f_iter)->get_type()) << ", " << (*f_iter)->get_key() << ")"
- << endl;
+ << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "self.");
- indent(out) << "oprot:writeFieldEnd()" << endl;
+ indent(out) << "oprot:writeFieldEnd()" << '\n';
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
}
- indent(out) << "oprot:writeFieldStop()" << endl;
- indent(out) << "oprot:writeStructEnd()" << endl;
+ indent(out) << "oprot:writeFieldStop()" << '\n';
+ indent(out) << "oprot:writeStructEnd()" << '\n';
// end function
indent_down();
@@ -518,15 +516,15 @@
// Headers
f_service_ << autogen_comment() << lua_includes();
if (gen_requires_) {
- f_service_ << endl << "require '" << cur_ns << "ttypes'" << endl;
+ f_service_ << '\n' << "require '" << cur_ns << "ttypes'" << '\n';
if (tservice->get_extends() != nullptr) {
f_service_ << "require '" << get_namespace(tservice->get_extends()->get_program())
- << tservice->get_extends()->get_name() << "'" << endl;
+ << tservice->get_extends()->get_name() << "'" << '\n';
}
}
- f_service_ << endl;
+ f_service_ << '\n';
generate_service_client(f_service_, tservice);
generate_service_interface(f_service_, tservice);
@@ -544,11 +542,11 @@
// Interface object definition
out << classname << " = ";
if (extends_s) {
- out << extends_s->get_name() << "Iface:new{" << endl;
+ out << extends_s->get_name() << "Iface:new{" << '\n';
} else {
- out << "__TObject:new{" << endl;
+ out << "__TObject:new{" << '\n';
}
- out << " __type = '" << classname << "'" << endl << "}" << endl << endl;
+ out << " __type = '" << classname << "'" << '\n' << "}" << '\n' << '\n';
}
void t_lua_generator::generate_service_client(ostream& out, t_service* tservice) {
@@ -562,7 +560,7 @@
} else {
out << "__TClient";
}
- out << ", {" << endl << " __type = '" << classname << "'" << endl << "})" << endl;
+ out << ", {" << '\n' << " __type = '" << classname << "'" << '\n' << "})" << '\n';
// Send/Recv functions
vector<t_function*> functions = tservice->get_functions();
@@ -572,28 +570,28 @@
string funcname = (*f_iter)->get_name();
// Wrapper function
- indent(out) << endl << "function " << classname << ":" << sig << endl;
+ indent(out) << '\n' << "function " << classname << ":" << sig << '\n';
indent_up();
- indent(out) << "self:send_" << sig << endl << indent();
+ indent(out) << "self:send_" << sig << '\n' << indent();
if (!(*f_iter)->is_oneway()) {
if (!(*f_iter)->get_returntype()->is_void()) {
out << "return ";
}
- out << "self:recv_" << sig << endl;
+ out << "self:recv_" << sig << '\n';
}
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
// Send function
- indent(out) << endl << "function " << classname << ":send_" << sig << endl;
+ indent(out) << '\n' << "function " << classname << ":send_" << sig << '\n';
indent_up();
indent(out) << "self.oprot:writeMessageBegin('" << funcname << "', "
<< ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
- << ", self._seqid)" << endl;
- indent(out) << "local args = " << funcname << "_args:new{}" << endl;
+ << ", self._seqid)" << '\n';
+ indent(out) << "local args = " << funcname << "_args:new{}" << '\n';
// Set the args
const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
@@ -603,60 +601,60 @@
if ((*fld_iter)->get_value() != nullptr) {
// Insert default value for nil arguments
t_type* type = get_true_type((*fld_iter)->get_type());
- indent(out) << "if " << argname << " ~= nil then" << endl;
+ indent(out) << "if " << argname << " ~= nil then" << '\n';
indent_up();
- indent(out) << "args." << argname << " = " << argname << endl;
+ indent(out) << "args." << argname << " = " << argname << '\n';
indent_down();
- indent(out) << "else" << endl;
+ indent(out) << "else" << '\n';
indent_up();
- indent(out) << "args." << argname << " = " << render_const_value(type, (*fld_iter)->get_value()) << endl;
+ indent(out) << "args." << argname << " = " << render_const_value(type, (*fld_iter)->get_value()) << '\n';
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
} else {
- indent(out) << "args." << argname << " = " << argname << endl;
+ indent(out) << "args." << argname << " = " << argname << '\n';
}
}
- indent(out) << "args:write(self.oprot)" << endl;
- indent(out) << "self.oprot:writeMessageEnd()" << endl;
- indent(out) << "self.oprot.trans:flush()" << endl;
+ indent(out) << "args:write(self.oprot)" << '\n';
+ indent(out) << "self.oprot:writeMessageEnd()" << '\n';
+ indent(out) << "self.oprot.trans:flush()" << '\n';
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
// Recv function
if (!(*f_iter)->is_oneway()) {
- indent(out) << endl << "function " << classname << ":recv_" << sig << endl;
+ indent(out) << '\n' << "function " << classname << ":recv_" << sig << '\n';
indent_up();
out << indent() << "local fname, mtype, rseqid = self.iprot:"
- << "readMessageBegin()" << endl << indent() << "if mtype == TMessageType.EXCEPTION then"
- << endl << indent() << " local x = TApplicationException:new{}" << endl << indent()
- << " x:read(self.iprot)" << endl << indent() << " self.iprot:readMessageEnd()" << endl
- << indent() << " error(x)" << endl << indent() << "end" << endl << indent()
- << "local result = " << funcname << "_result:new{}" << endl << indent()
- << "result:read(self.iprot)" << endl << indent() << "self.iprot:readMessageEnd()" << endl;
+ << "readMessageBegin()" << '\n' << indent() << "if mtype == TMessageType.EXCEPTION then"
+ << '\n' << indent() << " local x = TApplicationException:new{}" << '\n' << indent()
+ << " x:read(self.iprot)" << '\n' << indent() << " self.iprot:readMessageEnd()" << '\n'
+ << indent() << " error(x)" << '\n' << indent() << "end" << '\n' << indent()
+ << "local result = " << funcname << "_result:new{}" << '\n' << indent()
+ << "result:read(self.iprot)" << '\n' << indent() << "self.iprot:readMessageEnd()" << '\n';
// Return the result if it's not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- out << indent() << "if result.success ~= nil then" << endl << indent() << " return result.success"
- << endl;
+ out << indent() << "if result.success ~= nil then" << '\n' << indent() << " return result.success"
+ << '\n';
// Throw custom exceptions
const std::vector<t_field*>& xf = (*f_iter)->get_xceptions()->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
- out << indent() << "elseif result." << (*x_iter)->get_name() << " then" << endl
- << indent() << " error(result." << (*x_iter)->get_name() << ")" << endl;
+ out << indent() << "elseif result." << (*x_iter)->get_name() << " then" << '\n'
+ << indent() << " error(result." << (*x_iter)->get_name() << ")" << '\n';
}
- out << indent() << "end" << endl << indent()
+ out << indent() << "end" << '\n' << indent()
<< "error(TApplicationException:new{errorCode = "
- << "TApplicationException.MISSING_RESULT})" << endl;
+ << "TApplicationException.MISSING_RESULT})" << '\n';
}
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
}
}
}
@@ -666,40 +664,40 @@
t_service* extends_s = tservice->get_extends();
// Define processor table
- out << endl << classname << " = __TObject.new(";
+ out << '\n' << classname << " = __TObject.new(";
if (extends_s != nullptr) {
- out << extends_s->get_name() << "Processor" << endl;
+ out << extends_s->get_name() << "Processor" << '\n';
} else {
- out << "__TProcessor" << endl;
+ out << "__TProcessor" << '\n';
}
- out << ", {" << endl << " __type = '" << classname << "'" << endl << "})" << endl;
+ out << ", {" << '\n' << " __type = '" << classname << "'" << '\n' << "})" << '\n';
// Process function
- indent(out) << endl << "function " << classname << ":process(iprot, oprot, server_ctx)" << endl;
+ indent(out) << '\n' << "function " << classname << ":process(iprot, oprot, server_ctx)" << '\n';
indent_up();
- indent(out) << "local name, mtype, seqid = iprot:readMessageBegin()" << endl;
- indent(out) << "local func_name = 'process_' .. name" << endl;
- indent(out) << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then" << endl;
+ indent(out) << "local name, mtype, seqid = iprot:readMessageBegin()" << '\n';
+ indent(out) << "local func_name = 'process_' .. name" << '\n';
+ indent(out) << "if not self[func_name] or ttype(self[func_name]) ~= 'function' then" << '\n';
indent_up();
indent(out) << "if oprot ~= nil then";
indent_up();
- out << endl << indent() << "iprot:skip(TType.STRUCT)" << endl << indent()
- << "iprot:readMessageEnd()" << endl << indent() << "x = TApplicationException:new{" << endl
- << indent() << " errorCode = TApplicationException.UNKNOWN_METHOD" << endl << indent() << "}"
- << endl << indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, "
- << "seqid)" << endl << indent() << "x:write(oprot)" << endl << indent()
- << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl;
+ out << '\n' << indent() << "iprot:skip(TType.STRUCT)" << '\n' << indent()
+ << "iprot:readMessageEnd()" << '\n' << indent() << "x = TApplicationException:new{" << '\n'
+ << indent() << " errorCode = TApplicationException.UNKNOWN_METHOD" << '\n' << indent() << "}"
+ << '\n' << indent() << "oprot:writeMessageBegin(name, TMessageType.EXCEPTION, "
+ << "seqid)" << '\n' << indent() << "x:write(oprot)" << '\n' << indent()
+ << "oprot:writeMessageEnd()" << '\n' << indent() << "oprot.trans:flush()" << '\n';
indent_down();
- out << indent() << "end" << endl << indent()
- << "return false, 'Unknown function '..name" << endl;
+ out << indent() << "end" << '\n' << indent()
+ << "return false, 'Unknown function '..name" << '\n';
indent_down();
- indent(out) << "else" << endl << indent()
- << " return self[func_name](self, seqid, iprot, oprot, server_ctx)" << endl << indent()
- << "end" << endl;
+ indent(out) << "else" << '\n' << indent()
+ << " return self[func_name](self, seqid, iprot, oprot, server_ctx)" << '\n' << indent()
+ << "end" << '\n';
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
// Generate the process subfunctions
vector<t_function*> functions = tservice->get_functions();
@@ -717,18 +715,18 @@
string resultname = tfunction->get_name() + "_result";
string fn_name = tfunction->get_name();
- indent(out) << endl << "function " << classname << ":process_" << fn_name
- << "(seqid, iprot, oprot, server_ctx)" << endl;
+ indent(out) << '\n' << "function " << classname << ":process_" << fn_name
+ << "(seqid, iprot, oprot, server_ctx)" << '\n';
indent_up();
// Read the request
- out << indent() << "local args = " << argsname << ":new{}" << endl << indent()
- << "local reply_type = TMessageType.REPLY" << endl << indent() << "args:read(iprot)" << endl
- << indent() << "iprot:readMessageEnd()" << endl;
+ out << indent() << "local args = " << argsname << ":new{}" << '\n' << indent()
+ << "local reply_type = TMessageType.REPLY" << '\n' << indent() << "args:read(iprot)" << '\n'
+ << indent() << "iprot:readMessageEnd()" << '\n';
if (!tfunction->is_oneway()) {
out << indent() << "local result = " << resultname
- << ":new{}" << endl;
+ << ":new{}" << '\n';
}
out << indent() << "local status, res = pcall(self.handler." << fn_name
@@ -738,13 +736,13 @@
if (args->get_members().size() > 0) {
out << ", " << argument_list(args, "args.");
}
- out << ")" << endl;
+ out << ")" << '\n';
if (!tfunction->is_oneway()) {
// Check for errors
- out << indent() << "if not status then" << endl << indent()
- << " reply_type = TMessageType.EXCEPTION" << endl << indent()
- << " result = TApplicationException:new{message = res}" << endl;
+ out << indent() << "if not status then" << '\n' << indent()
+ << " reply_type = TMessageType.EXCEPTION" << '\n' << indent()
+ << " result = TApplicationException:new{message = res}" << '\n';
// Handle custom exceptions
const std::vector<t_field*>& xf = tfunction->get_xceptions()->get_members();
@@ -752,19 +750,19 @@
vector<t_field*>::const_iterator x_iter;
for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
out << indent() << "elseif ttype(res) == '" << (*x_iter)->get_type()->get_name() << "' then"
- << endl << indent() << " result." << (*x_iter)->get_name() << " = res" << endl;
+ << '\n' << indent() << " result." << (*x_iter)->get_name() << " = res" << '\n';
}
}
// Set the result and write the reply
- out << indent() << "else" << endl << indent() << " result.success = res" << endl << indent()
- << "end" << endl << indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, "
- << "seqid)" << endl << indent() << "result:write(oprot)" << endl << indent()
- << "oprot:writeMessageEnd()" << endl << indent() << "oprot.trans:flush()" << endl;
+ out << indent() << "else" << '\n' << indent() << " result.success = res" << '\n' << indent()
+ << "end" << '\n' << indent() << "oprot:writeMessageBegin('" << fn_name << "', reply_type, "
+ << "seqid)" << '\n' << indent() << "result:write(oprot)" << '\n' << indent()
+ << "oprot:writeMessageEnd()" << '\n' << indent() << "oprot.trans:flush()" << '\n';
}
- out << indent() << "return status, res" << endl;
+ out << indent() << "return status, res" << '\n';
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
}
// Service helpers
@@ -772,7 +770,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- out << endl << "-- HELPER FUNCTIONS AND STRUCTURES";
+ out << '\n' << "-- HELPER FUNCTIONS AND STRUCTURES";
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
generate_lua_struct_definition(out, ts, false);
@@ -853,7 +851,7 @@
} else if (type->is_enum()) {
out << "readI32()";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
@@ -867,7 +865,7 @@
bool local,
string prefix) {
indent(out) << (local ? "local " : "") << prefix << " = " << tstruct->get_name() << ":new{}"
- << endl << indent() << prefix << ":read(iprot)" << endl;
+ << '\n' << indent() << prefix << ":read(iprot)" << '\n';
}
void t_lua_generator::generate_deserialize_container(ostream& out,
@@ -885,18 +883,18 @@
t_field fetype(g_type_i8, etype);
// Declare variables, read header
- indent(out) << (local ? "local " : "") << prefix << " = {}" << endl;
+ indent(out) << (local ? "local " : "") << prefix << " = {}" << '\n';
if (ttype->is_map()) {
indent(out) << "local " << ktype << ", " << vtype << ", " << size << " = iprot:readMapBegin() "
- << endl;
+ << '\n';
} else if (ttype->is_set()) {
- indent(out) << "local " << etype << ", " << size << " = iprot:readSetBegin()" << endl;
+ indent(out) << "local " << etype << ", " << size << " = iprot:readSetBegin()" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "local " << etype << ", " << size << " = iprot:readListBegin()" << endl;
+ indent(out) << "local " << etype << ", " << size << " = iprot:readListBegin()" << '\n';
}
// Deserialize
- indent(out) << "for _i=1," << size << " do" << endl;
+ indent(out) << "for _i=1," << size << " do" << '\n';
indent_up();
if (ttype->is_map()) {
@@ -908,15 +906,15 @@
}
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
// Read container end
if (ttype->is_map()) {
- indent(out) << "iprot:readMapEnd()" << endl;
+ indent(out) << "iprot:readMapEnd()" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "iprot:readSetEnd()" << endl;
+ indent(out) << "iprot:readSetEnd()" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "iprot:readListEnd()" << endl;
+ indent(out) << "iprot:readListEnd()" << '\n';
}
}
@@ -930,7 +928,7 @@
generate_deserialize_field(out, &fkey, true);
generate_deserialize_field(out, &fval, true);
- indent(out) << prefix << "[" << key << "] = " << val << endl;
+ indent(out) << prefix << "[" << key << "] = " << val << '\n';
}
void t_lua_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
@@ -940,7 +938,7 @@
generate_deserialize_field(out, &felem, true);
- indent(out) << prefix << "[" << elem << "] = " << elem << endl;
+ indent(out) << prefix << "[" << elem << "] = " << elem << '\n';
}
void t_lua_generator::generate_deserialize_list_element(ostream& out,
@@ -953,7 +951,7 @@
generate_deserialize_field(out, &felem, true);
- indent(out) << "table.insert(" << prefix << ", " << elem << ")" << endl;
+ indent(out) << "table.insert(" << prefix << ", " << elem << ")" << '\n';
}
/**
@@ -1008,7 +1006,7 @@
} else if (type->is_enum()) {
out << "writeI32(" << name << ")";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s' TYPE '%s'\n",
name.c_str(),
@@ -1018,7 +1016,7 @@
void t_lua_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- indent(out) << prefix << ":write(oprot)" << endl;
+ indent(out) << prefix << ":write(oprot)" << '\n';
}
void t_lua_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
@@ -1026,48 +1024,48 @@
if (ttype->is_map()) {
indent(out) << "oprot:writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "ttable_size(" << prefix << "))" << endl;
+ << "ttable_size(" << prefix << "))" << '\n';
} else if (ttype->is_set()) {
indent(out) << "oprot:writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
- << "ttable_size(" << prefix << "))" << endl;
+ << "ttable_size(" << prefix << "))" << '\n';
} else if (ttype->is_list()) {
indent(out) << "oprot:writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
<< ", "
- << "#" << prefix << ")" << endl;
+ << "#" << prefix << ")" << '\n';
}
// Serialize
if (ttype->is_map()) {
string kiter = tmp("kiter");
string viter = tmp("viter");
- indent(out) << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do" << endl;
+ indent(out) << "for " << kiter << "," << viter << " in pairs(" << prefix << ") do" << '\n';
indent_up();
generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
} else if (ttype->is_set()) {
string iter = tmp("iter");
- indent(out) << "for " << iter << ",_ in pairs(" << prefix << ") do" << endl;
+ indent(out) << "for " << iter << ",_ in pairs(" << prefix << ") do" << '\n';
indent_up();
generate_serialize_set_element(out, (t_set*)ttype, iter);
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
} else if (ttype->is_list()) {
string iter = tmp("iter");
- indent(out) << "for _," << iter << " in ipairs(" << prefix << ") do" << endl;
+ indent(out) << "for _," << iter << " in ipairs(" << prefix << ") do" << '\n';
indent_up();
generate_serialize_list_element(out, (t_list*)ttype, iter);
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
}
// Finish writing
if (ttype->is_map()) {
- indent(out) << "oprot:writeMapEnd()" << endl;
+ indent(out) << "oprot:writeMapEnd()" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "oprot:writeSetEnd()" << endl;
+ indent(out) << "oprot:writeSetEnd()" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "oprot:writeListEnd()" << endl;
+ indent(out) << "oprot:writeListEnd()" << '\n';
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_markdown_generator.cc b/compiler/cpp/src/thrift/generate/t_markdown_generator.cc
index 76fe98b..fbcaccc 100644
--- a/compiler/cpp/src/thrift/generate/t_markdown_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_markdown_generator.cc
@@ -38,9 +38,6 @@
using std::stringstream;
using std::vector;
-static const char endl = '\n'; // avoid ostream << std::endl flushes
-
-
/**
* MARKDOWN code generator
*
@@ -55,7 +52,7 @@
const std::map<std::string, std::string>& parsed_options,
const std::string& option_string)
: t_generator(program) {
-
+
(void)option_string;
std::map<std::string, std::string>::const_iterator iter;
@@ -128,14 +125,14 @@
/**
- * string to markdown-id link reference
+ * string to markdown-id link reference
*/
std::string t_markdown_generator::str_to_id(const std::string& s) {
std::string id;
for(auto chr=s.begin();chr<=s.end(); ++chr) {
if(*chr == '.' || *chr == 0)
continue;
- id += tolower(*chr);
+ id += tolower(*chr);
}
return id;
}
@@ -144,10 +141,10 @@
* Emits the Table of Contents links at the top of the module's page
*/
void t_markdown_generator::generate_program_toc() {
- f_out_ << "| Module | Services & Functions | Data types | Constants |" << endl
- << "| --- | --- | --- | --- |" << endl;
+ f_out_ << "| Module | Services & Functions | Data types | Constants |" << '\n'
+ << "| --- | --- | --- | --- |" << '\n';
generate_program_toc_row(program_);
- f_out_ << endl;
+ f_out_ << '\n';
}
/**
@@ -191,24 +188,24 @@
fill = &filling.back();
}
string name = get_service_name(*sv_iter);
- (*fill)[1] = "[" + name + "]("
- + make_file_link(fname)
+ (*fill)[1] = "[" + name + "]("
+ + make_file_link(fname)
+ "#service-" + str_to_id(name) + ")";
-
+
vector<t_function*> functions = (*sv_iter)->get_functions();
vector<t_function*>::iterator fn_iter;
- for (fn_iter = functions.begin(); fn_iter != functions.end(); ++fn_iter) {
- string fn_name = (*fn_iter)->get_name();
+ for (fn_iter = functions.begin(); fn_iter != functions.end(); ++fn_iter) {
+ string fn_name = (*fn_iter)->get_name();
filling.emplace_back();
fill = &filling.back();
- (*fill)[1] = " [ • " + fn_name + "]("
- + make_file_link(fname)
+ (*fill)[1] = " [ • " + fn_name + "]("
+ + make_file_link(fname)
+ "#function-" + str_to_id(name + fn_name) + ")";
}
}
}
-
- // Data Types Column
+
+ // Data Types Column
auto it_fill = filling.begin();
if (!tprog->get_enums().empty()) {
@@ -224,8 +221,8 @@
++it_fill;
}
string name = (*en_iter)->get_name();
- (*fill)[2] = "[" + name + "]("
- + make_file_link(fname)
+ (*fill)[2] = "[" + name + "]("
+ + make_file_link(fname)
+ "#enumeration-" + str_to_id(name) + ")";
}
}
@@ -242,15 +239,15 @@
++it_fill;
}
string name = (*td_iter)->get_symbolic();
- (*fill)[2] = "[" + name + "]("
- + make_file_link(fname)
+ (*fill)[2] = "[" + name + "]("
+ + make_file_link(fname)
+ "#typedef-" + str_to_id(name) + ")";
}
}
if (!tprog->get_objects().empty()) {
vector<t_struct*> objects = tprog->get_objects();
vector<t_struct*>::iterator o_iter;
- for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) {
+ for (o_iter = objects.begin(); o_iter != objects.end(); ++o_iter) {
if(it_fill == filling.end()) {
filling.emplace_back();
fill = &filling.back();
@@ -261,7 +258,7 @@
}
string name = (*o_iter)->get_name();
(*fill)[2] = "[" + name + "](" + make_file_link(fname);
-
+
if ((*o_iter)->is_xception()) {
(*fill)[2] += "#exception-";
} else if ((*o_iter)->is_struct() && (*o_iter)->is_union()) {
@@ -270,11 +267,11 @@
(*fill)[2] += "#struct-";
}
(*fill)[2] += str_to_id(name) + ")";
-
+
}
}
-
- // Constants Column
+
+ // Constants Column
it_fill = filling.begin();
if (!tprog->get_consts().empty()) {
@@ -291,19 +288,19 @@
++it_fill;
}
string name = (*con_iter)->get_name();
- (*fill)[3] = "[" + name + "]("
- + make_file_link(fname)
+ (*fill)[3] = "[" + name + "]("
+ + make_file_link(fname)
+ "#constant-" + str_to_id(name) + ")";
}
-
+
}
-
+
for(auto& fill : filling) {
for(auto& c : fill)
- f_out_ << '|' << c;
- f_out_ << '|' << endl;
+ f_out_ << '|' << c;
+ f_out_ << '|' << '\n';
}
- f_out_ << endl;
+ f_out_ << '\n';
}
/**
@@ -318,24 +315,24 @@
current_file_ = make_file_name(pname);
string fname = get_out_dir() + current_file_;
f_out_.open(fname.c_str());
- f_out_ << "# Thrift module: " << pname << endl << endl;
+ f_out_ << "# Thrift module: " << pname << '\n' << '\n';
print_doc(program_);
- f_out_ << endl << endl;
+ f_out_ << '\n' << '\n';
generate_program_toc();
if (!program_->get_consts().empty()) {
- f_out_ << "***" << endl << "## Constants" << endl << endl;
+ f_out_ << "***" << '\n' << "## Constants" << '\n' << '\n';
vector<t_const*> consts = program_->get_consts();
- f_out_ << "|Constant|Type|Value||" << endl
- << "|---|---|---|---|" << endl;
+ f_out_ << "|Constant|Type|Value||" << '\n'
+ << "|---|---|---|---|" << '\n';
generate_consts(consts);
- f_out_ << endl;
+ f_out_ << '\n';
}
if (!program_->get_enums().empty()) {
- f_out_ << "***" << endl << "## Enumerations" << endl << endl;
+ f_out_ << "***" << '\n' << "## Enumerations" << '\n' << '\n';
// Generate enums
vector<t_enum*> enums = program_->get_enums();
vector<t_enum*>::iterator en_iter;
@@ -345,7 +342,7 @@
}
if (!program_->get_typedefs().empty()) {
- f_out_ << "***" << endl << "## Type declarations" << endl << endl;
+ f_out_ << "***" << '\n' << "## Type declarations" << '\n' << '\n';
// Generate typedefs
vector<t_typedef*> typedefs = program_->get_typedefs();
vector<t_typedef*>::iterator td_iter;
@@ -355,7 +352,7 @@
}
if (!program_->get_objects().empty()) {
- f_out_ << "***" << endl << "## Data structures" << endl << endl;
+ f_out_ << "***" << '\n' << "## Data structures" << '\n' << '\n';
// Generate structs and exceptions in declared order
vector<t_struct*> objects = program_->get_objects();
vector<t_struct*>::iterator o_iter;
@@ -369,7 +366,7 @@
}
if (!program_->get_services().empty()) {
- f_out_ << "***" << endl << "## Services" << endl << endl;
+ f_out_ << "***" << '\n' << "## Services" << '\n' << '\n';
// Generate services
vector<t_service*> services = program_->get_services();
vector<t_service*>::iterator sv_iter;
@@ -379,7 +376,7 @@
}
}
- f_out_ << endl;
+ f_out_ << '\n';
f_out_.close();
generate_index();
@@ -392,15 +389,15 @@
current_file_ = make_file_name("index");
string index_fname = get_out_dir() + current_file_;
f_out_.open(index_fname.c_str());
-
- f_out_ << "# Thrift declarations" << endl;
- f_out_ << "| Module | Services & Functions | Data types | Constants |"
- << endl
- << "| --- | --- | --- | --- |"
- << endl;
+
+ f_out_ << "# Thrift declarations" << '\n';
+ f_out_ << "| Module | Services & Functions | Data types | Constants |"
+ << '\n'
+ << "| --- | --- | --- | --- |"
+ << '\n';
vector<t_program*> programs;
generate_program_toc_rows(program_, programs);
- f_out_ << endl;
+ f_out_ << '\n';
f_out_.close();
}
@@ -716,13 +713,13 @@
f_out_ << ">";
}
} else if (ttype->is_base_type()) {
- f_out_ << "```" << (ttype->is_binary() ? "binary" : ttype->get_name())
+ f_out_ << "```" << (ttype->is_binary() ? "binary" : ttype->get_name())
<< "```";
len = ttype->get_name().size();
} else {
string prog_name = ttype->get_program()->get_name();
string type_name = ttype->get_name();
- f_out_ << "[```" << type_name << "```]("
+ f_out_ << "[```" << type_name << "```]("
<< make_file_link(make_file_name(prog_name)) << "#";
if (ttype->is_typedef()) {
f_out_ << "typedef-";
@@ -740,7 +737,7 @@
}
len = type_name.size();
if (ttype->get_program() != program_) {
- f_out_ << str_to_id(prog_name);
+ f_out_ << str_to_id(prog_name);
len += prog_name.size() + 1;
}
f_out_ << str_to_id(type_name) << ')';
@@ -757,8 +754,8 @@
if (tvalue->get_type() == t_const_value::CV_IDENTIFIER) {
string fname = make_file_name(program_->get_name());
string name = escape_html(tvalue->get_identifier());
- f_out_ << "[```" << name << "```]("
- + make_file_link(fname)
+ f_out_ << "[```" << name << "```]("
+ + make_file_link(fname)
+ "#constant-" + str_to_id(name) + ")";
return;
}
@@ -773,7 +770,7 @@
t_base_type::t_base tbase = ((t_base_type*)truetype)->get_base();
f_out_ << "```";
switch (tbase) {
- case t_base_type::TYPE_STRING:
+ case t_base_type::TYPE_STRING:
f_out_ << escape_html(get_escaped_string(tvalue));
break;
case t_base_type::TYPE_BOOL:
@@ -893,17 +890,17 @@
}
if (has_docs) {
arg_iter = args.begin();
- f_out_ << endl << "* parameters:" << endl;
+ f_out_ << '\n' << "* parameters:" << '\n';
for (int n = 1; arg_iter != args.end(); ++arg_iter, ++n ) {
f_out_ << n << ". " << (*arg_iter)->get_name();
f_out_ << " - " << escape_html((*arg_iter)->get_doc());
- f_out_ << endl;
+ f_out_ << '\n';
}
- f_out_ << endl;
+ f_out_ << '\n';
}
}
- if(!has_docs)
- f_out_ << endl;
+ if(!has_docs)
+ f_out_ << '\n';
has_docs = false;
vector<t_field*> excepts = tfunction->get_xceptions()->get_members();
@@ -917,14 +914,14 @@
}
if (has_docs) {
ex_iter = excepts.begin();
- f_out_ << "* exceptions:" << endl;
+ f_out_ << "* exceptions:" << '\n';
for (; ex_iter != excepts.end(); ex_iter++) {
f_out_ << " * " << (*ex_iter)->get_type()->get_name();
f_out_ << " - ";
f_out_ << escape_html((*ex_iter)->get_doc());
- f_out_ << endl;
+ f_out_ << '\n';
}
- f_out_ << endl;
+ f_out_ << '\n';
}
}
}
@@ -936,13 +933,13 @@
*/
void t_markdown_generator::generate_typedef(t_typedef* ttypedef) {
string name = ttypedef->get_name();
- f_out_ << "### Typedef: " << name << endl;
+ f_out_ << "### Typedef: " << name << '\n';
print_doc(ttypedef);
- f_out_ << endl << endl;
+ f_out_ << '\n' << '\n';
f_out_ << "_Base type_: **";
print_type(ttypedef->get_type());
- f_out_ << "**" << endl << endl;
- f_out_ << endl;
+ f_out_ << "**" << '\n' << '\n';
+ f_out_ << '\n';
}
/**
@@ -952,10 +949,10 @@
*/
void t_markdown_generator::generate_enum(t_enum* tenum) {
string name = tenum->get_name();
- f_out_ << "### Enumeration: " << name << endl;
+ f_out_ << "### Enumeration: " << name << '\n';
print_doc(tenum);
- f_out_ << endl << endl << "|Name|Value|Description|" << endl
- << "|---|---|---|" << endl;
+ f_out_ << '\n' << '\n' << "|Name|Value|Description|" << '\n'
+ << "|---|---|---|" << '\n';
vector<t_enum_value*> values = tenum->get_constants();
vector<t_enum_value*>::iterator val_iter;
for (val_iter = values.begin(); val_iter != values.end(); ++val_iter) {
@@ -965,9 +962,9 @@
f_out_ << (*val_iter)->get_value();
f_out_ << "```|";
print_doc((*val_iter));
- f_out_ << "|" << endl;
+ f_out_ << "|" << '\n';
}
- f_out_ << endl;
+ f_out_ << '\n';
}
/**
@@ -984,7 +981,7 @@
if (tconst->has_doc()) {
print_doc(tconst);
}
- f_out_ << '|' << endl;
+ f_out_ << '|' << '\n';
}
/**
@@ -1002,14 +999,14 @@
} else {
f_out_ << "Struct: ";
}
- f_out_ << name << endl;
+ f_out_ << name << '\n';
print_doc(tstruct);
- f_out_ << endl << endl;
+ f_out_ << '\n' << '\n';
vector<t_field*> members = tstruct->get_members();
vector<t_field*>::iterator mem_iter = members.begin();
f_out_ << "| Key | Field | Type | Description | Requiredness "
- "| Default value |" << endl
- << "| --- | --- | --- | --- | --- | --- |" << endl;
+ "| Default value |" << '\n'
+ << "| --- | --- | --- | --- | --- | --- |" << '\n';
for (; mem_iter != members.end(); mem_iter++) {
f_out_ << '|' << (*mem_iter)->get_key();
f_out_ << '|' << (*mem_iter)->get_name();
@@ -1030,9 +1027,9 @@
print_const_value((*mem_iter)->get_type(), default_val);
f_out_ << "```";
}
- f_out_ << '|' << endl;
+ f_out_ << '|' << '\n';
}
- f_out_ << endl;
+ f_out_ << '\n';
}
/**
@@ -1050,32 +1047,32 @@
* @param tservice The service definition
*/
void t_markdown_generator::generate_service(t_service* tservice) {
- f_out_ << "### Service: " << service_name_ << endl;
+ f_out_ << "### Service: " << service_name_ << '\n';
if (tservice->get_extends()) {
f_out_ << "**extends ** _";
print_type(tservice->get_extends());
- f_out_ << "_" << endl;
+ f_out_ << "_" << '\n';
}
print_doc(tservice);
- f_out_ << endl;
+ f_out_ << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator fn_iter = functions.begin();
for (; fn_iter != functions.end(); fn_iter++) {
string fn_name = (*fn_iter)->get_name();
- f_out_ << "#### Function: " << service_name_ << "." << fn_name << endl;
+ f_out_ << "#### Function: " << service_name_ << "." << fn_name << '\n';
print_doc(*fn_iter);
- f_out_ << endl << endl;
+ f_out_ << '\n' << '\n';
print_type((*fn_iter)->get_returntype());
bool first = true;
- f_out_ << endl << " _" << fn_name << "_(";
+ f_out_ << '\n' << " _" << fn_name << "_(";
vector<t_field*> args = (*fn_iter)->get_arglist()->get_members();
vector<t_field*>::iterator arg_iter = args.begin();
for (; arg_iter != args.end(); arg_iter++) {
if (!first) {
- f_out_ << "," << endl;
+ f_out_ << "," << '\n';
}
first = false;
print_type((*arg_iter)->get_type());
@@ -1085,7 +1082,7 @@
print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
}
}
- f_out_ << ")" << endl;
+ f_out_ << ")" << '\n';
first = true;
vector<t_field*> excepts = (*fn_iter)->get_xceptions()->get_members();
vector<t_field*>::iterator ex_iter = excepts.begin();
@@ -1098,10 +1095,10 @@
first = false;
print_type((*ex_iter)->get_type());
}
- f_out_ << endl;
+ f_out_ << '\n';
}
print_fn_args_doc(*fn_iter);
- f_out_ << endl;
+ f_out_ << '\n';
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
index 1a27c0c..6e46454 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
@@ -203,26 +203,26 @@
void t_netstd_generator::pragmas_and_directives(ostream& out)
{
if( target_net_version >= 6) {
- out << "// Thrift code generated for net" << target_net_version << endl;
- out << "#nullable enable // requires C# 8.0" << endl;
+ out << "// Thrift code generated for net" << target_net_version << '\n';
+ out << "#nullable enable // requires C# 8.0" << '\n';
}
// this one must be first
- out << "#pragma warning disable IDE0079 // remove unnecessary pragmas" << endl;
+ out << "#pragma warning disable IDE0079 // remove unnecessary pragmas" << '\n';
if( target_net_version >= 8) {
- out << "#pragma warning disable IDE0290 // use primary CTOR" << endl;
+ out << "#pragma warning disable IDE0290 // use primary CTOR" << '\n';
} else {
- out << "#pragma warning disable IDE0017 // object init can be simplified" << endl;
- out << "#pragma warning disable IDE0028 // collection init can be simplified" << endl;
+ out << "#pragma warning disable IDE0017 // object init can be simplified" << '\n';
+ out << "#pragma warning disable IDE0028 // collection init can be simplified" << '\n';
}
- out << "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << endl;
- out << "#pragma warning disable CA1822 // empty " << DEEP_COPY_METHOD_NAME << "() methods still non-static" << endl;
+ out << "#pragma warning disable IDE1006 // parts of the code use IDL spelling" << '\n';
+ out << "#pragma warning disable CA1822 // empty " << DEEP_COPY_METHOD_NAME << "() methods still non-static" << '\n';
if( target_net_version < 6) {
- out << "#pragma warning disable IDE0083 // pattern matching \"that is not SomeType\" requires net5.0 but we still support earlier versions" << endl;
+ out << "#pragma warning disable IDE0083 // pattern matching \"that is not SomeType\" requires net5.0 but we still support earlier versions" << '\n';
}
- out << endl;
+ out << '\n';
}
@@ -230,7 +230,7 @@
{
if (!namespace_name_.empty())
{
- out << "namespace " << namespace_name_ << endl;
+ out << "namespace " << namespace_name_ << '\n';
scope_up(out);
}
}
@@ -309,13 +309,13 @@
void t_netstd_generator::generate_enum(ostream& out, t_enum* tenum)
{
reset_indent();
- out << autogen_comment() << endl;
+ out << autogen_comment() << '\n';
pragmas_and_directives(out);
start_netstd_namespace(out);
generate_netstd_doc(out, tenum);
- out << indent() << "public enum " << type_name(tenum,false) << endl;
+ out << indent() << "public enum " << type_name(tenum,false) << '\n';
scope_up(out);
vector<t_enum_value*> constants = tenum->get_constants();
@@ -325,7 +325,7 @@
{
generate_netstd_doc(out, *c_iter);
int value = (*c_iter)->get_value();
- out << indent() << normalize_name((*c_iter)->get_name()) << " = " << value << "," << endl;
+ out << indent() << normalize_name((*c_iter)->get_name()) << " = " << value << "," << '\n';
}
scope_down(out);
@@ -356,12 +356,12 @@
}
reset_indent();
- out << autogen_comment() << netstd_type_usings() << endl << endl;
+ out << autogen_comment() << netstd_type_usings() << '\n' << '\n';
pragmas_and_directives(out);
start_netstd_namespace(out);
- out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Constants" << endl;
+ out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Constants" << '\n';
scope_up(out);
@@ -416,7 +416,7 @@
t_type* field_type = field->get_type();
string val = render_const_value(out, name, field_type, v_iter->second);
- out << indent() << name << "." << prop_name(field) << " = " << val << ";" << endl;
+ out << indent() << name << "." << prop_name(field) << " = " << val << ";" << '\n';
}
cleanup_member_name_mapping(static_cast<t_struct*>(type));
@@ -431,7 +431,7 @@
{
string key = render_const_value(out, name, ktype, v_iter->first);
string val = render_const_value(out, name, vtype, v_iter->second);
- out << indent() << name << "[" << key << "]" << " = " << val << ";" << endl;
+ out << indent() << name << "[" << key << "]" << " = " << val << ";" << '\n';
}
}
else if (type->is_list() || type->is_set())
@@ -451,14 +451,14 @@
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter)
{
string val = render_const_value(out, name, etype, *v_iter);
- out << indent() << name << ".Add(" << val << ");" << endl;
+ out << indent() << name << ".Add(" << val << ");" << '\n';
}
}
}
void t_netstd_generator::print_const_constructor(ostream& out, vector<t_const*> consts)
{
- out << indent() << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()" << endl;
+ out << indent() << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()" << '\n';
scope_up(out);
vector<t_const*>::iterator c_iter;
@@ -494,30 +494,30 @@
if (type->is_base_type())
{
string v2 = render_const_value(out, name, type, value);
- out << name << " = " << v2 << ";" << endl;
+ out << name << " = " << v2 << ";" << '\n';
need_static_construction = false;
}
else if (type->is_enum())
{
- out << name << " = " << type_name(type) << "." << value->get_identifier_name() << ";" << endl;
+ out << name << " = " << type_name(type) << "." << value->get_identifier_name() << ";" << '\n';
need_static_construction = false;
}
else if (type->is_struct() || type->is_xception())
{
if(target_net_version >= 6) {
- out << name << " = new();" << endl;
+ out << name << " = new();" << '\n';
} else {
- out << name << " = new " << type_name(type) << "();" << endl;
+ out << name << " = new " << type_name(type) << "();" << '\n';
}
}
else if (type->is_map() || type->is_list() || type->is_set())
{
if(target_net_version >= 8) {
- out << name << " = [];" << endl;
+ out << name << " = [];" << '\n';
} else if(target_net_version >= 6) {
- out << name << " = new();" << endl;
+ out << name << " = new();" << '\n';
} else {
- out << name << " = new " << type_name(type) << "();" << endl;
+ out << name << " = new " << type_name(type) << "();" << '\n';
}
}
@@ -672,49 +672,49 @@
reset_indent();
out << autogen_comment() << netstd_type_usings()
- << "using Thrift.Protocol;" << endl
- << endl << endl;
+ << "using Thrift.Protocol;" << '\n'
+ << '\n' << '\n';
pragmas_and_directives(out);
start_netstd_namespace(out);
- out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Extensions" << endl;
+ out << indent() << "public static class " << make_valid_csharp_identifier(program_name_) << "Extensions" << '\n';
scope_up(out);
bool needs_typecast = false;
std::map<string,t_type*>::const_iterator iter;
for( iter = types.begin(); iter != types.end(); ++iter)
{
- out << indent() << "public static bool Equals(this " << iter->first << " instance, object that)" << endl;
+ out << indent() << "public static bool Equals(this " << iter->first << " instance, object that)" << '\n';
scope_up(out);
if( target_net_version >= 6) {
- out << indent() << "if (that is not " << iter->first << " other) return false;" << endl;
+ out << indent() << "if (that is not " << iter->first << " other) return false;" << '\n';
} else {
- out << indent() << "if (!(that is " << iter->first << " other)) return false;" << endl;
+ out << indent() << "if (!(that is " << iter->first << " other)) return false;" << '\n';
}
- out << indent() << "if (ReferenceEquals(instance, other)) return true;" << endl;
- out << endl;
- out << indent() << "return TCollections.Equals(instance, other);" << endl;
+ out << indent() << "if (ReferenceEquals(instance, other)) return true;" << '\n';
+ out << '\n';
+ out << indent() << "return TCollections.Equals(instance, other);" << '\n';
scope_down(out);
- out << endl << endl;
+ out << '\n' << '\n';
- out << indent() << "public static int GetHashCode(this " << iter->first << " instance)" << endl;
+ out << indent() << "public static int GetHashCode(this " << iter->first << " instance)" << '\n';
scope_up(out);
- out << indent() << "return TCollections.GetHashCode(instance);" << endl;
+ out << indent() << "return TCollections.GetHashCode(instance);" << '\n';
scope_down(out);
- out << endl << endl;
+ out << '\n' << '\n';
if(! suppress_deepcopy) {
- out << indent() << "public static " << iter->first << nullable_field_suffix(iter->second) << " " << DEEP_COPY_METHOD_NAME << "(this " << iter->first << nullable_field_suffix(iter->second) << " source)" << endl;
+ out << indent() << "public static " << iter->first << nullable_field_suffix(iter->second) << " " << DEEP_COPY_METHOD_NAME << "(this " << iter->first << nullable_field_suffix(iter->second) << " source)" << '\n';
scope_up(out);
- out << indent() << "if (source == null)" << endl;
+ out << indent() << "if (source == null)" << '\n';
indent_up();
- out << indent() << "return null;" << endl << endl;
+ out << indent() << "return null;" << '\n' << '\n';
indent_down();
string suffix("");
string tmp_instance = tmp("tmp");
- out << indent() << "var " << tmp_instance << " = new " << iter->first << "(source.Count);" << endl;
+ out << indent() << "var " << tmp_instance << " = new " << iter->first << "(source.Count);" << '\n';
if( iter->second->is_map())
{
t_map* tmap = static_cast<t_map*>(iter->second);
@@ -723,7 +723,7 @@
bool null_key = type_can_be_null(tmap->get_key_type());
bool null_val = type_can_be_null(tmap->get_val_type());
- out << indent() << "foreach (var pair in source)" << endl;
+ out << indent() << "foreach (var pair in source)" << '\n';
indent_up();
if( target_net_version >= 6) {
out << indent() << tmp_instance << ".Add(pair.Key" << copy_key;
@@ -742,7 +742,7 @@
out << "pair.Value" << copy_val;
}
}
- out << ");" << endl;
+ out << ");" << '\n';
indent_down();
} else if( iter->second->is_set() || iter->second->is_list()) {
@@ -761,7 +761,7 @@
null_elm = type_can_be_null(tlist->get_elem_type());
}
- out << indent() << "foreach (var elem in source)" << endl;
+ out << indent() << "foreach (var elem in source)" << '\n';
indent_up();
if( target_net_version >= 6) {
out << indent() << tmp_instance << ".Add(elem" << copy_elm;
@@ -774,13 +774,13 @@
out << "elem" << copy_elm;
}
}
- out << ");" << endl;
+ out << ");" << '\n';
indent_down();
}
- out << indent() << "return " << tmp_instance << ";" << endl;
+ out << indent() << "return " << tmp_instance << ";" << '\n';
scope_down(out);
- out << endl << endl;
+ out << '\n' << '\n';
}
}
@@ -818,7 +818,7 @@
f_struct.open(f_struct_name.c_str());
reset_indent();
- f_struct << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << endl << endl;
+ f_struct << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << '\n' << '\n';
pragmas_and_directives(f_struct);
generate_netstd_struct_definition(f_struct, tstruct, is_exception);
@@ -835,7 +835,7 @@
start_netstd_namespace(out);
}
- out << endl;
+ out << '\n';
generate_netstd_doc(out, tstruct);
collect_extensions_types(tstruct);
@@ -843,7 +843,7 @@
if ((is_serialize_enabled() || is_wcf_enabled()) && !is_exception)
{
- out << indent() << "[DataContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl;
+ out << indent() << "[DataContract(Namespace=\"" << wcf_namespace_ << "\")]" << '\n';
}
bool is_final = tstruct->annotations_.find("final") != tstruct->annotations_.end();
@@ -857,8 +857,8 @@
out << "TException, ";
}
- out << "TBase" << endl
- << indent() << "{" << endl;
+ out << "TBase" << '\n'
+ << indent() << "{" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -870,10 +870,10 @@
// if the field is required, then we use auto-properties
if (!field_is_required((*m_iter)))
{
- out << indent() << "private " << declare_field(*m_iter, false, true, "_") << endl;
+ out << indent() << "private " << declare_field(*m_iter, false, true, "_") << '\n';
}
}
- out << endl;
+ out << '\n';
bool has_non_required_fields = false;
bool has_required_fields = false;
@@ -895,19 +895,19 @@
bool generate_isset = has_non_required_fields;
if (generate_isset)
{
- out << endl;
+ out << '\n';
if (is_serialize_enabled() || is_wcf_enabled())
{
- out << indent() << "[DataMember(Order = 1)]" << endl;
+ out << indent() << "[DataMember(Order = 1)]" << '\n';
}
- out << indent() << "public Isset __isset;" << endl;
+ out << indent() << "public Isset __isset;" << '\n';
if (is_serialize_enabled() || is_wcf_enabled())
{
- out << indent() << "[DataContract]" << endl;
+ out << indent() << "[DataContract]" << '\n';
}
- out << indent() << "public struct Isset" << endl
- << indent() << "{" << endl;
+ out << indent() << "public struct Isset" << '\n'
+ << indent() << "{" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
@@ -919,18 +919,18 @@
{
if (is_serialize_enabled() || is_wcf_enabled())
{
- out << indent() << "[DataMember]" << endl;
+ out << indent() << "[DataMember]" << '\n';
}
- out << indent() << "public bool " << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << endl;
+ out << indent() << "public bool " << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << '\n';
}
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
if (generate_isset && (is_serialize_enabled() || is_wcf_enabled()))
{
- out << indent() << "#region XmlSerializer support" << endl << endl;
+ out << indent() << "#region XmlSerializer support" << '\n' << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
{
@@ -939,22 +939,22 @@
// if it is not required, if it has a default value, we need to generate Isset
if (!is_required)
{
- out << indent() << "public bool ShouldSerialize" << prop_name(*m_iter) << "()" << endl
- << indent() << "{" << endl;
+ out << indent() << "public bool ShouldSerialize" << prop_name(*m_iter) << "()" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "return __isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << endl;
+ out << indent() << "return __isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << ";" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
}
- out << indent() << "#endregion XmlSerializer support" << endl << endl;
+ out << indent() << "#endregion XmlSerializer support" << '\n' << '\n';
}
}
// We always want a default, no argument constructor for Reading
- out << indent() << "public " << sharp_struct_name << "()" << endl
- << indent() << "{" << endl;
+ out << indent() << "public " << sharp_struct_name << "()" << '\n'
+ << indent() << "{" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
@@ -972,12 +972,12 @@
{
print_const_value(out, "this._" + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
// Optionals with defaults are marked set
- out << indent() << "this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << " = true;" << endl;
+ out << indent() << "this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name())) << " = true;" << '\n';
}
}
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
// if we have required fields, we add that CTOR too
if (has_required_fields)
@@ -999,20 +999,20 @@
out << type_name((*m_iter)->get_type()) << nullable_field_suffix(*m_iter) << " " << normalize_name((*m_iter)->get_name());
}
}
- out << ") : this()" << endl
- << indent() << "{" << endl;
+ out << ") : this()" << '\n'
+ << indent() << "{" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
{
if (field_is_required(*m_iter))
{
- out << indent() << "this." << prop_name(*m_iter) << " = " << normalize_name((*m_iter)->get_name()) << ";" << endl;
+ out << indent() << "this." << prop_name(*m_iter) << " = " << normalize_name((*m_iter)->get_name()) << ";" << '\n';
}
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
// DeepCopy()
@@ -1032,7 +1032,7 @@
generate_netstd_struct_tostring(out, tstruct);
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
// generate a corresponding WCF fault to wrap the exception
if ((is_serialize_enabled() || is_wcf_enabled()) && is_exception)
@@ -1050,13 +1050,13 @@
void t_netstd_generator::generate_netstd_wcffault(ostream& out, t_struct* tstruct)
{
- out << endl;
- out << indent() << "[DataContract]" << endl;
+ out << '\n';
+ out << indent() << "[DataContract]" << '\n';
bool is_final = tstruct->annotations_.find("final") != tstruct->annotations_.end();
- out << indent() << "public " << (is_final ? "sealed " : "") << "partial class " << type_name(tstruct,false) << "Fault" << endl
- << indent() << "{" << endl;
+ out << indent() << "public " << (is_final ? "sealed " : "") << "partial class " << type_name(tstruct,false) << "Fault" << '\n'
+ << indent() << "{" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
@@ -1068,10 +1068,10 @@
// if the field is required, then we use auto-properties
if (!field_is_required((*m_iter)))
{
- out << indent() << "private " << declare_field(*m_iter, false, true, "_") << endl;
+ out << indent() << "private " << declare_field(*m_iter, false, true, "_") << '\n';
}
}
- out << endl;
+ out << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
{
@@ -1079,7 +1079,7 @@
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_netstd_deepcopy_method(ostream& out, t_struct* tstruct, std::string sharp_struct_name)
@@ -1091,8 +1091,8 @@
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
- out << indent() << "public " << sharp_struct_name << " " << DEEP_COPY_METHOD_NAME << "()" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public " << sharp_struct_name << " " << DEEP_COPY_METHOD_NAME << "()" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
// return directly if there are only required fields
@@ -1100,10 +1100,10 @@
out << indent() << "var " << tmp_instance << " = new " << sharp_struct_name << "()";
bool inline_assignment = (target_net_version >= 6);
if(inline_assignment) {
- out << endl << indent() << "{" << endl;
+ out << '\n' << indent() << "{" << '\n';
indent_up();
} else {
- out << endl;
+ out << '\n';
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1118,7 +1118,7 @@
if(inline_assignment) {
if( null_allowed || (!is_required)) { // = has isset
indent_down();
- out << indent() << "};" << endl;
+ out << indent() << "};" << '\n';
inline_assignment = false;
}
}
@@ -1134,7 +1134,7 @@
out << "(" << type_name(ttype) << ")";
}
out << "this." << prop_name(*m_iter) << copy_op;
- out << (inline_assignment ? "," : ";") << endl;
+ out << (inline_assignment ? "," : ";") << '\n';
generate_null_check_end( out, *m_iter);
if( !is_required) {
@@ -1144,29 +1144,29 @@
}
out << "__isset." << get_isset_name(normalize_name((*m_iter)->get_name()));
out << " = this.__isset." << get_isset_name(normalize_name((*m_iter)->get_name()));
- out << (inline_assignment ? "," : ";") << endl;
+ out << (inline_assignment ? "," : ";") << '\n';
}
}
if(inline_assignment) {
indent_down();
- out << indent() << "};" << endl;
+ out << indent() << "};" << '\n';
}
- out << indent() << "return " << tmp_instance << ";" << endl;
+ out << indent() << "return " << tmp_instance << ";" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_netstd_struct_reader(ostream& out, t_struct* tstruct)
{
- out << indent() << "public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "iprot.IncrementRecursionDepth();" << endl
- << indent() << "try" << endl
- << indent() << "{" << endl;
+ out << indent() << "iprot.IncrementRecursionDepth();" << '\n'
+ << indent() << "try" << '\n'
+ << indent() << "{" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
@@ -1177,90 +1177,90 @@
{
if (field_is_required(*f_iter))
{
- out << indent() << "bool isset_" << (*f_iter)->get_name() << " = false;" << endl;
+ out << indent() << "bool isset_" << (*f_iter)->get_name() << " = false;" << '\n';
}
}
- out << indent() << "TField field;" << endl
- << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "while (true)" << endl
- << indent() << "{" << endl;
+ out << indent() << "TField field;" << '\n'
+ << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "while (true)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "if (field.Type == TType.Stop)" << endl
- << indent() << "{" << endl;
+ out << indent() << "field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "if (field.Type == TType.Stop)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "break;" << endl;
+ out << indent() << "break;" << '\n';
indent_down();
- out << indent() << "}" << endl << endl
- << indent() << "switch (field.ID)" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n' << '\n'
+ << indent() << "switch (field.ID)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
bool is_required = field_is_required(*f_iter);
- out << indent() << "case " << (*f_iter)->get_key() << ":" << endl;
+ out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
generate_deserialize_field(out, *f_iter);
if (is_required)
{
- out << indent() << "isset_" << (*f_iter)->get_name() << " = true;" << endl;
+ out << indent() << "isset_" << (*f_iter)->get_name() << " = true;" << '\n';
}
indent_down();
- out << indent() << "}" << endl
- << indent() << "else" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "else" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
indent_down();
- out << indent() << "}" << endl
- << indent() << "break;" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "break;" << '\n';
indent_down();
}
- out << indent() << "default: " << endl;
+ out << indent() << "default: " << '\n';
indent_up();
- out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "break;" << endl;
+ out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "break;" << '\n';
indent_down();
indent_down();
- out << indent() << "}" << endl
- << endl
- << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "}" << '\n'
+ << '\n'
+ << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
indent_down();
- out << indent() << "}" << endl
- << endl
- << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "}" << '\n'
+ << '\n'
+ << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
if (field_is_required((*f_iter)))
{
- out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "if (!isset_" << (*f_iter)->get_name() << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << endl;
+ out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "finally" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "finally" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "iprot.DecrementRecursionDepth();" << endl;
+ out << indent() << "iprot.DecrementRecursionDepth();" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
@@ -1284,8 +1284,8 @@
out << "__isset." << get_isset_name(normalize_name(tfield->get_name()));
}
- out << ")" << endl
- << indent() << "{" << endl;
+ out << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
}
}
@@ -1297,19 +1297,19 @@
if( null_allowed || (!is_required)) {
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
void t_netstd_generator::generate_netstd_struct_writer(ostream& out, t_struct* tstruct)
{
- out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "oprot.IncrementRecursionDepth();" << endl
- << indent() << "try" << endl
- << indent() << "{" << endl;
+ out << indent() << "oprot.IncrementRecursionDepth();" << '\n'
+ << indent() << "try" << '\n'
+ << indent() << "{" << '\n';
indent_up();
string name = tstruct->get_name();
@@ -1317,57 +1317,57 @@
vector<t_field*>::const_iterator f_iter;
string tmpvar = tmp("tmp");
- out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << endl
- << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << '\n'
+ << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n';
if (fields.size() > 0)
{
tmpvar = tmp("tmp");
if(target_net_version >= 8) {
- out << indent() << "#pragma warning disable IDE0017 // simplified init" << endl;
+ out << indent() << "#pragma warning disable IDE0017 // simplified init" << '\n';
}
- out << indent() << "var " << tmpvar << " = new TField();" << endl;
+ out << indent() << "var " << tmpvar << " = new TField();" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
generate_null_check_begin( out, *f_iter);
- out << indent() << tmpvar << ".Name = \"" << (*f_iter)->get_name() << "\";" << endl
- << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << endl
- << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << endl
- << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << tmpvar << ".Name = \"" << (*f_iter)->get_name() << "\";" << '\n'
+ << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << '\n'
+ << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << '\n'
+ << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n';
generate_serialize_field(out, *f_iter);
- out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
generate_null_check_end(out, *f_iter);
}
if(target_net_version >= 8) {
- out << indent() << "#pragma warning restore IDE0017 // simplified init" << endl;
+ out << indent() << "#pragma warning restore IDE0017 // simplified init" << '\n';
}
}
- out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
indent_down();
- out << indent() << "}" << endl
- << indent() << "finally" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "finally" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "oprot.DecrementRecursionDepth();" << endl;
+ out << indent() << "oprot.DecrementRecursionDepth();" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_netstd_struct_result_writer(ostream& out, t_struct* tstruct)
{
- out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "oprot.IncrementRecursionDepth();" << endl
- << indent() << "try" << endl
- << indent() << "{" << endl;
+ out << indent() << "oprot.IncrementRecursionDepth();" << '\n'
+ << indent() << "try" << '\n'
+ << indent() << "{" << '\n';
indent_up();
string name = tstruct->get_name();
@@ -1375,85 +1375,85 @@
vector<t_field*>::const_iterator f_iter;
string tmpvar = tmp("tmp");
- out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << endl
- << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "var " << tmpvar << " = new TStruct(\"" << name << "\");" << '\n'
+ << indent() << "await oprot.WriteStructBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n';
if (fields.size() > 0)
{
tmpvar = tmp("tmp");
if(target_net_version >= 8) {
- out << indent() << "#pragma warning disable IDE0017 // simplified init" << endl;
+ out << indent() << "#pragma warning disable IDE0017 // simplified init" << '\n';
}
- out << indent() << "var " << tmpvar << " = new TField();" << endl;
+ out << indent() << "var " << tmpvar << " = new TField();" << '\n';
bool first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
if (first)
{
first = false;
- out << endl << indent() << "if";
+ out << '\n' << indent() << "if";
}
else
{
out << indent() << "else if";
}
- out << "(this.__isset." << get_isset_name(normalize_name((*f_iter)->get_name())) << ")" << endl
- << indent() << "{" << endl;
+ out << "(this.__isset." << get_isset_name(normalize_name((*f_iter)->get_name())) << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
bool null_allowed = type_can_be_null((*f_iter)->get_type());
if (null_allowed)
{
- out << indent() << "if (" << prop_name(*f_iter) << " != null)" << endl
- << indent() << "{" << endl;
+ out << indent() << "if (" << prop_name(*f_iter) << " != null)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
}
- out << indent() << tmpvar << ".Name = \"" << prop_name(*f_iter) << "\";" << endl
- << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << endl
- << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << endl
- << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << tmpvar << ".Name = \"" << prop_name(*f_iter) << "\";" << '\n'
+ << indent() << tmpvar << ".Type = " << type_to_enum((*f_iter)->get_type()) << ";" << '\n'
+ << indent() << tmpvar << ".ID = " << (*f_iter)->get_key() << ";" << '\n'
+ << indent() << "await oprot.WriteFieldBeginAsync(" << tmpvar << ", " << CANCELLATION_TOKEN_NAME << ");" << '\n';
generate_serialize_field(out, *f_iter);
- out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
if (null_allowed)
{
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
if(target_net_version >= 8) {
- out << indent() << "#pragma warning restore IDE0017 // simplified init" << endl;
+ out << indent() << "#pragma warning restore IDE0017 // simplified init" << '\n';
}
}
- out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
indent_down();
- out << indent() << "}" << endl
- << indent() << "finally" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "finally" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "oprot.DecrementRecursionDepth();" << endl;
+ out << indent() << "oprot.DecrementRecursionDepth();" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_netstd_struct_tostring(ostream& out, t_struct* tstruct)
{
string tmpvar = tmp("tmp");
- out << indent() << "public override string ToString()" << endl
- << indent() << "{" << endl;
+ out << indent() << "public override string ToString()" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "var " << tmpvar << " = new StringBuilder(\"" << tstruct->get_name() << "(\");" << endl;
+ out << indent() << "var " << tmpvar << " = new StringBuilder(\"" << tstruct->get_name() << "(\");" << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -1464,7 +1464,7 @@
{
if (!field_is_required((*f_iter)))
{
- out << indent() << "int " << tmp_count.c_str() << " = 0;" << endl;
+ out << indent() << "int " << tmp_count.c_str() << " = 0;" << '\n';
useFirstFlag = true;
}
break;
@@ -1479,15 +1479,15 @@
if (useFirstFlag && (!had_required))
{
- out << indent() << "if(0 < " << tmp_count.c_str() << (is_required ? "" : "++") << ") { " << tmpvar << ".Append(\", \"); }" << endl;
- out << indent() << tmpvar << ".Append(\"" << prop_name(*f_iter) << ": \");" << endl;
+ out << indent() << "if(0 < " << tmp_count.c_str() << (is_required ? "" : "++") << ") { " << tmpvar << ".Append(\", \"); }" << '\n';
+ out << indent() << tmpvar << ".Append(\"" << prop_name(*f_iter) << ": \");" << '\n';
}
else
{
- out << indent() << tmpvar << ".Append(\", " << prop_name(*f_iter) << ": \");" << endl;
+ out << indent() << tmpvar << ".Append(\", " << prop_name(*f_iter) << ": \");" << '\n';
}
- out << indent() << prop_name(*f_iter) << ".ToString(" << tmpvar << ");" << endl;
+ out << indent() << prop_name(*f_iter) << ".ToString(" << tmpvar << ");" << '\n';
generate_null_check_end(out, *f_iter);
if (is_required) {
@@ -1495,10 +1495,10 @@
}
}
- out << indent() << tmpvar << ".Append(')');" << endl
- << indent() << "return " << tmpvar << ".ToString();" << endl;
+ out << indent() << tmpvar << ".Append(')');" << '\n'
+ << indent() << "return " << tmpvar << ".ToString();" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
void t_netstd_generator::generate_netstd_union(t_struct* tunion)
@@ -1511,7 +1511,7 @@
f_union.open(f_union_name.c_str());
reset_indent();
- f_union << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << endl << endl;
+ f_union << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << '\n' << '\n';
pragmas_and_directives(f_union);
generate_netstd_union_definition(f_union, tunion);
@@ -1526,75 +1526,75 @@
// Let's define the class first
start_netstd_namespace(out);
- out << indent() << "public abstract partial class " << normalize_name(tunion->get_name()) << " : TUnionBase" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public abstract partial class " << normalize_name(tunion->get_name()) << " : TUnionBase" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "public abstract global::System.Threading.Tasks.Task WriteAsync(TProtocol tProtocol, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "public readonly int Isset;" << endl
- << indent() << "public abstract object" << nullable_suffix() <<" Data { get; }" << endl
- << indent() << "protected " << normalize_name(tunion->get_name()) << "(int isset)" << endl
- << indent() << "{" << endl;
+ out << indent() << "public abstract global::System.Threading.Tasks.Task WriteAsync(TProtocol tProtocol, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "public readonly int Isset;" << '\n'
+ << indent() << "public abstract object" << nullable_suffix() <<" Data { get; }" << '\n'
+ << indent() << "protected " << normalize_name(tunion->get_name()) << "(int isset)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "Isset = isset;" << endl;
+ out << indent() << "Isset = isset;" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
const vector<t_field*>& fields = tunion->get_members();
vector<t_field*>::const_iterator f_iter;
- out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl;
+ out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << '\n';
scope_up(out);
if( target_net_version >= 6) {
- out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << endl;
+ out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << '\n';
} else {
- out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << endl;
+ out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << '\n';
}
- out << indent() << "if (ReferenceEquals(this, other)) return true;" << endl;
- out << endl;
- out << indent() << "if(this.Isset != other.Isset) return false;" << endl;
- out << endl;
+ out << indent() << "if (ReferenceEquals(this, other)) return true;" << '\n';
+ out << '\n';
+ out << indent() << "if(this.Isset != other.Isset) return false;" << '\n';
+ out << '\n';
if(target_net_version >= 6) {
- out << indent() << "return Isset switch" << endl;
+ out << indent() << "return Isset switch" << '\n';
scope_up(out);
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
bool needs_typecast = false;
string suffix("");
get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix);
- out << indent() << (*f_iter)->get_key() << " => Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ")," << endl;
+ out << indent() << (*f_iter)->get_key() << " => Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ")," << '\n';
}
- out << indent() << "_ => true," << endl;
+ out << indent() << "_ => true," << '\n';
indent_down();
- out << indent() << "};" << endl;
+ out << indent() << "};" << '\n';
} else {
- out << indent() << "switch (Isset)" << endl;
+ out << indent() << "switch (Isset)" << '\n';
scope_up(out);
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
bool needs_typecast = false;
string suffix("");
get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix);
- out << indent() << "case " << (*f_iter)->get_key() << ":" << endl;
+ out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- out << indent() << "return Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ");" << endl;
+ out << indent() << "return Equals(As_" << (*f_iter)->get_name() << ", other.As_" << (*f_iter)->get_name() << ");" << '\n';
indent_down();
}
- out << indent() << "default:" << endl;
+ out << indent() << "default:" << '\n';
indent_up();
- out << indent() << "return true;" << endl;
+ out << indent() << "return true;" << '\n';
indent_down();
scope_down(out);
}
scope_down(out);
- out << endl;
+ out << '\n';
- out << indent() << "public override int GetHashCode()" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public override int GetHashCode()" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
if(target_net_version >= 6) {
- out << indent() << "return Isset switch" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "return Isset switch" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
@@ -1603,108 +1603,108 @@
if( null_coalesce.size() > 0) {
out << " ?? 0";
}
- out << "," << endl;
+ out << "," << '\n';
}
- out << indent() << "_ => (new ___undefined()).GetHashCode()" << endl;
+ out << indent() << "_ => (new ___undefined()).GetHashCode()" << '\n';
indent_down();
- out << indent() << "};" << endl;
+ out << indent() << "};" << '\n';
} else {
- out << indent() << "switch (Isset)" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "switch (Isset)" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
string null_coalesce(is_nullable_type((*f_iter)->get_type()) ? "?" : "");
- out << indent() << "case " << (*f_iter)->get_key() << ":" << endl;
+ out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
out << indent() << "return As_" << (*f_iter)->get_name() << null_coalesce << ".GetHashCode()";
if( null_coalesce.size() > 0) {
out << " ?? 0";
}
- out << ";" << endl;
+ out << ";" << '\n';
indent_down();
}
- out << indent() << "default:" << endl;
+ out << indent() << "default:" << '\n';
indent_up();
- out << indent() << "return (new ___undefined()).GetHashCode();" << endl;
+ out << indent() << "return (new ___undefined()).GetHashCode();" << '\n';
indent_down();
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
if( ! suppress_deepcopy) {
- out << indent() << "public " << tunion->get_name() << " " << DEEP_COPY_METHOD_NAME << "()" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public " << tunion->get_name() << " " << DEEP_COPY_METHOD_NAME << "()" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
if(target_net_version >= 6) {
- out << indent() << "return Isset switch" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "return Isset switch" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
bool needs_typecast = false;
string suffix("");
string copy_op = get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix);
- out << indent() << (*f_iter)->get_key() << " => new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ")," << endl;
+ out << indent() << (*f_iter)->get_key() << " => new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ")," << '\n';
}
- out << indent() << "_ => new ___undefined()" << endl;
+ out << indent() << "_ => new ___undefined()" << '\n';
indent_down();
- out << indent() << "};" << endl;
+ out << indent() << "};" << '\n';
} else {
- out << indent() << "switch (Isset)" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "switch (Isset)" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
bool needs_typecast = false;
string suffix("");
string copy_op = get_deep_copy_method_call((*f_iter)->get_type(), false, needs_typecast, suffix);
- out << indent() << "case " << (*f_iter)->get_key() << ":" << endl;
+ out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- out << indent() << "return new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ");" << endl;
+ out << indent() << "return new " << (*f_iter)->get_name() << "(As_" << (*f_iter)->get_name() << suffix << copy_op << ");" << '\n';
indent_down();
}
- out << indent() << "default:" << endl;
+ out << indent() << "default:" << '\n';
indent_up();
- out << indent() << "return new ___undefined();" << endl;
+ out << indent() << "return new ___undefined();" << '\n';
indent_down();
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
- out << indent() << "public class ___undefined : " << tunion->get_name() << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public class ___undefined : " << tunion->get_name() << '\n';
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "public override object" << nullable_suffix() <<" Data { get { return null; } }" << endl
- << indent() << "public ___undefined() : base(0) {}" << endl << endl;
+ out << indent() << "public override object" << nullable_suffix() <<" Data { get { return null; } }" << '\n'
+ << indent() << "public ___undefined() : base(0) {}" << '\n' << '\n';
if( ! suppress_deepcopy) {
- out << indent() << "public new ___undefined " << DEEP_COPY_METHOD_NAME << "()" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public new ___undefined " << DEEP_COPY_METHOD_NAME << "()" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "return new ___undefined();" << endl;
+ out << indent() << "return new ___undefined();" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
t_struct undefined_struct(program_,"___undefined");
generate_netstd_struct_equals(out, &undefined_struct);
generate_netstd_struct_hashcode(out, &undefined_struct);
- out << indent() << "public override global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "public override global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "throw new TProtocolException( TProtocolException.INVALID_DATA, \"Cannot persist an union type which is not set.\");" << endl;
+ out << indent() << "throw new TProtocolException( TProtocolException.INVALID_DATA, \"Cannot persist an union type which is not set.\");" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
@@ -1714,128 +1714,128 @@
generate_netstd_union_reader(out, tunion);
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
end_netstd_namespace(out);
}
void t_netstd_generator::generate_netstd_union_class(ostream& out, t_struct* tunion, t_field* tfield)
{
- out << indent() << "public " << type_name(tfield->get_type()) << nullable_field_suffix(tfield) << " As_" << tfield->get_name() << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public " << type_name(tfield->get_type()) << nullable_field_suffix(tfield) << " As_" << tfield->get_name() << '\n';
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "get" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "get" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
out << indent() << "return (" << tfield->get_key() << " == Isset) && (Data != null)"
<< " ? (" << type_name(tfield->get_type()) << nullable_field_suffix(tfield) << ")Data"
<< " : default"
<< (target_net_version >= 6 ? "" : ("(" + type_name(tfield->get_type()) + ")"))
- << ";" << endl;
+ << ";" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl
- << endl;
+ out << indent() << "}" << '\n'
+ << '\n';
- out << indent() << "public class " << normalize_name(tfield->get_name()) << " : " << normalize_name(tunion->get_name()) << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public class " << normalize_name(tfield->get_name()) << " : " << normalize_name(tunion->get_name()) << '\n';
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "private readonly " << type_name(tfield->get_type()) << " _data;" << endl
- << indent() << "public override object" << nullable_suffix() <<" Data { get { return _data; } }" << endl
- << indent() << "public " << normalize_name(tfield->get_name()) << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << endl
- << indent() << "{" << endl;
+ out << indent() << "private readonly " << type_name(tfield->get_type()) << " _data;" << '\n'
+ << indent() << "public override object" << nullable_suffix() <<" Data { get { return _data; } }" << '\n'
+ << indent() << "public " << normalize_name(tfield->get_name()) << "(" << type_name(tfield->get_type()) << " data) : base("<< tfield->get_key() <<")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "this._data = data;" << endl;
+ out << indent() << "this._data = data;" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if( ! suppress_deepcopy) {
- out << indent() << "public new " << normalize_name(tfield->get_name()) << " " << DEEP_COPY_METHOD_NAME << "()" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public new " << normalize_name(tfield->get_name()) << " " << DEEP_COPY_METHOD_NAME << "()" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
bool needs_typecast = false;
string suffix("");
string copy_op = get_deep_copy_method_call(tfield->get_type(), true, needs_typecast, suffix);
- out << indent() << "return new " << normalize_name(tfield->get_name()) << "(_data" << copy_op << ");" << endl;
+ out << indent() << "return new " << normalize_name(tfield->get_name()) << "(_data" << copy_op << ");" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
- out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
if(target_net_version >= 6) {
- out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << endl;
+ out << indent() << "if (that is not " << tunion->get_name() << " other) return false;" << '\n';
} else {
- out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << endl;
+ out << indent() << "if (!(that is " << tunion->get_name() << " other)) return false;" << '\n';
}
- out << indent() << "if (ReferenceEquals(this, other)) return true;" << endl;
- out << endl;
- out << indent() << "return Equals( _data, other.As_" << tfield->get_name() << ");" << endl;
+ out << indent() << "if (ReferenceEquals(this, other)) return true;" << '\n';
+ out << '\n';
+ out << indent() << "return Equals( _data, other.As_" << tfield->get_name() << ");" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
- out << indent() << "public override int GetHashCode()" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public override int GetHashCode()" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "return _data.GetHashCode();" << endl;
+ out << indent() << "return _data.GetHashCode();" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
- out << indent() << "public override async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ") {" << endl;
+ out << indent() << "public override async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ") {" << '\n';
indent_up();
- out << indent() << "oprot.IncrementRecursionDepth();" << endl
- << indent() << "try" << endl
- << indent() << "{" << endl;
+ out << indent() << "oprot.IncrementRecursionDepth();" << '\n'
+ << indent() << "try" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "var struc = new TStruct(\"" << tunion->get_name() << "\");" << endl
- << indent() << "await oprot.WriteStructBeginAsync(struc, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "var struc = new TStruct(\"" << tunion->get_name() << "\");" << '\n'
+ << indent() << "await oprot.WriteStructBeginAsync(struc, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
- out << indent() << "var field = new TField()" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "var field = new TField()" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "Name = \"" << tfield->get_name() << "\"," << endl
- << indent() << "Type = " << type_to_enum(tfield->get_type()) << "," << endl
- << indent() << "ID = " << tfield->get_key() << endl;
+ out << indent() << "Name = \"" << tfield->get_name() << "\"," << '\n'
+ << indent() << "Type = " << type_to_enum(tfield->get_type()) << "," << '\n'
+ << indent() << "ID = " << tfield->get_key() << '\n';
indent_down();
- out << indent() << "};" << endl;
- out << indent() << "await oprot.WriteFieldBeginAsync(field, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "};" << '\n';
+ out << indent() << "await oprot.WriteFieldBeginAsync(field, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
generate_serialize_field(out, tfield, "_data", true, false);
- out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await oprot.WriteFieldStopAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await oprot.WriteStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
indent_down();
- out << indent() << "}" << endl
- << indent() << "finally" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "finally" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "oprot.DecrementRecursionDepth();" << endl;
+ out << indent() << "oprot.DecrementRecursionDepth();" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_netstd_struct_equals(ostream& out, t_struct* tstruct)
{
- out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << endl
- << indent() << "{" << endl;
+ out << indent() << "public override bool Equals(object" << nullable_suffix() << " that)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
if(target_net_version >= 6) {
- out << indent() << "if (that is not " << type_name(tstruct,false) << " other) return false;" << endl;
+ out << indent() << "if (that is not " << type_name(tstruct,false) << " other) return false;" << '\n';
} else {
- out << indent() << "if (!(that is " << type_name(tstruct,false) << " other)) return false;" << endl;
+ out << indent() << "if (!(that is " << type_name(tstruct,false) << " other)) return false;" << '\n';
}
- out << indent() << "if (ReferenceEquals(this, other)) return true;" << endl;
+ out << indent() << "if (ReferenceEquals(this, other)) return true;" << '\n';
const vector<t_field*>& fields = tstruct->get_members();
@@ -1853,7 +1853,7 @@
}
else
{
- out << endl;
+ out << '\n';
out << indent() << "&& ";
}
if (!field_is_required((*f_iter)))
@@ -1879,25 +1879,25 @@
}
if (first)
{
- out << indent() << "return true;" << endl;
+ out << indent() << "return true;" << '\n';
}
else
{
- out << ";" << endl;
+ out << ";" << '\n';
indent_down();
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_netstd_struct_hashcode(ostream& out, t_struct* tstruct)
{
- out << indent() << "public override int GetHashCode() {" << endl;
+ out << indent() << "public override int GetHashCode() {" << '\n';
indent_up();
- out << indent() << "int hashcode = 157;" << endl;
- out << indent() << "unchecked {" << endl;
+ out << indent() << "int hashcode = 157;" << '\n';
+ out << indent() << "unchecked {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
@@ -1915,17 +1915,17 @@
else {
out << prop_name(*f_iter) << ".GetHashCode()";
}
- out << ";" << endl;
+ out << ";" << '\n';
generate_null_check_end(out, *f_iter);
}
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "return hashcode;" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "return hashcode;" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_service(t_service* tservice)
@@ -1937,13 +1937,13 @@
f_service.open(f_service_name.c_str());
reset_indent();
- f_service << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << endl << endl;
+ f_service << autogen_comment() << netstd_type_usings() << netstd_thrift_usings() << '\n' << '\n';
pragmas_and_directives(f_service);
start_netstd_namespace(f_service);
- f_service << indent() << "public partial class " << normalize_name(service_name_) << endl
- << indent() << "{" << endl;
+ f_service << indent() << "public partial class " << normalize_name(service_name_) << '\n'
+ << indent() << "{" << '\n';
indent_up();
generate_service_interface(f_service, tservice);
@@ -1952,7 +1952,7 @@
generate_service_helpers(f_service, tservice);
indent_down();
- f_service << indent() << "}" << endl;
+ f_service << indent() << "}" << '\n';
end_netstd_namespace(f_service);
f_service.close();
@@ -1970,18 +1970,18 @@
extends_iface = " : " + extends + ".IAsync";
}
- //out << endl << endl;
+ //out << '\n' << '\n';
generate_netstd_doc(out, tservice);
if (is_wcf_enabled())
{
- out << indent() << "[ServiceContract(Namespace=\"" << wcf_namespace_ << "\")]" << endl;
+ out << indent() << "[ServiceContract(Namespace=\"" << wcf_namespace_ << "\")]" << '\n';
}
prepare_member_name_mapping(tservice);
- out << indent() << "public interface IAsync" << extends_iface << endl
- << indent() << "{" << endl;
+ out << indent() << "public interface IAsync" << extends_iface << '\n'
+ << indent() << "{" << '\n';
indent_up();
vector<t_function*> functions = tservice->get_functions();
@@ -1993,21 +1993,21 @@
// if we're using WCF, add the corresponding attributes
if (is_wcf_enabled())
{
- out << indent() << "[OperationContract]" << endl;
+ out << indent() << "[OperationContract]" << '\n';
const vector<t_field*>& xceptions = (*f_iter)->get_xceptions()->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter)
{
- out << indent() << "[FaultContract(typeof(" + type_name((*x_iter)->get_type()) + "Fault))]" << endl;
+ out << indent() << "[FaultContract(typeof(" + type_name((*x_iter)->get_type()) + "Fault))]" << '\n';
}
}
generate_deprecation_attribute(out, *f_iter);
- out << indent() << function_signature_async(*f_iter) << ";" << endl << endl;
+ out << indent() << function_signature_async(*f_iter) << ";" << '\n' << '\n';
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
cleanup_member_name_mapping(tservice);
}
@@ -2020,7 +2020,7 @@
if ((iter->second.back().length() > 0) && (iter->second.back() != "1")) {
out << "(" << make_csharp_string_literal(iter->second.back()) << ")";
}
- out << "]" << endl;
+ out << "]" << '\n';
}
}
@@ -2030,8 +2030,8 @@
vector<t_function*>::iterator f_iter;
prepare_member_name_mapping(tservice);
- out << indent() << "public class InternalStructs" << endl;
- out << indent() << "{" << endl;
+ out << indent() << "public class InternalStructs" << '\n';
+ out << indent() << "{" << '\n';
indent_up();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter)
@@ -2043,7 +2043,7 @@
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
cleanup_member_name_mapping(tservice);
}
@@ -2061,22 +2061,22 @@
extends_client = "TBaseClient, IDisposable, ";
}
- out << endl;
+ out << '\n';
generate_netstd_doc(out, tservice);
prepare_member_name_mapping(tservice);
- out << indent() << "public class Client : " << extends_client << "IAsync" << endl
- << indent() << "{" << endl;
+ out << indent() << "public class Client : " << extends_client << "IAsync" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "public Client(TProtocol protocol) : this(protocol, protocol)" << endl
- << indent() << "{" << endl
- << indent() << "}" << endl
- << endl
- << indent() << "public Client(TProtocol inputProtocol, TProtocol outputProtocol) : base(inputProtocol, outputProtocol)" << endl
- << indent() << "{" << endl
- << indent() << "}" << endl
- << endl;
+ out << indent() << "public Client(TProtocol protocol) : this(protocol, protocol)" << '\n'
+ << indent() << "{" << '\n'
+ << indent() << "}" << '\n'
+ << '\n'
+ << indent() << "public Client(TProtocol inputProtocol, TProtocol outputProtocol) : base(inputProtocol, outputProtocol)" << '\n'
+ << indent() << "{" << '\n'
+ << indent() << "}" << '\n'
+ << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::const_iterator functions_iterator;
@@ -2088,26 +2088,26 @@
// async
generate_deprecation_attribute(out, *functions_iterator);
- out << indent() << "public async " << function_signature_async(*functions_iterator, "") << endl
- << indent() << "{" << endl;
+ out << indent() << "public async " << function_signature_async(*functions_iterator, "") << '\n'
+ << indent() << "{" << '\n';
indent_up();
out << indent() << "await send_" << function_name << "(";
string call_args = argument_list((*functions_iterator)->get_arglist(),false);
if(! call_args.empty()) {
out << call_args << ", ";
}
- out << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << CANCELLATION_TOKEN_NAME << ");" << '\n';
if(! (*functions_iterator)->is_oneway()) {
out << indent() << ((*functions_iterator)->get_returntype()->is_void() ? "" : "return ")
- << "await recv_" << function_name << "(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ << "await recv_" << function_name << "(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
// async send
generate_deprecation_attribute(out, *functions_iterator);
- out << indent() << "public async " << function_signature_async(*functions_iterator, "send_", MODE_NO_RETURN) << endl
- << indent() << "{" << endl;
+ out << indent() << "public async " << function_signature_async(*functions_iterator, "send_", MODE_NO_RETURN) << '\n'
+ << indent() << "{" << '\n';
indent_up();
string tmpvar = tmp("tmp");
@@ -2115,9 +2115,9 @@
out << indent() << "await OutputProtocol.WriteMessageBeginAsync(new TMessage(\"" << raw_func_name
<< "\", TMessageType." << ((*functions_iterator)->is_oneway() ? "Oneway" : "Call")
- << ", SeqId), " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << endl
- << indent() << "var " << tmpvar << " = new InternalStructs." << argsname << "() {" << endl;
+ << ", SeqId), " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << '\n'
+ << indent() << "var " << tmpvar << " = new InternalStructs." << argsname << "() {" << '\n';
indent_up();
t_struct* arg_struct = (*functions_iterator)->get_arglist();
@@ -2128,27 +2128,27 @@
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter)
{
- out << indent() << prop_name(*fld_iter) << " = " << normalize_name((*fld_iter)->get_name(),true) << "," << endl;
+ out << indent() << prop_name(*fld_iter) << " = " << normalize_name((*fld_iter)->get_name(),true) << "," << '\n';
}
indent_down();
- out << indent() << "};" << endl;
+ out << indent() << "};" << '\n';
- out << indent() << endl
- << indent() << "await " << tmpvar << ".WriteAsync(OutputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await OutputProtocol.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await OutputProtocol.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << '\n'
+ << indent() << "await " << tmpvar << ".WriteAsync(OutputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await OutputProtocol.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await OutputProtocol.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
if (!(*functions_iterator)->is_oneway())
{
// async recv
generate_deprecation_attribute(out, *functions_iterator);
- out << indent() << "public async " << function_signature_async(*functions_iterator, "recv_", MODE_NO_ARGS) << endl
- << indent() << "{" << endl;
+ out << indent() << "public async " << function_signature_async(*functions_iterator, "recv_", MODE_NO_ARGS) << '\n'
+ << indent() << "{" << '\n';
indent_up();
string resultname = (*functions_iterator)->get_name() + "_result";
@@ -2158,64 +2158,64 @@
prepare_member_name_mapping(xs, xs->get_members(), resultname);
tmpvar = tmp("tmp");
- out << indent() << endl
- << indent() << "var " << tmpvar << " = await InputProtocol.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "if (" << tmpvar << ".Type == TMessageType.Exception)" << endl
- << indent() << "{" << endl;
+ out << indent() << '\n'
+ << indent() << "var " << tmpvar << " = await InputProtocol.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "if (" << tmpvar << ".Type == TMessageType.Exception)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
tmpvar = tmp("tmp");
- out << indent() << "var " << tmpvar << " = await TApplicationException.ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "throw " << tmpvar << ";" << endl;
+ out << indent() << "var " << tmpvar << " = await TApplicationException.ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "throw " << tmpvar << ";" << '\n';
indent_down();
tmpvar = tmp("tmp");
- out << indent() << "}" << endl
- << endl
- << indent() << "var " << tmpvar << " = new InternalStructs." << resultname << "();" << endl
- << indent() << "await " << tmpvar << ".ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "}" << '\n'
+ << '\n'
+ << indent() << "var " << tmpvar << " = new InternalStructs." << resultname << "();" << '\n'
+ << indent() << "await " << tmpvar << ".ReadAsync(InputProtocol, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await InputProtocol.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
if (!(*functions_iterator)->get_returntype()->is_void())
{
- out << indent() << "if (" << tmpvar << ".__isset.success)" << endl
- << indent() << "{" << endl;
+ out << indent() << "if (" << tmpvar << ".__isset.success)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
string nullable_value = nullable_value_access((*functions_iterator)->get_returntype());
- out << indent() << "return " << tmpvar << ".Success" << nullable_value << ";" << endl;
+ out << indent() << "return " << tmpvar << ".Success" << nullable_value << ";" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
const vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter)
{
- out << indent() << "if (" << tmpvar << ".__isset." << get_isset_name(normalize_name((*x_iter)->get_name())) << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "if (" << tmpvar << ".__isset." << get_isset_name(normalize_name((*x_iter)->get_name())) << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "throw " << tmpvar << "." << prop_name(*x_iter) << nullable_value_access((*x_iter)->get_type()) << ";" << endl;
+ out << indent() << "throw " << tmpvar << "." << prop_name(*x_iter) << nullable_value_access((*x_iter)->get_type()) << ";" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
if (!(*functions_iterator)->get_returntype()->is_void())
{
out << indent() << "throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, \""
- << function_name << " failed: unknown result\");" << endl;
+ << function_name << " failed: unknown result\");" << '\n';
}
cleanup_member_name_mapping(xs);
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
cleanup_member_name_mapping(arg_struct);
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
cleanup_member_name_mapping(tservice);
}
@@ -2233,14 +2233,14 @@
}
prepare_member_name_mapping(tservice);
- out << indent() << "public class AsyncProcessor : " << extends_processor << "ITAsyncProcessor" << endl
- << indent() << "{" << endl;
+ out << indent() << "public class AsyncProcessor : " << extends_processor << "ITAsyncProcessor" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "private readonly IAsync _iAsync;" << endl
- << indent() << "private readonly ILogger<AsyncProcessor>" << nullable_suffix() << " _logger;" << endl
- << endl
+ out << indent() << "private readonly IAsync _iAsync;" << '\n'
+ << indent() << "private readonly ILogger<AsyncProcessor>" << nullable_suffix() << " _logger;" << '\n'
+ << '\n'
<< indent() << "public AsyncProcessor(IAsync iAsync, ILogger<AsyncProcessor>" << nullable_suffix() << " logger = default)";
if (!extends.empty())
@@ -2248,101 +2248,101 @@
out << " : base(iAsync)";
}
- out << endl
- << indent() << "{" << endl;
+ out << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "_iAsync = iAsync ?? throw new ArgumentNullException(nameof(iAsync));" << endl;
- out << indent() << "_logger = logger;" << endl;
+ out << indent() << "_iAsync = iAsync ?? throw new ArgumentNullException(nameof(iAsync));" << '\n';
+ out << indent() << "_logger = logger;" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter)
{
string raw_func_name = (*f_iter)->get_name();
- out << indent() << "processMap_[\"" << raw_func_name << "\"] = " << raw_func_name << "_ProcessAsync;" << endl;
+ out << indent() << "processMap_[\"" << raw_func_name << "\"] = " << raw_func_name << "_ProcessAsync;" << '\n';
}
indent_down();
- out << indent() << "}" << endl
- << endl;
+ out << indent() << "}" << '\n'
+ << '\n';
if (extends.empty())
{
- out << indent() << "protected delegate global::System.Threading.Tasks.Task ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "protected delegate global::System.Threading.Tasks.Task ProcessFunction(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
if (extends.empty())
{
out << indent() << "protected Dictionary<string, ProcessFunction> processMap_ = ";
if(target_net_version >= 8) {
- out << "[];" << endl;
+ out << "[];" << '\n';
} else if(target_net_version >= 6) {
- out << "new();" << endl;
+ out << "new();" << '\n';
} else {
- out << "new Dictionary<string, ProcessFunction>();" << endl;
+ out << "new Dictionary<string, ProcessFunction>();" << '\n';
}
}
- out << endl;
+ out << '\n';
if (extends.empty())
{
- out << indent() << "public async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot)" << endl
- << indent() << "{" << endl;
+ out << indent() << "public async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << endl;
+ out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
- out << indent() << "public async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl;
+ out << indent() << "public async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n';
}
else
{
- out << indent() << "public new async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot)" << endl
- << indent() << "{" << endl;
+ out << indent() << "public new async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << endl;
+ out << indent() << "return await ProcessAsync(iprot, oprot, CancellationToken.None);" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
- out << indent() << "public new async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl;
+ out << indent() << "public new async Task<bool> ProcessAsync(TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n';
}
- out << indent() << "{" << endl;
+ out << indent() << "{" << '\n';
indent_up();
- out << indent() << "try" << endl
- << indent() << "{" << endl;
+ out << indent() << "try" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "var msg = await iprot.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << endl
- << indent() << "processMap_.TryGetValue(msg.Name, out var fn);" << endl
- << endl
- << indent() << "if (fn == null)" << endl
- << indent() << "{" << endl;
+ out << indent() << "var msg = await iprot.ReadMessageBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << '\n'
+ << indent() << "processMap_.TryGetValue(msg.Name, out var fn);" << '\n'
+ << '\n'
+ << indent() << "if (fn == null)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "await TProtocolUtil.SkipAsync(iprot, TType.Struct, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "var x = new TApplicationException (TApplicationException.ExceptionType.UnknownMethod, \"Invalid method name: '\" + msg.Name + \"'\");" << endl
- << indent() << "await oprot.WriteMessageBeginAsync(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID), " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await x.WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "return true;" << endl;
+ out << indent() << "await TProtocolUtil.SkipAsync(iprot, TType.Struct, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "var x = new TApplicationException (TApplicationException.ExceptionType.UnknownMethod, \"Invalid method name: '\" + msg.Name + \"'\");" << '\n'
+ << indent() << "await oprot.WriteMessageBeginAsync(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID), " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await x.WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "return true;" << '\n';
indent_down();
- out << indent() << "}" << endl
- << endl
- << indent() << "await fn(msg.SeqID, iprot, oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << endl;
+ out << indent() << "}" << '\n'
+ << '\n'
+ << indent() << "await fn(msg.SeqID, iprot, oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << indent() << "catch (IOException)" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n';
+ out << indent() << "catch (IOException)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "return false;" << endl;
+ out << indent() << "return false;" << '\n';
indent_down();
- out << indent() << "}" << endl
- << endl
- << indent() << "return true;" << endl;
+ out << indent() << "}" << '\n'
+ << '\n'
+ << indent() << "return true;" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter)
{
@@ -2350,7 +2350,7 @@
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
cleanup_member_name_mapping(tservice);
}
@@ -2384,26 +2384,26 @@
{
(void)tservice;
out << indent() << "public async global::System.Threading.Tasks.Task " << tfunction->get_name()
- << "_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl
- << indent() << "{" << endl;
+ << "_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
string argsname = tfunction->get_name() + "_args";
string resultname = tfunction->get_name() + "_result";
string args = tmp("tmp");
- out << indent() << "var " << args << " = new InternalStructs." << argsname << "();" << endl
- << indent() << "await " << args << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "var " << args << " = new InternalStructs." << argsname << "();" << '\n'
+ << indent() << "await " << args << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await iprot.ReadMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
string tmpResult = tmp("tmp");
if (!tfunction->is_oneway())
{
- out << indent() << "var " << tmpResult << " = new InternalStructs." << resultname << "();" << endl;
+ out << indent() << "var " << tmpResult << " = new InternalStructs." << resultname << "();" << '\n';
}
- out << indent() << "try" << endl
- << indent() << "{" << endl;
+ out << indent() << "try" << '\n'
+ << indent() << "{" << '\n';
indent_up();
t_struct* xs = tfunction->get_xceptions();
@@ -2411,8 +2411,8 @@
if (xceptions.size() > 0)
{
- out << indent() << "try" << endl
- << indent() << "{" << endl;
+ out << indent() << "try" << '\n'
+ << indent() << "{" << '\n';
indent_up();
}
@@ -2422,7 +2422,7 @@
bool is_deprecated = (tfunction->annotations_.end() != tfunction->annotations_.find("deprecated"));
if( is_deprecated) {
- out << indent() << "#pragma warning disable CS0618,CS0612" << endl;
+ out << indent() << "#pragma warning disable CS0618,CS0612" << '\n';
}
out << indent();
@@ -2457,10 +2457,10 @@
out << ", ";
}
- out << "" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << "" << CANCELLATION_TOKEN_NAME << ");" << '\n';
if( is_deprecated) {
- out << indent() << "#pragma warning restore CS0618,CS0612" << endl;
+ out << indent() << "#pragma warning restore CS0618,CS0612" << '\n';
}
vector<t_field*>::const_iterator x_iter;
@@ -2470,76 +2470,76 @@
if (xceptions.size() > 0)
{
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter)
{
string tmpex = tmp("tmp");
- out << indent() << "catch (" << type_name((*x_iter)->get_type()) << " " << tmpex << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "catch (" << type_name((*x_iter)->get_type()) << " " << tmpex << ")" << '\n'
+ << indent() << "{" << '\n';
if (!tfunction->is_oneway())
{
indent_up();
- out << indent() << tmpResult << "." << prop_name(*x_iter) << " = " << tmpex << ";" << endl;
+ out << indent() << tmpResult << "." << prop_name(*x_iter) << " = " << tmpex << ";" << '\n';
indent_down();
}
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
if (!tfunction->is_oneway())
{
out << indent() << "await oprot.WriteMessageBeginAsync(new TMessage(\""
- << tfunction->get_name() << "\", TMessageType.Reply, seqid), " << CANCELLATION_TOKEN_NAME << "); " << endl
- << indent() << "await " << tmpResult << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ << tfunction->get_name() << "\", TMessageType.Reply, seqid), " << CANCELLATION_TOKEN_NAME << "); " << '\n'
+ << indent() << "await " << tmpResult << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
indent_down();
cleanup_member_name_mapping(xs);
string tmpex = tmp("tmp");
- out << indent() << "}" << endl
- << indent() << "catch (TTransportException)" << endl
- << indent() << "{" << endl
- << indent() << " throw;" << endl
- << indent() << "}" << endl
- << indent() << "catch (Exception " << tmpex << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "catch (TTransportException)" << '\n'
+ << indent() << "{" << '\n'
+ << indent() << " throw;" << '\n'
+ << indent() << "}" << '\n'
+ << indent() << "catch (Exception " << tmpex << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
string tmpvar = tmp("tmp");
- out << indent() << "var " << tmpvar << " = $\"Error occurred in {GetType().FullName}: {" << tmpex << ".Message}\";" << endl;
- out << indent() << "if(_logger != null)" << endl;
+ out << indent() << "var " << tmpvar << " = $\"Error occurred in {GetType().FullName}: {" << tmpex << ".Message}\";" << '\n';
+ out << indent() << "if(_logger != null)" << '\n';
indent_up();
- out << indent() << "_logger.LogError(\"{Exception}, {Message}\", " << tmpex << ", " << tmpvar << ");" << endl;
+ out << indent() << "_logger.LogError(\"{Exception}, {Message}\", " << tmpex << ", " << tmpvar << ");" << '\n';
indent_down();
- out << indent() << "else" << endl;
+ out << indent() << "else" << '\n';
indent_up();
- out << indent() << "Console.Error.WriteLine(" << tmpvar << ");" << endl;
+ out << indent() << "Console.Error.WriteLine(" << tmpvar << ");" << '\n';
indent_down();
if (tfunction->is_oneway())
{
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
else
{
tmpvar = tmp("tmp");
- out << indent() << "var " << tmpvar << " = new TApplicationException(TApplicationException.ExceptionType.InternalError,\" Internal error.\");" << endl
+ out << indent() << "var " << tmpvar << " = new TApplicationException(TApplicationException.ExceptionType.InternalError,\" Internal error.\");" << '\n'
<< indent() << "await oprot.WriteMessageBeginAsync(new TMessage(\"" << tfunction->get_name()
- << "\", TMessageType.Exception, seqid), " << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await " << tmpvar << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ << "\", TMessageType.Exception, seqid), " << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await " << tmpvar << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
indent_down();
- out << indent() << "}" << endl
- << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl
- << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "await oprot.WriteMessageEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n'
+ << indent() << "await oprot.Transport.FlushAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_netstd_union_reader(ostream& out, t_struct* tunion)
@@ -2548,76 +2548,76 @@
const vector<t_field*>& fields = tunion->get_members();
vector<t_field*>::const_iterator f_iter;
- out << indent() << "public static async Task<" << tunion->get_name() << "> ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << endl;
+ out << indent() << "public static async Task<" << tunion->get_name() << "> ReadAsync(TProtocol iprot, CancellationToken " << CANCELLATION_TOKEN_NAME << ")" << '\n';
scope_up(out);
- out << indent() << "iprot.IncrementRecursionDepth();" << endl;
- out << indent() << "try" << endl;
+ out << indent() << "iprot.IncrementRecursionDepth();" << '\n';
+ out << indent() << "try" << '\n';
scope_up(out);
string tmpRetval = tmp("tmp");
- out << indent() << tunion->get_name() << " " << tmpRetval << ";" << endl;
- out << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
- out << indent() << "TField field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << tunion->get_name() << " " << tmpRetval << ";" << '\n';
+ out << indent() << "await iprot.ReadStructBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
+ out << indent() << "TField field = await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
// we cannot have the first field be a stop -- we must have a single field defined
- out << indent() << "if (field.Type == TType.Stop)" << endl;
+ out << indent() << "if (field.Type == TType.Stop)" << '\n';
scope_up(out);
- out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
- out << indent() << "" << tmpRetval << " = new ___undefined();" << endl;
+ out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
+ out << indent() << "" << tmpRetval << " = new ___undefined();" << '\n';
scope_down(out);
- out << indent() << "else" << endl;
+ out << indent() << "else" << '\n';
scope_up(out);
- out << indent() << "switch (field.ID)" << endl;
+ out << indent() << "switch (field.ID)" << '\n';
scope_up(out);
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
- out << indent() << "case " << (*f_iter)->get_key() << ":" << endl;
+ out << indent() << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+ out << indent() << "if (field.Type == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n';
indent_up();
string tmpvar = tmp("tmp");
- out << indent() << type_name((*f_iter)->get_type()) << " " << tmpvar << ";" << endl;
+ out << indent() << type_name((*f_iter)->get_type()) << " " << tmpvar << ";" << '\n';
generate_deserialize_field(out, (*f_iter), tmpvar, true);
- out << indent() << tmpRetval << " = new " << (*f_iter)->get_name() << "(" << tmpvar << ");" << endl;
+ out << indent() << tmpRetval << " = new " << (*f_iter)->get_name() << "(" << tmpvar << ");" << '\n';
indent_down();
- out << indent() << "} else { " << endl << indent() << " await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");"
- << endl << indent() << " " << tmpRetval << " = new ___undefined();" << endl << indent() << "}" << endl
- << indent() << "break;" << endl;
+ out << indent() << "} else { " << '\n' << indent() << " await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");"
+ << '\n' << indent() << " " << tmpRetval << " = new ___undefined();" << '\n' << indent() << "}" << '\n'
+ << indent() << "break;" << '\n';
indent_down();
}
- out << indent() << "default: " << endl;
+ out << indent() << "default: " << '\n';
indent_up();
- out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << endl << indent()
- << tmpRetval << " = new ___undefined();" << endl;
- out << indent() << "break;" << endl;
+ out << indent() << "await TProtocolUtil.SkipAsync(iprot, field.Type, " << CANCELLATION_TOKEN_NAME << ");" << '\n' << indent()
+ << tmpRetval << " = new ___undefined();" << '\n';
+ out << indent() << "break;" << '\n';
indent_down();
scope_down(out);
- out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await iprot.ReadFieldEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
- out << indent() << "if ((await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ")).Type != TType.Stop)" << endl;
+ out << indent() << "if ((await iprot.ReadFieldBeginAsync(" << CANCELLATION_TOKEN_NAME << ")).Type != TType.Stop)" << '\n';
scope_up(out);
- out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << endl;
+ out << indent() << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << '\n';
scope_down(out);
// end of else for TStop
scope_down(out);
- out << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
- out << indent() << "return " << tmpRetval << ";" << endl;
+ out << indent() << "await iprot.ReadStructEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
+ out << indent() << "return " << tmpRetval << ";" << '\n';
indent_down();
scope_down(out);
- out << indent() << "finally" << endl;
+ out << indent() << "finally" << '\n';
scope_up(out);
- out << indent() << "iprot.DecrementRecursionDepth();" << endl;
+ out << indent() << "iprot.DecrementRecursionDepth();" << '\n';
scope_down(out);
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
void t_netstd_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix, bool is_propertyless)
@@ -2698,7 +2698,7 @@
{
out << "ReadI32Async(" << CANCELLATION_TOKEN_NAME << ");";
}
- out << endl;
+ out << '\n';
}
else
{
@@ -2710,18 +2710,18 @@
{
if (is_union_enabled() && tstruct->is_union())
{
- out << indent() << prefix << " = await " << type_name(tstruct) << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << prefix << " = await " << type_name(tstruct) << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else
{
- out << indent() << prefix << " = new " << type_name(tstruct) << "();" << endl
- << indent() << "await " << prefix << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << prefix << " = new " << type_name(tstruct) << "();" << '\n'
+ << indent() << "await " << prefix << ".ReadAsync(iprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
}
void t_netstd_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix)
{
- out << indent() << "{" << endl;
+ out << indent() << "{" << '\n';
indent_up();
string obj;
@@ -2741,21 +2741,21 @@
if (ttype->is_map())
{
- out << indent() << "var " << obj << " = await iprot.ReadMapBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "var " << obj << " = await iprot.ReadMapBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_set())
{
- out << indent() << "var " << obj << " = await iprot.ReadSetBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "var " << obj << " = await iprot.ReadSetBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_list())
{
- out << indent() << "var " << obj << " = await iprot.ReadListBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "var " << obj << " = await iprot.ReadListBeginAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
- out << indent() << prefix << " = new " << type_name(ttype) << "(" << obj << ".Count);" << endl;
+ out << indent() << prefix << " = new " << type_name(ttype) << "(" << obj << ".Count);" << '\n';
string i = tmp("_i");
- out << indent() << "for(int " << i << " = 0; " << i << " < " << obj << ".Count; ++" << i << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "for(int " << i << " = 0; " << i << " < " << obj << ".Count; ++" << i << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
if (ttype->is_map())
@@ -2772,23 +2772,23 @@
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (ttype->is_map())
{
- out << indent() << "await iprot.ReadMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await iprot.ReadMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_set())
{
- out << indent() << "await iprot.ReadSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await iprot.ReadSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_list())
{
- out << indent() << "await iprot.ReadListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await iprot.ReadListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
void t_netstd_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix)
@@ -2799,13 +2799,13 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- out << indent() << declare_field(&fkey, false, false) << endl;
- out << indent() << declare_field(&fval, false, false) << endl;
+ out << indent() << declare_field(&fkey, false, false) << '\n';
+ out << indent() << declare_field(&fval, false, false) << '\n';
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
- out << indent() << prefix << "[" << key << "] = " << val << ";" << endl;
+ out << indent() << prefix << "[" << key << "] = " << val << ";" << '\n';
}
void t_netstd_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix)
@@ -2813,11 +2813,11 @@
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
- out << indent() << declare_field(&felem, false, false) << endl;
+ out << indent() << declare_field(&felem, false, false) << '\n';
generate_deserialize_field(out, &felem);
- out << indent() << prefix << ".Add(" << elem << ");" << endl;
+ out << indent() << prefix << ".Add(" << elem << ");" << '\n';
}
void t_netstd_generator::generate_deserialize_list_element(ostream& out, t_list* tlist, string prefix)
@@ -2825,11 +2825,11 @@
string elem = tmp("_elem");
t_field felem(tlist->get_elem_type(), elem);
- out << indent() << declare_field(&felem, false, false) << endl;
+ out << indent() << declare_field(&felem, false, false) << '\n';
generate_deserialize_field(out, &felem);
- out << indent() << prefix << ".Add(" << elem << ");" << endl;
+ out << indent() << prefix << ".Add(" << elem << ");" << '\n';
}
void t_netstd_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix, bool is_propertyless, bool allow_nullable)
@@ -2904,7 +2904,7 @@
{
out << "WriteI32Async((int)" << name << ", " << CANCELLATION_TOKEN_NAME << ");";
}
- out << endl;
+ out << '\n';
}
else
{
@@ -2915,7 +2915,7 @@
void t_netstd_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix)
{
(void)tstruct;
- out << indent() << "await " << prefix << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await " << prefix << ".WriteAsync(oprot, " << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
void t_netstd_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix)
@@ -2924,18 +2924,18 @@
{
out << indent() << "await oprot.WriteMapBeginAsync(new TMap(" << type_to_enum(static_cast<t_map*>(ttype)->get_key_type())
<< ", " << type_to_enum(static_cast<t_map*>(ttype)->get_val_type()) << ", " << prefix
- << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_set())
{
out << indent() << "await oprot.WriteSetBeginAsync(new TSet(" << type_to_enum(static_cast<t_set*>(ttype)->get_elem_type())
- << ", " << prefix << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << endl;
+ << ", " << prefix << ".Count), " << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_list())
{
out << indent() << "await oprot.WriteListBeginAsync(new TList("
<< type_to_enum(static_cast<t_list*>(ttype)->get_elem_type()) << ", " << prefix << ".Count), " << CANCELLATION_TOKEN_NAME << ");"
- << endl;
+ << '\n';
}
string iter = tmp("_iter");
@@ -2955,8 +2955,8 @@
<< " in " << prefix << ")";
}
- out << endl;
- out << indent() << "{" << endl;
+ out << '\n';
+ out << indent() << "{" << '\n';
indent_up();
if (ttype->is_map())
@@ -2973,19 +2973,19 @@
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (ttype->is_map())
{
- out << indent() << "await oprot.WriteMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteMapEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_set())
{
- out << indent() << "await oprot.WriteSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteSetEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
else if (ttype->is_list())
{
- out << indent() << "await oprot.WriteListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << endl;
+ out << indent() << "await oprot.WriteListEndAsync(" << CANCELLATION_TOKEN_NAME << ");" << '\n';
}
}
@@ -3018,7 +3018,7 @@
{
if ((is_serialize_enabled() || is_wcf_enabled()) && isPublic)
{
- out << indent() << "[DataMember(Order = 0)]" << endl;
+ out << indent() << "[DataMember(Order = 0)]" << '\n';
}
out << indent()
@@ -3036,37 +3036,37 @@
if( (target_net_version >= 6) && (!force_member_nullable(tfield))) {
out << initialize_field(tfield) << ";";
}
- out << endl;
+ out << '\n';
}
else
{
- out << endl
- << indent() << "{" << endl;
+ out << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "get" << endl
- << indent() << "{" << endl;
+ out << indent() << "get" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "return " << fieldPrefix + tfield->get_name() << ";" << endl;
+ out << indent() << "return " << fieldPrefix + tfield->get_name() << ";" << '\n';
indent_down();
- out << indent() << "}" << endl
- << indent() << "set" << endl
- << indent() << "{" << endl;
+ out << indent() << "}" << '\n'
+ << indent() << "set" << '\n'
+ << indent() << "{" << '\n';
indent_up();
if (generateIsset)
{
- out << indent() << "__isset." << get_isset_name(normalize_name(tfield->get_name())) << " = true;" << endl;
+ out << indent() << "__isset." << get_isset_name(normalize_name(tfield->get_name())) << " = true;" << '\n';
}
- out << indent() << "this." << fieldPrefix + tfield->get_name() << " = value;" << endl;
+ out << indent() << "this." << fieldPrefix + tfield->get_name() << " = value;" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
- out << endl;
+ out << '\n';
}
string t_netstd_generator::make_csharp_string_literal( string const& value)
@@ -3749,14 +3749,14 @@
void t_netstd_generator::generate_netstd_docstring_comment(ostream& out, string contents)
{
- docstring_comment(out, "/// <summary>" + endl, "/// ", contents, "/// </summary>" + endl);
+ docstring_comment(out, "/// <summary>" + string("\n"), "/// ", contents, "/// </summary>" + string("\n"));
}
void t_netstd_generator::generate_netstd_doc(ostream& out, t_field* field)
{
if (field->get_type()->is_enum())
{
- string combined_message = field->get_doc() + endl + "<seealso cref=\"" + get_enum_class_name(field->get_type()) + "\"/>";
+ string combined_message = field->get_doc() + "\n" + "<seealso cref=\"" + get_enum_class_name(field->get_type()) + "\"/>";
generate_netstd_docstring_comment(out, combined_message);
}
else
@@ -3783,7 +3783,7 @@
for (p_iter = fields.begin(); p_iter != fields.end(); ++p_iter)
{
t_field* p = *p_iter;
- ps << endl << "<param name=\"" << p->get_name() << "\">";
+ ps << '\n' << "<param name=\"" << p->get_name() << "\">";
if (p->has_doc())
{
string str = p->get_doc();
@@ -3796,7 +3796,7 @@
docstring_comment(out,
"",
"/// ",
- "<summary>" + endl + tfunction->get_doc() + "</summary>" + ps.str(),
+ "<summary>" + string("\n") + tfunction->get_doc() + "</summary>" + ps.str(),
"");
}
}
@@ -3818,11 +3818,11 @@
// Just prnt a newline when the line & prefix are empty.
if (strlen(line) == 0 && line_prefix == "" && !docs.eof())
{
- out << endl;
+ out << '\n';
}
else if (strlen(line) > 0 || !docs.eof())
{ // skip the empty last line
- out << indent() << line_prefix << line << endl;
+ out << indent() << line_prefix << line << '\n';
}
}
if (comment_end != "")
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.h b/compiler/cpp/src/thrift/generate/t_netstd_generator.h
index ff3cfb1..a6e4d90 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.h
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.h
@@ -44,8 +44,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
static const string DEEP_COPY_METHOD_NAME = "DeepCopy";
static const string CANCELLATION_TOKEN_NAME = "cancellationToken";
@@ -165,7 +163,7 @@
comment += " */\n";
return comment;
}
-
+
private:
string namespace_name_;
@@ -182,15 +180,15 @@
const std::string CSHARP_KEYWORDS[101] = {
// C# keywords
- "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue",
- "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally",
- "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock",
- "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected",
- "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string",
- "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort",
- "using", "virtual", "void", "volatile", "while",
+ "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue",
+ "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally",
+ "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock",
+ "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected",
+ "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string",
+ "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort",
+ "using", "virtual", "void", "volatile", "while",
// C# contextual keywords
- "add", "alias", "ascending", "async", "await", "descending", "dynamic", "from", "get", "global", "group", "into",
+ "add", "alias", "ascending", "async", "await", "descending", "dynamic", "from", "get", "global", "group", "into",
"join", "let", "orderby", "partial", "remove", "select", "set", "value", "var", "when", "where", "yield"
};
@@ -199,7 +197,7 @@
vector<member_mapping_scope> member_mapping_scopes;
map<string, t_type*> collected_extension_types;
map<string, t_type*> checked_extension_types;
-
+
string normalize_name(string name, bool is_arg_name = false);
string make_valid_csharp_identifier(string const& fromName);
string make_csharp_string_literal( string const& value);
diff --git a/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc b/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc
index 5f9b80c..34dda40 100644
--- a/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc
@@ -38,8 +38,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* OCaml code generator.
*
@@ -241,10 +239,10 @@
f_consts_.open(f_consts_name.c_str());
// Print header
- f_types_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
- f_types_i_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
- f_consts_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl << "open "
- << capitalize(program_name_) << "_types" << endl;
+ f_types_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n';
+ f_types_i_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n';
+ f_consts_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n' << "open "
+ << capitalize(program_name_) << "_types" << '\n';
}
/**
@@ -277,9 +275,9 @@
*/
void t_ocaml_generator::generate_typedef(t_typedef* ttypedef) {
f_types_ << indent() << "type " << decapitalize(ttypedef->get_symbolic()) << " = "
- << render_ocaml_type(ttypedef->get_type()) << endl << endl;
+ << render_ocaml_type(ttypedef->get_type()) << '\n' << '\n';
f_types_i_ << indent() << "type " << decapitalize(ttypedef->get_symbolic()) << " = "
- << render_ocaml_type(ttypedef->get_type()) << endl << endl;
+ << render_ocaml_type(ttypedef->get_type()) << '\n' << '\n';
}
/**
@@ -289,46 +287,46 @@
* @param tenum The enumeration
*/
void t_ocaml_generator::generate_enum(t_enum* tenum) {
- indent(f_types_) << "module " << capitalize(tenum->get_name()) << " = " << endl << "struct"
- << endl;
- indent(f_types_i_) << "module " << capitalize(tenum->get_name()) << " : " << endl << "sig"
- << endl;
+ indent(f_types_) << "module " << capitalize(tenum->get_name()) << " = " << '\n' << "struct"
+ << '\n';
+ indent(f_types_i_) << "module " << capitalize(tenum->get_name()) << " : " << '\n' << "sig"
+ << '\n';
indent_up();
- indent(f_types_) << "type t = " << endl;
- indent(f_types_i_) << "type t = " << endl;
+ indent(f_types_) << "type t = " << '\n';
+ indent(f_types_i_) << "type t = " << '\n';
indent_up();
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
string name = capitalize((*c_iter)->get_name());
- indent(f_types_) << "| " << name << endl;
- indent(f_types_i_) << "| " << name << endl;
+ indent(f_types_) << "| " << name << '\n';
+ indent(f_types_i_) << "| " << name << '\n';
}
indent_down();
- indent(f_types_) << "let to_i = function" << endl;
- indent(f_types_i_) << "val to_i : t -> Int32.t" << endl;
+ indent(f_types_) << "let to_i = function" << '\n';
+ indent(f_types_i_) << "val to_i : t -> Int32.t" << '\n';
indent_up();
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
string name = capitalize((*c_iter)->get_name());
- indent(f_types_) << "| " << name << " -> " << value << "l" << endl;
+ indent(f_types_) << "| " << name << " -> " << value << "l" << '\n';
}
indent_down();
- indent(f_types_) << "let of_i = function" << endl;
- indent(f_types_i_) << "val of_i : Int32.t -> t" << endl;
+ indent(f_types_) << "let of_i = function" << '\n';
+ indent(f_types_i_) << "val of_i : Int32.t -> t" << '\n';
indent_up();
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
string name = capitalize((*c_iter)->get_name());
- indent(f_types_) << "| " << value << "l -> " << name << endl;
+ indent(f_types_) << "| " << value << "l -> " << name << '\n';
}
- indent(f_types_) << "| _ -> raise Thrift_error" << endl;
+ indent(f_types_) << "| _ -> raise Thrift_error" << '\n';
indent_down();
indent_down();
- indent(f_types_) << "end" << endl;
- indent(f_types_i_) << "end" << endl;
+ indent(f_types_) << "end" << '\n';
+ indent(f_types_i_) << "end" << '\n';
}
/**
@@ -339,7 +337,7 @@
string name = decapitalize(tconst->get_name());
t_const_value* value = tconst->get_value();
- indent(f_consts_) << "let " << name << " = " << render_const_value(type, value) << endl << endl;
+ indent(f_consts_) << "let " << name << " = " << render_const_value(type, value) << '\n' << '\n';
}
/**
@@ -395,9 +393,9 @@
} else if (type->is_struct() || type->is_xception()) {
string cname = type_name(type);
string ct = tmp("_c");
- out << endl;
+ out << '\n';
indent_up();
- indent(out) << "(let " << ct << " = new " << cname << " in" << endl;
+ indent(out) << "(let " << ct << " = new " << cname << " in" << '\n';
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -417,7 +415,7 @@
out << indent();
out << ct << "#set_" << fname << " ";
out << render_const_value(field_type, v_iter->second);
- out << ";" << endl;
+ out << ";" << '\n';
}
indent(out) << ct << ")";
indent_down();
@@ -428,14 +426,14 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
string hm = tmp("_hm");
- out << endl;
+ out << '\n';
indent_up();
- indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << endl;
+ indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << '\n';
indent_up();
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(ktype, v_iter->first);
string val = render_const_value(vtype, v_iter->second);
- indent(out) << "Hashtbl.add " << hm << " " << key << " " << val << ";" << endl;
+ indent(out) << "Hashtbl.add " << hm << " " << key << " " << val << ";" << '\n';
}
indent(out) << hm << ")";
indent_down();
@@ -443,14 +441,14 @@
} else if (type->is_list()) {
t_type* etype;
etype = ((t_list*)type)->get_elem_type();
- out << "[" << endl;
+ out << "[" << '\n';
indent_up();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << indent();
out << render_const_value(etype, *v_iter);
- out << ";" << endl;
+ out << ";" << '\n';
}
indent_down();
indent(out) << "]";
@@ -459,15 +457,15 @@
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
string hm = tmp("_hm");
- indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << endl;
+ indent(out) << "(let " << hm << " = Hashtbl.create " << val.size() << " in" << '\n';
indent_up();
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string val = render_const_value(etype, *v_iter);
- indent(out) << "Hashtbl.add " << hm << " " << val << " true;" << endl;
+ indent(out) << "Hashtbl.add " << hm << " " << val << " true;" << '\n';
}
- indent(out) << hm << ")" << endl;
+ indent(out) << hm << ")" << '\n';
indent_down();
- out << endl;
+ out << '\n';
} else {
throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name();
}
@@ -503,15 +501,15 @@
vector<t_field*>::const_iterator m_iter;
/* Create a copy of the current object */
- indent(out) << "method copy =" << endl;
+ indent(out) << "method copy =" << '\n';
indent_up();
indent_up();
- indent(out) << "let _new = Oo.copy self in" << endl;
+ indent(out) << "let _new = Oo.copy self in" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
generate_ocaml_member_copy(out, *m_iter);
indent_down();
- indent(out) << "_new" << endl;
+ indent(out) << "_new" << '\n';
indent_down();
}
@@ -564,10 +562,10 @@
if (copy_of != grab_field) {
indent(out);
if (!struct_member_persistent(tmember)) {
- out << "if _" << mname << " <> None then" << endl;
+ out << "if _" << mname << " <> None then" << '\n';
indent(out) << " ";
}
- out << "_new#set_" << mname << " " << copy_of << ";" << endl;
+ out << "_new#set_" << mname << " " << copy_of << ";" << '\n';
}
}
@@ -582,24 +580,24 @@
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
string tname = type_name(tstruct);
- indent(out) << "class " << tname << " =" << endl;
- indent(out) << "object (self)" << endl;
+ indent(out) << "class " << tname << " =" << '\n';
+ indent(out) << "object (self)" << '\n';
indent_up();
if (members.size() > 0) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
generate_ocaml_struct_member(out, tname, (*m_iter));
- out << endl;
+ out << '\n';
}
}
generate_ocaml_method_copy(out, members);
generate_ocaml_struct_writer(out, tstruct);
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
if (is_exception) {
- indent(out) << "exception " << capitalize(tname) << " of " << tname << endl;
+ indent(out) << "exception " << capitalize(tname) << " of " << tname << '\n';
}
generate_ocaml_struct_reader(out, tstruct);
@@ -621,37 +619,37 @@
t_const_value* val = tmember->get_value();
if (val) {
if (struct_member_persistent(tmember))
- out << " = " << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
+ out << " = " << render_const_value(tmember->get_type(), tmember->get_value()) << '\n';
else
out << " option = Some " << render_const_value(tmember->get_type(), tmember->get_value())
- << endl;
+ << '\n';
} else {
// assert(!struct_member_persistent(tmember))
- out << " option = None" << endl;
+ out << " option = None" << '\n';
}
if (struct_member_persistent(tmember)) {
- indent(out) << "method get_" << mname << " = Some _" << mname << endl;
- indent(out) << "method grab_" << mname << " = _" << mname << endl;
- indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- " << x << endl;
+ indent(out) << "method get_" << mname << " = Some _" << mname << '\n';
+ indent(out) << "method grab_" << mname << " = _" << mname << '\n';
+ indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- " << x << '\n';
} else {
- indent(out) << "method get_" << mname << " = _" << mname << endl;
+ indent(out) << "method get_" << mname << " = _" << mname << '\n';
indent(out) << "method grab_" << mname << " = match _" << mname
<< " with None->raise (Field_empty \"" << tname << "." << mname << "\") | Some "
- << x << " -> " << x << endl;
+ << x << " -> " << x << '\n';
indent(out) << "method set_" << mname << " " << x << " = _" << mname << " <- Some " << x
- << endl;
- indent(out) << "method unset_" << mname << " = _" << mname << " <- None" << endl;
+ << '\n';
+ indent(out) << "method unset_" << mname << " = _" << mname << " <- None" << '\n';
}
indent(out) << "method reset_" << mname << " = _" << mname << " <- ";
if (val) {
if (struct_member_persistent(tmember))
- out << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
+ out << render_const_value(tmember->get_type(), tmember->get_value()) << '\n';
else
- out << "Some " << render_const_value(tmember->get_type(), tmember->get_value()) << endl;
+ out << "Some " << render_const_value(tmember->get_type(), tmember->get_value()) << '\n';
} else {
- out << "None" << endl;
+ out << "None" << '\n';
}
}
@@ -719,8 +717,8 @@
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
string tname = type_name(tstruct);
- indent(out) << "class " << tname << " :" << endl;
- indent(out) << "object ('a)" << endl;
+ indent(out) << "class " << tname << " :" << '\n';
+ indent(out) << "object ('a)" << '\n';
indent_up();
@@ -729,24 +727,24 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string mname = decapitalize((*m_iter)->get_name());
string type = render_ocaml_type((*m_iter)->get_type());
- indent(out) << "method get_" << mname << " : " << type << " option" << endl;
- indent(out) << "method grab_" << mname << " : " << type << endl;
- indent(out) << "method set_" << mname << " : " << type << " -> unit" << endl;
+ indent(out) << "method get_" << mname << " : " << type << " option" << '\n';
+ indent(out) << "method grab_" << mname << " : " << type << '\n';
+ indent(out) << "method set_" << mname << " : " << type << " -> unit" << '\n';
if (!struct_member_persistent(*m_iter))
- indent(out) << "method unset_" << mname << " : unit" << endl;
- indent(out) << "method reset_" << mname << " : unit" << endl;
+ indent(out) << "method unset_" << mname << " : unit" << '\n';
+ indent(out) << "method reset_" << mname << " : unit" << '\n';
}
}
- indent(out) << "method copy : 'a" << endl;
- indent(out) << "method write : Protocol.t -> unit" << endl;
+ indent(out) << "method copy : 'a" << '\n';
+ indent(out) << "method write : Protocol.t -> unit" << '\n';
indent_down();
- indent(out) << "end" << endl;
+ indent(out) << "end" << '\n';
if (is_exception) {
- indent(out) << "exception " << capitalize(tname) << " of " << tname << endl;
+ indent(out) << "exception " << capitalize(tname) << " of " << tname << '\n';
}
- indent(out) << "val read_" << tname << " : Protocol.t -> " << tname << endl;
+ indent(out) << "val read_" << tname << " : Protocol.t -> " << tname << '\n';
}
/**
@@ -759,55 +757,55 @@
string str = tmp("_str");
string t = tmp("_t");
string id = tmp("_id");
- indent(out) << "let rec read_" << sname << " (iprot : Protocol.t) =" << endl;
+ indent(out) << "let rec read_" << sname << " (iprot : Protocol.t) =" << '\n';
indent_up();
- indent(out) << "let " << str << " = new " << sname << " in" << endl;
+ indent(out) << "let " << str << " = new " << sname << " in" << '\n';
indent_up();
- indent(out) << "ignore(iprot#readStructBegin);" << endl;
+ indent(out) << "ignore(iprot#readStructBegin);" << '\n';
// Loop over reading in fields
- indent(out) << "(try while true do" << endl;
+ indent(out) << "(try while true do" << '\n';
indent_up();
indent_up();
// Read beginning field marker
- indent(out) << "let (_," << t << "," << id << ") = iprot#readFieldBegin in" << endl;
+ indent(out) << "let (_," << t << "," << id << ") = iprot#readFieldBegin in" << '\n';
// Check for field STOP marker and break
- indent(out) << "if " << t << " = Protocol.T_STOP then" << endl;
+ indent(out) << "if " << t << " = Protocol.T_STOP then" << '\n';
indent_up();
- indent(out) << "raise Break" << endl;
+ indent(out) << "raise Break" << '\n';
indent_down();
- indent(out) << "else ();" << endl;
+ indent(out) << "else ();" << '\n';
- indent(out) << "(match " << id << " with " << endl;
+ indent(out) << "(match " << id << " with " << '\n';
indent_up();
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent(out) << "| " << (*f_iter)->get_key() << " -> (";
- out << "if " << t << " = " << type_to_enum((*f_iter)->get_type()) << " then" << endl;
+ out << "if " << t << " = " << type_to_enum((*f_iter)->get_type()) << " then" << '\n';
indent_up();
indent_up();
generate_deserialize_field(out, *f_iter, str);
indent_down();
- out << indent() << "else" << endl << indent() << " iprot#skip " << t << ")" << endl;
+ out << indent() << "else" << '\n' << indent() << " iprot#skip " << t << ")" << '\n';
indent_down();
}
// In the default case we skip the field
out << indent() << "| _ -> "
- << "iprot#skip " << t << ");" << endl;
+ << "iprot#skip " << t << ");" << '\n';
indent_down();
// Read field end marker
- indent(out) << "iprot#readFieldEnd;" << endl;
+ indent(out) << "iprot#readFieldEnd;" << '\n';
indent_down();
- indent(out) << "done; ()" << endl;
+ indent(out) << "done; ()" << '\n';
indent_down();
- indent(out) << "with Break -> ());" << endl;
+ indent(out) << "with Break -> ());" << '\n';
- indent(out) << "iprot#readStructEnd;" << endl;
+ indent(out) << "iprot#readStructEnd;" << '\n';
- indent(out) << str << endl << endl;
+ indent(out) << str << '\n' << '\n';
indent_down();
indent_down();
}
@@ -819,9 +817,9 @@
string str = tmp("_str");
string f = tmp("_f");
- indent(out) << "method write (oprot : Protocol.t) =" << endl;
+ indent(out) << "method write (oprot : Protocol.t) =" << '\n';
indent_up();
- indent(out) << "oprot#writeStructBegin \"" << name << "\";" << endl;
+ indent(out) << "oprot#writeStructBegin \"" << name << "\";" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* tmember = (*f_iter);
@@ -835,10 +833,10 @@
// Avoid redundant encoding of members having default values.
indent(out) << "(match " << mname << " with "
<< render_const_value(tmember->get_type(), tmember->get_value()) << " -> () | "
- << _v << " -> " << endl;
+ << _v << " -> " << '\n';
} else {
_v = mname;
- indent(out) << "(" << endl;
+ indent(out) << "(" << '\n';
}
} else {
@@ -853,12 +851,12 @@
out << " | Some " << render_const_value(tmember->get_type(), tmember->get_value())
<< " -> ()";
}
- out << " | Some _v -> " << endl;
+ out << " | Some _v -> " << '\n';
} else {
- out << endl;
+ out << '\n';
indent(out) << "| None -> raise (Field_empty \"" << type_name(tstruct) << "." << mname
- << "\")" << endl;
- indent(out) << "| Some _v -> " << endl;
+ << "\")" << '\n';
+ indent(out) << "| Some _v -> " << '\n';
}
_v = "_v";
@@ -866,20 +864,20 @@
indent_up();
// Write field header
indent(out) << "oprot#writeFieldBegin(\"" << tmember->get_name() << "\","
- << type_to_enum(tmember->get_type()) << "," << tmember->get_key() << ");" << endl;
+ << type_to_enum(tmember->get_type()) << "," << tmember->get_key() << ");" << '\n';
// Write field contents
generate_serialize_field(out, tmember, _v);
// Write field closer
- indent(out) << "oprot#writeFieldEnd" << endl;
+ indent(out) << "oprot#writeFieldEnd" << '\n';
indent_down();
- indent(out) << ");" << endl;
+ indent(out) << ");" << '\n';
}
// Write the struct map
- out << indent() << "oprot#writeFieldStop;" << endl << indent() << "oprot#writeStructEnd" << endl;
+ out << indent() << "oprot#writeFieldStop;" << '\n' << indent() << "oprot#writeStructEnd" << '\n';
indent_down();
}
@@ -895,19 +893,19 @@
string f_service_i_name = get_out_dir() + capitalize(service_name_) + ".mli";
f_service_i_.open(f_service_i_name.c_str());
- f_service_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
- f_service_i_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
+ f_service_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n';
+ f_service_i_ << ocaml_autogen_comment() << '\n' << ocaml_imports() << '\n';
/* if (tservice->get_extends() != nullptr) {
f_service_ <<
- "open " << capitalize(tservice->get_extends()->get_name()) << endl;
+ "open " << capitalize(tservice->get_extends()->get_name()) << '\n';
f_service_i_ <<
- "open " << capitalize(tservice->get_extends()->get_name()) << endl;
+ "open " << capitalize(tservice->get_extends()->get_name()) << '\n';
}
*/
- f_service_ << "open " << capitalize(program_name_) << "_types" << endl << endl;
+ f_service_ << "open " << capitalize(program_name_) << "_types" << '\n' << '\n';
- f_service_i_ << "open " << capitalize(program_name_) << "_types" << endl << endl;
+ f_service_i_ << "open " << capitalize(program_name_) << "_types" << '\n' << '\n';
// Generate the three main parts of the service
generate_service_helpers(tservice);
@@ -925,7 +923,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- indent(f_service_) << "(* HELPER FUNCTIONS AND STRUCTURES *)" << endl << endl;
+ indent(f_service_) << "(* HELPER FUNCTIONS AND STRUCTURES *)" << '\n' << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
@@ -961,15 +959,15 @@
* @param tservice The service to generate a header definition for
*/
void t_ocaml_generator::generate_service_interface(t_service* tservice) {
- f_service_ << indent() << "class virtual iface =" << endl << "object (self)" << endl;
- f_service_i_ << indent() << "class virtual iface :" << endl << "object" << endl;
+ f_service_ << indent() << "class virtual iface =" << '\n' << "object (self)" << '\n';
+ f_service_i_ << indent() << "class virtual iface :" << '\n' << "object" << '\n';
indent_up();
if (tservice->get_extends() != nullptr) {
string extends = type_name(tservice->get_extends());
- indent(f_service_) << "inherit " << extends << ".iface" << endl;
- indent(f_service_i_) << "inherit " << extends << ".iface" << endl;
+ indent(f_service_) << "inherit " << extends << ".iface" << '\n';
+ indent(f_service_i_) << "inherit " << extends << ".iface" << '\n';
}
vector<t_function*> functions = tservice->get_functions();
@@ -977,13 +975,13 @@
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string ft = function_type(*f_iter, true, true);
f_service_ << indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : "
- << ft << endl;
+ << ft << '\n';
f_service_i_ << indent() << "method virtual " << decapitalize((*f_iter)->get_name()) << " : "
- << ft << endl;
+ << ft << '\n';
}
indent_down();
- indent(f_service_) << "end" << endl << endl;
- indent(f_service_i_) << "end" << endl << endl;
+ indent(f_service_) << "end" << '\n' << '\n';
+ indent(f_service_i_) << "end" << '\n' << '\n';
}
/**
@@ -995,17 +993,17 @@
*/
void t_ocaml_generator::generate_service_client(t_service* tservice) {
string extends = "";
- indent(f_service_) << "class client (iprot : Protocol.t) (oprot : Protocol.t) =" << endl
- << "object (self)" << endl;
- indent(f_service_i_) << "class client : Protocol.t -> Protocol.t -> " << endl << "object" << endl;
+ indent(f_service_) << "class client (iprot : Protocol.t) (oprot : Protocol.t) =" << '\n'
+ << "object (self)" << '\n';
+ indent(f_service_i_) << "class client : Protocol.t -> Protocol.t -> " << '\n' << "object" << '\n';
indent_up();
if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
- indent(f_service_) << "inherit " << extends << ".client iprot oprot as super" << endl;
- indent(f_service_i_) << "inherit " << extends << ".client" << endl;
+ indent(f_service_) << "inherit " << extends << ".client iprot oprot as super" << '\n';
+ indent(f_service_i_) << "inherit " << extends << ".client" << '\n';
}
- indent(f_service_) << "val mutable seqid = 0" << endl;
+ indent(f_service_) << "val mutable seqid = 0" << '\n';
// Generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -1017,24 +1015,24 @@
string funname = (*f_iter)->get_name();
// Open function
- indent(f_service_) << "method " << function_signature(*f_iter) << " = " << endl;
+ indent(f_service_) << "method " << function_signature(*f_iter) << " = " << '\n';
indent(f_service_i_) << "method " << decapitalize((*f_iter)->get_name()) << " : "
- << function_type(*f_iter, true, false) << endl;
+ << function_type(*f_iter, true, false) << '\n';
indent_up();
indent(f_service_) << "self#send_" << funname;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << " " << decapitalize((*fld_iter)->get_name());
}
- f_service_ << ";" << endl;
+ f_service_ << ";" << '\n';
if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
- f_service_ << "self#recv_" << funname << endl;
+ f_service_ << "self#recv_" << funname << '\n';
}
indent_down();
- indent(f_service_) << "method private send_" << function_signature(*f_iter) << " = " << endl;
+ indent(f_service_) << "method private send_" << function_signature(*f_iter) << " = " << '\n';
indent_up();
std::string argsname = decapitalize((*f_iter)->get_name() + "_args");
@@ -1042,19 +1040,19 @@
// Serialize the request header
f_service_ << indent() << "oprot#writeMessageBegin (\"" << (*f_iter)->get_name() << "\", "
<< ((*f_iter)->is_oneway() ? "Protocol.ONEWAY" : "Protocol.CALL") << ", seqid);"
- << endl;
+ << '\n';
- f_service_ << indent() << "let args = new " << argsname << " in" << endl;
+ f_service_ << indent() << "let args = new " << argsname << " in" << '\n';
indent_up();
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << "args#set_" << (*fld_iter)->get_name() << " "
- << (*fld_iter)->get_name() << ";" << endl;
+ << (*fld_iter)->get_name() << ";" << '\n';
}
// Write to the stream
- f_service_ << indent() << "args#write oprot;" << endl << indent() << "oprot#writeMessageEnd;"
- << endl << indent() << "oprot#getTransport#flush" << endl;
+ f_service_ << indent() << "args#write oprot;" << '\n' << indent() << "oprot#writeMessageEnd;"
+ << '\n' << indent() << "oprot#getTransport#flush" << '\n';
indent_down();
indent_down();
@@ -1068,20 +1066,20 @@
&noargs);
// Open function
f_service_ << indent() << "method private " << function_signature(&recv_function) << " ="
- << endl;
+ << '\n';
indent_up();
// TODO(mcslee): Validate message reply here, seq ids etc.
- f_service_ << indent() << "let (fname, mtype, rseqid) = iprot#readMessageBegin in" << endl;
+ f_service_ << indent() << "let (fname, mtype, rseqid) = iprot#readMessageBegin in" << '\n';
indent_up();
- f_service_ << indent() << "(if mtype = Protocol.EXCEPTION then" << endl << indent()
- << " let x = Application_Exn.read iprot in" << endl;
+ f_service_ << indent() << "(if mtype = Protocol.EXCEPTION then" << '\n' << indent()
+ << " let x = Application_Exn.read iprot in" << '\n';
indent_up();
f_service_ << indent() << " (iprot#readMessageEnd;" << indent()
- << " raise (Application_Exn.E x))" << endl;
+ << " raise (Application_Exn.E x))" << '\n';
indent_down();
- f_service_ << indent() << "else ());" << endl;
+ f_service_ << indent() << "else ());" << '\n';
string res = "_";
t_struct* xs = (*f_iter)->get_xceptions();
@@ -1090,32 +1088,32 @@
if (!(*f_iter)->get_returntype()->is_void() || xceptions.size() > 0) {
res = "result";
}
- f_service_ << indent() << "let " << res << " = read_" << resultname << " iprot in" << endl;
+ f_service_ << indent() << "let " << res << " = read_" << resultname << " iprot in" << '\n';
indent_up();
- f_service_ << indent() << "iprot#readMessageEnd;" << endl;
+ f_service_ << indent() << "iprot#readMessageEnd;" << '\n';
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "match result#get_success with Some v -> v | None -> (" << endl;
+ f_service_ << indent() << "match result#get_success with Some v -> v | None -> (" << '\n';
indent_up();
}
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << indent() << "(match result#get_" << (*x_iter)->get_name()
- << " with None -> () | Some _v ->" << endl;
+ << " with None -> () | Some _v ->" << '\n';
indent(f_service_) << " raise (" << capitalize(exception_ctor((*x_iter)->get_type()))
- << " _v));" << endl;
+ << " _v));" << '\n';
}
// Careful, only return _result if not a void function
if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "()" << endl;
+ indent(f_service_) << "()" << '\n';
} else {
f_service_
<< indent()
<< "raise (Application_Exn.E (Application_Exn.create Application_Exn.MISSING_RESULT \""
- << (*f_iter)->get_name() << " failed: unknown result\")))" << endl;
+ << (*f_iter)->get_name() << " failed: unknown result\")))" << '\n';
indent_down();
}
@@ -1127,8 +1125,8 @@
}
indent_down();
- indent(f_service_) << "end" << endl << endl;
- indent(f_service_i_) << "end" << endl << endl;
+ indent(f_service_) << "end" << '\n' << '\n';
+ indent(f_service_i_) << "end" << '\n' << '\n';
}
/**
@@ -1142,50 +1140,50 @@
vector<t_function*>::iterator f_iter;
// Generate the header portion
- indent(f_service_) << "class processor (handler : iface) =" << endl << indent() << "object (self)"
- << endl;
- indent(f_service_i_) << "class processor : iface ->" << endl << indent() << "object" << endl;
+ indent(f_service_) << "class processor (handler : iface) =" << '\n' << indent() << "object (self)"
+ << '\n';
+ indent(f_service_i_) << "class processor : iface ->" << '\n' << indent() << "object" << '\n';
indent_up();
- f_service_ << indent() << "inherit Processor.t" << endl << endl;
- f_service_i_ << indent() << "inherit Processor.t" << endl << endl;
+ f_service_ << indent() << "inherit Processor.t" << '\n' << '\n';
+ f_service_i_ << indent() << "inherit Processor.t" << '\n' << '\n';
string extends = "";
if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
indent(f_service_) << "inherit " + extends + ".processor (handler :> " + extends + ".iface)"
- << endl;
- indent(f_service_i_) << "inherit " + extends + ".processor" << endl;
+ << '\n';
+ indent(f_service_i_) << "inherit " + extends + ".processor" << '\n';
}
if (extends.empty()) {
- indent(f_service_) << "val processMap = Hashtbl.create " << functions.size() << endl;
+ indent(f_service_) << "val processMap = Hashtbl.create " << functions.size() << '\n';
}
indent(f_service_i_)
- << "val processMap : (string, int * Protocol.t * Protocol.t -> unit) Hashtbl.t" << endl;
+ << "val processMap : (string, int * Protocol.t * Protocol.t -> unit) Hashtbl.t" << '\n';
// Generate the server implementation
- indent(f_service_) << "method process iprot oprot =" << endl;
- indent(f_service_i_) << "method process : Protocol.t -> Protocol.t -> bool" << endl;
+ indent(f_service_) << "method process iprot oprot =" << '\n';
+ indent(f_service_i_) << "method process : Protocol.t -> Protocol.t -> bool" << '\n';
indent_up();
- f_service_ << indent() << "let (name, typ, seqid) = iprot#readMessageBegin in" << endl;
+ f_service_ << indent() << "let (name, typ, seqid) = iprot#readMessageBegin in" << '\n';
indent_up();
// TODO(mcslee): validate message
// HOT: dictionary function lookup
- f_service_ << indent() << "if Hashtbl.mem processMap name then" << endl << indent()
- << " (Hashtbl.find processMap name) (seqid, iprot, oprot)" << endl << indent()
- << "else (" << endl << indent() << " iprot#skip(Protocol.T_STRUCT);" << endl
- << indent() << " iprot#readMessageEnd;" << endl << indent()
+ f_service_ << indent() << "if Hashtbl.mem processMap name then" << '\n' << indent()
+ << " (Hashtbl.find processMap name) (seqid, iprot, oprot)" << '\n' << indent()
+ << "else (" << '\n' << indent() << " iprot#skip(Protocol.T_STRUCT);" << '\n'
+ << indent() << " iprot#readMessageEnd;" << '\n' << indent()
<< " let x = Application_Exn.create Application_Exn.UNKNOWN_METHOD (\"Unknown "
- "function \"^name) in" << endl << indent()
- << " oprot#writeMessageBegin(name, Protocol.EXCEPTION, seqid);" << endl << indent()
- << " x#write oprot;" << endl << indent() << " oprot#writeMessageEnd;" << endl
- << indent() << " oprot#getTransport#flush" << endl << indent() << ");" << endl;
+ "function \"^name) in" << '\n' << indent()
+ << " oprot#writeMessageBegin(name, Protocol.EXCEPTION, seqid);" << '\n' << indent()
+ << " x#write oprot;" << '\n' << indent() << " oprot#writeMessageEnd;" << '\n'
+ << indent() << " oprot#getTransport#flush" << '\n' << indent() << ");" << '\n';
// Read end of args field, the T_STOP, and the struct close
- f_service_ << indent() << "true" << endl;
+ f_service_ << indent() << "true" << '\n';
indent_down();
indent_down();
// Generate the process subfunctions
@@ -1193,17 +1191,17 @@
generate_process_function(tservice, *f_iter);
}
- indent(f_service_) << "initializer" << endl;
+ indent(f_service_) << "initializer" << '\n';
indent_up();
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
f_service_ << indent() << "Hashtbl.add processMap \"" << (*f_iter)->get_name()
- << "\" self#process_" << (*f_iter)->get_name() << ";" << endl;
+ << "\" self#process_" << (*f_iter)->get_name() << ";" << '\n';
}
indent_down();
indent_down();
- indent(f_service_) << "end" << endl << endl;
- indent(f_service_i_) << "end" << endl << endl;
+ indent(f_service_) << "end" << '\n' << '\n';
+ indent(f_service_i_) << "end" << '\n' << '\n';
}
/**
@@ -1215,7 +1213,7 @@
(void)tservice;
// Open function
indent(f_service_) << "method private process_" << tfunction->get_name()
- << " (seqid, iprot, oprot) =" << endl;
+ << " (seqid, iprot, oprot) =" << '\n';
indent_up();
string argsname = decapitalize(tfunction->get_name()) + "_args";
@@ -1231,9 +1229,9 @@
args = "_";
}
- f_service_ << indent() << "let " << args << " = read_" << argsname << " iprot in" << endl;
+ f_service_ << indent() << "let " << args << " = read_" << argsname << " iprot in" << '\n';
indent_up();
- f_service_ << indent() << "iprot#readMessageEnd;" << endl;
+ f_service_ << indent() << "iprot#readMessageEnd;" << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -1241,13 +1239,13 @@
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "let result = new " << resultname << " in" << endl;
+ f_service_ << indent() << "let result = new " << resultname << " in" << '\n';
indent_up();
}
// Try block for a function with exceptions
if (xceptions.size() > 0) {
- f_service_ << indent() << "(try" << endl;
+ f_service_ << indent() << "(try" << '\n';
indent_up();
}
@@ -1259,20 +1257,20 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
f_service_ << " args#get_" << (*f_iter)->get_name();
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
if (xceptions.size() > 0) {
indent_down();
- indent(f_service_) << "with" << endl;
+ indent(f_service_) << "with" << '\n';
indent_up();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << indent() << "| " << capitalize(exception_ctor((*x_iter)->get_type())) << " "
- << (*x_iter)->get_name() << " -> " << endl;
+ << (*x_iter)->get_name() << " -> " << '\n';
indent_up();
indent_up();
if (!tfunction->is_oneway()) {
f_service_ << indent() << "result#set_" << (*x_iter)->get_name() << " "
- << (*x_iter)->get_name() << endl;
+ << (*x_iter)->get_name() << '\n';
} else {
indent(f_service_) << "()";
}
@@ -1280,21 +1278,21 @@
indent_down();
}
indent_down();
- f_service_ << indent() << ");" << endl;
+ f_service_ << indent() << ");" << '\n';
}
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- f_service_ << indent() << "()" << endl;
+ f_service_ << indent() << "()" << '\n';
indent_down();
indent_down();
return;
}
f_service_ << indent() << "oprot#writeMessageBegin (\"" << tfunction->get_name()
- << "\", Protocol.REPLY, seqid);" << endl << indent() << "result#write oprot;" << endl
- << indent() << "oprot#writeMessageEnd;" << endl << indent()
- << "oprot#getTransport#flush" << endl;
+ << "\", Protocol.REPLY, seqid);" << '\n' << indent() << "result#write oprot;" << '\n'
+ << indent() << "oprot#writeMessageEnd;" << '\n' << indent()
+ << "oprot#getTransport#flush" << '\n';
// Close function
indent_down();
@@ -1311,7 +1309,7 @@
string name = decapitalize(tfield->get_name());
indent(out) << prefix << "#set_" << name << " ";
generate_deserialize_type(out, type);
- out << endl;
+ out << '\n';
}
/**
@@ -1396,46 +1394,46 @@
t_field fvtype(g_type_i8, vtype);
t_field fetype(g_type_i8, etype);
- out << endl;
+ out << '\n';
indent_up();
// Declare variables, read header
if (ttype->is_map()) {
indent(out) << "(let (" << ktype << "," << vtype << "," << size << ") = iprot#readMapBegin in"
- << endl;
- indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << endl;
+ << '\n';
+ indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << '\n';
indent_up();
- indent(out) << "for i = 1 to " << size << " do" << endl;
+ indent(out) << "for i = 1 to " << size << " do" << '\n';
indent_up();
indent(out) << "let _k = ";
generate_deserialize_type(out, ((t_map*)ttype)->get_key_type());
- out << " in" << endl;
+ out << " in" << '\n';
indent(out) << "let _v = ";
generate_deserialize_type(out, ((t_map*)ttype)->get_val_type());
- out << " in" << endl;
+ out << " in" << '\n';
indent_up();
- indent(out) << "Hashtbl.add " << con << " _k _v" << endl;
+ indent(out) << "Hashtbl.add " << con << " _k _v" << '\n';
indent_down();
indent_down();
indent(out) << "done; iprot#readMapEnd; " << con << ")";
indent_down();
} else if (ttype->is_set()) {
- indent(out) << "(let (" << etype << "," << size << ") = iprot#readSetBegin in" << endl;
- indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << endl;
+ indent(out) << "(let (" << etype << "," << size << ") = iprot#readSetBegin in" << '\n';
+ indent(out) << "let " << con << " = Hashtbl.create " << size << " in" << '\n';
indent_up();
- indent(out) << "for i = 1 to " << size << " do" << endl;
+ indent(out) << "for i = 1 to " << size << " do" << '\n';
indent_up();
indent(out) << "Hashtbl.add " << con << " ";
generate_deserialize_type(out, ((t_set*)ttype)->get_elem_type());
- out << " true" << endl;
+ out << " true" << '\n';
indent_down();
indent(out) << "done; iprot#readSetEnd; " << con << ")";
indent_down();
} else if (ttype->is_list()) {
- indent(out) << "(let (" << etype << "," << size << ") = iprot#readListBegin in" << endl;
+ indent(out) << "(let (" << etype << "," << size << ") = iprot#readListBegin in" << '\n';
indent_up();
indent(out) << "let " << con << " = (Array.to_list (Array.init " << size << " (fun _ -> ";
generate_deserialize_type(out, ((t_list*)ttype)->get_elem_type());
- out << "))) in" << endl;
+ out << "))) in" << '\n';
indent_up();
indent(out) << "iprot#readListEnd; " << con << ")";
indent_down();
@@ -1510,7 +1508,7 @@
tfield->get_name().c_str(),
type->get_name().c_str());
}
- out << ";" << endl;
+ out << ";" << '\n';
}
/**
@@ -1528,38 +1526,38 @@
if (ttype->is_map()) {
indent(out) << "oprot#writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ",";
out << type_to_enum(((t_map*)ttype)->get_val_type()) << ",";
- out << "Hashtbl.length " << prefix << ");" << endl;
+ out << "Hashtbl.length " << prefix << ");" << '\n';
} else if (ttype->is_set()) {
indent(out) << "oprot#writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ",";
- out << "Hashtbl.length " << prefix << ");" << endl;
+ out << "Hashtbl.length " << prefix << ");" << '\n';
} else if (ttype->is_list()) {
indent(out) << "oprot#writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
<< ",";
- out << "List.length " << prefix << ");" << endl;
+ out << "List.length " << prefix << ");" << '\n';
}
if (ttype->is_map()) {
string kiter = tmp("_kiter");
string viter = tmp("_viter");
- indent(out) << "Hashtbl.iter (fun " << kiter << " -> fun " << viter << " -> " << endl;
+ indent(out) << "Hashtbl.iter (fun " << kiter << " -> fun " << viter << " -> " << '\n';
indent_up();
generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
indent_down();
- indent(out) << ") " << prefix << ";" << endl;
+ indent(out) << ") " << prefix << ";" << '\n';
} else if (ttype->is_set()) {
string iter = tmp("_iter");
indent(out) << "Hashtbl.iter (fun " << iter << " -> fun _ -> ";
indent_up();
generate_serialize_set_element(out, (t_set*)ttype, iter);
indent_down();
- indent(out) << ") " << prefix << ";" << endl;
+ indent(out) << ") " << prefix << ";" << '\n';
} else if (ttype->is_list()) {
string iter = tmp("_iter");
indent(out) << "List.iter (fun " << iter << " -> ";
indent_up();
generate_serialize_list_element(out, (t_list*)ttype, iter);
indent_down();
- indent(out) << ") " << prefix << ";" << endl;
+ indent(out) << ") " << prefix << ";" << '\n';
}
if (ttype->is_map()) {
diff --git a/compiler/cpp/src/thrift/generate/t_oop_generator.h b/compiler/cpp/src/thrift/generate/t_oop_generator.h
index 8841962..07b6216 100644
--- a/compiler/cpp/src/thrift/generate/t_oop_generator.h
+++ b/compiler/cpp/src/thrift/generate/t_oop_generator.h
@@ -42,13 +42,13 @@
*/
void scope_up(std::ostream& out) {
- indent(out) << "{" << std::endl;
+ indent(out) << "{" << '\n';
indent_up();
}
void scope_down(std::ostream& out) {
indent_down();
- indent(out) << "}" << std::endl;
+ indent(out) << "}" << '\n';
}
std::string upcase_string(std::string original) {
diff --git a/compiler/cpp/src/thrift/generate/t_perl_generator.cc b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
index d133b24..8e533ca 100644
--- a/compiler/cpp/src/thrift/generate/t_perl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
@@ -37,8 +37,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* PERL code generator.
*
@@ -246,8 +244,8 @@
f_types_ << autogen_comment() << perl_includes();
// Print header
- f_consts_ << autogen_comment() << "package " << perl_namespace(program_) << "Constants;" << endl
- << perl_includes() << endl;
+ f_consts_ << autogen_comment() << "package " << perl_namespace(program_) << "Constants;" << '\n'
+ << perl_includes() << '\n';
}
/**
@@ -271,10 +269,10 @@
*/
void t_perl_generator::close_generator() {
// Close types file
- f_types_ << "1;" << endl;
+ f_types_ << "1;" << '\n';
f_types_.close();
- f_consts_ << "1;" << endl;
+ f_consts_ << "1;" << '\n';
f_consts_.close();
}
@@ -294,13 +292,13 @@
* @param tenum The enumeration
*/
void t_perl_generator::generate_enum(t_enum* tenum) {
- f_types_ << "package " << perl_namespace(program_) << tenum->get_name() << ";" << endl;
+ f_types_ << "package " << perl_namespace(program_) << tenum->get_name() << ";" << '\n';
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
- f_types_ << "use constant " << (*c_iter)->get_name() << " => " << value << ";" << endl;
+ f_types_ << "use constant " << (*c_iter)->get_name() << " => " << value << ";" << '\n';
}
}
@@ -314,7 +312,7 @@
f_consts_ << "use constant " << name << " => ";
f_consts_ << render_const_value(type, value);
- f_consts_ << ";" << endl << endl;
+ f_consts_ << ";" << '\n' << '\n';
}
/**
@@ -355,7 +353,7 @@
} else if (type->is_enum()) {
out << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
- out << perl_namespace(type->get_program()) << type->get_name() << "->new({" << endl;
+ out << perl_namespace(type->get_program()) << type->get_name() << "->new({" << '\n';
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
@@ -376,14 +374,14 @@
out << " => ";
out << render_const_value(field_type, v_iter->second);
out << ",";
- out << endl;
+ out << '\n';
}
indent_down();
indent(out) << "})";
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
@@ -392,7 +390,7 @@
indent(out) << render_const_value(ktype, v_iter->first);
out << " => ";
out << render_const_value(vtype, v_iter->second);
- out << "," << endl;
+ out << "," << '\n';
}
indent_down();
indent(out) << "}";
@@ -403,7 +401,7 @@
} else {
etype = ((t_set*)type)->get_elem_type();
}
- out << "[" << endl;
+ out << "[" << '\n';
indent_up();
const vector<t_const_value*>& val = value->get_list();
@@ -414,7 +412,7 @@
if (type->is_set()) {
out << " => 1";
}
- out << "," << endl;
+ out << "," << '\n';
}
indent_down();
indent(out) << "]";
@@ -480,12 +478,12 @@
out << ") );\n";
}
- out << endl;
+ out << '\n';
// new()
indent_up();
- out << "sub new {" << endl << indent() << "my $classname = shift;" << endl << indent()
- << "my $self = {};" << endl << indent() << "my $vals = shift || {};" << endl;
+ out << "sub new {" << '\n' << indent() << "my $classname = shift;" << '\n' << indent()
+ << "my $self = {};" << '\n' << indent() << "my $vals = shift || {};" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string dval = "undef";
@@ -493,7 +491,7 @@
if ((*m_iter)->get_value() != nullptr && !(t->is_struct() || t->is_xception())) {
dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
}
- out << indent() << "$self->{" << (*m_iter)->get_name() << "} = " << dval << ";" << endl;
+ out << indent() << "$self->{" << (*m_iter)->get_name() << "} = " << dval << ";" << '\n';
}
// Generate constructor from array
@@ -503,27 +501,27 @@
t_type* t = get_true_type((*m_iter)->get_type());
if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) {
indent(out) << "$self->{" << (*m_iter)->get_name()
- << "} = " << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
+ << "} = " << render_const_value(t, (*m_iter)->get_value()) << ";" << '\n';
}
}
- out << indent() << "if (UNIVERSAL::isa($vals,'HASH')) {" << endl;
+ out << indent() << "if (UNIVERSAL::isa($vals,'HASH')) {" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- out << indent() << "if (defined $vals->{" << (*m_iter)->get_name() << "}) {" << endl
+ out << indent() << "if (defined $vals->{" << (*m_iter)->get_name() << "}) {" << '\n'
<< indent() << " $self->{" << (*m_iter)->get_name() << "} = $vals->{"
- << (*m_iter)->get_name() << "};" << endl << indent() << "}" << endl;
+ << (*m_iter)->get_name() << "};" << '\n' << indent() << "}" << '\n';
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
- out << indent() << "return bless ($self, $classname);" << endl;
+ out << indent() << "return bless ($self, $classname);" << '\n';
indent_down();
out << "}\n\n";
- out << "sub getName {" << endl << indent() << " return '" << tstruct->get_name() << "';" << endl
- << indent() << "}" << endl << endl;
+ out << "sub getName {" << '\n' << indent() << " return '" << tstruct->get_name() << "';" << '\n'
+ << indent() << "}" << '\n' << '\n';
generate_perl_struct_reader(out, tstruct);
generate_perl_struct_writer(out, tstruct);
@@ -536,32 +534,32 @@
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- out << "sub read {" << endl;
+ out << "sub read {" << '\n';
indent_up();
- out << indent() << "my ($self, $input) = @_;" << endl << indent() << "my $xfer = 0;" << endl
- << indent() << "my $fname;" << endl << indent() << "my $ftype = 0;" << endl << indent()
- << "my $fid = 0;" << endl;
+ out << indent() << "my ($self, $input) = @_;" << '\n' << indent() << "my $xfer = 0;" << '\n'
+ << indent() << "my $fname;" << '\n' << indent() << "my $ftype = 0;" << '\n' << indent()
+ << "my $fid = 0;" << '\n';
- indent(out) << "$xfer += $input->readStructBegin(\\$fname);" << endl;
+ indent(out) << "$xfer += $input->readStructBegin(\\$fname);" << '\n';
// Loop over reading in fields
- indent(out) << "while (1)" << endl;
+ indent(out) << "while (1)" << '\n';
scope_up(out);
- indent(out) << "$xfer += $input->readFieldBegin(\\$fname, \\$ftype, \\$fid);" << endl;
+ indent(out) << "$xfer += $input->readFieldBegin(\\$fname, \\$ftype, \\$fid);" << '\n';
// Check for field STOP marker and break
- indent(out) << "if ($ftype == Thrift::TType::STOP) {" << endl;
+ indent(out) << "if ($ftype == Thrift::TType::STOP) {" << '\n';
indent_up();
- indent(out) << "last;" << endl;
+ indent(out) << "last;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
// Switch statement on the field we are reading
- indent(out) << "SWITCH: for($fid)" << endl;
+ indent(out) << "SWITCH: for($fid)" << '\n';
scope_up(out);
@@ -569,34 +567,34 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent(out) << "/^" << (*f_iter)->get_key() << "$/ && do{";
- indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+ indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n';
indent_up();
generate_deserialize_field(out, *f_iter, "self->");
indent_down();
- indent(out) << "} else {" << endl;
+ indent(out) << "} else {" << '\n';
- indent(out) << " $xfer += $input->skip($ftype);" << endl;
+ indent(out) << " $xfer += $input->skip($ftype);" << '\n';
- out << indent() << "}" << endl << indent() << "last; };" << endl;
+ out << indent() << "}" << '\n' << indent() << "last; };" << '\n';
}
// In the default case we skip the field
- indent(out) << " $xfer += $input->skip($ftype);" << endl;
+ indent(out) << " $xfer += $input->skip($ftype);" << '\n';
scope_down(out);
- indent(out) << "$xfer += $input->readFieldEnd();" << endl;
+ indent(out) << "$xfer += $input->readFieldEnd();" << '\n';
scope_down(out);
- indent(out) << "$xfer += $input->readStructEnd();" << endl;
+ indent(out) << "$xfer += $input->readStructEnd();" << '\n';
- indent(out) << "return $xfer;" << endl;
+ indent(out) << "return $xfer;" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
/**
@@ -607,38 +605,38 @@
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- out << "sub write {" << endl;
+ out << "sub write {" << '\n';
indent_up();
- indent(out) << "my ($self, $output) = @_;" << endl;
- indent(out) << "my $xfer = 0;" << endl;
+ indent(out) << "my ($self, $output) = @_;" << '\n';
+ indent(out) << "my $xfer = 0;" << '\n';
- indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << endl;
+ indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- out << indent() << "if (defined $self->{" << (*f_iter)->get_name() << "}) {" << endl;
+ out << indent() << "if (defined $self->{" << (*f_iter)->get_name() << "}) {" << '\n';
indent_up();
indent(out) << "$xfer += $output->writeFieldBegin("
<< "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
- << ", " << (*f_iter)->get_key() << ");" << endl;
+ << ", " << (*f_iter)->get_key() << ");" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "self->");
- indent(out) << "$xfer += $output->writeFieldEnd();" << endl;
+ indent(out) << "$xfer += $output->writeFieldEnd();" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
- out << indent() << "$xfer += $output->writeFieldStop();" << endl << indent()
- << "$xfer += $output->writeStructEnd();" << endl;
+ out << indent() << "$xfer += $output->writeFieldStop();" << '\n' << indent()
+ << "$xfer += $output->writeStructEnd();" << '\n';
- out << indent() << "return $xfer;" << endl;
+ out << indent() << "return $xfer;" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
}
/**
@@ -655,13 +653,13 @@
std::vector<t_program*>& currInc = current->get_includes();
std::vector<t_program*>::size_type numInc = currInc.size();
if (selfish) {
- os << "use " << perl_namespace(current) << "Types;" << endl;
+ os << "use " << perl_namespace(current) << "Types;" << '\n';
}
for (std::vector<t_program*>::size_type i = 0; i < numInc; ++i) {
t_program* incProgram = currInc.at(i);
- os << "use " << perl_namespace(incProgram) << "Types;" << endl;
+ os << "use " << perl_namespace(incProgram) << "Types;" << '\n';
}
- os << endl;
+ os << '\n';
done = true;
}
}
@@ -683,10 +681,10 @@
t_service* extends_s = tservice->get_extends();
if (extends_s != nullptr) {
f_service_ << "use " << perl_namespace(extends_s->get_program()) << extends_s->get_name() << ";"
- << endl;
+ << '\n';
}
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the three main parts of the service (well, two for now in PERL)
generate_service_helpers(tservice);
@@ -696,7 +694,7 @@
generate_service_processor(tservice);
// Close service file
- f_service_ << "1;" << endl;
+ f_service_ << "1;" << '\n';
f_service_.close();
}
@@ -721,59 +719,59 @@
indent_up();
// Generate the header portion
- f_service_ << "package " << perl_namespace(program_) << service_name_ << "Processor;" << endl
- << endl << "use strict;" << endl << extends_processor << endl << endl;
+ f_service_ << "package " << perl_namespace(program_) << service_name_ << "Processor;" << '\n'
+ << '\n' << "use strict;" << '\n' << extends_processor << '\n' << '\n';
if (extends.empty()) {
- f_service_ << "sub new {" << endl;
+ f_service_ << "sub new {" << '\n';
indent_up();
- f_service_ << indent() << "my ($classname, $handler) = @_;" << endl << indent()
- << "my $self = {};" << endl;
+ f_service_ << indent() << "my ($classname, $handler) = @_;" << '\n' << indent()
+ << "my $self = {};" << '\n';
- f_service_ << indent() << "$self->{handler} = $handler;" << endl;
+ f_service_ << indent() << "$self->{handler} = $handler;" << '\n';
- f_service_ << indent() << "return bless ($self, $classname);" << endl;
+ f_service_ << indent() << "return bless ($self, $classname);" << '\n';
indent_down();
- f_service_ << "}" << endl << endl;
+ f_service_ << "}" << '\n' << '\n';
}
// Generate the server implementation
- f_service_ << "sub process {" << endl;
+ f_service_ << "sub process {" << '\n';
indent_up();
- f_service_ << indent() << "my ($self, $input, $output) = @_;" << endl;
+ f_service_ << indent() << "my ($self, $input, $output) = @_;" << '\n';
- f_service_ << indent() << "my $rseqid = 0;" << endl << indent() << "my $fname = undef;" << endl
- << indent() << "my $mtype = 0;" << endl << endl;
+ f_service_ << indent() << "my $rseqid = 0;" << '\n' << indent() << "my $fname = undef;" << '\n'
+ << indent() << "my $mtype = 0;" << '\n' << '\n';
- f_service_ << indent() << "$input->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" << endl;
+ f_service_ << indent() << "$input->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);" << '\n';
// HOT: check for method implementation
- f_service_ << indent() << "my $methodname = 'process_'.$fname;" << endl << indent()
- << "if (!$self->can($methodname)) {" << endl;
+ f_service_ << indent() << "my $methodname = 'process_'.$fname;" << '\n' << indent()
+ << "if (!$self->can($methodname)) {" << '\n';
indent_up();
- f_service_ << indent() << "$input->skip(Thrift::TType::STRUCT);" << endl << indent()
- << "$input->readMessageEnd();" << endl << indent()
+ f_service_ << indent() << "$input->skip(Thrift::TType::STRUCT);" << '\n' << indent()
+ << "$input->readMessageEnd();" << '\n' << indent()
<< "my $x = Thrift::TApplicationException->new('Function '.$fname.' not implemented.', "
- "Thrift::TApplicationException::UNKNOWN_METHOD);" << endl << indent()
- << "$output->writeMessageBegin($fname, Thrift::TMessageType::EXCEPTION, $rseqid);" << endl
- << indent() << "$x->write($output);" << endl << indent()
- << "$output->writeMessageEnd();" << endl << indent()
- << "$output->getTransport()->flush();" << endl << indent() << "return;" << endl;
+ "Thrift::TApplicationException::UNKNOWN_METHOD);" << '\n' << indent()
+ << "$output->writeMessageBegin($fname, Thrift::TMessageType::EXCEPTION, $rseqid);" << '\n'
+ << indent() << "$x->write($output);" << '\n' << indent()
+ << "$output->writeMessageEnd();" << '\n' << indent()
+ << "$output->getTransport()->flush();" << '\n' << indent() << "return;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl << indent()
- << "$self->$methodname($rseqid, $input, $output);" << endl << indent() << "return 1;"
- << endl;
+ f_service_ << indent() << "}" << '\n' << indent()
+ << "$self->$methodname($rseqid, $input, $output);" << '\n' << indent() << "return 1;"
+ << '\n';
indent_down();
- f_service_ << "}" << endl << endl;
+ f_service_ << "}" << '\n' << '\n';
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -788,21 +786,21 @@
*/
void t_perl_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
// Open function
- f_service_ << "sub process_" << tfunction->get_name() << " {" << endl;
+ f_service_ << "sub process_" << tfunction->get_name() << " {" << '\n';
indent_up();
- f_service_ << indent() << "my ($self, $seqid, $input, $output) = @_;" << endl;
+ f_service_ << indent() << "my ($self, $seqid, $input, $output) = @_;" << '\n';
string argsname = perl_namespace(tservice->get_program()) + service_name_ + "_"
+ tfunction->get_name() + "_args";
string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_"
+ tfunction->get_name() + "_result";
- f_service_ << indent() << "my $args = " << argsname << "->new();" << endl << indent()
- << "$args->read($input);" << endl;
+ f_service_ << indent() << "my $args = " << argsname << "->new();" << '\n' << indent()
+ << "$args->read($input);" << '\n';
- f_service_ << indent() << "$input->readMessageEnd();" << endl;
+ f_service_ << indent() << "$input->readMessageEnd();" << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -810,12 +808,12 @@
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "my $result = " << resultname << "->new();" << endl;
+ f_service_ << indent() << "my $result = " << resultname << "->new();" << '\n';
}
// Try block for a function with exceptions
if (xceptions.size() > 0) {
- f_service_ << indent() << "eval {" << endl;
+ f_service_ << indent() << "eval {" << '\n';
indent_up();
}
@@ -838,55 +836,55 @@
}
f_service_ << "$args->" << (*f_iter)->get_name();
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << indent() << "}; if( UNIVERSAL::isa($@,'"
<< perl_namespace((*x_iter)->get_type()->get_program())
- << (*x_iter)->get_type()->get_name() << "') ){ " << endl;
+ << (*x_iter)->get_type()->get_name() << "') ){ " << '\n';
indent_up();
- f_service_ << indent() << "$result->{" << (*x_iter)->get_name() << "} = $@;" << endl;
- f_service_ << indent() << "$@ = undef;" << endl;
+ f_service_ << indent() << "$result->{" << (*x_iter)->get_name() << "} = $@;" << '\n';
+ f_service_ << indent() << "$@ = undef;" << '\n';
indent_down();
f_service_ << indent();
}
- f_service_ << "}" << endl;
+ f_service_ << "}" << '\n';
// catch-all for unexpected exceptions (THRIFT-3191)
- f_service_ << indent() << "if ($@) {" << endl;
+ f_service_ << indent() << "if ($@) {" << '\n';
indent_up();
- f_service_ << indent() << "$@ =~ s/^\\s+|\\s+$//g;" << endl
- << indent() << "my $err = Thrift::TApplicationException->new(\"Unexpected Exception: \" . $@, Thrift::TApplicationException::INTERNAL_ERROR);" << endl
- << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::EXCEPTION, $seqid);" << endl
- << indent() << "$err->write($output);" << endl
- << indent() << "$output->writeMessageEnd();" << endl
- << indent() << "$output->getTransport()->flush();" << endl
- << indent() << "$@ = undef;" << endl
- << indent() << "return;" << endl;
+ f_service_ << indent() << "$@ =~ s/^\\s+|\\s+$//g;" << '\n'
+ << indent() << "my $err = Thrift::TApplicationException->new(\"Unexpected Exception: \" . $@, Thrift::TApplicationException::INTERNAL_ERROR);" << '\n'
+ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::EXCEPTION, $seqid);" << '\n'
+ << indent() << "$err->write($output);" << '\n'
+ << indent() << "$output->writeMessageEnd();" << '\n'
+ << indent() << "$output->getTransport()->flush();" << '\n'
+ << indent() << "$@ = undef;" << '\n'
+ << indent() << "return;" << '\n';
indent_down();
- f_service_ << indent() << "}" << endl;
+ f_service_ << indent() << "}" << '\n';
}
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- f_service_ << indent() << "return;" << endl;
+ f_service_ << indent() << "return;" << '\n';
indent_down();
- f_service_ << "}" << endl;
+ f_service_ << "}" << '\n';
return;
}
// Serialize the reply
- f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::REPLY, $seqid);" << endl
- << indent() << "$result->write($output);" << endl
- << indent() << "$output->writeMessageEnd();" << endl
- << indent() << "$output->getTransport()->flush();" << endl;
+ f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::REPLY, $seqid);" << '\n'
+ << indent() << "$result->write($output);" << '\n'
+ << indent() << "$output->writeMessageEnd();" << '\n'
+ << indent() << "$output->getTransport()->flush();" << '\n';
// Close function
indent_down();
- f_service_ << "}" << endl << endl;
+ f_service_ << "}" << '\n' << '\n';
}
/**
@@ -898,7 +896,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- f_service_ << "# HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+ f_service_ << "# HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
@@ -945,15 +943,15 @@
+ "If);";
}
- f_service_ << "package " << perl_namespace(program_) << service_name_ << "If;" << endl << endl
- << "use strict;" << endl << extends_if << endl << endl;
+ f_service_ << "package " << perl_namespace(program_) << service_name_ << "If;" << '\n' << '\n'
+ << "use strict;" << '\n' << extends_if << '\n' << '\n';
indent_up();
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- f_service_ << "sub " << function_signature(*f_iter) << endl << " die 'implement interface';\n}"
- << endl << endl;
+ f_service_ << "sub " << function_signature(*f_iter) << '\n' << " die 'implement interface';\n}"
+ << '\n' << '\n';
}
indent_down();
}
@@ -970,31 +968,31 @@
extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name()
+ "Rest);";
}
- f_service_ << "package " << perl_namespace(program_) << service_name_ << "Rest;" << endl << endl
- << "use strict;" << endl << extends_if << endl << endl;
+ f_service_ << "package " << perl_namespace(program_) << service_name_ << "Rest;" << '\n' << '\n'
+ << "use strict;" << '\n' << extends_if << '\n' << '\n';
if (extends.empty()) {
- f_service_ << "sub new {" << endl;
+ f_service_ << "sub new {" << '\n';
indent_up();
- f_service_ << indent() << "my ($classname, $impl) = @_;" << endl << indent()
- << "my $self ={ impl => $impl };" << endl << endl << indent()
- << "return bless($self,$classname);" << endl;
+ f_service_ << indent() << "my ($classname, $impl) = @_;" << '\n' << indent()
+ << "my $self ={ impl => $impl };" << '\n' << '\n' << indent()
+ << "return bless($self,$classname);" << '\n';
indent_down();
- f_service_ << "}" << endl << endl;
+ f_service_ << "}" << '\n' << '\n';
}
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- f_service_ << "sub " << (*f_iter)->get_name() << "{" << endl;
+ f_service_ << "sub " << (*f_iter)->get_name() << "{" << '\n';
indent_up();
- f_service_ << indent() << "my ($self, $request) = @_;" << endl << endl;
+ f_service_ << indent() << "my ($self, $request) = @_;" << '\n' << '\n';
const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
vector<t_field*>::const_iterator a_iter;
@@ -1002,19 +1000,19 @@
//t_type* atype = get_true_type((*a_iter)->get_type());
string req = "$request->{'" + (*a_iter)->get_name() + "'}";
f_service_ << indent() << "my $" << (*a_iter)->get_name() << " = (" << req << ") ? " << req
- << " : undef;" << endl;
+ << " : undef;" << '\n';
/* slist no longer supported
if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
f_service_ << indent() << "my @" << (*a_iter)->get_name() << " = split(/,/, $"
- << (*a_iter)->get_name() << ");" << endl << indent() << "$"
- << (*a_iter)->get_name() << " = \\@" << (*a_iter)->get_name() << endl;
+ << (*a_iter)->get_name() << ");" << '\n' << indent() << "$"
+ << (*a_iter)->get_name() << " = \\@" << (*a_iter)->get_name() << '\n';
}
*/
}
f_service_ << indent() << "return $self->{impl}->" << (*f_iter)->get_name() << "("
- << argument_list((*f_iter)->get_arglist()) << ");" << endl;
+ << argument_list((*f_iter)->get_arglist()) << ");" << '\n';
indent_down();
- indent(f_service_) << "}" << endl << endl;
+ indent(f_service_) << "}" << '\n' << '\n';
}
}
@@ -1032,31 +1030,31 @@
extends_client = "use base qw(" + extends + "Client);";
}
- f_service_ << "package " << perl_namespace(program_) << service_name_ << "Client;" << endl << endl
- << extends_client << endl << "use base qw(" << perl_namespace(program_)
- << service_name_ << "If);" << endl;
+ f_service_ << "package " << perl_namespace(program_) << service_name_ << "Client;" << '\n' << '\n'
+ << extends_client << '\n' << "use base qw(" << perl_namespace(program_)
+ << service_name_ << "If);" << '\n';
// Constructor function
- f_service_ << "sub new {" << endl;
+ f_service_ << "sub new {" << '\n';
indent_up();
- f_service_ << indent() << "my ($classname, $input, $output) = @_;" << endl << indent()
- << "my $self = {};" << endl;
+ f_service_ << indent() << "my ($classname, $input, $output) = @_;" << '\n' << indent()
+ << "my $self = {};" << '\n';
if (!extends.empty()) {
- f_service_ << indent() << "$self = $classname->SUPER::new($input, $output);" << endl;
+ f_service_ << indent() << "$self = $classname->SUPER::new($input, $output);" << '\n';
} else {
- f_service_ << indent() << "$self->{input} = $input;" << endl << indent()
- << "$self->{output} = defined $output ? $output : $input;" << endl << indent()
- << "$self->{seqid} = 0;" << endl;
+ f_service_ << indent() << "$self->{input} = $input;" << '\n' << indent()
+ << "$self->{output} = defined $output ? $output : $input;" << '\n' << indent()
+ << "$self->{seqid} = 0;" << '\n';
}
- f_service_ << indent() << "return bless($self,$classname);" << endl;
+ f_service_ << indent() << "return bless($self,$classname);" << '\n';
indent_down();
- f_service_ << "}" << endl << endl;
+ f_service_ << "}" << '\n' << '\n';
// Generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -1068,7 +1066,7 @@
string funname = (*f_iter)->get_name();
// Open function
- f_service_ << "sub " << function_signature(*f_iter) << endl;
+ f_service_ << "sub " << function_signature(*f_iter) << '\n';
indent_up();
@@ -1083,21 +1081,21 @@
}
f_service_ << "$" << (*fld_iter)->get_name();
}
- f_service_ << ");" << endl;
+ f_service_ << ");" << '\n';
if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
- f_service_ << "$self->recv_" << funname << "();" << endl;
+ f_service_ << "$self->recv_" << funname << "();" << '\n';
}
indent_down();
- f_service_ << "}" << endl << endl;
+ f_service_ << "}" << '\n' << '\n';
- f_service_ << "sub send_" << function_signature(*f_iter) << endl;
+ f_service_ << "sub send_" << function_signature(*f_iter) << '\n';
indent_up();
@@ -1107,23 +1105,23 @@
// Serialize the request header
f_service_ << indent() << "$self->{output}->writeMessageBegin('" << (*f_iter)->get_name()
<< "', " << ((*f_iter)->is_oneway() ? "Thrift::TMessageType::ONEWAY" : "Thrift::TMessageType::CALL")
- << ", $self->{seqid});" << endl;
+ << ", $self->{seqid});" << '\n';
- f_service_ << indent() << "my $args = " << argsname << "->new();" << endl;
+ f_service_ << indent() << "my $args = " << argsname << "->new();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << "$args->{" << (*fld_iter)->get_name() << "} = $"
- << (*fld_iter)->get_name() << ";" << endl;
+ << (*fld_iter)->get_name() << ";" << '\n';
}
// Write to the stream
- f_service_ << indent() << "$args->write($self->{output});" << endl << indent()
- << "$self->{output}->writeMessageEnd();" << endl << indent()
- << "$self->{output}->getTransport()->flush();" << endl;
+ f_service_ << indent() << "$args->write($self->{output});" << '\n' << indent()
+ << "$self->{output}->writeMessageEnd();" << '\n' << indent()
+ << "$self->{output}->getTransport()->flush();" << '\n';
indent_down();
- f_service_ << "}" << endl;
+ f_service_ << "}" << '\n';
if (!(*f_iter)->is_oneway()) {
std::string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_"
@@ -1134,29 +1132,29 @@
string("recv_") + (*f_iter)->get_name(),
&noargs);
// Open function
- f_service_ << endl << "sub " << function_signature(&recv_function) << endl;
+ f_service_ << '\n' << "sub " << function_signature(&recv_function) << '\n';
indent_up();
- f_service_ << indent() << "my $rseqid = 0;" << endl << indent() << "my $fname;" << endl
- << indent() << "my $mtype = 0;" << endl << endl;
+ f_service_ << indent() << "my $rseqid = 0;" << '\n' << indent() << "my $fname;" << '\n'
+ << indent() << "my $mtype = 0;" << '\n' << '\n';
f_service_ << indent() << "$self->{input}->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);"
- << endl << indent() << "if ($mtype == Thrift::TMessageType::EXCEPTION) {" << endl
- << indent() << " my $x = Thrift::TApplicationException->new();" << endl << indent()
- << " $x->read($self->{input});" << endl << indent()
- << " $self->{input}->readMessageEnd();" << endl << indent() << " die $x;" << endl
- << indent() << "}" << endl;
+ << '\n' << indent() << "if ($mtype == Thrift::TMessageType::EXCEPTION) {" << '\n'
+ << indent() << " my $x = Thrift::TApplicationException->new();" << '\n' << indent()
+ << " $x->read($self->{input});" << '\n' << indent()
+ << " $self->{input}->readMessageEnd();" << '\n' << indent() << " die $x;" << '\n'
+ << indent() << "}" << '\n';
- f_service_ << indent() << "my $result = " << resultname << "->new();" << endl << indent()
- << "$result->read($self->{input});" << endl;
+ f_service_ << indent() << "my $result = " << resultname << "->new();" << '\n' << indent()
+ << "$result->read($self->{input});" << '\n';
- f_service_ << indent() << "$self->{input}->readMessageEnd();" << endl << endl;
+ f_service_ << indent() << "$self->{input}->readMessageEnd();" << '\n' << '\n';
// Careful, only return result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "if (defined $result->{success} ) {" << endl << indent()
- << " return $result->{success};" << endl << indent() << "}" << endl;
+ f_service_ << indent() << "if (defined $result->{success} ) {" << '\n' << indent()
+ << " return $result->{success};" << '\n' << indent() << "}" << '\n';
}
t_struct* xs = (*f_iter)->get_xceptions();
@@ -1164,21 +1162,21 @@
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ << indent() << "if (defined $result->{" << (*x_iter)->get_name() << "}) {"
- << endl << indent() << " die $result->{" << (*x_iter)->get_name() << "};"
- << endl << indent() << "}" << endl;
+ << '\n' << indent() << " die $result->{" << (*x_iter)->get_name() << "};"
+ << '\n' << indent() << "}" << '\n';
}
// Careful, only return _result if not a void function
if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_) << "return;" << endl;
+ indent(f_service_) << "return;" << '\n';
} else {
f_service_ << indent() << "die \"" << (*f_iter)->get_name() << " failed: unknown result\";"
- << endl;
+ << '\n';
}
// Close function
indent_down();
- f_service_ << "}" << endl;
+ f_service_ << "}" << '\n';
}
}
}
@@ -1244,7 +1242,7 @@
} else if (type->is_enum()) {
out << "readI32(\\$" << name << ");";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
@@ -1263,8 +1261,8 @@
t_struct* tstruct,
string prefix) {
out << indent() << "$" << prefix << " = " << perl_namespace(tstruct->get_program())
- << tstruct->get_name() << "->new();" << endl << indent() << "$xfer += $" << prefix
- << "->read($input);" << endl;
+ << tstruct->get_name() << "->new();" << '\n' << indent() << "$xfer += $" << prefix
+ << "->read($input);" << '\n';
}
void t_perl_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
@@ -1280,33 +1278,33 @@
t_field fvtype(g_type_i8, vtype);
t_field fetype(g_type_i8, etype);
- out << indent() << "my $" << size << " = 0;" << endl;
+ out << indent() << "my $" << size << " = 0;" << '\n';
// Declare variables, read header
if (ttype->is_map()) {
- out << indent() << "$" << prefix << " = {};" << endl << indent() << "my $" << ktype << " = 0;"
- << endl << indent() << "my $" << vtype << " = 0;" << endl;
+ out << indent() << "$" << prefix << " = {};" << '\n' << indent() << "my $" << ktype << " = 0;"
+ << '\n' << indent() << "my $" << vtype << " = 0;" << '\n';
out << indent() << "$xfer += $input->readMapBegin("
- << "\\$" << ktype << ", \\$" << vtype << ", \\$" << size << ");" << endl;
+ << "\\$" << ktype << ", \\$" << vtype << ", \\$" << size << ");" << '\n';
} else if (ttype->is_set()) {
- out << indent() << "$" << prefix << " = {};" << endl << indent() << "my $" << etype << " = 0;"
- << endl << indent() << "$xfer += $input->readSetBegin("
- << "\\$" << etype << ", \\$" << size << ");" << endl;
+ out << indent() << "$" << prefix << " = {};" << '\n' << indent() << "my $" << etype << " = 0;"
+ << '\n' << indent() << "$xfer += $input->readSetBegin("
+ << "\\$" << etype << ", \\$" << size << ");" << '\n';
} else if (ttype->is_list()) {
- out << indent() << "$" << prefix << " = [];" << endl << indent() << "my $" << etype << " = 0;"
- << endl << indent() << "$xfer += $input->readListBegin("
- << "\\$" << etype << ", \\$" << size << ");" << endl;
+ out << indent() << "$" << prefix << " = [];" << '\n' << indent() << "my $" << etype << " = 0;"
+ << '\n' << indent() << "$xfer += $input->readListBegin("
+ << "\\$" << etype << ", \\$" << size << ");" << '\n';
}
// For loop iterates over elements
string i = tmp("_i");
indent(out) << "for (my $" << i << " = 0; $" << i << " < $" << size << "; ++$" << i << ")"
- << endl;
+ << '\n';
scope_up(out);
@@ -1322,11 +1320,11 @@
// Read container end
if (ttype->is_map()) {
- indent(out) << "$xfer += $input->readMapEnd();" << endl;
+ indent(out) << "$xfer += $input->readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "$xfer += $input->readSetEnd();" << endl;
+ indent(out) << "$xfer += $input->readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "$xfer += $input->readListEnd();" << endl;
+ indent(out) << "$xfer += $input->readListEnd();" << '\n';
}
scope_down(out);
@@ -1341,24 +1339,24 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- indent(out) << declare_field(&fkey, true, true) << endl;
- indent(out) << declare_field(&fval, true, true) << endl;
+ indent(out) << declare_field(&fkey, true, true) << '\n';
+ indent(out) << declare_field(&fval, true, true) << '\n';
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
- indent(out) << "$" << prefix << "->{$" << key << "} = $" << val << ";" << endl;
+ indent(out) << "$" << prefix << "->{$" << key << "} = $" << val << ";" << '\n';
}
void t_perl_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
string elem = tmp("elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << "my $" << elem << " = undef;" << endl;
+ indent(out) << "my $" << elem << " = undef;" << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << "$" << prefix << "->{$" << elem << "} = 1;" << endl;
+ indent(out) << "$" << prefix << "->{$" << elem << "} = 1;" << '\n';
}
void t_perl_generator::generate_deserialize_list_element(ostream& out,
@@ -1367,11 +1365,11 @@
string elem = tmp("elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << "my $" << elem << " = undef;" << endl;
+ indent(out) << "my $" << elem << " = undef;" << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << "push(@{$" << prefix << "},$" << elem << ");" << endl;
+ indent(out) << "push(@{$" << prefix << "},$" << elem << ");" << '\n';
}
/**
@@ -1435,7 +1433,7 @@
} else if (type->is_enum()) {
out << "writeI32($" << name << ");";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
@@ -1453,7 +1451,7 @@
*/
void t_perl_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- indent(out) << "$xfer += $" << prefix << "->write($output);" << endl;
+ indent(out) << "$xfer += $" << prefix << "->write($output);" << '\n';
}
/**
@@ -1466,17 +1464,17 @@
indent(out) << "$xfer += $output->writeMapBegin("
<< type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "scalar(keys %{$" << prefix << "}));" << endl;
+ << "scalar(keys %{$" << prefix << "}));" << '\n';
} else if (ttype->is_set()) {
indent(out) << "$xfer += $output->writeSetBegin("
<< type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
- << "scalar(@{$" << prefix << "}));" << endl;
+ << "scalar(@{$" << prefix << "}));" << '\n';
} else if (ttype->is_list()) {
indent(out) << "$xfer += $output->writeListBegin("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", "
- << "scalar(@{$" << prefix << "}));" << endl;
+ << "scalar(@{$" << prefix << "}));" << '\n';
}
scope_up(out);
@@ -1485,7 +1483,7 @@
string kiter = tmp("kiter");
string viter = tmp("viter");
indent(out) << "while( my ($" << kiter << ",$" << viter << ") = each %{$" << prefix << "}) "
- << endl;
+ << '\n';
scope_up(out);
generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
@@ -1493,14 +1491,14 @@
} else if (ttype->is_set()) {
string iter = tmp("iter");
- indent(out) << "foreach my $" << iter << " (@{$" << prefix << "})" << endl;
+ indent(out) << "foreach my $" << iter << " (@{$" << prefix << "})" << '\n';
scope_up(out);
generate_serialize_set_element(out, (t_set*)ttype, iter);
scope_down(out);
} else if (ttype->is_list()) {
string iter = tmp("iter");
- indent(out) << "foreach my $" << iter << " (@{$" << prefix << "}) " << endl;
+ indent(out) << "foreach my $" << iter << " (@{$" << prefix << "}) " << '\n';
scope_up(out);
generate_serialize_list_element(out, (t_list*)ttype, iter);
scope_down(out);
@@ -1509,11 +1507,11 @@
scope_down(out);
if (ttype->is_map()) {
- indent(out) << "$xfer += $output->writeMapEnd();" << endl;
+ indent(out) << "$xfer += $output->writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "$xfer += $output->writeSetEnd();" << endl;
+ indent(out) << "$xfer += $output->writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "$xfer += $output->writeListEnd();" << endl;
+ indent(out) << "$xfer += $output->writeListEnd();" << '\n';
}
scope_down(out);
diff --git a/compiler/cpp/src/thrift/generate/t_php_generator.cc b/compiler/cpp/src/thrift/generate/t_php_generator.cc
index 8373858..6879501 100644
--- a/compiler/cpp/src/thrift/generate/t_php_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_php_generator.cc
@@ -35,8 +35,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
#define NSGLOBAL (nsglobal_.size() ? nsglobal_ : "")
#define NSGLOBAL_A ("\\" + NSGLOBAL)
#define NSGLOBAL_B (NSGLOBAL + "\\")
@@ -62,7 +60,7 @@
validate_ = false;
json_serializable_ = false;
getters_setters_ = false;
-
+
nsglobal_ = ""; // by default global namespace is empty
classmap_ = false;
for (iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
@@ -513,28 +511,28 @@
* Generates service header contains namespace suffix and includes inside file specified
*/
void t_php_generator::generate_service_header(t_service* tservice, std::ostream& file) {
- file << "<?php" << endl;
+ file << "<?php" << '\n';
if (!php_namespace_suffix(tservice->get_program()).empty()) {
- file << "namespace " << php_namespace_suffix(tservice->get_program()) << ";" << endl
- << endl;
+ file << "namespace " << php_namespace_suffix(tservice->get_program()) << ";" << '\n'
+ << '\n';
}
file << autogen_comment() << php_includes();
- file << endl;
+ file << '\n';
}
/**
* Generates program header contains namespace suffix and includes inside file specified
*/
void t_php_generator::generate_program_header(std::ostream& file) {
- file << "<?php" << endl;
+ file << "<?php" << '\n';
if (!php_namespace_suffix(get_program()).empty()) {
- file << "namespace " << php_namespace_suffix(get_program()) << ";" << endl
- << endl;
+ file << "namespace " << php_namespace_suffix(get_program()) << ";" << '\n'
+ << '\n';
}
file << autogen_comment() << php_includes();
- file << endl;
+ file << '\n';
}
/**
@@ -558,30 +556,30 @@
// code but you can't do things like an 'extract' on it, which is a bit of
// a downer.
generate_php_doc(f_enum, tenum);
- f_enum << "final class " << tenum->get_name() << endl
- << "{" << endl;
+ f_enum << "final class " << tenum->get_name() << '\n'
+ << "{" << '\n';
indent_up();
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
generate_php_doc(f_enum, *c_iter);
- indent(f_enum) << "const " << (*c_iter)->get_name() << " = " << value << ";" << endl
- << endl;
+ indent(f_enum) << "const " << (*c_iter)->get_name() << " = " << value << ";" << '\n'
+ << '\n';
}
- indent(f_enum) << "static public $__names = array(" << endl;
+ indent(f_enum) << "static public $__names = array(" << '\n';
indent_up();
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
- indent(f_enum) << value << " => '" << (*c_iter)->get_name() << "'," << endl;
+ indent(f_enum) << value << " => '" << (*c_iter)->get_name() << "'," << '\n';
}
indent_down();
- indent(f_enum) << ");" << endl;
+ indent(f_enum) << ");" << '\n';
indent_down();
- f_enum << "}" << endl << endl;
+ f_enum << "}" << '\n' << '\n';
if (!classmap_) {
f_enum.close();
}
@@ -604,8 +602,8 @@
f_consts.open(f_consts_name.c_str());
generate_program_header(f_consts);
}
- f_consts << "final class Constant extends \\Thrift\\Type\\TConstant"<< endl
- << "{" << endl;
+ f_consts << "final class Constant extends \\Thrift\\Type\\TConstant"<< '\n'
+ << "{" << '\n';
indent_up();
@@ -613,30 +611,30 @@
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
string name = (*c_iter)->get_name();
- indent(f_consts) << "static protected $" << name << ";" << endl;
+ indent(f_consts) << "static protected $" << name << ";" << '\n';
}
// Create init function
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
string name = (*c_iter)->get_name();
- f_consts << endl;
+ f_consts << '\n';
- f_consts << indent() << "protected static function init_" << name << "()" <<endl
- << indent() << "{" << endl;
+ f_consts << indent() << "protected static function init_" << name << "()" << '\n'
+ << indent() << "{" << '\n';
indent_up();
indent(f_consts) << "return ";
generate_php_doc(f_consts, *c_iter);
f_consts << render_const_value((*c_iter)->get_type(), (*c_iter)->get_value());
- f_consts << ";" << endl;
+ f_consts << ";" << '\n';
indent_down();
- indent(f_consts) << "}" << endl;
+ indent(f_consts) << "}" << '\n';
}
indent_down();
- f_consts << "}" << endl;
+ f_consts << "}" << '\n';
if (!classmap_) {
f_consts.close();
}
@@ -679,7 +677,7 @@
} else if (type->is_enum()) {
indent(out) << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
- out << "new " << php_namespace(type->get_program()) << type->get_name() << "(array(" << endl;
+ out << "new " << php_namespace(type->get_program()) << type->get_name() << "(array(" << '\n';
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -699,14 +697,14 @@
out << render_const_value(g_type_string, v_iter->first);
out << " => ";
out << render_const_value(field_type, v_iter->second);
- out << "," << endl;
+ out << "," << '\n';
}
indent_down();
indent(out) << "))";
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
- out << "array(" << endl;
+ out << "array(" << '\n';
indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
@@ -715,7 +713,7 @@
out << render_const_value(ktype, v_iter->first);
out << " => ";
out << render_const_value(vtype, v_iter->second);
- out << "," << endl;
+ out << "," << '\n';
}
indent_down();
indent(out) << ")";
@@ -726,7 +724,7 @@
} else {
etype = ((t_set*)type)->get_elem_type();
}
- out << "array(" << endl;
+ out << "array(" << '\n';
indent_up();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
@@ -736,7 +734,7 @@
if (type->is_set()) {
out << " => true";
}
- out << "," << endl;
+ out << "," << '\n';
}
indent_down();
indent(out) << ")";
@@ -779,27 +777,27 @@
void t_php_generator::generate_php_type_spec(ostream& out, t_type* t) {
t = get_true_type(t);
- indent(out) << "'type' => " << type_to_enum(t) << "," << endl;
+ indent(out) << "'type' => " << type_to_enum(t) << "," << '\n';
if (t->is_base_type()) {
// Noop, type is all we need
} else if (t->is_struct() || t->is_xception() || t->is_enum()) {
indent(out) << "'class' => '" << php_namespace(t->get_program()) << t->get_name() << "',"
- << endl;
+ << '\n';
} else if (t->is_map()) {
t_type* ktype = get_true_type(((t_map*)t)->get_key_type());
t_type* vtype = get_true_type(((t_map*)t)->get_val_type());
- indent(out) << "'ktype' => " << type_to_enum(ktype) << "," << endl;
- indent(out) << "'vtype' => " << type_to_enum(vtype) << "," << endl;
- indent(out) << "'key' => array(" << endl;
+ indent(out) << "'ktype' => " << type_to_enum(ktype) << "," << '\n';
+ indent(out) << "'vtype' => " << type_to_enum(vtype) << "," << '\n';
+ indent(out) << "'key' => array(" << '\n';
indent_up();
generate_php_type_spec(out, ktype);
indent_down();
- indent(out) << ")," << endl;
- indent(out) << "'val' => array(" << endl;
+ indent(out) << ")," << '\n';
+ indent(out) << "'val' => array(" << '\n';
indent_up();
generate_php_type_spec(out, vtype);
- indent(out) << ")," << endl;
+ indent(out) << ")," << '\n';
indent_down();
} else if (t->is_list() || t->is_set()) {
t_type* etype;
@@ -808,11 +806,11 @@
} else {
etype = get_true_type(((t_set*)t)->get_elem_type());
}
- indent(out) << "'etype' => " << type_to_enum(etype) << "," << endl;
- indent(out) << "'elem' => array(" << endl;
+ indent(out) << "'etype' => " << type_to_enum(etype) << "," << '\n';
+ indent(out) << "'elem' => array(" << '\n';
indent_up();
generate_php_type_spec(out, etype);
- indent(out) << ")," << endl;
+ indent(out) << ")," << '\n';
indent_down();
} else {
throw "compiler error: no type for php struct spec field";
@@ -824,24 +822,24 @@
* type information to generalize serialization routines.
*/
void t_php_generator::generate_php_struct_spec(ostream& out, t_struct* tstruct) {
- indent(out) << "static public $_TSPEC = array(" << endl;
+ indent(out) << "static public $_TSPEC = array(" << '\n';
indent_up();
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- indent(out) << (*m_iter)->get_key() << " => array(" << endl;
+ indent(out) << (*m_iter)->get_key() << " => array(" << '\n';
indent_up();
- out << indent() << "'var' => '" << (*m_iter)->get_name() << "'," << endl;
- out << indent() << "'isRequired' => " << ((*m_iter)->get_req() == t_field::T_REQUIRED ? "true" : "false") << "," << endl;
+ out << indent() << "'var' => '" << (*m_iter)->get_name() << "'," << '\n';
+ out << indent() << "'isRequired' => " << ((*m_iter)->get_req() == t_field::T_REQUIRED ? "true" : "false") << "," << '\n';
generate_php_type_spec(out, t);
indent_down();
- indent(out) << ")," << endl;
+ indent(out) << ")," << '\n';
}
indent_down();
- indent(out) << ");" << endl << endl;
+ indent(out) << ");" << '\n' << '\n';
}
/**
* Generates necessary accessors and mutators for the fields
@@ -865,10 +863,10 @@
indent_down();
}
- indent(out) << endl;
+ indent(out) << '\n';
out << getter_stream.str();
out << setter_stream.str();
- indent(out) << endl;
+ indent(out) << '\n';
}
/**
* Generates a getter for the generated private fields
@@ -878,16 +876,16 @@
string cap_name) {
- out << indent() << "public function " << "get" << cap_name << "()" << endl
- << indent() << "{" << endl;
+ out << indent() << "public function " << "get" << cap_name << "()" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "return $this->" << field_name << ";" << endl;
+ out << indent() << "return $this->" << field_name << ";" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << endl;
+ out << indent() << "}" << '\n';
+ out << '\n';
}
/**
* Generates a setter for the generated private fields
@@ -896,17 +894,17 @@
string field_name,
string cap_name) {
- out << indent() << "public function set" << cap_name << "(" << "$" << field_name << ")" << endl
- << indent() << "{" << endl;
+ out << indent() << "public function set" << cap_name << "(" << "$" << field_name << ")" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "$this->" << field_name << " = $" << field_name << ";" << endl;
+ out << indent() << "$this->" << field_name << " = $" << field_name << ";" << '\n';
indent_down();
- out << indent() << "}" << endl;
- out << endl;
+ out << indent() << "}" << '\n';
+ out << '\n';
}
/**
* Gets the first-letter capitalized name for the field
@@ -943,11 +941,11 @@
if (json_serializable_) {
out << " implements JsonSerializable";
}
- out << endl
- << "{" << endl;
+ out << '\n'
+ << "{" << '\n';
indent_up();
- out << indent() << "static public $isValidate = " << (validate_ ? "true" : "false") << ";" << endl << endl;
+ out << indent() << "static public $isValidate = " << (validate_ ? "true" : "false") << ";" << '\n' << '\n';
generate_php_struct_spec(out, tstruct);
@@ -959,15 +957,15 @@
}
generate_php_doc(out, *m_iter);
string access = (getters_setters_) ? "private" : "public";
- indent(out) << access << " $" << (*m_iter)->get_name() << " = " << dval << ";" << endl;
+ indent(out) << access << " $" << (*m_iter)->get_name() << " = " << dval << ";" << '\n';
}
- out << endl;
+ out << '\n';
// Generate constructor from array
string param = (members.size() > 0) ? "$vals = null" : "";
- out << indent() << "public function __construct(" << param << ")"<< endl
- << indent() << "{" << endl;
+ out << indent() << "public function __construct(" << param << ")"<< '\n'
+ << indent() << "{" << '\n';
indent_up();
if (members.size() > 0) {
@@ -975,62 +973,62 @@
t_type* t = get_true_type((*m_iter)->get_type());
if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) {
indent(out) << "$this->" << (*m_iter)->get_name() << " = "
- << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
+ << render_const_value(t, (*m_iter)->get_value()) << ";" << '\n';
}
}
- out << indent() << "if (is_array($vals)) {" << endl;
+ out << indent() << "if (is_array($vals)) {" << '\n';
indent_up();
if (oop_) {
- out << indent() << "parent::__construct(self::$_TSPEC, $vals);" << endl;
+ out << indent() << "parent::__construct(self::$_TSPEC, $vals);" << '\n';
} else {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- out << indent() << "if (isset($vals['" << (*m_iter)->get_name() << "'])) {" << endl;
+ out << indent() << "if (isset($vals['" << (*m_iter)->get_name() << "'])) {" << '\n';
indent_up();
out << indent() << "$this->" << (*m_iter)->get_name() << " = $vals['"
- << (*m_iter)->get_name() << "'];" << endl;
+ << (*m_iter)->get_name() << "'];" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
scope_down(out);
- out << endl;
+ out << '\n';
- out << indent() << "public function getName()" << endl
- << indent() << "{" << endl;
+ out << indent() << "public function getName()" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- out << indent() << "return '" << tstruct->get_name() << "';" << endl;
+ out << indent() << "return '" << tstruct->get_name() << "';" << '\n';
indent_down();
- out << indent() << "}" << endl << endl;
+ out << indent() << "}" << '\n' << '\n';
- out << endl;
+ out << '\n';
if (getters_setters_) {
generate_generic_field_getters_setters(out, tstruct);
}
generate_php_struct_reader(out, tstruct, is_result);
- out << endl;
+ out << '\n';
generate_php_struct_writer(out, tstruct, is_result);
if (needs_php_read_validator(tstruct, is_result)) {
- out << endl;
+ out << '\n';
generate_php_struct_read_validator(out, tstruct);
}
if (needs_php_write_validator(tstruct, is_result)) {
- out << endl;
+ out << '\n';
generate_php_struct_write_validator(out, tstruct);
}
if (json_serializable_) {
- out << endl;
+ out << '\n';
generate_php_struct_json_serialize(out, tstruct, is_result);
}
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
/**
@@ -1040,34 +1038,34 @@
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "public function read($input)" << endl;
+ indent(out) << "public function read($input)" << '\n';
scope_up(out);
if (oop_) {
if (needs_php_read_validator(tstruct, is_result)) {
indent(out) << "$tmp = $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);"
- << endl;
- indent(out) << "$this->_validateForRead();" << endl;
- indent(out) << "return $tmp;" << endl;
+ << '\n';
+ indent(out) << "$this->_validateForRead();" << '\n';
+ indent(out) << "return $tmp;" << '\n';
} else {
indent(out) << "return $this->_read('" << tstruct->get_name() << "', self::$_TSPEC, $input);"
- << endl;
+ << '\n';
}
scope_down(out);
- out << endl;
+ out << '\n';
return;
}
- out << indent() << "$xfer = 0;" << endl << indent() << "$fname = null;" << endl << indent()
- << "$ftype = 0;" << endl << indent() << "$fid = 0;" << endl;
+ out << indent() << "$xfer = 0;" << '\n' << indent() << "$fname = null;" << '\n' << indent()
+ << "$ftype = 0;" << '\n' << indent() << "$fid = 0;" << '\n';
// Declare stack tmp variables
if (!binary_inline_) {
- indent(out) << "$xfer += $input->readStructBegin($fname);" << endl;
+ indent(out) << "$xfer += $input->readStructBegin($fname);" << '\n';
}
// Loop over reading in fields
- indent(out) << "while (true) {" << endl;
+ indent(out) << "while (true) {" << '\n';
indent_up();
@@ -1077,80 +1075,80 @@
t_field ffid(g_type_i16, "fid");
generate_deserialize_field(out, &fftype);
out << indent() << "if ($ftype == "
- << "TType::STOP) {" << endl << indent() << " break;" << endl << indent() << "}" << endl;
+ << "TType::STOP) {" << '\n' << indent() << " break;" << '\n' << indent() << "}" << '\n';
generate_deserialize_field(out, &ffid);
} else {
- indent(out) << "$xfer += $input->readFieldBegin($fname, $ftype, $fid);" << endl;
+ indent(out) << "$xfer += $input->readFieldBegin($fname, $ftype, $fid);" << '\n';
// Check for field STOP marker and break
indent(out) << "if ($ftype == "
- << "TType::STOP) {" << endl;
+ << "TType::STOP) {" << '\n';
indent_up();
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
// Switch statement on the field we are reading
- indent(out) << "switch ($fid) {" << endl;
+ indent(out) << "switch ($fid) {" << '\n';
indent_up();
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case " << (*f_iter)->get_key() << ":" << endl;
+ indent(out) << "case " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+ indent(out) << "if ($ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << '\n';
indent_up();
generate_deserialize_field(out, *f_iter, "this->");
indent_down();
- out << indent() << "} else {" << endl;
+ out << indent() << "} else {" << '\n';
indent_up();
if (binary_inline_) {
- indent(out) << "$xfer += TProtocol::skipBinary($input, $ftype);" << endl;
+ indent(out) << "$xfer += TProtocol::skipBinary($input, $ftype);" << '\n';
} else {
- indent(out) << "$xfer += $input->skip($ftype);" << endl;
+ indent(out) << "$xfer += $input->skip($ftype);" << '\n';
}
indent_down();
- out << indent() << "}" << endl << indent() << "break;" << endl;
+ out << indent() << "}" << '\n' << indent() << "break;" << '\n';
indent_down();
}
// In the default case we skip the field
- indent(out) << "default:" << endl;
+ indent(out) << "default:" << '\n';
indent_up();
if (binary_inline_) {
indent(out) << "$xfer += "
- << "TProtocol::skipBinary($input, $ftype);" << endl;
+ << "TProtocol::skipBinary($input, $ftype);" << '\n';
} else {
- indent(out) << "$xfer += $input->skip($ftype);" << endl;
+ indent(out) << "$xfer += $input->skip($ftype);" << '\n';
}
- indent(out) << "break;" << endl;
+ indent(out) << "break;" << '\n';
indent_down();
scope_down(out);
if (!binary_inline_) {
// Read field end marker
- indent(out) << "$xfer += $input->readFieldEnd();" << endl;
+ indent(out) << "$xfer += $input->readFieldEnd();" << '\n';
}
scope_down(out);
if (!binary_inline_) {
- indent(out) << "$xfer += $input->readStructEnd();" << endl;
+ indent(out) << "$xfer += $input->readStructEnd();" << '\n';
}
if (needs_php_read_validator(tstruct, is_result)) {
- indent(out) << "$this->_validateForRead();" << endl;
+ indent(out) << "$this->_validateForRead();" << '\n';
}
- indent(out) << "return $xfer;" << endl;
+ indent(out) << "return $xfer;" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
/**
@@ -1162,33 +1160,33 @@
vector<t_field*>::const_iterator f_iter;
if (binary_inline_) {
- indent(out) << "public function write(&$output)" << endl;
+ indent(out) << "public function write(&$output)" << '\n';
} else {
- indent(out) << "public function write($output)" << endl;
+ indent(out) << "public function write($output)" << '\n';
}
- indent(out) << "{" << endl;
+ indent(out) << "{" << '\n';
indent_up();
if (needs_php_write_validator(tstruct, is_result)) {
- indent(out) << "$this->_validateForWrite();" << endl;
+ indent(out) << "$this->_validateForWrite();" << '\n';
}
if (oop_) {
indent(out) << "return $this->_write('" << tstruct->get_name() << "', self::$_TSPEC, $output);"
- << endl;
+ << '\n';
scope_down(out);
- out << endl;
+ out << '\n';
return;
}
- indent(out) << "$xfer = 0;" << endl;
+ indent(out) << "$xfer = 0;" << '\n';
if (!binary_inline_) {
- indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << endl;
+ indent(out) << "$xfer += $output->writeStructBegin('" << name << "');" << '\n';
}
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- out << indent() << "if ($this->" << (*f_iter)->get_name() << " !== null) {" << endl;
+ out << indent() << "if ($this->" << (*f_iter)->get_name() << " !== null) {" << '\n';
indent_up();
t_type* type = get_true_type((*f_iter)->get_type());
@@ -1200,22 +1198,22 @@
}
if (!expect.empty()) {
out << indent() << "if (!is_" << expect << "($this->" << (*f_iter)->get_name() << ")) {"
- << endl;
+ << '\n';
indent_up();
out << indent() << "throw new "
<< "TProtocolException('Bad type in structure.', "
- << "TProtocolException::INVALID_DATA);" << endl;
+ << "TProtocolException::INVALID_DATA);" << '\n';
scope_down(out);
}
// Write field header
if (binary_inline_) {
out << indent() << "$output .= pack('c', " << type_to_enum((*f_iter)->get_type()) << ");"
- << endl << indent() << "$output .= pack('n', " << (*f_iter)->get_key() << ");" << endl;
+ << '\n' << indent() << "$output .= pack('n', " << (*f_iter)->get_key() << ");" << '\n';
} else {
indent(out) << "$xfer += $output->writeFieldBegin("
<< "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
- << ", " << (*f_iter)->get_key() << ");" << endl;
+ << ", " << (*f_iter)->get_key() << ");" << '\n';
}
// Write field contents
@@ -1223,25 +1221,25 @@
// Write field closer
if (!binary_inline_) {
- indent(out) << "$xfer += $output->writeFieldEnd();" << endl;
+ indent(out) << "$xfer += $output->writeFieldEnd();" << '\n';
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
if (binary_inline_) {
out << indent() << "$output .= pack('c', "
- << "TType::STOP);" << endl;
+ << "TType::STOP);" << '\n';
} else {
- out << indent() << "$xfer += $output->writeFieldStop();" << endl << indent()
- << "$xfer += $output->writeStructEnd();" << endl;
+ out << indent() << "$xfer += $output->writeFieldStop();" << '\n' << indent()
+ << "$xfer += $output->writeStructEnd();" << '\n';
}
- out << indent() << "return $xfer;" << endl;
+ out << indent() << "return $xfer;" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
void t_php_generator::generate_php_struct_read_validator(ostream& out, t_struct* tstruct) {
@@ -1256,7 +1254,7 @@
t_struct* tstruct,
std::string method_name,
bool write_mode) {
- indent(out) << "private function " << method_name << "() {" << endl;
+ indent(out) << "private function " << method_name << "() {" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
@@ -1268,32 +1266,32 @@
t_field* field = (*f_iter);
if (field->get_req() == t_field::T_REQUIRED
|| (field->get_req() == t_field::T_OPT_IN_REQ_OUT && write_mode)) {
- indent(out) << "if ($this->" << field->get_name() << " === null) {" << endl;
+ indent(out) << "if ($this->" << field->get_name() << " === null) {" << '\n';
indent_up();
indent(out) << "throw new TProtocolException('Required field " << tstruct->get_name() << "."
- << field->get_name() << " is unset!');" << endl;
+ << field->get_name() << " is unset!');" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
}
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
void t_php_generator::generate_php_struct_json_serialize(ostream& out,
t_struct* tstruct,
bool is_result) {
- indent(out) << "#[\\ReturnTypeWillChange]" << endl;
- indent(out) << "public function jsonSerialize() {" << endl;
+ indent(out) << "#[\\ReturnTypeWillChange]" << '\n';
+ indent(out) << "public function jsonSerialize() {" << '\n';
indent_up();
if (needs_php_write_validator(tstruct, is_result)) {
- indent(out) << "$this->_validateForWrite();" << endl;
+ indent(out) << "$this->_validateForWrite();" << '\n';
}
- indent(out) << "$json = new stdClass;" << endl;
+ indent(out) << "$json = new stdClass;" << '\n';
const vector<t_field*>& fields = tstruct->get_members();
@@ -1312,7 +1310,7 @@
continue;
}
}
- indent(out) << "if ($this->" << name << " !== null) {" << endl;
+ indent(out) << "if ($this->" << name << " !== null) {" << '\n';
indent_up();
indent(out) << "$json->" << name << " = ";
if (type->is_map()) {
@@ -1320,16 +1318,16 @@
} else {
out << type_to_cast(type);
}
- out << "$this->" << name << ";" << endl;
+ out << "$this->" << name << ";" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
}
- indent(out) << "return $json;" << endl;
+ indent(out) << "return $json;" << '\n';
indent_down();
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
int t_php_generator::get_php_num_required_fields(const vector<t_field*>& fields, bool write_mode) {
@@ -1382,7 +1380,7 @@
if(classmap_) {
// Close service file
- f_service_ << endl;
+ f_service_ << '\n';
f_service_.close();
}
}
@@ -1413,34 +1411,34 @@
}
// Generate the header portion
- f_service_processor << "class " << service_name_ << "Processor" << extends_processor << endl
- << "{" << endl;
+ f_service_processor << "class " << service_name_ << "Processor" << extends_processor << '\n'
+ << "{" << '\n';
indent_up();
if (extends.empty()) {
- f_service_processor << indent() << "protected $handler_ = null;" << endl;
+ f_service_processor << indent() << "protected $handler_ = null;" << '\n';
}
- f_service_processor << indent() << "public function __construct($handler)"<< endl
- << indent() << "{" << endl;
+ f_service_processor << indent() << "public function __construct($handler)"<< '\n'
+ << indent() << "{" << '\n';
indent_up();
if (extends.empty()) {
- f_service_processor << indent() << "$this->handler_ = $handler;" << endl;
+ f_service_processor << indent() << "$this->handler_ = $handler;" << '\n';
} else {
- f_service_processor << indent() << "parent::__construct($handler);" << endl;
+ f_service_processor << indent() << "parent::__construct($handler);" << '\n';
}
indent_down();
- f_service_processor << indent() << "}" << endl << endl;
+ f_service_processor << indent() << "}" << '\n' << '\n';
// Generate the server implementation
- f_service_processor << indent() << "public function process($input, $output)" << endl
- << indent() << "{" << endl;
+ f_service_processor << indent() << "public function process($input, $output)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
- f_service_processor << indent() << "$rseqid = 0;" << endl << indent() << "$fname = null;" << endl
- << indent() << "$mtype = 0;" << endl << endl;
+ f_service_processor << indent() << "$rseqid = 0;" << '\n' << indent() << "$fname = null;" << '\n'
+ << indent() << "$mtype = 0;" << '\n' << '\n';
if (binary_inline_) {
t_field ffname(g_type_string, "fname");
@@ -1450,36 +1448,36 @@
generate_deserialize_field(f_service_processor, &fmtype, "", true);
generate_deserialize_field(f_service_processor, &fseqid, "", true);
} else {
- f_service_processor << indent() << "$input->readMessageBegin($fname, $mtype, $rseqid);" << endl;
+ f_service_processor << indent() << "$input->readMessageBegin($fname, $mtype, $rseqid);" << '\n';
}
// HOT: check for method implementation
- f_service_processor << indent() << "$methodname = 'process_'.$fname;" << endl
- << indent() << "if (!method_exists($this, $methodname)) {" << endl;
+ f_service_processor << indent() << "$methodname = 'process_'.$fname;" << '\n'
+ << indent() << "if (!method_exists($this, $methodname)) {" << '\n';
indent_up();
if (binary_inline_) {
- f_service_processor << indent() << "throw new \\Exception('Function '.$fname.' not implemented.');" << endl;
+ f_service_processor << indent() << "throw new \\Exception('Function '.$fname.' not implemented.');" << '\n';
} else {
f_service_processor << indent() << " $input->skip("
- << "TType::STRUCT);" << endl << indent() << " $input->readMessageEnd();" << endl
+ << "TType::STRUCT);" << '\n' << indent() << " $input->readMessageEnd();" << '\n'
<< indent() << " $x = new "
<< "TApplicationException('Function '.$fname.' not implemented.', "
- << "TApplicationException::UNKNOWN_METHOD);" << endl << indent()
+ << "TApplicationException::UNKNOWN_METHOD);" << '\n' << indent()
<< " $output->writeMessageBegin($fname, "
- << "TMessageType::EXCEPTION, $rseqid);" << endl << indent()
- << " $x->write($output);" << endl << indent() << " $output->writeMessageEnd();"
- << endl << indent() << " $output->getTransport()->flush();" << endl << indent()
- << " return;" << endl;
+ << "TMessageType::EXCEPTION, $rseqid);" << '\n' << indent()
+ << " $x->write($output);" << '\n' << indent() << " $output->writeMessageEnd();"
+ << '\n' << indent() << " $output->getTransport()->flush();" << '\n' << indent()
+ << " return;" << '\n';
}
indent_down();
- f_service_processor << indent() << "}" << endl
- << indent() << "$this->$methodname($rseqid, $input, $output);" << endl
- << indent() << "return true;" << endl;
+ f_service_processor << indent() << "}" << '\n'
+ << indent() << "$this->$methodname($rseqid, $input, $output);" << '\n'
+ << indent() << "return true;" << '\n';
indent_down();
- f_service_processor << indent() << "}" << endl << endl;
+ f_service_processor << indent() << "}" << '\n' << '\n';
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1487,7 +1485,7 @@
}
indent_down();
- f_service_processor << "}" << endl;
+ f_service_processor << "}" << '\n';
if (!classmap_) {
f_service_processor.close();
@@ -1501,8 +1499,8 @@
*/
void t_php_generator::generate_process_function(std::ostream& out, t_service* tservice, t_function* tfunction) {
// Open function
- out << indent() << "protected function process_" << tfunction->get_name() << "($seqid, $input, $output)" << endl
- << indent() << "{" << endl;
+ out << indent() << "protected function process_" << tfunction->get_name() << "($seqid, $input, $output)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
string argsname = php_namespace(tservice->get_program()) + service_name_ + "_"
@@ -1512,32 +1510,32 @@
out << indent() << "$bin_accel = ($input instanceof "
<< "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary_after_message_begin');"
- << endl;
- out << indent() << "if ($bin_accel) {" << endl;
+ << '\n';
+ out << indent() << "if ($bin_accel) {" << '\n';
indent_up();
- out << indent() << "$args = thrift_protocol_read_binary_after_message_begin(" <<endl;
+ out << indent() << "$args = thrift_protocol_read_binary_after_message_begin(" << '\n';
indent_up();
- out << indent() << "$input,"<<endl
- << indent() << "'" << argsname << "'," << endl
- << indent() << "$input->isStrictRead()" <<endl;
+ out << indent() << "$input," << '\n'
+ << indent() << "'" << argsname << "'," << '\n'
+ << indent() << "$input->isStrictRead()" << '\n';
indent_down();
- out << indent() <<");" << endl;
+ out << indent() <<");" << '\n';
indent_down();
- out << indent() << "} else {" << endl;
+ out << indent() << "} else {" << '\n';
indent_up();
- out << indent() << "$args = new " << argsname << "();" << endl
- << indent() << "$args->read($input);" << endl;
+ out << indent() << "$args = new " << argsname << "();" << '\n'
+ << indent() << "$args->read($input);" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
if (!binary_inline_) {
- out << indent() << "$input->readMessageEnd();" << endl;
+ out << indent() << "$input->readMessageEnd();" << '\n';
}
t_struct* xs = tfunction->get_xceptions();
@@ -1546,12 +1544,12 @@
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
- out << indent() << "$result = new " << resultname << "();" << endl;
+ out << indent() << "$result = new " << resultname << "();" << '\n';
}
// Try block for a function with exceptions
if (xceptions.size() > 0) {
- out << indent() << "try {" << endl;
+ out << indent() << "try {" << '\n';
indent_up();
}
@@ -1574,7 +1572,7 @@
}
out << "$args->" << (*f_iter)->get_name();
}
- out << ");" << endl;
+ out << ");" << '\n';
if (!tfunction->is_oneway() && xceptions.size() > 0) {
indent_down();
@@ -1582,70 +1580,70 @@
out << indent() << "} catch ("
<< php_namespace(get_true_type((*x_iter)->get_type())->get_program())
<< (*x_iter)->get_type()->get_name() << " $" << (*x_iter)->get_name() << ") {"
- << endl;
+ << '\n';
if (!tfunction->is_oneway()) {
indent_up();
out << indent() << "$result->" << (*x_iter)->get_name() << " = $"
- << (*x_iter)->get_name() << ";" << endl;
+ << (*x_iter)->get_name() << ";" << '\n';
indent_down();
out << indent();
}
}
- out << "}" << endl;
+ out << "}" << '\n';
}
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- out << indent() << "return;" << endl;
+ out << indent() << "return;" << '\n';
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
return;
}
out << indent() << "$bin_accel = ($output instanceof "
<< "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');"
- << endl;
+ << '\n';
- out << indent() << "if ($bin_accel) {" << endl;
+ out << indent() << "if ($bin_accel) {" << '\n';
indent_up();
- out << indent() << "thrift_protocol_write_binary(" << endl;
+ out << indent() << "thrift_protocol_write_binary(" << '\n';
indent_up();
- out << indent() << "$output,"<<endl
- << indent() << "'" << tfunction->get_name()<< "'," <<endl
- << indent() << "TMessageType::REPLY,"<< endl
- << indent() << "$result," << endl
- << indent() << "$seqid," << endl
- << indent() << "$output->isStrictWrite()"<<endl;
+ out << indent() << "$output,"<< '\n'
+ << indent() << "'" << tfunction->get_name()<< "'," << '\n'
+ << indent() << "TMessageType::REPLY,"<< '\n'
+ << indent() << "$result," << '\n'
+ << indent() << "$seqid," << '\n'
+ << indent() << "$output->isStrictWrite()"<< '\n';
indent_down();
- out << indent() << ");" << endl;
+ out << indent() << ");" << '\n';
indent_down();
- out << indent() << "} else {" << endl;
+ out << indent() << "} else {" << '\n';
indent_up();
// Serialize the request header
if (binary_inline_) {
out << indent() << "$buff = pack('N', (0x80010000 | "
- << "TMessageType::REPLY)); " << endl << indent() << "$buff .= pack('N', strlen('"
- << tfunction->get_name() << "'));" << endl << indent() << "$buff .= '"
- << tfunction->get_name() << "';" << endl << indent() << "$buff .= pack('N', $seqid);"
- << endl << indent() << "$result->write($buff);" << endl << indent()
- << "$output->write($buff);" << endl << indent() << "$output->flush();" << endl;
+ << "TMessageType::REPLY)); " << '\n' << indent() << "$buff .= pack('N', strlen('"
+ << tfunction->get_name() << "'));" << '\n' << indent() << "$buff .= '"
+ << tfunction->get_name() << "';" << '\n' << indent() << "$buff .= pack('N', $seqid);"
+ << '\n' << indent() << "$result->write($buff);" << '\n' << indent()
+ << "$output->write($buff);" << '\n' << indent() << "$output->flush();" << '\n';
} else {
out << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', "
- << "TMessageType::REPLY, $seqid);" << endl << indent() << "$result->write($output);"
- << endl << indent() << "$output->writeMessageEnd();" << endl << indent()
- << "$output->getTransport()->flush();" << endl;
+ << "TMessageType::REPLY, $seqid);" << '\n' << indent() << "$result->write($output);"
+ << '\n' << indent() << "$output->writeMessageEnd();" << '\n' << indent()
+ << "$output->getTransport()->flush();" << '\n';
}
scope_down(out);
// Close function
indent_down();
- out << indent() << "}" << endl;
+ out << indent() << "}" << '\n';
}
/**
@@ -1659,7 +1657,7 @@
ofstream_with_content_based_conditional_update& f_struct_definition = f_service_;
if (classmap_) {
- f_struct_definition << "// HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+ f_struct_definition << "// HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n';
}
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1738,18 +1736,18 @@
+ tservice->get_extends()->get_name() + "If";
}
generate_php_doc(f_service_interface, tservice);
- f_service_interface << "interface " << php_namespace_declaration(tservice) << "If" << extends_if << endl
- << "{" << endl;
+ f_service_interface << "interface " << php_namespace_declaration(tservice) << "If" << extends_if << '\n'
+ << "{" << '\n';
indent_up();
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_php_doc(f_service_interface, *f_iter);
- indent(f_service_interface) << "public function " << function_signature(*f_iter) << ";" << endl;
+ indent(f_service_interface) << "public function " << function_signature(*f_iter) << ";" << '\n';
}
indent_down();
- f_service_interface << "}" << endl;
+ f_service_interface << "}" << '\n';
// Close service interface file
if (!classmap_) {
@@ -1776,21 +1774,21 @@
extends_if = " extends " + php_namespace(tservice->get_extends()->get_program())
+ tservice->get_extends()->get_name() + "Rest";
}
- f_service_rest << "class " << service_name_ << "Rest" << extends_if << endl
- << "{" << endl;
+ f_service_rest << "class " << service_name_ << "Rest" << extends_if << '\n'
+ << "{" << '\n';
indent_up();
if (extends.empty()) {
- f_service_rest << indent() << "protected $impl_;" << endl << endl;
+ f_service_rest << indent() << "protected $impl_;" << '\n' << '\n';
}
- f_service_rest << indent() << "public function __construct($impl) {" << endl << indent()
- << " $this->impl_ = $impl;" << endl << indent() << "}" << endl << endl;
+ f_service_rest << indent() << "public function __construct($impl) {" << '\n' << indent()
+ << " $this->impl_ = $impl;" << '\n' << indent() << "}" << '\n' << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- indent(f_service_rest) << "public function " << (*f_iter)->get_name() << "($request) {" << endl;
+ indent(f_service_rest) << "public function " << (*f_iter)->get_name() << "($request) {" << '\n';
indent_up();
const vector<t_field*>& args = (*f_iter)->get_arglist()->get_members();
vector<t_field*>::const_iterator a_iter;
@@ -1800,39 +1798,39 @@
string req = "$request['" + (*a_iter)->get_name() + "']";
if (atype->is_bool()) {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = " << cast << "(!empty(" << req
- << ") && (" << req << " !== 'false'));" << endl;
+ << ") && (" << req << " !== 'false'));" << '\n';
} else {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = isset(" << req << ") ? "
- << cast << req << " : null;" << endl;
+ << cast << req << " : null;" << '\n';
}
/* slist no longer supported
if (atype->is_string() && ((t_base_type*)atype)->is_string_list()) {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = explode(',', $"
- << (*a_iter)->get_name() << ");" << endl;
+ << (*a_iter)->get_name() << ");" << '\n';
} else */
if (atype->is_map() || atype->is_list()) {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = json_decode($"
- << (*a_iter)->get_name() << ", true);" << endl;
+ << (*a_iter)->get_name() << ", true);" << '\n';
} else if (atype->is_set()) {
f_service_rest << indent() << "$" << (*a_iter)->get_name() << " = array_fill_keys(json_decode($"
- << (*a_iter)->get_name() << ", true), 1);" << endl;
+ << (*a_iter)->get_name() << ", true), 1);" << '\n';
} else if (atype->is_struct() || atype->is_xception()) {
- f_service_rest << indent() << "if ($" << (*a_iter)->get_name() << " !== null) {" << endl
+ f_service_rest << indent() << "if ($" << (*a_iter)->get_name() << " !== null) {" << '\n'
<< indent() << " $" << (*a_iter)->get_name() << " = new "
<< php_namespace(atype->get_program()) << atype->get_name() << "(json_decode($"
- << (*a_iter)->get_name() << ", true));" << endl << indent() << "}" << endl;
+ << (*a_iter)->get_name() << ", true));" << '\n' << indent() << "}" << '\n';
}
}
f_service_rest << indent() << "return $this->impl_->" << (*f_iter)->get_name() << "("
- << argument_list((*f_iter)->get_arglist(), false) << ");" << endl;
+ << argument_list((*f_iter)->get_arglist(), false) << ");" << '\n';
indent_down();
- indent(f_service_rest) << "}" << endl << endl;
+ indent(f_service_rest) << "}" << '\n' << '\n';
}
indent_down();
- f_service_rest << "}" << endl << endl;
+ f_service_rest << "}" << '\n' << '\n';
// Close service rest file
- f_service_rest << endl;
+ f_service_rest << '\n';
if (!classmap_) {
f_service_rest.close();
}
@@ -1860,31 +1858,31 @@
}
f_service_client << "class " << php_namespace_declaration(tservice) << "Client" << extends_client
- << " implements " << php_namespace(tservice->get_program()) << service_name_ << "If" << endl
- <<"{"<< endl;
+ << " implements " << php_namespace(tservice->get_program()) << service_name_ << "If" << '\n'
+ <<"{"<< '\n';
indent_up();
// Private members
if (extends.empty()) {
- f_service_client << indent() << "protected $input_ = null;" << endl << indent()
- << "protected $output_ = null;" << endl << endl;
- f_service_client << indent() << "protected $seqid_ = 0;" << endl << endl;
+ f_service_client << indent() << "protected $input_ = null;" << '\n' << indent()
+ << "protected $output_ = null;" << '\n' << '\n';
+ f_service_client << indent() << "protected $seqid_ = 0;" << '\n' << '\n';
}
// Constructor function
- f_service_client << indent() << "public function __construct($input, $output = null)" << endl
- << indent() << "{" << endl;
+ f_service_client << indent() << "public function __construct($input, $output = null)" << '\n'
+ << indent() << "{" << '\n';
indent_up();
if (!extends.empty()) {
- f_service_client << indent() << "parent::__construct($input, $output);" << endl;
+ f_service_client << indent() << "parent::__construct($input, $output);" << '\n';
} else {
- f_service_client << indent() << "$this->input_ = $input;" << endl
- << indent() << "$this->output_ = $output ? $output : $input;" << endl;
+ f_service_client << indent() << "$this->input_ = $input;" << '\n'
+ << indent() << "$this->output_ = $output ? $output : $input;" << '\n';
}
indent_down();
- f_service_client << indent() << "}" << endl << endl;
+ f_service_client << indent() << "}" << '\n' << '\n';
// Generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -1895,10 +1893,10 @@
vector<t_field*>::const_iterator fld_iter;
string funname = (*f_iter)->get_name();
- f_service_client << endl;
+ f_service_client << '\n';
// Open function
- indent(f_service_client) << "public function " << function_signature(*f_iter) << endl;
+ indent(f_service_client) << "public function " << function_signature(*f_iter) << '\n';
scope_up(f_service_client);
indent(f_service_client) << "$this->send_" << funname << "(";
@@ -1911,77 +1909,77 @@
}
f_service_client << "$" << (*fld_iter)->get_name();
}
- f_service_client << ");" << endl;
+ f_service_client << ");" << '\n';
if (!(*f_iter)->is_oneway()) {
f_service_client << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_client << "return ";
}
- f_service_client << "$this->recv_" << funname << "();" << endl;
+ f_service_client << "$this->recv_" << funname << "();" << '\n';
}
scope_down(f_service_client);
- f_service_client << endl;
+ f_service_client << '\n';
- indent(f_service_client) << "public function send_" << function_signature(*f_iter) << endl;
+ indent(f_service_client) << "public function send_" << function_signature(*f_iter) << '\n';
scope_up(f_service_client);
std::string argsname = php_namespace(tservice->get_program()) + service_name_ + "_"
+ (*f_iter)->get_name() + "_args";
- f_service_client << indent() << "$args = new " << argsname << "();" << endl;
+ f_service_client << indent() << "$args = new " << argsname << "();" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_client << indent() << "$args->" << (*fld_iter)->get_name() << " = $"
- << (*fld_iter)->get_name() << ";" << endl;
+ << (*fld_iter)->get_name() << ";" << '\n';
}
f_service_client << indent() << "$bin_accel = ($this->output_ instanceof "
<< "TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');"
- << endl;
+ << '\n';
- f_service_client << indent() << "if ($bin_accel) {" << endl;
+ f_service_client << indent() << "if ($bin_accel) {" << '\n';
indent_up();
string messageType = (*f_iter)->is_oneway() ? "TMessageType::ONEWAY" : "TMessageType::CALL";
- f_service_client << indent() << "thrift_protocol_write_binary(" << endl;
+ f_service_client << indent() << "thrift_protocol_write_binary(" << '\n';
indent_up();
- f_service_client << indent() << "$this->output_," << endl
- << indent() << "'" << (*f_iter)->get_name() << "'," << endl
- << indent() << messageType << "," << endl
- << indent() << "$args," << endl
- << indent() << "$this->seqid_," << endl
- << indent() << "$this->output_->isStrictWrite()" << endl;
+ f_service_client << indent() << "$this->output_," << '\n'
+ << indent() << "'" << (*f_iter)->get_name() << "'," << '\n'
+ << indent() << messageType << "," << '\n'
+ << indent() << "$args," << '\n'
+ << indent() << "$this->seqid_," << '\n'
+ << indent() << "$this->output_->isStrictWrite()" << '\n';
indent_down();
- f_service_client << indent() << ");" << endl;
+ f_service_client << indent() << ");" << '\n';
indent_down();
- f_service_client << indent() << "} else {" << endl;
+ f_service_client << indent() << "} else {" << '\n';
indent_up();
// Serialize the request header
if (binary_inline_) {
- f_service_client << indent() << "$buff = pack('N', (0x80010000 | " << messageType << "));" << endl
- << indent() << "$buff .= pack('N', strlen('" << funname << "'));" << endl
- << indent() << "$buff .= '" << funname << "';" << endl << indent()
- << "$buff .= pack('N', $this->seqid_);" << endl;
+ f_service_client << indent() << "$buff = pack('N', (0x80010000 | " << messageType << "));" << '\n'
+ << indent() << "$buff .= pack('N', strlen('" << funname << "'));" << '\n'
+ << indent() << "$buff .= '" << funname << "';" << '\n' << indent()
+ << "$buff .= pack('N', $this->seqid_);" << '\n';
} else {
f_service_client << indent() << "$this->output_->writeMessageBegin('" << (*f_iter)->get_name()
- << "', " << messageType << ", $this->seqid_);" << endl;
+ << "', " << messageType << ", $this->seqid_);" << '\n';
}
// Write to the stream
if (binary_inline_) {
- f_service_client << indent() << "$args->write($buff);" << endl << indent()
- << "$this->output_->write($buff);" << endl << indent()
- << "$this->output_->flush();" << endl;
+ f_service_client << indent() << "$args->write($buff);" << '\n' << indent()
+ << "$this->output_->write($buff);" << '\n' << indent()
+ << "$this->output_->flush();" << '\n';
} else {
- f_service_client << indent() << "$args->write($this->output_);" << endl << indent()
- << "$this->output_->writeMessageEnd();" << endl << indent()
- << "$this->output_->getTransport()->flush();" << endl;
+ f_service_client << indent() << "$args->write($this->output_);" << '\n' << indent()
+ << "$this->output_->writeMessageEnd();" << '\n' << indent()
+ << "$this->output_->getTransport()->flush();" << '\n';
}
scope_down(f_service_client);
@@ -1997,98 +1995,98 @@
string("recv_") + (*f_iter)->get_name(),
&noargs);
// Open function
- f_service_client << endl << indent() << "public function " << function_signature(&recv_function)
- << endl;
+ f_service_client << '\n' << indent() << "public function " << function_signature(&recv_function)
+ << '\n';
scope_up(f_service_client);
f_service_client << indent() << "$bin_accel = ($this->input_ instanceof "
<< "TBinaryProtocolAccelerated)"
- << " && function_exists('thrift_protocol_read_binary');" << endl;
+ << " && function_exists('thrift_protocol_read_binary');" << '\n';
- f_service_client << indent() << "if ($bin_accel) {" << endl;
+ f_service_client << indent() << "if ($bin_accel) {" << '\n';
indent_up();
- f_service_client << indent() << "$result = thrift_protocol_read_binary(" << endl;
+ f_service_client << indent() << "$result = thrift_protocol_read_binary(" << '\n';
indent_up();
- f_service_client << indent() << "$this->input_," << endl
- << indent() << "'" << resultname << "'," << endl
- << indent() << "$this->input_->isStrictRead()" << endl;
+ f_service_client << indent() << "$this->input_," << '\n'
+ << indent() << "'" << resultname << "'," << '\n'
+ << indent() << "$this->input_->isStrictRead()" << '\n';
indent_down();
- f_service_client << indent() << ");" << endl;
+ f_service_client << indent() << ");" << '\n';
indent_down();
- f_service_client << indent() << "} else {" << endl;
+ f_service_client << indent() << "} else {" << '\n';
indent_up();
- f_service_client << indent() << "$rseqid = 0;" << endl
- << indent() << "$fname = null;" << endl
- << indent() << "$mtype = 0;" << endl << endl;
+ f_service_client << indent() << "$rseqid = 0;" << '\n'
+ << indent() << "$fname = null;" << '\n'
+ << indent() << "$mtype = 0;" << '\n' << '\n';
if (binary_inline_) {
t_field ffname(g_type_string, "fname");
t_field fseqid(g_type_i32, "rseqid");
- f_service_client << indent() << "$ver = unpack('N', $this->input_->readAll(4));" << endl
- << indent() << "$ver = $ver[1];" << endl << indent() << "$mtype = $ver & 0xff;"
- << endl << indent() << "$ver = $ver & 0xffff0000;" << endl << indent()
+ f_service_client << indent() << "$ver = unpack('N', $this->input_->readAll(4));" << '\n'
+ << indent() << "$ver = $ver[1];" << '\n' << indent() << "$mtype = $ver & 0xff;"
+ << '\n' << indent() << "$ver = $ver & 0xffff0000;" << '\n' << indent()
<< "if ($ver != 0x80010000) throw new "
<< "TProtocolException('Bad version identifier: '.$ver, "
- << "TProtocolException::BAD_VERSION);" << endl;
+ << "TProtocolException::BAD_VERSION);" << '\n';
generate_deserialize_field(f_service_client, &ffname, "", true);
generate_deserialize_field(f_service_client, &fseqid, "", true);
} else {
- f_service_client << indent() << "$this->input_->readMessageBegin($fname, $mtype, $rseqid);" << endl
- << indent() << "if ($mtype == TMessageType::EXCEPTION) {" << endl;
+ f_service_client << indent() << "$this->input_->readMessageBegin($fname, $mtype, $rseqid);" << '\n'
+ << indent() << "if ($mtype == TMessageType::EXCEPTION) {" << '\n';
indent_up();
- f_service_client << indent() << "$x = new TApplicationException();" << endl
- << indent() << "$x->read($this->input_);" << endl
- << indent() << "$this->input_->readMessageEnd();" << endl
- << indent() << "throw $x;" << endl;
+ f_service_client << indent() << "$x = new TApplicationException();" << '\n'
+ << indent() << "$x->read($this->input_);" << '\n'
+ << indent() << "$this->input_->readMessageEnd();" << '\n'
+ << indent() << "throw $x;" << '\n';
indent_down();
- f_service_client << indent() << "}" << endl;
+ f_service_client << indent() << "}" << '\n';
}
- f_service_client << indent() << "$result = new " << resultname << "();" << endl
- << indent() << "$result->read($this->input_);" << endl;
+ f_service_client << indent() << "$result = new " << resultname << "();" << '\n'
+ << indent() << "$result->read($this->input_);" << '\n';
if (!binary_inline_) {
- f_service_client << indent() << "$this->input_->readMessageEnd();" << endl;
+ f_service_client << indent() << "$this->input_->readMessageEnd();" << '\n';
}
scope_down(f_service_client);
// Careful, only return result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_client << indent() << "if ($result->success !== null) {" << endl;
+ f_service_client << indent() << "if ($result->success !== null) {" << '\n';
indent_up();
- f_service_client << indent() << "return $result->success;" << endl;
+ f_service_client << indent() << "return $result->success;" << '\n';
indent_down();
- f_service_client << indent() << "}" << endl;
+ f_service_client << indent() << "}" << '\n';
}
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
- f_service_client << indent() << "if ($result->" << (*x_iter)->get_name() << " !== null) {" << endl;
+ f_service_client << indent() << "if ($result->" << (*x_iter)->get_name() << " !== null) {" << '\n';
indent_up();
- f_service_client << indent() << "throw $result->" << (*x_iter)->get_name() << ";" << endl;
+ f_service_client << indent() << "throw $result->" << (*x_iter)->get_name() << ";" << '\n';
indent_down();
- f_service_client << indent() << "}" << endl;
+ f_service_client << indent() << "}" << '\n';
}
// Careful, only return _result if not a void function
if ((*f_iter)->get_returntype()->is_void()) {
- indent(f_service_client) << "return;" << endl;
+ indent(f_service_client) << "return;" << '\n';
} else {
f_service_client << indent() << "throw new \\Exception(\"" << (*f_iter)->get_name()
- << " failed: unknown result\");" << endl;
+ << " failed: unknown result\");" << '\n';
}
// Close function
@@ -2097,7 +2095,7 @@
}
indent_down();
- f_service_client << "}" << endl;
+ f_service_client << "}" << '\n';
// Close service client file
if (!classmap_) {
@@ -2138,54 +2136,54 @@
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
- out << indent() << "$len = unpack('N', " << itrans << "->readAll(4));" << endl
- << indent() << "$len = $len[1];" << endl << indent() << "if ($len > 0x7fffffff) {"
- << endl << indent() << " $len = 0 - (($len - 1) ^ 0xffffffff);" << endl << indent()
- << "}" << endl << indent() << "$" << name << " = " << itrans << "->readAll($len);"
- << endl;
+ out << indent() << "$len = unpack('N', " << itrans << "->readAll(4));" << '\n'
+ << indent() << "$len = $len[1];" << '\n' << indent() << "if ($len > 0x7fffffff) {"
+ << '\n' << indent() << " $len = 0 - (($len - 1) ^ 0xffffffff);" << '\n' << indent()
+ << "}" << '\n' << indent() << "$" << name << " = " << itrans << "->readAll($len);"
+ << '\n';
break;
case t_base_type::TYPE_BOOL:
out << indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));"
- << endl << indent() << "$" << name << " = (bool)$" << name << "[1];" << endl;
+ << '\n' << indent() << "$" << name << " = (bool)$" << name << "[1];" << '\n';
break;
case t_base_type::TYPE_I8:
out << indent() << "$" << name << " = unpack('c', " << itrans << "->readAll(1));"
- << endl << indent() << "$" << name << " = $" << name << "[1];" << endl;
+ << '\n' << indent() << "$" << name << " = $" << name << "[1];" << '\n';
break;
case t_base_type::TYPE_I16:
- out << indent() << "$val = unpack('n', " << itrans << "->readAll(2));" << endl
- << indent() << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fff) {"
- << endl << indent() << " $val = 0 - (($val - 1) ^ 0xffff);" << endl << indent()
- << "}" << endl << indent() << "$" << name << " = $val;" << endl;
+ out << indent() << "$val = unpack('n', " << itrans << "->readAll(2));" << '\n'
+ << indent() << "$val = $val[1];" << '\n' << indent() << "if ($val > 0x7fff) {"
+ << '\n' << indent() << " $val = 0 - (($val - 1) ^ 0xffff);" << '\n' << indent()
+ << "}" << '\n' << indent() << "$" << name << " = $val;" << '\n';
break;
case t_base_type::TYPE_I32:
- out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl
- << indent() << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fffffff) {"
- << endl << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << endl << indent()
- << "}" << endl << indent() << "$" << name << " = $val;" << endl;
+ out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << '\n'
+ << indent() << "$val = $val[1];" << '\n' << indent() << "if ($val > 0x7fffffff) {"
+ << '\n' << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << '\n' << indent()
+ << "}" << '\n' << indent() << "$" << name << " = $val;" << '\n';
break;
case t_base_type::TYPE_I64:
- out << indent() << "$arr = unpack('N2', " << itrans << "->readAll(8));" << endl
- << indent() << "if ($arr[1] & 0x80000000) {" << endl << indent()
- << " $arr[1] = $arr[1] ^ 0xFFFFFFFF;" << endl << indent()
- << " $arr[2] = $arr[2] ^ 0xFFFFFFFF;" << endl << indent() << " $" << name
- << " = 0 - $arr[1]*4294967296 - $arr[2] - 1;" << endl << indent() << "} else {"
- << endl << indent() << " $" << name << " = $arr[1]*4294967296 + $arr[2];" << endl
- << indent() << "}" << endl;
+ out << indent() << "$arr = unpack('N2', " << itrans << "->readAll(8));" << '\n'
+ << indent() << "if ($arr[1] & 0x80000000) {" << '\n' << indent()
+ << " $arr[1] = $arr[1] ^ 0xFFFFFFFF;" << '\n' << indent()
+ << " $arr[2] = $arr[2] ^ 0xFFFFFFFF;" << '\n' << indent() << " $" << name
+ << " = 0 - $arr[1]*4294967296 - $arr[2] - 1;" << '\n' << indent() << "} else {"
+ << '\n' << indent() << " $" << name << " = $arr[1]*4294967296 + $arr[2];" << '\n'
+ << indent() << "}" << '\n';
break;
case t_base_type::TYPE_DOUBLE:
- out << indent() << "$arr = unpack('d', strrev(" << itrans << "->readAll(8)));" << endl
- << indent() << "$" << name << " = $arr[1];" << endl;
+ out << indent() << "$arr = unpack('d', strrev(" << itrans << "->readAll(8)));" << '\n'
+ << indent() << "$" << name << " = $arr[1];" << '\n';
break;
default:
throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase)
+ tfield->get_name();
}
} else if (type->is_enum()) {
- out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << endl << indent()
- << "$val = $val[1];" << endl << indent() << "if ($val > 0x7fffffff) {" << endl
- << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << endl << indent() << "}"
- << endl << indent() << "$" << name << " = $val;" << endl;
+ out << indent() << "$val = unpack('N', " << itrans << "->readAll(4));" << '\n' << indent()
+ << "$val = $val[1];" << '\n' << indent() << "if ($val > 0x7fffffff) {" << '\n'
+ << indent() << " $val = 0 - (($val - 1) ^ 0xffffffff);" << '\n' << indent() << "}"
+ << '\n' << indent() << "$" << name << " = $val;" << '\n';
}
} else {
@@ -2224,7 +2222,7 @@
} else if (type->is_enum()) {
out << "readI32($" << name << ");";
}
- out << endl;
+ out << '\n';
}
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
@@ -2242,8 +2240,8 @@
*/
void t_php_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
out << indent() << "$" << prefix << " = new " << php_namespace(tstruct->get_program())
- << tstruct->get_name() << "();" << endl << indent() << "$xfer += $" << prefix
- << "->read($input);" << endl;
+ << tstruct->get_name() << "();" << '\n' << indent() << "$xfer += $" << prefix
+ << "->read($input);" << '\n';
}
void t_php_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
@@ -2257,44 +2255,44 @@
t_field fvtype(g_type_i8, vtype);
t_field fetype(g_type_i8, etype);
- out << indent() << "$" << prefix << " = array();" << endl << indent() << "$" << size << " = 0;"
- << endl;
+ out << indent() << "$" << prefix << " = array();" << '\n' << indent() << "$" << size << " = 0;"
+ << '\n';
// Declare variables, read header
if (ttype->is_map()) {
- out << indent() << "$" << ktype << " = 0;" << endl << indent() << "$" << vtype << " = 0;"
- << endl;
+ out << indent() << "$" << ktype << " = 0;" << '\n' << indent() << "$" << vtype << " = 0;"
+ << '\n';
if (binary_inline_) {
generate_deserialize_field(out, &fktype);
generate_deserialize_field(out, &fvtype);
generate_deserialize_field(out, &fsize);
} else {
out << indent() << "$xfer += $input->readMapBegin("
- << "$" << ktype << ", $" << vtype << ", $" << size << ");" << endl;
+ << "$" << ktype << ", $" << vtype << ", $" << size << ");" << '\n';
}
} else if (ttype->is_set()) {
if (binary_inline_) {
generate_deserialize_field(out, &fetype);
generate_deserialize_field(out, &fsize);
} else {
- out << indent() << "$" << etype << " = 0;" << endl << indent()
+ out << indent() << "$" << etype << " = 0;" << '\n' << indent()
<< "$xfer += $input->readSetBegin("
- << "$" << etype << ", $" << size << ");" << endl;
+ << "$" << etype << ", $" << size << ");" << '\n';
}
} else if (ttype->is_list()) {
if (binary_inline_) {
generate_deserialize_field(out, &fetype);
generate_deserialize_field(out, &fsize);
} else {
- out << indent() << "$" << etype << " = 0;" << endl << indent()
+ out << indent() << "$" << etype << " = 0;" << '\n' << indent()
<< "$xfer += $input->readListBegin("
- << "$" << etype << ", $" << size << ");" << endl;
+ << "$" << etype << ", $" << size << ");" << '\n';
}
}
// For loop iterates over elements
string i = tmp("_i");
- indent(out) << "for ($" << i << " = 0; $" << i << " < $" << size << "; ++$" << i << ") {" << endl;
+ indent(out) << "for ($" << i << " = 0; $" << i << " < $" << size << "; ++$" << i << ") {" << '\n';
indent_up();
@@ -2311,11 +2309,11 @@
if (!binary_inline_) {
// Read container end
if (ttype->is_map()) {
- indent(out) << "$xfer += $input->readMapEnd();" << endl;
+ indent(out) << "$xfer += $input->readMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "$xfer += $input->readSetEnd();" << endl;
+ indent(out) << "$xfer += $input->readSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "$xfer += $input->readListEnd();" << endl;
+ indent(out) << "$xfer += $input->readListEnd();" << '\n';
}
}
}
@@ -2329,28 +2327,28 @@
t_field fkey(tmap->get_key_type(), key);
t_field fval(tmap->get_val_type(), val);
- indent(out) << declare_field(&fkey, true, true) << endl;
- indent(out) << declare_field(&fval, true, true) << endl;
+ indent(out) << declare_field(&fkey, true, true) << '\n';
+ indent(out) << declare_field(&fval, true, true) << '\n';
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
- indent(out) << "$" << prefix << "[$" << key << "] = $" << val << ";" << endl;
+ indent(out) << "$" << prefix << "[$" << key << "] = $" << val << ";" << '\n';
}
void t_php_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
string elem = tmp("elem");
t_field felem(tset->get_elem_type(), elem);
- indent(out) << "$" << elem << " = null;" << endl;
+ indent(out) << "$" << elem << " = null;" << '\n';
generate_deserialize_field(out, &felem);
t_type* elem_type = tset->get_elem_type();
if(php_is_scalar(elem_type)) {
- indent(out) << "$" << prefix << "[$" << elem << "] = true;" << endl;
+ indent(out) << "$" << prefix << "[$" << elem << "] = true;" << '\n';
} else {
- indent(out) << "$" << prefix << "[] = $" << elem << ";" << endl;
+ indent(out) << "$" << prefix << "[] = $" << elem << ";" << '\n';
}
}
@@ -2360,11 +2358,11 @@
string elem = tmp("elem");
t_field felem(tlist->get_elem_type(), elem);
- indent(out) << "$" << elem << " = null;" << endl;
+ indent(out) << "$" << elem << " = null;" << '\n';
generate_deserialize_field(out, &felem);
- indent(out) << "$" << prefix << " []= $" << elem << ";" << endl;
+ indent(out) << "$" << prefix << " []= $" << elem << ";" << '\n';
}
/**
@@ -2397,33 +2395,33 @@
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
- out << indent() << "$output .= pack('N', strlen($" << name << "));" << endl << indent()
- << "$output .= $" << name << ";" << endl;
+ out << indent() << "$output .= pack('N', strlen($" << name << "));" << '\n' << indent()
+ << "$output .= $" << name << ";" << '\n';
break;
case t_base_type::TYPE_BOOL:
- out << indent() << "$output .= pack('c', $" << name << " ? 1 : 0);" << endl;
+ out << indent() << "$output .= pack('c', $" << name << " ? 1 : 0);" << '\n';
break;
case t_base_type::TYPE_I8:
- out << indent() << "$output .= pack('c', $" << name << ");" << endl;
+ out << indent() << "$output .= pack('c', $" << name << ");" << '\n';
break;
case t_base_type::TYPE_I16:
- out << indent() << "$output .= pack('n', $" << name << ");" << endl;
+ out << indent() << "$output .= pack('n', $" << name << ");" << '\n';
break;
case t_base_type::TYPE_I32:
- out << indent() << "$output .= pack('N', $" << name << ");" << endl;
+ out << indent() << "$output .= pack('N', $" << name << ");" << '\n';
break;
case t_base_type::TYPE_I64:
out << indent() << "$output .= pack('N2', $" << name << " >> 32, $" << name
- << " & 0xFFFFFFFF);" << endl;
+ << " & 0xFFFFFFFF);" << '\n';
break;
case t_base_type::TYPE_DOUBLE:
- out << indent() << "$output .= strrev(pack('d', $" << name << "));" << endl;
+ out << indent() << "$output .= strrev(pack('d', $" << name << "));" << '\n';
break;
default:
throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase);
}
} else if (type->is_enum()) {
- out << indent() << "$output .= pack('N', $" << name << ");" << endl;
+ out << indent() << "$output .= pack('N', $" << name << ");" << '\n';
}
} else {
@@ -2462,7 +2460,7 @@
} else if (type->is_enum()) {
out << "writeI32($" << name << ");";
}
- out << endl;
+ out << '\n';
}
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
@@ -2480,7 +2478,7 @@
*/
void t_php_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- indent(out) << "$xfer += $" << prefix << "->write($output);" << endl;
+ indent(out) << "$xfer += $" << prefix << "->write($output);" << '\n';
}
/**
@@ -2490,35 +2488,35 @@
if (ttype->is_map()) {
if (binary_inline_) {
out << indent() << "$output .= pack('c', " << type_to_enum(((t_map*)ttype)->get_key_type())
- << ");" << endl << indent() << "$output .= pack('c', "
- << type_to_enum(((t_map*)ttype)->get_val_type()) << ");" << endl << indent()
- << "$output .= strrev(pack('l', count($" << prefix << ")));" << endl;
+ << ");" << '\n' << indent() << "$output .= pack('c', "
+ << type_to_enum(((t_map*)ttype)->get_val_type()) << ");" << '\n' << indent()
+ << "$output .= strrev(pack('l', count($" << prefix << ")));" << '\n';
} else {
indent(out) << "$output->writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type())
<< ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "count($" << prefix << "));" << endl;
+ << "count($" << prefix << "));" << '\n';
}
} else if (ttype->is_set()) {
if (binary_inline_) {
out << indent() << "$output .= pack('c', " << type_to_enum(((t_set*)ttype)->get_elem_type())
- << ");" << endl << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));"
- << endl;
+ << ");" << '\n' << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));"
+ << '\n';
} else {
indent(out) << "$output->writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type())
<< ", "
- << "count($" << prefix << "));" << endl;
+ << "count($" << prefix << "));" << '\n';
}
} else if (ttype->is_list()) {
if (binary_inline_) {
out << indent() << "$output .= pack('c', " << type_to_enum(((t_list*)ttype)->get_elem_type())
- << ");" << endl << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));"
- << endl;
+ << ");" << '\n' << indent() << "$output .= strrev(pack('l', count($" << prefix << ")));"
+ << '\n';
} else {
indent(out) << "$output->writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
<< ", "
- << "count($" << prefix << "));" << endl;
+ << "count($" << prefix << "));" << '\n';
}
}
@@ -2526,14 +2524,14 @@
string kiter = tmp("kiter");
string viter = tmp("viter");
indent(out) << "foreach ($" << prefix << " as "
- << "$" << kiter << " => $" << viter << ") {" << endl;
+ << "$" << kiter << " => $" << viter << ") {" << '\n';
indent_up();
generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
scope_down(out);
} else if (ttype->is_set()) {
string iter = tmp("iter");
string iter_val = tmp("iter");
- indent(out) << "foreach ($" << prefix << " as $" << iter << " => $" << iter_val << ") {" << endl;
+ indent(out) << "foreach ($" << prefix << " as $" << iter << " => $" << iter_val << ") {" << '\n';
indent_up();
t_type* elem_type = ((t_set*)ttype)->get_elem_type();
@@ -2545,7 +2543,7 @@
scope_down(out);
} else if (ttype->is_list()) {
string iter = tmp("iter");
- indent(out) << "foreach ($" << prefix << " as $" << iter << ") {" << endl;
+ indent(out) << "foreach ($" << prefix << " as $" << iter << ") {" << '\n';
indent_up();
generate_serialize_list_element(out, (t_list*)ttype, iter);
scope_down(out);
@@ -2553,11 +2551,11 @@
if (!binary_inline_) {
if (ttype->is_map()) {
- indent(out) << "$output->writeMapEnd();" << endl;
+ indent(out) << "$output->writeMapEnd();" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "$output->writeSetEnd();" << endl;
+ indent(out) << "$output->writeSetEnd();" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "$output->writeListEnd();" << endl;
+ indent(out) << "$output->writeListEnd();" << '\n';
}
}
}
@@ -2617,12 +2615,12 @@
// prepend free-style doc if available
if (field->has_doc()) {
- ss << field->get_doc() << endl;
+ ss << field->get_doc() << '\n';
}
// append @var tag
t_type* type = get_true_type(field->get_type());
- ss << "@var " << type_to_phpdoc(type) << endl;
+ ss << "@var " << type_to_phpdoc(type) << '\n';
generate_php_docstring_comment(out, ss.str());
}
@@ -2633,7 +2631,7 @@
void t_php_generator::generate_php_doc(ostream& out, t_function* function) {
stringstream ss;
if (function->has_doc()) {
- ss << function->get_doc() << endl;
+ ss << function->get_doc() << '\n';
}
// generate parameter types doc
@@ -2645,7 +2643,7 @@
if (arg->has_doc()) {
ss << " " << arg->get_doc();
}
- ss << endl;
+ ss << '\n';
}
// generate return type doc
@@ -2655,7 +2653,7 @@
if (ret_type->has_doc()) {
ss << " " << ret_type->get_doc();
}
- ss << endl;
+ ss << '\n';
}
// generate exceptions doc
@@ -2667,7 +2665,7 @@
if (exc->has_doc()) {
ss << " " << exc->get_doc();
}
- ss << endl;
+ ss << '\n';
}
generate_docstring_comment(out, "/**\n", " * ", ss.str(), " */\n");
diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc
index ffabd56..d3f23b6 100644
--- a/compiler/cpp/src/thrift/generate/t_py_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc
@@ -40,8 +40,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* Python code generator.
*
@@ -414,22 +412,22 @@
for (sv_iter = services.begin(); sv_iter != services.end(); ++sv_iter) {
f_init << ", '" << (*sv_iter)->get_name() << "'";
}
- f_init << "]" << endl;
+ f_init << "]" << '\n';
f_init.close();
// Print header
- f_types_ << py_autogen_comment() << endl
- << py_imports() << endl
- << render_includes() << endl
- << "from thrift.transport import TTransport" << endl
+ f_types_ << py_autogen_comment() << '\n'
+ << py_imports() << '\n'
+ << render_includes() << '\n'
+ << "from thrift.transport import TTransport" << '\n'
<< import_dynbase_;
- f_types_ << "all_structs = []" << endl;
+ f_types_ << "all_structs = []" << '\n';
f_consts_ <<
- py_autogen_comment() << endl <<
- py_imports() << endl <<
- "from .ttypes import *" << endl;
+ py_autogen_comment() << '\n' <<
+ py_imports() << '\n' <<
+ "from .ttypes import *" << '\n';
}
/**
@@ -464,16 +462,16 @@
ostringstream ss;
ss << "from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, "
"TApplicationException"
- << endl
+ << '\n'
<< "from thrift.protocol.TProtocol import TProtocolException"
- << endl
+ << '\n'
<< "from thrift.TRecursive import fix_spec"
- << endl;
+ << '\n';
if (gen_enum_) {
- ss << "from enum import IntEnum" << endl;
+ ss << "from enum import IntEnum" << '\n';
}
if (gen_utf8strings_) {
- ss << endl << "import sys";
+ ss << '\n' << "import sys";
}
return ss.str();
}
@@ -484,8 +482,8 @@
void t_py_generator::close_generator() {
// Fix thrift_spec definitions for recursive structs.
- f_types_ << "fix_spec(all_structs)" << endl;
- f_types_ << "del all_structs" << endl;
+ f_types_ << "fix_spec(all_structs)" << '\n';
+ f_types_ << "del all_structs" << '\n';
// Close types file
f_types_.close();
@@ -519,37 +517,37 @@
base_class = gen_dynbaseclass_;
}
- f_types_ << endl
- << endl
+ f_types_ << '\n'
+ << '\n'
<< "class " << tenum->get_name()
<< (base_class.empty() ? "" : "(" + base_class + ")")
<< ":"
- << endl;
+ << '\n';
indent_up();
generate_python_docstring(f_types_, tenum);
- to_string_mapping << indent() << "_VALUES_TO_NAMES = {" << endl;
- from_string_mapping << indent() << "_NAMES_TO_VALUES = {" << endl;
+ to_string_mapping << indent() << "_VALUES_TO_NAMES = {" << '\n';
+ from_string_mapping << indent() << "_NAMES_TO_VALUES = {" << '\n';
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
- indent(f_types_) << (*c_iter)->get_name() << " = " << value << endl;
+ indent(f_types_) << (*c_iter)->get_name() << " = " << value << '\n';
// Dictionaries to/from string names of enums
to_string_mapping << indent() << indent() << value << ": \""
- << escape_string((*c_iter)->get_name()) << "\"," << endl;
+ << escape_string((*c_iter)->get_name()) << "\"," << '\n';
from_string_mapping << indent() << indent() << '"' << escape_string((*c_iter)->get_name())
- << "\": " << value << ',' << endl;
+ << "\": " << value << ',' << '\n';
}
- to_string_mapping << indent() << "}" << endl;
- from_string_mapping << indent() << "}" << endl;
+ to_string_mapping << indent() << "}" << '\n';
+ from_string_mapping << indent() << "}" << '\n';
indent_down();
- f_types_ << endl;
+ f_types_ << '\n';
if (!gen_enum_) {
- f_types_ << to_string_mapping.str() << endl << from_string_mapping.str();
+ f_types_ << to_string_mapping.str() << '\n' << from_string_mapping.str();
}
}
@@ -562,7 +560,7 @@
t_const_value* value = tconst->get_value();
indent(f_consts_) << name << " = " << render_const_value(type, value);
- f_consts_ << endl;
+ f_consts_ << '\n';
}
/**
@@ -612,7 +610,7 @@
out << int_val;
}
} else if (type->is_struct() || type->is_xception()) {
- out << type_name(type) << "(**{" << endl;
+ out << type_name(type) << "(**{" << '\n';
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -629,7 +627,7 @@
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
indent(out) << render_const_value(g_type_string, v_iter->first) << ": "
- << render_const_value(field_type, v_iter->second) << "," << endl;
+ << render_const_value(field_type, v_iter->second) << "," << '\n';
}
indent_down();
indent(out) << "})";
@@ -639,13 +637,13 @@
if (is_immutable(type)) {
out << "TFrozenDict(";
}
- out << "{" << endl;
+ out << "{" << '\n';
indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
indent(out) << render_const_value(ktype, v_iter->first) << ": "
- << render_const_value(vtype, v_iter->second) << "," << endl;
+ << render_const_value(vtype, v_iter->second) << "," << '\n';
}
indent_down();
indent(out) << "}";
@@ -666,15 +664,15 @@
out << "set(";
}
if (is_immutable(type) || type->is_set()) {
- out << "(" << endl;
+ out << "(" << '\n';
} else {
- out << "[" << endl;
+ out << "[" << '\n';
}
indent_up();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- indent(out) << render_const_value(etype, *v_iter) << "," << endl;
+ indent(out) << render_const_value(etype, *v_iter) << "," << '\n';
}
indent_down();
if (is_immutable(type) || type->is_set()) {
@@ -743,17 +741,17 @@
vector<t_field*>::const_iterator m_iter;
// Add struct definition to list so thrift_spec can be fixed for recursive structures.
- indent(out) << "all_structs.append(" << tstruct->get_name() << ")" << endl;
+ indent(out) << "all_structs.append(" << tstruct->get_name() << ")" << '\n';
if (sorted_members.empty() || (sorted_members[0]->get_key() >= 0)) {
- indent(out) << tstruct->get_name() << ".thrift_spec = (" << endl;
+ indent(out) << tstruct->get_name() << ".thrift_spec = (" << '\n';
indent_up();
int sorted_keys_pos = 0;
for (m_iter = sorted_members.begin(); m_iter != sorted_members.end(); ++m_iter) {
for (; sorted_keys_pos != (*m_iter)->get_key(); sorted_keys_pos++) {
- indent(out) << "None, # " << sorted_keys_pos << endl;
+ indent(out) << "None, # " << sorted_keys_pos << '\n';
}
indent(out) << "(" << (*m_iter)->get_key() << ", " << type_to_enum((*m_iter)->get_type())
@@ -762,15 +760,15 @@
<< ", " << type_to_spec_args((*m_iter)->get_type()) << ", "
<< render_field_default_value(*m_iter) << ", "
<< "),"
- << " # " << sorted_keys_pos << endl;
+ << " # " << sorted_keys_pos << '\n';
sorted_keys_pos++;
}
indent_down();
- indent(out) << ")" << endl;
+ indent(out) << ")" << '\n';
} else {
- indent(out) << tstruct->get_name() << ".thrift_spec = ()" << endl;
+ indent(out) << tstruct->get_name() << ".thrift_spec = ()" << '\n';
}
}
@@ -786,7 +784,7 @@
const vector<t_field*>& sorted_members = tstruct->get_sorted_members();
vector<t_field*>::const_iterator m_iter;
- out << endl << endl << "class " << tstruct->get_name();
+ out << '\n' << '\n' << "class " << tstruct->get_name();
if (is_exception) {
if (gen_dynamic_) {
if (is_immutable(tstruct)) {
@@ -806,11 +804,11 @@
} else if (gen_newstyle_) {
out << "(object)";
}
- out << ":" << endl;
+ out << ":" << '\n';
indent_up();
generate_python_docstring(out, tstruct);
- out << endl;
+ out << '\n';
/*
Here we generate the structure specification for the fastbinary codec.
@@ -833,13 +831,13 @@
*/
if (gen_slots_) {
- indent(out) << "__slots__ = (" << endl;
+ indent(out) << "__slots__ = (" << '\n';
indent_up();
for (m_iter = sorted_members.begin(); m_iter != sorted_members.end(); ++m_iter) {
- indent(out) << "'" << (*m_iter)->get_name() << "'," << endl;
+ indent(out) << "'" << (*m_iter)->get_name() << "'," << '\n';
}
indent_down();
- indent(out) << ")" << endl << endl;
+ indent(out) << ")" << '\n' << '\n';
}
// TODO(dreiss): Look into generating an empty tuple instead of None
@@ -848,13 +846,13 @@
// don't have thrift_spec.
if (members.size() > 0) {
- out << endl;
+ out << '\n';
out << indent() << "def __init__(self,";
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
out << " " << declare_argument(*m_iter) << ",";
}
- out << "):" << endl;
+ out << "):" << '\n';
indent_up();
@@ -863,10 +861,10 @@
t_type* type = (*m_iter)->get_type();
if (!type->is_base_type() && !type->is_enum() && (*m_iter)->get_value() != nullptr) {
indent(out) << "if " << (*m_iter)->get_name() << " is "
- << "self.thrift_spec[" << (*m_iter)->get_key() << "][4]:" << endl;
+ << "self.thrift_spec[" << (*m_iter)->get_key() << "][4]:" << '\n';
indent_up();
indent(out) << (*m_iter)->get_name() << " = " << render_field_default_value(*m_iter)
- << endl;
+ << '\n';
indent_down();
}
@@ -875,16 +873,16 @@
indent(out) << "super(" << tstruct->get_name() << ", self).__setattr__('"
<< (*m_iter)->get_name() << "', " << (*m_iter)->get_name()
<< " if hasattr(" << (*m_iter)->get_name() << ", 'value') else "
- << type_name(type) << ".__members__.get(" << (*m_iter)->get_name() << "))" << endl;
+ << type_name(type) << ".__members__.get(" << (*m_iter)->get_name() << "))" << '\n';
} else if (gen_newstyle_ || gen_dynamic_) {
indent(out) << "super(" << tstruct->get_name() << ", self).__setattr__('"
- << (*m_iter)->get_name() << "', " << (*m_iter)->get_name() << ")" << endl;
+ << (*m_iter)->get_name() << "', " << (*m_iter)->get_name() << ")" << '\n';
} else {
indent(out) << "self.__dict__['" << (*m_iter)->get_name()
- << "'] = " << (*m_iter)->get_name() << endl;
+ << "'] = " << (*m_iter)->get_name() << '\n';
}
} else {
- indent(out) << "self." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << endl;
+ indent(out) << "self." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << '\n';
}
}
@@ -892,8 +890,8 @@
}
if (is_immutable(tstruct)) {
- out << endl;
- out << indent() << "def __setattr__(self, *args):" << endl;
+ out << '\n';
+ out << indent() << "def __setattr__(self, *args):" << '\n';
indent_up();
// Not user-provided fields should be editable so that the Python Standard Library can edit
@@ -902,16 +900,16 @@
// trivial because we know which fields are user-provided, without slots we need to build a
// way to know which fields are user-provided.
if (gen_slots_ && !gen_dynamic_) {
- out << indent() << "if args[0] not in self.__slots__:" << endl;
+ out << indent() << "if args[0] not in self.__slots__:" << '\n';
indent_up();
- out << indent() << "super().__setattr__(*args)" << endl
- << indent() << "return" << endl;
+ out << indent() << "super().__setattr__(*args)" << '\n'
+ << indent() << "return" << '\n';
indent_down();
}
- out << indent() << "raise TypeError(\"can't modify immutable instance\")" << endl;
+ out << indent() << "raise TypeError(\"can't modify immutable instance\")" << '\n';
indent_down();
- out << endl;
- out << indent() << "def __delattr__(self, *args):" << endl;
+ out << '\n';
+ out << indent() << "def __delattr__(self, *args):" << '\n';
indent_up();
// Not user-provided fields should be editable so that the Python Standard Library can edit
@@ -920,26 +918,26 @@
// trivial because we know which fields are user-provided, without slots we need to build a
// way to know which fields are user-provided.
if (gen_slots_ && !gen_dynamic_) {
- out << indent() << "if args[0] not in self.__slots__:" << endl;
+ out << indent() << "if args[0] not in self.__slots__:" << '\n';
indent_up();
- out << indent() << "super().__delattr__(*args)" << endl
- << indent() << "return" << endl;
+ out << indent() << "super().__delattr__(*args)" << '\n'
+ << indent() << "return" << '\n';
indent_down();
}
- out << indent() << "raise TypeError(\"can't modify immutable instance\")" << endl;
+ out << indent() << "raise TypeError(\"can't modify immutable instance\")" << '\n';
indent_down();
- out << endl;
+ out << '\n';
// Hash all of the members in order, and also hash in the class
// to avoid collisions for stuff like single-field structures.
- out << indent() << "def __hash__(self):" << endl
+ out << indent() << "def __hash__(self):" << '\n'
<< indent() << indent_str() << "return hash(self.__class__) ^ hash((";
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
out << "self." << (*m_iter)->get_name() << ", ";
}
- out << "))" << endl;
+ out << "))" << '\n';
} else if (gen_enum_) {
bool has_enum = false;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -951,25 +949,25 @@
}
if (has_enum) {
- out << endl;
- indent(out) << "def __setattr__(self, name, value):" << endl;
+ out << '\n';
+ indent(out) << "def __setattr__(self, name, value):" << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* type = (*m_iter)->get_type();
if (type->is_enum()) {
- out << indent() << "if name == \"" << (*m_iter)->get_name() << "\":" << endl
+ out << indent() << "if name == \"" << (*m_iter)->get_name() << "\":" << '\n'
<< indent() << indent_str() << "super().__setattr__(name, value if hasattr(value, 'value') else "
- << type_name(type) << ".__members__.get(value))" << endl
- << indent() << indent_str() << "return" << endl;
+ << type_name(type) << ".__members__.get(value))" << '\n'
+ << indent() << indent_str() << "return" << '\n';
}
}
- indent(out) << "super().__setattr__(name, value)" << endl << endl;
+ indent(out) << "super().__setattr__(name, value)" << '\n' << '\n';
indent_down();
}
}
if (!gen_dynamic_) {
- out << endl;
+ out << '\n';
generate_py_struct_reader(out, tstruct);
generate_py_struct_writer(out, tstruct);
}
@@ -978,64 +976,64 @@
// because when raised exceptions are printed to the console, __repr__
// isn't used. See python bug #5882
if (is_exception) {
- out << endl;
- out << indent() << "def __str__(self):" << endl
- << indent() << indent_str() << "return repr(self)" << endl;
+ out << '\n';
+ out << indent() << "def __str__(self):" << '\n'
+ << indent() << indent_str() << "return repr(self)" << '\n';
}
if (!gen_slots_) {
- out << endl;
+ out << '\n';
// Printing utilities so that on the command line thrift
// structs look pretty like dictionaries
- indent(out) << "def __repr__(self):" << endl;
+ indent(out) << "def __repr__(self):" << '\n';
indent_up();
- out << indent() << "L = ['%s=%r' % (key, value)" << endl
- << indent() << " for key, value in self.__dict__.items()]" << endl
- << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl
- << endl;
+ out << indent() << "L = ['%s=%r' % (key, value)" << '\n'
+ << indent() << " for key, value in self.__dict__.items()]" << '\n'
+ << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << '\n'
+ << '\n';
indent_down();
// Equality and inequality methods that compare by value
- out << indent() << "def __eq__(self, other):" << endl;
+ out << indent() << "def __eq__(self, other):" << '\n';
indent_up();
out << indent() << "return isinstance(other, self.__class__) and "
- "self.__dict__ == other.__dict__" << endl;
+ "self.__dict__ == other.__dict__" << '\n';
indent_down();
- out << endl;
+ out << '\n';
- out << indent() << "def __ne__(self, other):" << endl;
+ out << indent() << "def __ne__(self, other):" << '\n';
indent_up();
- out << indent() << "return not (self == other)" << endl;
+ out << indent() << "return not (self == other)" << '\n';
indent_down();
} else if (!gen_dynamic_) {
- out << endl;
+ out << '\n';
// no base class available to implement __eq__ and __repr__ and __ne__ for us
// so we must provide one that uses __slots__
- indent(out) << "def __repr__(self):" << endl;
+ indent(out) << "def __repr__(self):" << '\n';
indent_up();
- out << indent() << "L = ['%s=%r' % (key, getattr(self, key))" << endl
- << indent() << " for key in self.__slots__]" << endl
- << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << endl
- << endl;
+ out << indent() << "L = ['%s=%r' % (key, getattr(self, key))" << '\n'
+ << indent() << " for key in self.__slots__]" << '\n'
+ << indent() << "return '%s(%s)' % (self.__class__.__name__, ', '.join(L))" << '\n'
+ << '\n';
indent_down();
// Equality method that compares each attribute by value and type, walking __slots__
- out << indent() << "def __eq__(self, other):" << endl;
+ out << indent() << "def __eq__(self, other):" << '\n';
indent_up();
- out << indent() << "if not isinstance(other, self.__class__):" << endl
- << indent() << indent_str() << "return False" << endl
- << indent() << "for attr in self.__slots__:" << endl
- << indent() << indent_str() << "my_val = getattr(self, attr)" << endl
- << indent() << indent_str() << "other_val = getattr(other, attr)" << endl
- << indent() << indent_str() << "if my_val != other_val:" << endl
- << indent() << indent_str() << indent_str() << "return False" << endl
- << indent() << "return True" << endl
- << endl;
+ out << indent() << "if not isinstance(other, self.__class__):" << '\n'
+ << indent() << indent_str() << "return False" << '\n'
+ << indent() << "for attr in self.__slots__:" << '\n'
+ << indent() << indent_str() << "my_val = getattr(self, attr)" << '\n'
+ << indent() << indent_str() << "other_val = getattr(other, attr)" << '\n'
+ << indent() << indent_str() << "if my_val != other_val:" << '\n'
+ << indent() << indent_str() << indent_str() << "return False" << '\n'
+ << indent() << "return True" << '\n'
+ << '\n';
indent_down();
- out << indent() << "def __ne__(self, other):" << endl
- << indent() << indent_str() << "return not (self == other)" << endl;
+ out << indent() << "def __ne__(self, other):" << '\n'
+ << indent() << indent_str() << "return not (self == other)" << '\n';
}
indent_down();
}
@@ -1048,9 +1046,9 @@
vector<t_field*>::const_iterator f_iter;
if (is_immutable(tstruct)) {
- out << indent() << "@classmethod" << endl << indent() << "def read(cls, iprot):" << endl;
+ out << indent() << "@classmethod" << '\n' << indent() << "def read(cls, iprot):" << '\n';
} else {
- indent(out) << "def read(self, iprot):" << endl;
+ indent(out) << "def read(self, iprot):" << '\n';
}
indent_up();
@@ -1059,18 +1057,18 @@
indent(out) << "if iprot._fast_decode is not None "
"and isinstance(iprot.trans, TTransport.CReadableTransport) "
"and "
- << id << ".thrift_spec is not None:" << endl;
+ << id << ".thrift_spec is not None:" << '\n';
indent_up();
if (is_immutable(tstruct)) {
- indent(out) << "return iprot._fast_decode(None, iprot, [cls, cls.thrift_spec])" << endl;
+ indent(out) << "return iprot._fast_decode(None, iprot, [cls, cls.thrift_spec])" << '\n';
} else {
- indent(out) << "iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])" << endl;
- indent(out) << "return" << endl;
+ indent(out) << "iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])" << '\n';
+ indent(out) << "return" << '\n';
}
indent_down();
- indent(out) << "iprot.readStructBegin()" << endl;
+ indent(out) << "iprot.readStructBegin()" << '\n';
if (is_immutable(tstruct)) {
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1082,21 +1080,21 @@
} else {
result << "None";
}
- indent(out) << result.str() << endl;
+ indent(out) << result.str() << '\n';
}
}
// Loop over reading in fields
- indent(out) << "while True:" << endl;
+ indent(out) << "while True:" << '\n';
indent_up();
// Read beginning field marker
- indent(out) << "(fname, ftype, fid) = iprot.readFieldBegin()" << endl;
+ indent(out) << "(fname, ftype, fid) = iprot.readFieldBegin()" << '\n';
// Check for field STOP marker and break
- indent(out) << "if ftype == TType.STOP:" << endl;
+ indent(out) << "if ftype == TType.STOP:" << '\n';
indent_up();
- indent(out) << "break" << endl;
+ indent(out) << "break" << '\n';
indent_down();
// Switch statement on the field we are reading
@@ -1110,9 +1108,9 @@
} else {
out << indent() << "elif ";
}
- out << "fid == " << (*f_iter)->get_key() << ":" << endl;
+ out << "fid == " << (*f_iter)->get_key() << ":" << '\n';
indent_up();
- indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << ":" << endl;
+ indent(out) << "if ftype == " << type_to_enum((*f_iter)->get_type()) << ":" << '\n';
indent_up();
if (is_immutable(tstruct)) {
generate_deserialize_field(out, *f_iter);
@@ -1120,32 +1118,32 @@
generate_deserialize_field(out, *f_iter, "self.");
}
indent_down();
- out << indent() << "else:" << endl << indent() << indent_str() << "iprot.skip(ftype)" << endl;
+ out << indent() << "else:" << '\n' << indent() << indent_str() << "iprot.skip(ftype)" << '\n';
indent_down();
}
// In the default case we skip the field
- out << indent() << "else:" << endl << indent() << indent_str() << "iprot.skip(ftype)" << endl;
+ out << indent() << "else:" << '\n' << indent() << indent_str() << "iprot.skip(ftype)" << '\n';
// Read field end marker
- indent(out) << "iprot.readFieldEnd()" << endl;
+ indent(out) << "iprot.readFieldEnd()" << '\n';
indent_down();
- indent(out) << "iprot.readStructEnd()" << endl;
+ indent(out) << "iprot.readStructEnd()" << '\n';
if (is_immutable(tstruct)) {
- indent(out) << "return cls(" << endl;
+ indent(out) << "return cls(" << '\n';
indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << (*f_iter)->get_name() << "=" << (*f_iter)->get_name() << "," << endl;
+ indent(out) << (*f_iter)->get_name() << "=" << (*f_iter)->get_name() << "," << '\n';
}
indent_down();
- indent(out) << ")" << endl;
+ indent(out) << ")" << '\n';
}
indent_down();
- out << endl;
+ out << '\n';
}
void t_py_generator::generate_py_struct_writer(ostream& out, t_struct* tstruct) {
@@ -1153,49 +1151,49 @@
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "def write(self, oprot):" << endl;
+ indent(out) << "def write(self, oprot):" << '\n';
indent_up();
- indent(out) << "if oprot._fast_encode is not None and self.thrift_spec is not None:" << endl;
+ indent(out) << "if oprot._fast_encode is not None and self.thrift_spec is not None:" << '\n';
indent_up();
indent(out)
<< "oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))"
- << endl;
- indent(out) << "return" << endl;
+ << '\n';
+ indent(out) << "return" << '\n';
indent_down();
- indent(out) << "oprot.writeStructBegin('" << name << "')" << endl;
+ indent(out) << "oprot.writeStructBegin('" << name << "')" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
// Write field header
- indent(out) << "if self." << (*f_iter)->get_name() << " is not None:" << endl;
+ indent(out) << "if self." << (*f_iter)->get_name() << " is not None:" << '\n';
indent_up();
indent(out) << "oprot.writeFieldBegin("
<< "'" << (*f_iter)->get_name() << "', " << type_to_enum((*f_iter)->get_type())
- << ", " << (*f_iter)->get_key() << ")" << endl;
+ << ", " << (*f_iter)->get_key() << ")" << '\n';
// Write field contents
generate_serialize_field(out, *f_iter, "self.");
// Write field closer
- indent(out) << "oprot.writeFieldEnd()" << endl;
+ indent(out) << "oprot.writeFieldEnd()" << '\n';
indent_down();
}
// Write the struct map
- out << indent() << "oprot.writeFieldStop()" << endl << indent() << "oprot.writeStructEnd()"
- << endl;
+ out << indent() << "oprot.writeFieldStop()" << '\n' << indent() << "oprot.writeStructEnd()"
+ << '\n';
- out << endl;
+ out << '\n';
indent_down();
generate_py_struct_required_validator(out, tstruct);
}
void t_py_generator::generate_py_struct_required_validator(ostream& out, t_struct* tstruct) {
- indent(out) << "def validate(self):" << endl;
+ indent(out) << "def validate(self):" << '\n';
indent_up();
const vector<t_field*>& fields = tstruct->get_members();
@@ -1206,14 +1204,14 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field* field = (*f_iter);
if (field->get_req() == t_field::T_REQUIRED) {
- indent(out) << "if self." << field->get_name() << " is None:" << endl;
+ indent(out) << "if self." << field->get_name() << " is None:" << '\n';
indent(out) << indent_str() << "raise TProtocolException(message='Required field "
- << field->get_name() << " is unset!')" << endl;
+ << field->get_name() << " is unset!')" << '\n';
}
}
}
- indent(out) << "return" << endl;
+ indent(out) << "return" << '\n';
indent_down();
}
@@ -1226,32 +1224,32 @@
string f_service_name = package_dir_ + "/" + service_name_ + ".py";
f_service_.open(f_service_name.c_str());
- f_service_ << py_autogen_comment() << endl << py_imports() << endl;
+ f_service_ << py_autogen_comment() << '\n' << py_imports() << '\n';
if (tservice->get_extends() != nullptr) {
f_service_ << "import "
<< get_real_py_module(tservice->get_extends()->get_program(), gen_twisted_, package_prefix_) << "."
- << tservice->get_extends()->get_name() << endl;
+ << tservice->get_extends()->get_name() << '\n';
}
- f_service_ << "import logging" << endl
- << "from .ttypes import *" << endl
- << "from thrift.Thrift import TProcessor" << endl
- << "from thrift.transport import TTransport" << endl
+ f_service_ << "import logging" << '\n'
+ << "from .ttypes import *" << '\n'
+ << "from thrift.Thrift import TProcessor" << '\n'
+ << "from thrift.transport import TTransport" << '\n'
<< import_dynbase_;
if (gen_zope_interface_) {
- f_service_ << "from zope.interface import Interface, implementer" << endl;
+ f_service_ << "from zope.interface import Interface, implementer" << '\n';
}
if (gen_twisted_) {
- f_service_ << "from twisted.internet import defer" << endl
- << "from thrift.transport import TTwisted" << endl;
+ f_service_ << "from twisted.internet import defer" << '\n'
+ << "from thrift.transport import TTwisted" << '\n';
} else if (gen_tornado_) {
- f_service_ << "from tornado import gen" << endl;
- f_service_ << "from tornado import concurrent" << endl;
+ f_service_ << "from tornado import gen" << '\n';
+ f_service_ << "from tornado import concurrent" << '\n';
}
- f_service_ << "all_structs = []" << endl;
+ f_service_ << "all_structs = []" << '\n';
// Generate the three main parts of the service
generate_service_interface(tservice);
@@ -1261,8 +1259,8 @@
generate_service_remote(tservice);
// Close service file
- f_service_ << "fix_spec(all_structs)" << endl
- << "del all_structs" << endl;
+ f_service_ << "fix_spec(all_structs)" << '\n'
+ << "del all_structs" << '\n';
f_service_.close();
}
@@ -1275,7 +1273,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- f_service_ << endl << "# HELPER FUNCTIONS AND STRUCTURES" << endl;
+ f_service_ << '\n' << "# HELPER FUNCTIONS AND STRUCTURES" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
@@ -1328,12 +1326,12 @@
}
}
- f_service_ << endl << endl << "class Iface" << extends_if << ":" << endl;
+ f_service_ << '\n' << '\n' << "class Iface" << extends_if << ":" << '\n';
indent_up();
generate_python_docstring(f_service_, tservice);
vector<t_function*> functions = tservice->get_functions();
if (functions.empty()) {
- f_service_ << indent() << "pass" << endl;
+ f_service_ << indent() << "pass" << '\n';
} else {
vector<t_function*>::iterator f_iter;
bool first = true;
@@ -1341,12 +1339,12 @@
if (first) {
first = false;
} else {
- f_service_ << endl;
+ f_service_ << '\n';
}
- f_service_ << indent() << "def " << function_signature(*f_iter, true) << ":" << endl;
+ f_service_ << indent() << "def " << function_signature(*f_iter, true) << ":" << '\n';
indent_up();
generate_python_docstring(f_service_, (*f_iter));
- f_service_ << indent() << "pass" << endl;
+ f_service_ << indent() << "pass" << '\n';
indent_down();
}
}
@@ -1375,91 +1373,91 @@
}
}
- f_service_ << endl << endl;
+ f_service_ << '\n' << '\n';
if (gen_zope_interface_) {
- f_service_ << "@implementer(Iface)" << endl
- << "class Client" << extends_client << ":" << endl
- << endl;
+ f_service_ << "@implementer(Iface)" << '\n'
+ << "class Client" << extends_client << ":" << '\n'
+ << '\n';
} else {
- f_service_ << "class Client(" << extends_client << "Iface):" << endl;
+ f_service_ << "class Client(" << extends_client << "Iface):" << '\n';
}
indent_up();
generate_python_docstring(f_service_, tservice);
// Constructor function
if (gen_twisted_) {
- f_service_ << indent() << "def __init__(self, transport, oprot_factory):" << endl;
+ f_service_ << indent() << "def __init__(self, transport, oprot_factory):" << '\n';
} else if (gen_tornado_) {
f_service_ << indent()
- << "def __init__(self, transport, iprot_factory, oprot_factory=None):" << endl;
+ << "def __init__(self, transport, iprot_factory, oprot_factory=None):" << '\n';
} else {
- f_service_ << indent() << "def __init__(self, iprot, oprot=None):" << endl;
+ f_service_ << indent() << "def __init__(self, iprot, oprot=None):" << '\n';
}
indent_up();
if (extends.empty()) {
if (gen_twisted_) {
- f_service_ << indent() << "self._transport = transport" << endl
- << indent() << "self._oprot_factory = oprot_factory" << endl
- << indent() << "self._seqid = 0" << endl
- << indent() << "self._reqs = {}" << endl;
+ f_service_ << indent() << "self._transport = transport" << '\n'
+ << indent() << "self._oprot_factory = oprot_factory" << '\n'
+ << indent() << "self._seqid = 0" << '\n'
+ << indent() << "self._reqs = {}" << '\n';
} else if (gen_tornado_) {
- f_service_ << indent() << "self._transport = transport" << endl
- << indent() << "self._iprot_factory = iprot_factory" << endl
+ f_service_ << indent() << "self._transport = transport" << '\n'
+ << indent() << "self._iprot_factory = iprot_factory" << '\n'
<< indent() << "self._oprot_factory = (oprot_factory if oprot_factory is not None"
- << endl
- << indent() << " else iprot_factory)" << endl
- << indent() << "self._seqid = 0" << endl
- << indent() << "self._reqs = {}" << endl
+ << '\n'
+ << indent() << " else iprot_factory)" << '\n'
+ << indent() << "self._seqid = 0" << '\n'
+ << indent() << "self._reqs = {}" << '\n'
<< indent() << "self._transport.io_loop.spawn_callback(self._start_receiving)"
- << endl;
+ << '\n';
} else {
- f_service_ << indent() << "self._iprot = self._oprot = iprot" << endl
- << indent() << "if oprot is not None:" << endl
- << indent() << indent_str() << "self._oprot = oprot" << endl
- << indent() << "self._seqid = 0" << endl;
+ f_service_ << indent() << "self._iprot = self._oprot = iprot" << '\n'
+ << indent() << "if oprot is not None:" << '\n'
+ << indent() << indent_str() << "self._oprot = oprot" << '\n'
+ << indent() << "self._seqid = 0" << '\n';
}
} else {
if (gen_twisted_) {
f_service_ << indent() << extends
- << ".Client.__init__(self, transport, oprot_factory)" << endl;
+ << ".Client.__init__(self, transport, oprot_factory)" << '\n';
} else if (gen_tornado_) {
f_service_ << indent() << extends
- << ".Client.__init__(self, transport, iprot_factory, oprot_factory)" << endl;
+ << ".Client.__init__(self, transport, iprot_factory, oprot_factory)" << '\n';
} else {
- f_service_ << indent() << extends << ".Client.__init__(self, iprot, oprot)" << endl;
+ f_service_ << indent() << extends << ".Client.__init__(self, iprot, oprot)" << '\n';
}
}
indent_down();
if (gen_tornado_ && extends.empty()) {
- f_service_ << endl <<
- indent() << "@gen.engine" << endl <<
- indent() << "def _start_receiving(self):" << endl;
+ f_service_ << '\n' <<
+ indent() << "@gen.engine" << '\n' <<
+ indent() << "def _start_receiving(self):" << '\n';
indent_up();
- indent(f_service_) << "while True:" << endl;
+ indent(f_service_) << "while True:" << '\n';
indent_up();
- f_service_ << indent() << "try:" << endl
- << indent() << indent_str() << "frame = yield self._transport.readFrame()" << endl
- << indent() << "except TTransport.TTransportException as e:" << endl
- << indent() << indent_str() << "for future in self._reqs.values():" << endl
- << indent() << indent_str() << indent_str() << "future.set_exception(e)" << endl
- << indent() << indent_str() << "self._reqs = {}" << endl
- << indent() << indent_str() << "return" << endl
- << indent() << "tr = TTransport.TMemoryBuffer(frame)" << endl
- << indent() << "iprot = self._iprot_factory.getProtocol(tr)" << endl
- << indent() << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << endl
- << indent() << "method = getattr(self, 'recv_' + fname)" << endl
- << indent() << "future = self._reqs.pop(rseqid, None)" << endl
- << indent() << "if not future:" << endl
- << indent() << indent_str() << "# future has already been discarded" << endl
- << indent() << indent_str() << "continue" << endl
- << indent() << "try:" << endl
- << indent() << indent_str() << "result = method(iprot, mtype, rseqid)" << endl
- << indent() << "except Exception as e:" << endl
- << indent() << indent_str() << "future.set_exception(e)" << endl
- << indent() << "else:" << endl
- << indent() << indent_str() << "future.set_result(result)" << endl;
+ f_service_ << indent() << "try:" << '\n'
+ << indent() << indent_str() << "frame = yield self._transport.readFrame()" << '\n'
+ << indent() << "except TTransport.TTransportException as e:" << '\n'
+ << indent() << indent_str() << "for future in self._reqs.values():" << '\n'
+ << indent() << indent_str() << indent_str() << "future.set_exception(e)" << '\n'
+ << indent() << indent_str() << "self._reqs = {}" << '\n'
+ << indent() << indent_str() << "return" << '\n'
+ << indent() << "tr = TTransport.TMemoryBuffer(frame)" << '\n'
+ << indent() << "iprot = self._iprot_factory.getProtocol(tr)" << '\n'
+ << indent() << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << '\n'
+ << indent() << "method = getattr(self, 'recv_' + fname)" << '\n'
+ << indent() << "future = self._reqs.pop(rseqid, None)" << '\n'
+ << indent() << "if not future:" << '\n'
+ << indent() << indent_str() << "# future has already been discarded" << '\n'
+ << indent() << indent_str() << "continue" << '\n'
+ << indent() << "try:" << '\n'
+ << indent() << indent_str() << "result = method(iprot, mtype, rseqid)" << '\n'
+ << indent() << "except Exception as e:" << '\n'
+ << indent() << indent_str() << "future.set_exception(e)" << '\n'
+ << indent() << "else:" << '\n'
+ << indent() << indent_str() << "future.set_result(result)" << '\n';
indent_down();
indent_down();
}
@@ -1473,20 +1471,20 @@
vector<t_field*>::const_iterator fld_iter;
string funname = (*f_iter)->get_name();
- f_service_ << endl;
+ f_service_ << '\n';
// Open function
- indent(f_service_) << "def " << function_signature(*f_iter, false) << ":" << endl;
+ indent(f_service_) << "def " << function_signature(*f_iter, false) << ":" << '\n';
indent_up();
generate_python_docstring(f_service_, (*f_iter));
if (gen_twisted_) {
- indent(f_service_) << "seqid = self._seqid = self._seqid + 1" << endl;
- indent(f_service_) << "self._reqs[seqid] = defer.Deferred()" << endl << endl;
+ indent(f_service_) << "seqid = self._seqid = self._seqid + 1" << '\n';
+ indent(f_service_) << "self._reqs[seqid] = defer.Deferred()" << '\n' << '\n';
indent(f_service_) << "d = defer.maybeDeferred(self.send_" << funname;
} else if (gen_tornado_) {
- indent(f_service_) << "self._seqid += 1" << endl;
+ indent(f_service_) << "self._seqid += 1" << '\n';
if (!(*f_iter)->is_oneway()) {
- indent(f_service_) << "future = self._reqs[self._seqid] = concurrent.Future()" << endl;
+ indent(f_service_) << "future = self._reqs[self._seqid] = concurrent.Future()" << '\n';
}
indent(f_service_) << "self.send_" << funname << "(";
@@ -1509,19 +1507,19 @@
f_service_ << (*fld_iter)->get_name();
}
- f_service_ << ")" << endl;
+ f_service_ << ")" << '\n';
if (!(*f_iter)->is_oneway()) {
if (gen_twisted_) {
// nothing. See the next block.
} else if (gen_tornado_) {
- indent(f_service_) << "return future" << endl;
+ indent(f_service_) << "return future" << '\n';
} else {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
- f_service_ << "self.recv_" << funname << "()" << endl;
+ f_service_ << "self.recv_" << funname << "()" << '\n';
}
}
indent_down();
@@ -1529,40 +1527,40 @@
if (gen_twisted_) {
// This block injects the body of the send_<> method for twisted (and a cb/eb pair)
indent_up();
- indent(f_service_) << "d.addCallbacks(" << endl;
+ indent(f_service_) << "d.addCallbacks(" << '\n';
indent_up();
- f_service_ << indent() << "callback=self.cb_send_" << funname << "," << endl << indent()
- << "callbackArgs=(seqid,)," << endl << indent() << "errback=self.eb_send_"
- << funname << "," << endl << indent() << "errbackArgs=(seqid,))" << endl;
+ f_service_ << indent() << "callback=self.cb_send_" << funname << "," << '\n' << indent()
+ << "callbackArgs=(seqid,)," << '\n' << indent() << "errback=self.eb_send_"
+ << funname << "," << '\n' << indent() << "errbackArgs=(seqid,))" << '\n';
indent_down();
- indent(f_service_) << "return d" << endl;
+ indent(f_service_) << "return d" << '\n';
indent_down();
- f_service_ << endl;
+ f_service_ << '\n';
- indent(f_service_) << "def cb_send_" << funname << "(self, _, seqid):" << endl;
+ indent(f_service_) << "def cb_send_" << funname << "(self, _, seqid):" << '\n';
indent_up();
if ((*f_iter)->is_oneway()) {
// if one-way, fire the deferred & remove it from _reqs
- f_service_ << indent() << "d = self._reqs.pop(seqid)" << endl << indent()
- << "d.callback(None)" << endl << indent() << "return d" << endl;
+ f_service_ << indent() << "d = self._reqs.pop(seqid)" << '\n' << indent()
+ << "d.callback(None)" << '\n' << indent() << "return d" << '\n';
} else {
- f_service_ << indent() << "return self._reqs[seqid]" << endl;
+ f_service_ << indent() << "return self._reqs[seqid]" << '\n';
}
indent_down();
- f_service_ << endl;
+ f_service_ << '\n';
// add an errback to fail the request if the call to send_<> raised an exception
- indent(f_service_) << "def eb_send_" << funname << "(self, f, seqid):" << endl;
+ indent(f_service_) << "def eb_send_" << funname << "(self, f, seqid):" << '\n';
indent_up();
- f_service_ << indent() << "d = self._reqs.pop(seqid)" << endl << indent() << "d.errback(f)"
- << endl << indent() << "return d" << endl;
+ f_service_ << indent() << "d = self._reqs.pop(seqid)" << '\n' << indent() << "d.errback(f)"
+ << '\n' << indent() << "return d" << '\n';
indent_down();
}
- f_service_ << endl;
- indent(f_service_) << "def send_" << function_signature(*f_iter, false) << ":" << endl;
+ f_service_ << '\n';
+ indent(f_service_) << "def send_" << function_signature(*f_iter, false) << ":" << '\n';
indent_up();
std::string argsname = (*f_iter)->get_name() + "_args";
@@ -1570,29 +1568,29 @@
// Serialize the request header
if (gen_twisted_ || gen_tornado_) {
- f_service_ << indent() << "oprot = self._oprot_factory.getProtocol(self._transport)" << endl
+ f_service_ << indent() << "oprot = self._oprot_factory.getProtocol(self._transport)" << '\n'
<< indent() << "oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', "
- << messageType << ", self._seqid)" << endl;
+ << messageType << ", self._seqid)" << '\n';
} else {
f_service_ << indent() << "self._oprot.writeMessageBegin('" << (*f_iter)->get_name() << "', "
- << messageType << ", self._seqid)" << endl;
+ << messageType << ", self._seqid)" << '\n';
}
- f_service_ << indent() << "args = " << argsname << "()" << endl;
+ f_service_ << indent() << "args = " << argsname << "()" << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << "args." << (*fld_iter)->get_name() << " = "
- << (*fld_iter)->get_name() << endl;
+ << (*fld_iter)->get_name() << '\n';
}
// Write to the stream
if (gen_twisted_ || gen_tornado_) {
- f_service_ << indent() << "args.write(oprot)" << endl << indent() << "oprot.writeMessageEnd()"
- << endl << indent() << "oprot.trans.flush()" << endl;
+ f_service_ << indent() << "args.write(oprot)" << '\n' << indent() << "oprot.writeMessageEnd()"
+ << '\n' << indent() << "oprot.trans.flush()" << '\n';
} else {
- f_service_ << indent() << "args.write(self._oprot)" << endl << indent()
- << "self._oprot.writeMessageEnd()" << endl << indent()
- << "self._oprot.trans.flush()" << endl;
+ f_service_ << indent() << "args.write(self._oprot)" << '\n' << indent()
+ << "self._oprot.writeMessageEnd()" << '\n' << indent()
+ << "self._oprot.trans.flush()" << '\n';
}
indent_down();
@@ -1600,51 +1598,51 @@
if (!(*f_iter)->is_oneway()) {
std::string resultname = (*f_iter)->get_name() + "_result";
// Open function
- f_service_ << endl;
+ f_service_ << '\n';
if (gen_twisted_ || gen_tornado_) {
f_service_ << indent() << "def recv_" << (*f_iter)->get_name()
- << "(self, iprot, mtype, rseqid):" << endl;
+ << "(self, iprot, mtype, rseqid):" << '\n';
} else {
t_struct noargs(program_);
t_function recv_function((*f_iter)->get_returntype(),
string("recv_") + (*f_iter)->get_name(),
&noargs);
- f_service_ << indent() << "def " << function_signature(&recv_function) << ":" << endl;
+ f_service_ << indent() << "def " << function_signature(&recv_function) << ":" << '\n';
}
indent_up();
// TODO(mcslee): Validate message reply here, seq ids etc.
if (gen_twisted_) {
- f_service_ << indent() << "d = self._reqs.pop(rseqid)" << endl;
+ f_service_ << indent() << "d = self._reqs.pop(rseqid)" << '\n';
} else if (gen_tornado_) {
} else {
- f_service_ << indent() << "iprot = self._iprot" << endl << indent()
- << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << endl;
+ f_service_ << indent() << "iprot = self._iprot" << '\n' << indent()
+ << "(fname, mtype, rseqid) = iprot.readMessageBegin()" << '\n';
}
- f_service_ << indent() << "if mtype == TMessageType.EXCEPTION:" << endl
- << indent() << indent_str() << "x = TApplicationException()" << endl;
+ f_service_ << indent() << "if mtype == TMessageType.EXCEPTION:" << '\n'
+ << indent() << indent_str() << "x = TApplicationException()" << '\n';
if (gen_twisted_) {
- f_service_ << indent() << indent_str() << "x.read(iprot)" << endl << indent()
- << indent_str() << "iprot.readMessageEnd()" << endl << indent() << indent_str() << "return d.errback(x)"
- << endl << indent() << "result = " << resultname << "()" << endl << indent()
- << "result.read(iprot)" << endl << indent() << "iprot.readMessageEnd()" << endl;
+ f_service_ << indent() << indent_str() << "x.read(iprot)" << '\n' << indent()
+ << indent_str() << "iprot.readMessageEnd()" << '\n' << indent() << indent_str() << "return d.errback(x)"
+ << '\n' << indent() << "result = " << resultname << "()" << '\n' << indent()
+ << "result.read(iprot)" << '\n' << indent() << "iprot.readMessageEnd()" << '\n';
} else {
- f_service_ << indent() << indent_str() << "x.read(iprot)" << endl << indent()
- << indent_str() << "iprot.readMessageEnd()" << endl << indent() << indent_str() << "raise x" << endl
- << indent() << "result = " << resultname << "()" << endl << indent()
- << "result.read(iprot)" << endl << indent() << "iprot.readMessageEnd()" << endl;
+ f_service_ << indent() << indent_str() << "x.read(iprot)" << '\n' << indent()
+ << indent_str() << "iprot.readMessageEnd()" << '\n' << indent() << indent_str() << "raise x" << '\n'
+ << indent() << "result = " << resultname << "()" << '\n' << indent()
+ << "result.read(iprot)" << '\n' << indent() << "iprot.readMessageEnd()" << '\n';
}
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_ << indent() << "if result.success is not None:" << endl;
+ f_service_ << indent() << "if result.success is not None:" << '\n';
if (gen_twisted_) {
- f_service_ << indent() << indent_str() << "return d.callback(result.success)" << endl;
+ f_service_ << indent() << indent_str() << "return d.callback(result.success)" << '\n';
} else {
- f_service_ << indent() << indent_str() << "return result.success" << endl;
+ f_service_ << indent() << indent_str() << "return result.success" << '\n';
}
}
@@ -1653,32 +1651,32 @@
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
const string& xname = (*x_iter)->get_name();
- f_service_ << indent() << "if result." << xname << " is not None:" << endl;
+ f_service_ << indent() << "if result." << xname << " is not None:" << '\n';
if (gen_twisted_) {
f_service_ << indent() << indent_str() << "return d.errback(result." << xname << ")"
- << endl;
+ << '\n';
} else {
- f_service_ << indent() << indent_str() << "raise result." << xname << "" << endl;
+ f_service_ << indent() << indent_str() << "raise result." << xname << "" << '\n';
}
}
// Careful, only return _result if not a void function
if ((*f_iter)->get_returntype()->is_void()) {
if (gen_twisted_) {
- f_service_ << indent() << "return d.callback(None)" << endl;
+ f_service_ << indent() << "return d.callback(None)" << '\n';
} else {
- f_service_ << indent() << "return" << endl;
+ f_service_ << indent() << "return" << '\n';
}
} else {
if (gen_twisted_) {
f_service_
<< indent()
<< "return d.errback(TApplicationException(TApplicationException.MISSING_RESULT, \""
- << (*f_iter)->get_name() << " failed: unknown result\"))" << endl;
+ << (*f_iter)->get_name() << " failed: unknown result\"))" << '\n';
} else {
f_service_ << indent()
<< "raise TApplicationException(TApplicationException.MISSING_RESULT, \""
- << (*f_iter)->get_name() << " failed: unknown result\")" << endl;
+ << (*f_iter)->get_name() << " failed: unknown result\")" << '\n';
}
}
@@ -1711,29 +1709,27 @@
f_remote.open(f_remote_name.c_str());
f_remote <<
- "#!/usr/bin/env python" << endl <<
- py_autogen_comment() << endl <<
- "import sys" << endl <<
- "import pprint" << endl <<
- "if sys.version_info[0] > 2:" << endl <<
- indent_str() << "from urllib.parse import urlparse" << endl <<
- "else:" << endl <<
- indent_str() << "from urlparse import urlparse" << endl <<
- "from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient" << endl <<
- "from thrift.protocol.TBinaryProtocol import TBinaryProtocol" << endl <<
- endl;
+ "#!/usr/bin/env python" << '\n' <<
+ py_autogen_comment() << '\n' <<
+ "import sys" << '\n' <<
+ "import pprint" << '\n' <<
+ "if sys.version_info[0] > 2:" << '\n' <<
+ indent_str() << "from urllib.parse import urlparse" << '\n' <<
+ "else:" << '\n' <<
+ indent_str() << "from urlparse import urlparse" << '\n' <<
+ "from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient" << '\n' <<
+ "from thrift.protocol.TBinaryProtocol import TBinaryProtocol" << '\n' << '\n';
f_remote <<
- "from " << module_ << " import " << service_name_ << endl <<
- "from " << module_ << ".ttypes import *" << endl <<
- endl;
+ "from " << module_ << " import " << service_name_ << '\n' <<
+ "from " << module_ << ".ttypes import *" << '\n' << '\n';
f_remote <<
- "if len(sys.argv) <= 1 or sys.argv[1] == '--help':" << endl <<
- indent_str() << "print('')" << endl <<
- indent_str() << "print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]')" << endl <<
- indent_str() << "print('')" << endl <<
- indent_str() << "print('Functions:')" << endl;
+ "if len(sys.argv) <= 1 or sys.argv[1] == '--help':" << '\n' <<
+ indent_str() << "print('')" << '\n' <<
+ indent_str() << "print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]')" << '\n' <<
+ indent_str() << "print('')" << '\n' <<
+ indent_str() << "print('Functions:')" << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
f_remote << indent_str() << "print(' " << (*f_iter)->get_returntype()->get_name() << " "
<< (*f_iter)->get_name() << "(";
@@ -1749,88 +1745,88 @@
}
f_remote << args[i]->get_type()->get_name() << " " << args[i]->get_name();
}
- f_remote << ")')" << endl;
+ f_remote << ")')" << '\n';
}
- f_remote << indent_str() << "print('')" << endl << indent_str() << "sys.exit(0)" << endl << endl;
+ f_remote << indent_str() << "print('')" << '\n' << indent_str() << "sys.exit(0)" << '\n' << '\n';
- f_remote << "pp = pprint.PrettyPrinter(indent=2)" << endl
- << "host = 'localhost'" << endl
- << "port = 9090" << endl
- << "uri = ''" << endl
- << "framed = False" << endl
- << "ssl = False" << endl
- << "validate = True" << endl
- << "ca_certs = None" << endl
- << "keyfile = None" << endl
- << "certfile = None" << endl
- << "http = False" << endl
- << "argi = 1" << endl
- << endl
- << "if sys.argv[argi] == '-h':" << endl
- << indent_str() << "parts = sys.argv[argi + 1].split(':')" << endl
- << indent_str() << "host = parts[0]" << endl
- << indent_str() << "if len(parts) > 1:" << endl
- << indent_str() << indent_str() << "port = int(parts[1])" << endl
- << indent_str() << "argi += 2" << endl
- << endl
- << "if sys.argv[argi] == '-u':" << endl
- << indent_str() << "url = urlparse(sys.argv[argi + 1])" << endl
- << indent_str() << "parts = url[1].split(':')" << endl
- << indent_str() << "host = parts[0]" << endl
- << indent_str() << "if len(parts) > 1:" << endl
- << indent_str() << indent_str() << "port = int(parts[1])" << endl
- << indent_str() << "else:" << endl
- << indent_str() << indent_str() << "port = 80" << endl
- << indent_str() << "uri = url[2]" << endl
- << indent_str() << "if url[4]:" << endl
- << indent_str() << indent_str() << "uri += '?%s' % url[4]" << endl
- << indent_str() << "http = True" << endl
- << indent_str() << "argi += 2" << endl
- << endl
- << "if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':" << endl
- << indent_str() << "framed = True" << endl
- << indent_str() << "argi += 1" << endl
- << endl
- << "if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':" << endl
- << indent_str() << "ssl = True" << endl
- << indent_str() << "argi += 1" << endl
- << endl
- << "if sys.argv[argi] == '-novalidate':" << endl
- << indent_str() << "validate = False" << endl
- << indent_str() << "argi += 1" << endl
- << endl
- << "if sys.argv[argi] == '-ca_certs':" << endl
- << indent_str() << "ca_certs = sys.argv[argi+1]" << endl
- << indent_str() << "argi += 2" << endl
- << endl
- << "if sys.argv[argi] == '-keyfile':" << endl
- << indent_str() << "keyfile = sys.argv[argi+1]" << endl
- << indent_str() << "argi += 2" << endl
- << endl
- << "if sys.argv[argi] == '-certfile':" << endl
- << indent_str() << "certfile = sys.argv[argi+1]" << endl
- << indent_str() << "argi += 2" << endl
- << endl
- << "cmd = sys.argv[argi]" << endl
- << "args = sys.argv[argi + 1:]" << endl
- << endl
- << "if http:" << endl
- << indent_str() << "transport = THttpClient.THttpClient(host, port, uri)" << endl
- << "else:" << endl
- << indent_str() << "if ssl:" << endl
+ f_remote << "pp = pprint.PrettyPrinter(indent=2)" << '\n'
+ << "host = 'localhost'" << '\n'
+ << "port = 9090" << '\n'
+ << "uri = ''" << '\n'
+ << "framed = False" << '\n'
+ << "ssl = False" << '\n'
+ << "validate = True" << '\n'
+ << "ca_certs = None" << '\n'
+ << "keyfile = None" << '\n'
+ << "certfile = None" << '\n'
+ << "http = False" << '\n'
+ << "argi = 1" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-h':" << '\n'
+ << indent_str() << "parts = sys.argv[argi + 1].split(':')" << '\n'
+ << indent_str() << "host = parts[0]" << '\n'
+ << indent_str() << "if len(parts) > 1:" << '\n'
+ << indent_str() << indent_str() << "port = int(parts[1])" << '\n'
+ << indent_str() << "argi += 2" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-u':" << '\n'
+ << indent_str() << "url = urlparse(sys.argv[argi + 1])" << '\n'
+ << indent_str() << "parts = url[1].split(':')" << '\n'
+ << indent_str() << "host = parts[0]" << '\n'
+ << indent_str() << "if len(parts) > 1:" << '\n'
+ << indent_str() << indent_str() << "port = int(parts[1])" << '\n'
+ << indent_str() << "else:" << '\n'
+ << indent_str() << indent_str() << "port = 80" << '\n'
+ << indent_str() << "uri = url[2]" << '\n'
+ << indent_str() << "if url[4]:" << '\n'
+ << indent_str() << indent_str() << "uri += '?%s' % url[4]" << '\n'
+ << indent_str() << "http = True" << '\n'
+ << indent_str() << "argi += 2" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':" << '\n'
+ << indent_str() << "framed = True" << '\n'
+ << indent_str() << "argi += 1" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':" << '\n'
+ << indent_str() << "ssl = True" << '\n'
+ << indent_str() << "argi += 1" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-novalidate':" << '\n'
+ << indent_str() << "validate = False" << '\n'
+ << indent_str() << "argi += 1" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-ca_certs':" << '\n'
+ << indent_str() << "ca_certs = sys.argv[argi+1]" << '\n'
+ << indent_str() << "argi += 2" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-keyfile':" << '\n'
+ << indent_str() << "keyfile = sys.argv[argi+1]" << '\n'
+ << indent_str() << "argi += 2" << '\n'
+ << '\n'
+ << "if sys.argv[argi] == '-certfile':" << '\n'
+ << indent_str() << "certfile = sys.argv[argi+1]" << '\n'
+ << indent_str() << "argi += 2" << '\n'
+ << '\n'
+ << "cmd = sys.argv[argi]" << '\n'
+ << "args = sys.argv[argi + 1:]" << '\n'
+ << '\n'
+ << "if http:" << '\n'
+ << indent_str() << "transport = THttpClient.THttpClient(host, port, uri)" << '\n'
+ << "else:" << '\n'
+ << indent_str() << "if ssl:" << '\n'
<< indent_str() << indent_str() << "socket = TSSLSocket.TSSLSocket(host, port, "
"validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile)"
- << endl
- << indent_str() << "else:" << endl
- << indent_str() << indent_str() << "socket = TSocket.TSocket(host, port)" << endl
- << indent_str() << "if framed:" << endl
- << indent_str() << indent_str() << "transport = TTransport.TFramedTransport(socket)" << endl
- << indent_str() << "else:" << endl
- << indent_str() << indent_str() << "transport = TTransport.TBufferedTransport(socket)" << endl
- << "protocol = TBinaryProtocol(transport)" << endl
- << "client = " << service_name_ << ".Client(protocol)" << endl
- << "transport.open()" << endl
- << endl;
+ << '\n'
+ << indent_str() << "else:" << '\n'
+ << indent_str() << indent_str() << "socket = TSocket.TSocket(host, port)" << '\n'
+ << indent_str() << "if framed:" << '\n'
+ << indent_str() << indent_str() << "transport = TTransport.TFramedTransport(socket)" << '\n'
+ << indent_str() << "else:" << '\n'
+ << indent_str() << indent_str() << "transport = TTransport.TBufferedTransport(socket)" << '\n'
+ << "protocol = TBinaryProtocol(transport)" << '\n'
+ << "client = " << service_name_ << ".Client(protocol)" << '\n'
+ << "transport.open()" << '\n'
+ << '\n';
// Generate the dispatch methods
bool first = true;
@@ -1846,12 +1842,12 @@
const std::vector<t_field*>& args = arg_struct->get_members();
std::vector<t_field*>::size_type num_args = args.size();
- f_remote << "if cmd == '" << (*f_iter)->get_name() << "':" << endl;
+ f_remote << "if cmd == '" << (*f_iter)->get_name() << "':" << '\n';
indent_up();
- f_remote << indent() << "if len(args) != " << num_args << ":" << endl
+ f_remote << indent() << "if len(args) != " << num_args << ":" << '\n'
<< indent() << indent_str() << "print('" << (*f_iter)->get_name() << " requires " << num_args
- << " args')" << endl
- << indent() << indent_str() << "sys.exit(1)" << endl
+ << " args')" << '\n'
+ << indent() << indent_str() << "sys.exit(1)" << '\n'
<< indent() << "pp.pprint(client." << (*f_iter)->get_name() << "(";
indent_down();
bool first_arg = true;
@@ -1866,19 +1862,19 @@
f_remote << "eval(args[" << i << "]),";
}
}
- f_remote << "))" << endl;
+ f_remote << "))" << '\n';
- f_remote << endl;
+ f_remote << '\n';
}
if (functions.size() > 0) {
- f_remote << "else:" << endl;
- f_remote << indent_str() << "print('Unrecognized method %s' % cmd)" << endl;
- f_remote << indent_str() << "sys.exit(1)" << endl;
- f_remote << endl;
+ f_remote << "else:" << '\n';
+ f_remote << indent_str() << "print('Unrecognized method %s' % cmd)" << '\n';
+ f_remote << indent_str() << "sys.exit(1)" << '\n';
+ f_remote << '\n';
}
- f_remote << "transport.close()" << endl;
+ f_remote << "transport.close()" << '\n';
// Close service file
f_remote.close();
@@ -1913,100 +1909,100 @@
extends_processor = extends + ".Processor, ";
}
- f_service_ << endl << endl;
+ f_service_ << '\n' << '\n';
// Generate the header portion
if (gen_zope_interface_) {
- f_service_ << "@implementer(Iface)" << endl
- << "class Processor(" << extends_processor << "TProcessor):" << endl;
+ f_service_ << "@implementer(Iface)" << '\n'
+ << "class Processor(" << extends_processor << "TProcessor):" << '\n';
} else {
- f_service_ << "class Processor(" << extends_processor << "Iface, TProcessor):" << endl;
+ f_service_ << "class Processor(" << extends_processor << "Iface, TProcessor):" << '\n';
}
indent_up();
- indent(f_service_) << "def __init__(self, handler):" << endl;
+ indent(f_service_) << "def __init__(self, handler):" << '\n';
indent_up();
if (extends.empty()) {
if (gen_zope_interface_) {
- f_service_ << indent() << "self._handler = Iface(handler)" << endl;
+ f_service_ << indent() << "self._handler = Iface(handler)" << '\n';
} else {
- f_service_ << indent() << "self._handler = handler" << endl;
+ f_service_ << indent() << "self._handler = handler" << '\n';
}
- f_service_ << indent() << "self._processMap = {}" << endl;
+ f_service_ << indent() << "self._processMap = {}" << '\n';
} else {
if (gen_zope_interface_) {
- f_service_ << indent() << extends << ".Processor.__init__(self, Iface(handler))" << endl;
+ f_service_ << indent() << extends << ".Processor.__init__(self, Iface(handler))" << '\n';
} else {
- f_service_ << indent() << extends << ".Processor.__init__(self, handler)" << endl;
+ f_service_ << indent() << extends << ".Processor.__init__(self, handler)" << '\n';
}
}
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
f_service_ << indent() << "self._processMap[\"" << (*f_iter)->get_name()
- << "\"] = Processor.process_" << (*f_iter)->get_name() << endl;
+ << "\"] = Processor.process_" << (*f_iter)->get_name() << '\n';
}
- f_service_ << indent() << "self._on_message_begin = None" << endl;
+ f_service_ << indent() << "self._on_message_begin = None" << '\n';
indent_down();
- f_service_ << endl;
+ f_service_ << '\n';
- f_service_ << indent() << "def on_message_begin(self, func):" << endl;
+ f_service_ << indent() << "def on_message_begin(self, func):" << '\n';
indent_up();
- f_service_ << indent() << "self._on_message_begin = func" << endl;
+ f_service_ << indent() << "self._on_message_begin = func" << '\n';
indent_down();
- f_service_ << endl;
+ f_service_ << '\n';
// Generate the server implementation
- f_service_ << indent() << "def process(self, iprot, oprot):" << endl;
+ f_service_ << indent() << "def process(self, iprot, oprot):" << '\n';
indent_up();
- f_service_ << indent() << "(name, type, seqid) = iprot.readMessageBegin()" << endl;
- f_service_ << indent() << "if self._on_message_begin:" << endl;
+ f_service_ << indent() << "(name, type, seqid) = iprot.readMessageBegin()" << '\n';
+ f_service_ << indent() << "if self._on_message_begin:" << '\n';
indent_up();
- f_service_ << indent() << "self._on_message_begin(name, type, seqid)" << endl;
+ f_service_ << indent() << "self._on_message_begin(name, type, seqid)" << '\n';
indent_down();
// TODO(mcslee): validate message
// HOT: dictionary function lookup
- f_service_ << indent() << "if name not in self._processMap:" << endl;
+ f_service_ << indent() << "if name not in self._processMap:" << '\n';
indent_up();
- f_service_ << indent() << "iprot.skip(TType.STRUCT)" << endl
- << indent() << "iprot.readMessageEnd()" << endl
+ f_service_ << indent() << "iprot.skip(TType.STRUCT)" << '\n'
+ << indent() << "iprot.readMessageEnd()" << '\n'
<< indent()
<< "x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown "
"function %s' % (name))"
- << endl
- << indent() << "oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)" << endl
- << indent() << "x.write(oprot)" << endl
- << indent() << "oprot.writeMessageEnd()" << endl
- << indent() << "oprot.trans.flush()" << endl;
+ << '\n'
+ << indent() << "oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)" << '\n'
+ << indent() << "x.write(oprot)" << '\n'
+ << indent() << "oprot.writeMessageEnd()" << '\n'
+ << indent() << "oprot.trans.flush()" << '\n';
if (gen_twisted_) {
- f_service_ << indent() << "return defer.succeed(None)" << endl;
+ f_service_ << indent() << "return defer.succeed(None)" << '\n';
} else {
- f_service_ << indent() << "return" << endl;
+ f_service_ << indent() << "return" << '\n';
}
indent_down();
- f_service_ << indent() << "else:" << endl;
+ f_service_ << indent() << "else:" << '\n';
if (gen_twisted_ || gen_tornado_) {
f_service_ << indent() << indent_str()
- << "return self._processMap[name](self, seqid, iprot, oprot)" << endl;
+ << "return self._processMap[name](self, seqid, iprot, oprot)" << '\n';
} else {
f_service_ << indent() << indent_str() << "self._processMap[name](self, seqid, iprot, oprot)"
- << endl;
+ << '\n';
// Read end of args field, the T_STOP, and the struct close
- f_service_ << indent() << "return True" << endl;
+ f_service_ << indent() << "return True" << '\n';
}
indent_down();
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- f_service_ << endl;
+ f_service_ << '\n';
generate_process_function(tservice, *f_iter);
}
@@ -2022,11 +2018,11 @@
(void)tservice;
// Open function
if (gen_tornado_) {
- f_service_ << indent() << "@gen.coroutine" << endl << indent() << "def process_"
- << tfunction->get_name() << "(self, seqid, iprot, oprot):" << endl;
+ f_service_ << indent() << "@gen.coroutine" << '\n' << indent() << "def process_"
+ << tfunction->get_name() << "(self, seqid, iprot, oprot):" << '\n';
} else {
f_service_ << indent() << "def process_" << tfunction->get_name()
- << "(self, seqid, iprot, oprot):" << endl;
+ << "(self, seqid, iprot, oprot):" << '\n';
}
indent_up();
@@ -2034,8 +2030,8 @@
string argsname = tfunction->get_name() + "_args";
string resultname = tfunction->get_name() + "_result";
- f_service_ << indent() << "args = " << argsname << "()" << endl << indent() << "args.read(iprot)"
- << endl << indent() << "iprot.readMessageEnd()" << endl;
+ f_service_ << indent() << "args = " << argsname << "()" << '\n' << indent() << "args.read(iprot)"
+ << '\n' << indent() << "iprot.readMessageEnd()" << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -2043,7 +2039,7 @@
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "result = " << resultname << "()" << endl;
+ f_service_ << indent() << "result = " << resultname << "()" << '\n';
}
if (gen_twisted_) {
@@ -2063,85 +2059,85 @@
}
f_service_ << "args." << (*f_iter)->get_name();
}
- f_service_ << ")" << endl;
+ f_service_ << ")" << '\n';
if (tfunction->is_oneway()) {
f_service_ << indent() << "d.addErrback(self.handle_exception_" << tfunction->get_name()
- << ", seqid)" << endl;
+ << ", seqid)" << '\n';
} else {
f_service_ << indent() << "d.addCallback(self.write_results_success_" << tfunction->get_name()
- << ", result, seqid, oprot)" << endl
+ << ", result, seqid, oprot)" << '\n'
<< indent() << "d.addErrback(self.write_results_exception_"
- << tfunction->get_name() << ", result, seqid, oprot)" << endl;
+ << tfunction->get_name() << ", result, seqid, oprot)" << '\n';
}
- f_service_ << indent() << "return d" << endl << endl;
+ f_service_ << indent() << "return d" << '\n' << '\n';
indent_down();
if (tfunction->is_oneway()) {
indent(f_service_) << "def handle_exception_" << tfunction->get_name()
- << "(self, error, seqid):" << endl;
+ << "(self, error, seqid):" << '\n';
} else {
indent(f_service_) << "def write_results_success_" << tfunction->get_name()
- << "(self, success, result, seqid, oprot):" << endl;
+ << "(self, success, result, seqid, oprot):" << '\n';
indent_up();
if (!tfunction->get_returntype()->is_void()) {
- f_service_ << indent() << "result.success = success" << endl;
+ f_service_ << indent() << "result.success = success" << '\n';
}
f_service_ << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name()
- << "\", TMessageType.REPLY, seqid)" << endl
- << indent() << "result.write(oprot)" << endl
- << indent() << "oprot.writeMessageEnd()" << endl
- << indent() << "oprot.trans.flush()" << endl
- << endl;
+ << "\", TMessageType.REPLY, seqid)" << '\n'
+ << indent() << "result.write(oprot)" << '\n'
+ << indent() << "oprot.writeMessageEnd()" << '\n'
+ << indent() << "oprot.trans.flush()" << '\n'
+ << '\n';
indent_down();
indent(f_service_) << "def write_results_exception_" << tfunction->get_name()
- << "(self, error, result, seqid, oprot):" << endl;
+ << "(self, error, result, seqid, oprot):" << '\n';
}
indent_up();
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "msg_type = TMessageType.REPLY" << endl;
+ f_service_ << indent() << "msg_type = TMessageType.REPLY" << '\n';
}
- f_service_ << indent() << "try:" << endl;
+ f_service_ << indent() << "try:" << '\n';
// Kinda absurd
- f_service_ << indent() << indent_str() << "error.raiseException()" << endl;
+ f_service_ << indent() << indent_str() << "error.raiseException()" << '\n';
if (!tfunction->is_oneway()) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
const string& xname = (*x_iter)->get_name();
f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << " as " << xname
- << ":" << endl;
+ << ":" << '\n';
indent_up();
- f_service_ << indent() << "result." << xname << " = " << xname << endl;
+ f_service_ << indent() << "result." << xname << " = " << xname << '\n';
indent_down();
}
}
- f_service_ << indent() << "except TTransport.TTransportException:" << endl
- << indent() << indent_str() << "raise" << endl;
+ f_service_ << indent() << "except TTransport.TTransportException:" << '\n'
+ << indent() << indent_str() << "raise" << '\n';
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "except TApplicationException as ex:" << endl
+ f_service_ << indent() << "except TApplicationException as ex:" << '\n'
<< indent() << indent_str()
- << "logging.exception('TApplication exception in handler')" << endl
- << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl
- << indent() << indent_str() << "result = ex" << endl
- << indent() << "except Exception:" << endl
+ << "logging.exception('TApplication exception in handler')" << '\n'
+ << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n'
+ << indent() << indent_str() << "result = ex" << '\n'
+ << indent() << "except Exception:" << '\n'
<< indent() << indent_str()
- << "logging.exception('Unexpected exception in handler')" << endl
- << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl
+ << "logging.exception('Unexpected exception in handler')" << '\n'
+ << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n'
<< indent() << indent_str()
<< "result = TApplicationException(TApplicationException.INTERNAL_ERROR, "
"'Internal error')"
- << endl
+ << '\n'
<< indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name()
- << "\", msg_type, seqid)" << endl
- << indent() << "result.write(oprot)" << endl
- << indent() << "oprot.writeMessageEnd()" << endl
- << indent() << "oprot.trans.flush()" << endl;
+ << "\", msg_type, seqid)" << '\n'
+ << indent() << "result.write(oprot)" << '\n'
+ << indent() << "oprot.writeMessageEnd()" << '\n'
+ << indent() << "oprot.trans.flush()" << '\n';
} else {
- f_service_ << indent() << "except Exception:" << endl
+ f_service_ << indent() << "except Exception:" << '\n'
<< indent() << indent_str()
- << "logging.exception('Exception in oneway handler')" << endl;
+ << "logging.exception('Exception in oneway handler')" << '\n';
}
indent_down();
@@ -2152,9 +2148,9 @@
vector<t_field*>::const_iterator f_iter;
if (!tfunction->is_oneway()) {
- indent(f_service_) << "msg_type = TMessageType.REPLY" << endl;
+ indent(f_service_) << "msg_type = TMessageType.REPLY" << '\n';
}
- f_service_ << indent() << "try:" << endl;
+ f_service_ << indent() << "try:" << '\n';
indent_up();
f_service_ << indent();
if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
@@ -2170,45 +2166,45 @@
}
f_service_ << "args." << (*f_iter)->get_name();
}
- f_service_ << "))" << endl;
+ f_service_ << "))" << '\n';
indent_down();
if (!tfunction->is_oneway()) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
const string& xname = (*x_iter)->get_name();
f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << " as " << xname
- << ":" << endl
- << indent() << indent_str() << "result." << xname << " = " << xname << endl;
+ << ":" << '\n'
+ << indent() << indent_str() << "result." << xname << " = " << xname << '\n';
}
}
- f_service_ << indent() << "except TTransport.TTransportException:" << endl
- << indent() << indent_str() << "raise" << endl;
+ f_service_ << indent() << "except TTransport.TTransportException:" << '\n'
+ << indent() << indent_str() << "raise" << '\n';
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "except TApplicationException as ex:" << endl
+ f_service_ << indent() << "except TApplicationException as ex:" << '\n'
<< indent() << indent_str()
- << "logging.exception('TApplication exception in handler')" << endl
- << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl
- << indent() << indent_str() << "result = ex" << endl
- << indent() << "except Exception:" << endl
+ << "logging.exception('TApplication exception in handler')" << '\n'
+ << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n'
+ << indent() << indent_str() << "result = ex" << '\n'
+ << indent() << "except Exception:" << '\n'
<< indent() << indent_str()
- << "logging.exception('Unexpected exception in handler')" << endl
- << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl
+ << "logging.exception('Unexpected exception in handler')" << '\n'
+ << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n'
<< indent() << indent_str()
<< "result = TApplicationException(TApplicationException.INTERNAL_ERROR, "
"'Internal error')"
- << endl;
+ << '\n';
} else {
- f_service_ << indent() << "except Exception:" << endl
+ f_service_ << indent() << "except Exception:" << '\n'
<< indent() << indent_str()
- << "logging.exception('Exception in oneway handler')" << endl;
+ << "logging.exception('Exception in oneway handler')" << '\n';
}
if (!tfunction->is_oneway()) {
f_service_ << indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name()
- << "\", msg_type, seqid)" << endl
- << indent() << "result.write(oprot)" << endl
- << indent() << "oprot.writeMessageEnd()" << endl
- << indent() << "oprot.trans.flush()" << endl;
+ << "\", msg_type, seqid)" << '\n'
+ << indent() << "result.write(oprot)" << '\n'
+ << indent() << "oprot.writeMessageEnd()" << '\n'
+ << indent() << "oprot.trans.flush()" << '\n';
}
// Close function
@@ -2217,7 +2213,7 @@
} else { // py
// Try block for a function with exceptions
// It also catches arbitrary exceptions raised by handler method to propagate them to the client
- f_service_ << indent() << "try:" << endl;
+ f_service_ << indent() << "try:" << '\n';
indent_up();
// Generate the function call
@@ -2239,48 +2235,48 @@
}
f_service_ << "args." << (*f_iter)->get_name();
}
- f_service_ << ")" << endl;
+ f_service_ << ")" << '\n';
if (!tfunction->is_oneway()) {
- f_service_ << indent() << "msg_type = TMessageType.REPLY" << endl;
+ f_service_ << indent() << "msg_type = TMessageType.REPLY" << '\n';
}
indent_down();
f_service_ << indent()
- << "except TTransport.TTransportException:" << endl
- << indent() << indent_str() << "raise" << endl;
+ << "except TTransport.TTransportException:" << '\n'
+ << indent() << indent_str() << "raise" << '\n';
if (!tfunction->is_oneway()) {
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
const string& xname = (*x_iter)->get_name();
f_service_ << indent() << "except " << type_name((*x_iter)->get_type()) << " as " << xname
- << ":" << endl;
+ << ":" << '\n';
indent_up();
- f_service_ << indent() << "msg_type = TMessageType.REPLY" << endl;
- f_service_ << indent() << "result." << xname << " = " << xname << endl;
+ f_service_ << indent() << "msg_type = TMessageType.REPLY" << '\n';
+ f_service_ << indent() << "result." << xname << " = " << xname << '\n';
indent_down();
}
- f_service_ << indent() << "except TApplicationException as ex:" << endl
+ f_service_ << indent() << "except TApplicationException as ex:" << '\n'
<< indent() << indent_str()
- << "logging.exception('TApplication exception in handler')" << endl
- << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl
- << indent() << indent_str() << "result = ex" << endl
- << indent() << "except Exception:" << endl
+ << "logging.exception('TApplication exception in handler')" << '\n'
+ << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n'
+ << indent() << indent_str() << "result = ex" << '\n'
+ << indent() << "except Exception:" << '\n'
<< indent() << indent_str()
- << "logging.exception('Unexpected exception in handler')" << endl
- << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << endl
+ << "logging.exception('Unexpected exception in handler')" << '\n'
+ << indent() << indent_str() << "msg_type = TMessageType.EXCEPTION" << '\n'
<< indent() << indent_str()
<< "result = TApplicationException(TApplicationException.INTERNAL_ERROR, "
"'Internal error')"
- << endl
+ << '\n'
<< indent() << "oprot.writeMessageBegin(\"" << tfunction->get_name()
- << "\", msg_type, seqid)" << endl
- << indent() << "result.write(oprot)" << endl
- << indent() << "oprot.writeMessageEnd()" << endl
- << indent() << "oprot.trans.flush()" << endl;
+ << "\", msg_type, seqid)" << '\n'
+ << indent() << "result.write(oprot)" << '\n'
+ << indent() << "oprot.writeMessageEnd()" << '\n'
+ << indent() << "oprot.trans.flush()" << '\n';
} else {
- f_service_ << indent() << "except Exception:" << endl
- << indent() << indent_str() << "logging.exception('Exception in oneway handler')" << endl;
+ f_service_ << indent() << "except Exception:" << '\n'
+ << indent() << indent_str() << "logging.exception('Exception in oneway handler')" << '\n';
}
// Close function
@@ -2345,14 +2341,14 @@
throw "compiler error: no Python name for base type " + t_base_type::t_base_name(tbase);
}
}
- out << endl;
+ out << '\n';
} else if (type->is_enum()) {
if (gen_enum_) {
indent(out) << name << " = " << type_name(type) << "(iprot.readI32())";
} else {
indent(out) << name << " = iprot.readI32()";
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
tfield->get_name().c_str(),
@@ -2365,10 +2361,10 @@
*/
void t_py_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
if (is_immutable(tstruct)) {
- out << indent() << prefix << " = " << type_name(tstruct) << ".read(iprot)" << endl;
+ out << indent() << prefix << " = " << type_name(tstruct) << ".read(iprot)" << '\n';
} else {
- out << indent() << prefix << " = " << type_name(tstruct) << "()" << endl
- << indent() << prefix << ".read(iprot)" << endl;
+ out << indent() << prefix << " = " << type_name(tstruct) << "()" << '\n'
+ << indent() << prefix << ".read(iprot)" << '\n';
}
}
@@ -2389,20 +2385,20 @@
// Declare variables, read header
if (ttype->is_map()) {
- out << indent() << prefix << " = {}" << endl << indent() << "(" << ktype << ", " << vtype
- << ", " << size << ") = iprot.readMapBegin()" << endl;
+ out << indent() << prefix << " = {}" << '\n' << indent() << "(" << ktype << ", " << vtype
+ << ", " << size << ") = iprot.readMapBegin()" << '\n';
} else if (ttype->is_set()) {
- out << indent() << prefix << " = set()" << endl << indent() << "(" << etype << ", " << size
- << ") = iprot.readSetBegin()" << endl;
+ out << indent() << prefix << " = set()" << '\n' << indent() << "(" << etype << ", " << size
+ << ") = iprot.readSetBegin()" << '\n';
} else if (ttype->is_list()) {
- out << indent() << prefix << " = []" << endl << indent() << "(" << etype << ", " << size
- << ") = iprot.readListBegin()" << endl;
+ out << indent() << prefix << " = []" << '\n' << indent() << "(" << etype << ", " << size
+ << ") = iprot.readListBegin()" << '\n';
}
// For loop iterates over elements
string i = tmp("_i");
indent(out) <<
- "for " << i << " in range(" << size << "):" << endl;
+ "for " << i << " in range(" << size << "):" << '\n';
indent_up();
@@ -2418,20 +2414,20 @@
// Read container end
if (ttype->is_map()) {
- indent(out) << "iprot.readMapEnd()" << endl;
+ indent(out) << "iprot.readMapEnd()" << '\n';
if (is_immutable(ttype)) {
- indent(out) << prefix << " = TFrozenDict(" << prefix << ")" << endl;
+ indent(out) << prefix << " = TFrozenDict(" << prefix << ")" << '\n';
}
} else if (ttype->is_set()) {
- indent(out) << "iprot.readSetEnd()" << endl;
+ indent(out) << "iprot.readSetEnd()" << '\n';
if (is_immutable(ttype)) {
- indent(out) << prefix << " = frozenset(" << prefix << ")" << endl;
+ indent(out) << prefix << " = frozenset(" << prefix << ")" << '\n';
}
} else if (ttype->is_list()) {
if (is_immutable(ttype)) {
- indent(out) << prefix << " = tuple(" << prefix << ")" << endl;
+ indent(out) << prefix << " = tuple(" << prefix << ")" << '\n';
}
- indent(out) << "iprot.readListEnd()" << endl;
+ indent(out) << "iprot.readListEnd()" << '\n';
}
}
@@ -2447,7 +2443,7 @@
generate_deserialize_field(out, &fkey);
generate_deserialize_field(out, &fval);
- indent(out) << prefix << "[" << key << "] = " << val << endl;
+ indent(out) << prefix << "[" << key << "] = " << val << '\n';
}
/**
@@ -2459,7 +2455,7 @@
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".add(" << elem << ")" << endl;
+ indent(out) << prefix << ".add(" << elem << ")" << '\n';
}
/**
@@ -2473,7 +2469,7 @@
generate_deserialize_field(out, &felem);
- indent(out) << prefix << ".append(" << elem << ")" << endl;
+ indent(out) << prefix << ".append(" << elem << ")" << '\n';
}
/**
@@ -2543,7 +2539,7 @@
out << "writeI32(" << name << ")";
}
}
- out << endl;
+ out << '\n';
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
prefix.c_str(),
@@ -2560,50 +2556,50 @@
*/
void t_py_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
- indent(out) << prefix << ".write(oprot)" << endl;
+ indent(out) << prefix << ".write(oprot)" << '\n';
}
void t_py_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
if (ttype->is_map()) {
indent(out) << "oprot.writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "len(" << prefix << "))" << endl;
+ << "len(" << prefix << "))" << '\n';
} else if (ttype->is_set()) {
indent(out) << "oprot.writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
- << "len(" << prefix << "))" << endl;
+ << "len(" << prefix << "))" << '\n';
} else if (ttype->is_list()) {
indent(out) << "oprot.writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
<< ", "
- << "len(" << prefix << "))" << endl;
+ << "len(" << prefix << "))" << '\n';
}
if (ttype->is_map()) {
string kiter = tmp("kiter");
string viter = tmp("viter");
- indent(out) << "for " << kiter << ", " << viter << " in " << prefix << ".items():" << endl;
+ indent(out) << "for " << kiter << ", " << viter << " in " << prefix << ".items():" << '\n';
indent_up();
generate_serialize_map_element(out, (t_map*)ttype, kiter, viter);
indent_down();
} else if (ttype->is_set()) {
string iter = tmp("iter");
- indent(out) << "for " << iter << " in " << prefix << ":" << endl;
+ indent(out) << "for " << iter << " in " << prefix << ":" << '\n';
indent_up();
generate_serialize_set_element(out, (t_set*)ttype, iter);
indent_down();
} else if (ttype->is_list()) {
string iter = tmp("iter");
- indent(out) << "for " << iter << " in " << prefix << ":" << endl;
+ indent(out) << "for " << iter << " in " << prefix << ":" << '\n';
indent_up();
generate_serialize_list_element(out, (t_list*)ttype, iter);
indent_down();
}
if (ttype->is_map()) {
- indent(out) << "oprot.writeMapEnd()" << endl;
+ indent(out) << "oprot.writeMapEnd()" << '\n';
} else if (ttype->is_set()) {
- indent(out) << "oprot.writeSetEnd()" << endl;
+ indent(out) << "oprot.writeSetEnd()" << '\n';
} else if (ttype->is_list()) {
- indent(out) << "oprot.writeListEnd()" << endl;
+ indent(out) << "oprot.writeListEnd()" << '\n';
}
}
@@ -2669,7 +2665,7 @@
const vector<t_field*>& fields = tstruct->get_members();
if (fields.size() > 0) {
if (has_doc) {
- ss << endl;
+ ss << '\n';
}
has_doc = true;
ss << subheader << ":\n";
@@ -2680,7 +2676,7 @@
if (p->has_doc()) {
ss << ": " << p->get_doc();
} else {
- ss << endl;
+ ss << '\n';
}
}
}
diff --git a/compiler/cpp/src/thrift/generate/t_rb_generator.cc b/compiler/cpp/src/thrift/generate/t_rb_generator.cc
index 17e57cf..e946573 100644
--- a/compiler/cpp/src/thrift/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_rb_generator.cc
@@ -43,8 +43,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* A subclass of std::ofstream that includes indenting functionality.
*/
@@ -283,11 +281,11 @@
f_consts_.open(f_consts_name.c_str());
// Print header
- f_types_ << rb_autogen_comment() << endl << render_require_thrift() << render_includes() << endl;
+ f_types_ << rb_autogen_comment() << '\n' << render_require_thrift() << render_includes() << '\n';
begin_namespace(f_types_, ruby_modules(program_));
- f_consts_ << rb_autogen_comment() << endl << render_require_thrift() << "require '"
- << require_prefix_ << underscore(program_name_) << "_types'" << endl << endl;
+ f_consts_ << rb_autogen_comment() << '\n' << render_require_thrift() << "require '"
+ << require_prefix_ << underscore(program_name_) << "_types'" << '\n' << '\n';
begin_namespace(f_consts_, ruby_modules(program_));
}
@@ -360,7 +358,7 @@
* @param tenum The enumeration
*/
void t_rb_generator::generate_enum(t_enum* tenum) {
- f_types_.indent() << "module " << capitalize(tenum->get_name()) << endl;
+ f_types_.indent() << "module " << capitalize(tenum->get_name()) << '\n';
f_types_.indent_up();
vector<t_enum_value*> constants = tenum->get_constants();
@@ -374,7 +372,7 @@
string name = capitalize((*c_iter)->get_name());
generate_rdoc(f_types_, *c_iter);
- f_types_.indent() << name << " = " << value << endl;
+ f_types_.indent() << name << " = " << value << '\n';
}
// Create a hash mapping values back to their names (as strings) since ruby has no native enum
@@ -387,7 +385,7 @@
f_types_ << ", ";
f_types_ << value << " => \"" << capitalize((*c_iter)->get_name()) << "\"";
}
- f_types_ << "}" << endl;
+ f_types_ << "}" << '\n';
// Create a set with valid values for this enum
f_types_.indent() << "VALID_VALUES = Set.new([";
@@ -397,10 +395,10 @@
f_types_ << ", ";
f_types_ << capitalize((*c_iter)->get_name());
}
- f_types_ << "]).freeze" << endl;
+ f_types_ << "]).freeze" << '\n';
f_types_.indent_down();
- f_types_.indent() << "end" << endl << endl;
+ f_types_.indent() << "end" << '\n' << '\n';
}
/**
@@ -414,7 +412,7 @@
name[0] = toupper(name[0]);
f_consts_.indent() << name << " = ";
- render_const_value(f_consts_, type, value) << endl << endl;
+ render_const_value(f_consts_, type, value) << '\n' << '\n';
}
/**
@@ -454,7 +452,7 @@
} else if (type->is_enum()) {
out.indent() << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
- out << full_type_name(type) << ".new({" << endl;
+ out << full_type_name(type) << ".new({" << '\n';
out.indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -472,21 +470,21 @@
}
out.indent();
render_const_value(out, g_type_string, v_iter->first) << " => ";
- render_const_value(out, field_type, v_iter->second) << "," << endl;
+ render_const_value(out, field_type, v_iter->second) << "," << '\n';
}
out.indent_down();
out.indent() << "})";
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
- out << "{" << endl;
+ out << "{" << '\n';
out.indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out.indent();
render_const_value(out, ktype, v_iter->first) << " => ";
- render_const_value(out, vtype, v_iter->second) << "," << endl;
+ render_const_value(out, vtype, v_iter->second) << "," << '\n';
}
out.indent_down();
out.indent() << "}";
@@ -498,16 +496,16 @@
etype = ((t_set*)type)->get_elem_type();
}
if (type->is_set()) {
- out << "Set.new([" << endl;
+ out << "Set.new([" << '\n';
} else {
- out << "[" << endl;
+ out << "[" << '\n';
}
out.indent_up();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out.indent();
- render_const_value(out, etype, *v_iter) << "," << endl;
+ render_const_value(out, etype, *v_iter) << "," << '\n';
}
out.indent_down();
if (type->is_set()) {
@@ -552,7 +550,7 @@
if (is_exception) {
out << " < ::Thrift::Exception";
}
- out << "; end" << endl << endl;
+ out << "; end" << '\n' << '\n';
}
/**
@@ -576,10 +574,10 @@
if (is_exception) {
out << " < ::Thrift::Exception";
}
- out << endl;
+ out << '\n';
out.indent_up();
- out.indent() << "include ::Thrift::Struct, ::Thrift::Struct_Union" << endl;
+ out.indent() << "include ::Thrift::Struct, ::Thrift::Struct_Union" << '\n';
if (is_exception) {
generate_rb_simple_exception_constructor(out, tstruct);
@@ -589,10 +587,10 @@
generate_field_defns(out, tstruct);
generate_rb_struct_required_validator(out, tstruct);
- out.indent() << "::Thrift::Struct.generate_accessors self" << endl;
+ out.indent() << "::Thrift::Struct.generate_accessors self" << '\n';
out.indent_down();
- out.indent() << "end" << endl << endl;
+ out.indent() << "end" << '\n' << '\n';
}
/**
@@ -603,10 +601,10 @@
bool is_exception = false) {
(void)is_exception;
generate_rdoc(out, tstruct);
- out.indent() << "class " << type_name(tstruct) << " < ::Thrift::Union" << endl;
+ out.indent() << "class " << type_name(tstruct) << " < ::Thrift::Union" << '\n';
out.indent_up();
- out.indent() << "include ::Thrift::Struct_Union" << endl;
+ out.indent() << "include ::Thrift::Struct_Union" << '\n';
generate_field_constructors(out, tstruct);
@@ -614,15 +612,15 @@
generate_field_defns(out, tstruct);
generate_rb_union_validator(out, tstruct);
- out.indent() << "::Thrift::Union.generate_accessors self" << endl;
+ out.indent() << "::Thrift::Union.generate_accessors self" << '\n';
out.indent_down();
- out.indent() << "end" << endl << endl;
+ out.indent() << "end" << '\n' << '\n';
}
void t_rb_generator::generate_field_constructors(t_rb_ofstream& out, t_struct* tstruct) {
- out.indent() << "class << self" << endl;
+ out.indent() << "class << self" << '\n';
out.indent_up();
const vector<t_field*>& fields = tstruct->get_members();
@@ -630,19 +628,19 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (f_iter != fields.begin()) {
- out << endl;
+ out << '\n';
}
std::string field_name = (*f_iter)->get_name();
- out.indent() << "def " << field_name << "(val)" << endl;
- out.indent() << " " << tstruct->get_name() << ".new(:" << field_name << ", val)" << endl;
- out.indent() << "end" << endl;
+ out.indent() << "def " << field_name << "(val)" << '\n';
+ out.indent() << " " << tstruct->get_name() << ".new(:" << field_name << ", val)" << '\n';
+ out.indent() << "end" << '\n';
}
out.indent_down();
- out.indent() << "end" << endl;
+ out.indent() << "end" << '\n';
- out << endl;
+ out << '\n';
}
void t_rb_generator::generate_rb_simple_exception_constructor(t_rb_ofstream& out,
@@ -655,15 +653,15 @@
if ((*m_iter)->get_type()->is_string()) {
string name = (*m_iter)->get_name();
- out.indent() << "def initialize(message=nil)" << endl;
+ out.indent() << "def initialize(message=nil)" << '\n';
out.indent_up();
- out.indent() << "super()" << endl;
- out.indent() << "self." << name << " = message" << endl;
+ out.indent() << "super()" << '\n';
+ out.indent() << "self." << name << " = message" << '\n';
out.indent_down();
- out.indent() << "end" << endl << endl;
+ out.indent() << "end" << '\n' << '\n';
if (name != "message") {
- out.indent() << "def message; " << name << " end" << endl << endl;
+ out.indent() << "def message; " << name << " end" << '\n' << '\n';
}
}
}
@@ -677,20 +675,20 @@
std::string field_name = (*f_iter)->get_name();
std::string cap_field_name = upcase_string(field_name);
- out.indent() << cap_field_name << " = " << (*f_iter)->get_key() << endl;
+ out.indent() << cap_field_name << " = " << (*f_iter)->get_key() << '\n';
}
- out << endl;
+ out << '\n';
}
void t_rb_generator::generate_field_defns(t_rb_ofstream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- out.indent() << "FIELDS = {" << endl;
+ out.indent() << "FIELDS = {" << '\n';
out.indent_up();
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (f_iter != fields.begin()) {
- out << "," << endl;
+ out << "," << '\n';
}
// generate the field docstrings within the FIELDS constant. no real better place...
@@ -705,10 +703,10 @@
(*f_iter)->get_req() == t_field::T_OPTIONAL);
}
out.indent_down();
- out << endl;
- out.indent() << "}" << endl << endl;
+ out << '\n';
+ out.indent() << "}" << '\n' << '\n';
- out.indent() << "def struct_fields; FIELDS; end" << endl << endl;
+ out.indent() << "def struct_fields; FIELDS; end" << '\n' << '\n';
}
void t_rb_generator::generate_field_data(t_rb_ofstream& out,
@@ -765,7 +763,7 @@
void t_rb_generator::begin_namespace(t_rb_ofstream& out, vector<std::string> modules) {
for (auto & module : modules) {
- out.indent() << "module " << module << endl;
+ out.indent() << "module " << module << '\n';
out.indent_up();
}
}
@@ -774,7 +772,7 @@
for (vector<std::string>::reverse_iterator m_iter = modules.rbegin(); m_iter != modules.rend();
++m_iter) {
out.indent_down();
- out.indent() << "end" << endl;
+ out.indent() << "end" << '\n';
}
}
@@ -787,25 +785,25 @@
string f_service_name = namespace_dir_ + underscore(service_name_) + ".rb";
f_service_.open(f_service_name.c_str());
- f_service_ << rb_autogen_comment() << endl << render_require_thrift();
+ f_service_ << rb_autogen_comment() << '\n' << render_require_thrift();
if (tservice->get_extends() != nullptr) {
if (namespaced_) {
f_service_ << "require '" << rb_namespace_to_path_prefix(
tservice->get_extends()->get_program()->get_namespace("rb"))
- << underscore(tservice->get_extends()->get_name()) << "'" << endl;
+ << underscore(tservice->get_extends()->get_name()) << "'" << '\n';
} else {
f_service_ << "require '" << require_prefix_
- << underscore(tservice->get_extends()->get_name()) << "'" << endl;
+ << underscore(tservice->get_extends()->get_name()) << "'" << '\n';
}
}
- f_service_ << "require '" << require_prefix_ << underscore(program_name_) << "_types'" << endl
- << endl;
+ f_service_ << "require '" << require_prefix_ << underscore(program_name_) << "_types'" << '\n'
+ << '\n';
begin_namespace(f_service_, ruby_modules(tservice->get_program()));
- f_service_.indent() << "module " << capitalize(tservice->get_name()) << endl;
+ f_service_.indent() << "module " << capitalize(tservice->get_name()) << '\n';
f_service_.indent_up();
// Generate the three main parts of the service (well, two for now in PHP)
@@ -814,7 +812,7 @@
generate_service_helpers(tservice);
f_service_.indent_down();
- f_service_.indent() << "end" << endl << endl;
+ f_service_.indent() << "end" << '\n' << '\n';
end_namespace(f_service_, ruby_modules(tservice->get_program()));
@@ -831,7 +829,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- f_service_.indent() << "# HELPER FUNCTIONS AND STRUCTURES" << endl << endl;
+ f_service_.indent() << "# HELPER FUNCTIONS AND STRUCTURES" << '\n' << '\n';
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_struct* ts = (*f_iter)->get_arglist();
@@ -874,10 +872,10 @@
extends_client = " < " + extends + "::Client ";
}
- f_service_.indent() << "class Client" << extends_client << endl;
+ f_service_.indent() << "class Client" << extends_client << '\n';
f_service_.indent_up();
- f_service_.indent() << "include ::Thrift::Client" << endl << endl;
+ f_service_.indent() << "include ::Thrift::Client" << '\n' << '\n';
// Generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -889,7 +887,7 @@
string funname = (*f_iter)->get_name();
// Open function
- f_service_.indent() << "def " << function_signature(*f_iter) << endl;
+ f_service_.indent() << "def " << function_signature(*f_iter) << '\n';
f_service_.indent_up();
f_service_.indent() << "send_" << funname << "(";
@@ -902,20 +900,20 @@
}
f_service_ << (*fld_iter)->get_name();
}
- f_service_ << ")" << endl;
+ f_service_ << ")" << '\n';
if (!(*f_iter)->is_oneway()) {
f_service_.indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
- f_service_ << "recv_" << funname << "()" << endl;
+ f_service_ << "recv_" << funname << "()" << '\n';
}
f_service_.indent_down();
- f_service_.indent() << "end" << endl;
- f_service_ << endl;
+ f_service_.indent() << "end" << '\n';
+ f_service_ << '\n';
- f_service_.indent() << "def send_" << function_signature(*f_iter) << endl;
+ f_service_.indent() << "def send_" << function_signature(*f_iter) << '\n';
f_service_.indent_up();
std::string argsname = capitalize((*f_iter)->get_name() + "_args");
@@ -927,10 +925,10 @@
f_service_ << ", :" << (*fld_iter)->get_name() << " => " << (*fld_iter)->get_name();
}
- f_service_ << ")" << endl;
+ f_service_ << ")" << '\n';
f_service_.indent_down();
- f_service_.indent() << "end" << endl;
+ f_service_.indent() << "end" << '\n';
if (!(*f_iter)->is_oneway()) {
std::string resultname = capitalize((*f_iter)->get_name() + "_result");
@@ -940,22 +938,22 @@
string("recv_") + (*f_iter)->get_name(),
&noargs);
// Open function
- f_service_ << endl;
- f_service_.indent() << "def " << function_signature(&recv_function) << endl;
+ f_service_ << '\n';
+ f_service_.indent() << "def " << function_signature(&recv_function) << '\n';
f_service_.indent_up();
- f_service_.indent() << "fname, mtype, rseqid = receive_message_begin()" << endl;
- f_service_.indent() << "handle_exception(mtype)" << endl;
+ f_service_.indent() << "fname, mtype, rseqid = receive_message_begin()" << '\n';
+ f_service_.indent() << "handle_exception(mtype)" << '\n';
- f_service_.indent() << "if reply_seqid(rseqid)==false" << endl;
- f_service_.indent() << " raise \"seqid reply faild\"" << endl;
- f_service_.indent() << "end" << endl;
+ f_service_.indent() << "if reply_seqid(rseqid)==false" << '\n';
+ f_service_.indent() << " raise \"seqid reply faild\"" << '\n';
+ f_service_.indent() << "end" << '\n';
- f_service_.indent() << "result = receive_message(" << resultname << ")" << endl;
+ f_service_.indent() << "result = receive_message(" << resultname << ")" << '\n';
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
- f_service_.indent() << "return result.success unless result.success.nil?" << endl;
+ f_service_.indent() << "return result.success unless result.success.nil?" << '\n';
}
t_struct* xs = (*f_iter)->get_xceptions();
@@ -963,27 +961,27 @@
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_.indent() << "raise result." << (*x_iter)->get_name() << " unless result."
- << (*x_iter)->get_name() << ".nil?" << endl;
+ << (*x_iter)->get_name() << ".nil?" << '\n';
}
// Careful, only return _result if not a void function
if ((*f_iter)->get_returntype()->is_void()) {
- f_service_.indent() << "return" << endl;
+ f_service_.indent() << "return" << '\n';
} else {
f_service_.indent() << "raise "
"::Thrift::ApplicationException.new(::Thrift::ApplicationException::"
"MISSING_RESULT, '" << (*f_iter)->get_name()
- << " failed: unknown result')" << endl;
+ << " failed: unknown result')" << '\n';
}
// Close function
f_service_.indent_down();
- f_service_.indent() << "end" << endl << endl;
+ f_service_.indent() << "end" << '\n' << '\n';
}
}
f_service_.indent_down();
- f_service_.indent() << "end" << endl << endl;
+ f_service_.indent() << "end" << '\n' << '\n';
}
/**
@@ -1004,10 +1002,10 @@
}
// Generate the header portion
- f_service_.indent() << "class Processor" << extends_processor << endl;
+ f_service_.indent() << "class Processor" << extends_processor << '\n';
f_service_.indent_up();
- f_service_.indent() << "include ::Thrift::Processor" << endl << endl;
+ f_service_.indent() << "include ::Thrift::Processor" << '\n' << '\n';
// Generate the process subfunctions
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1015,7 +1013,7 @@
}
f_service_.indent_down();
- f_service_.indent() << "end" << endl << endl;
+ f_service_.indent() << "end" << '\n' << '\n';
}
/**
@@ -1026,13 +1024,13 @@
void t_rb_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
(void)tservice;
// Open function
- f_service_.indent() << "def process_" << tfunction->get_name() << "(seqid, iprot, oprot)" << endl;
+ f_service_.indent() << "def process_" << tfunction->get_name() << "(seqid, iprot, oprot)" << '\n';
f_service_.indent_up();
string argsname = capitalize(tfunction->get_name()) + "_args";
string resultname = capitalize(tfunction->get_name()) + "_result";
- f_service_.indent() << "args = read_args(iprot, " << argsname << ")" << endl;
+ f_service_.indent() << "args = read_args(iprot, " << argsname << ")" << '\n';
t_struct* xs = tfunction->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -1040,12 +1038,12 @@
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
- f_service_.indent() << "result = " << resultname << ".new()" << endl;
+ f_service_.indent() << "result = " << resultname << ".new()" << '\n';
}
// Try block for a function with exceptions
if (xceptions.size() > 0) {
- f_service_.indent() << "begin" << endl;
+ f_service_.indent() << "begin" << '\n';
f_service_.indent_up();
}
@@ -1068,37 +1066,37 @@
}
f_service_ << "args." << (*f_iter)->get_name();
}
- f_service_ << ")" << endl;
+ f_service_ << ")" << '\n';
if (!tfunction->is_oneway() && xceptions.size() > 0) {
f_service_.indent_down();
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_.indent() << "rescue " << full_type_name((*x_iter)->get_type()) << " => "
- << (*x_iter)->get_name() << endl;
+ << (*x_iter)->get_name() << '\n';
if (!tfunction->is_oneway()) {
f_service_.indent_up();
f_service_.indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name()
- << endl;
+ << '\n';
f_service_.indent_down();
}
}
- f_service_.indent() << "end" << endl;
+ f_service_.indent() << "end" << '\n';
}
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- f_service_.indent() << "return" << endl;
+ f_service_.indent() << "return" << '\n';
f_service_.indent_down();
- f_service_.indent() << "end" << endl << endl;
+ f_service_.indent() << "end" << '\n' << '\n';
return;
}
f_service_.indent() << "write_result(result, oprot, '" << tfunction->get_name() << "', seqid)"
- << endl;
+ << '\n';
// Close function
f_service_.indent_down();
- f_service_.indent() << "end" << endl << endl;
+ f_service_.indent() << "end" << '\n' << '\n';
}
/**
@@ -1219,7 +1217,7 @@
}
void t_rb_generator::generate_rb_struct_required_validator(t_rb_ofstream& out, t_struct* tstruct) {
- out.indent() << "def validate" << endl;
+ out.indent() << "def validate" << '\n';
out.indent_up();
const vector<t_field*>& fields = tstruct->get_members();
@@ -1235,7 +1233,7 @@
} else {
out << " unless @" << field->get_name();
}
- out << endl;
+ out << '\n';
}
}
@@ -1246,21 +1244,21 @@
if (field->get_type()->is_enum()) {
out.indent() << "unless @" << field->get_name() << ".nil? || "
<< full_type_name(field->get_type()) << "::VALID_VALUES.include?(@"
- << field->get_name() << ")" << endl;
+ << field->get_name() << ")" << '\n';
out.indent_up();
out.indent() << "raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, "
- "'Invalid value of field " << field->get_name() << "!')" << endl;
+ "'Invalid value of field " << field->get_name() << "!')" << '\n';
out.indent_down();
- out.indent() << "end" << endl;
+ out.indent() << "end" << '\n';
}
}
out.indent_down();
- out.indent() << "end" << endl << endl;
+ out.indent() << "end" << '\n' << '\n';
}
void t_rb_generator::generate_rb_union_validator(t_rb_ofstream& out, t_struct* tstruct) {
- out.indent() << "def validate" << endl;
+ out.indent() << "def validate" << '\n';
out.indent_up();
const vector<t_field*>& fields = tstruct->get_members();
@@ -1268,25 +1266,25 @@
out.indent()
<< "raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?"
- << endl;
+ << '\n';
// if field is an enum, check that its value is valid
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
const t_field* field = (*f_iter);
if (field->get_type()->is_enum()) {
- out.indent() << "if get_set_field == :" << field->get_name() << endl;
+ out.indent() << "if get_set_field == :" << field->get_name() << '\n';
out.indent() << " raise "
"::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, "
"'Invalid value of field " << field->get_name() << "!') unless "
<< full_type_name(field->get_type()) << "::VALID_VALUES.include?(get_value)"
- << endl;
- out.indent() << "end" << endl;
+ << '\n';
+ out.indent() << "end" << '\n';
}
}
out.indent_down();
- out.indent() << "end" << endl << endl;
+ out.indent() << "end" << '\n' << '\n';
}
std::string t_rb_generator::display_name() const {
diff --git a/compiler/cpp/src/thrift/generate/t_rs_generator.cc b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
index 2742724..780c8fd 100644
--- a/compiler/cpp/src/thrift/generate/t_rs_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
@@ -31,7 +31,6 @@
using std::string;
using std::vector;
-static const string endl("\n"); // avoid ostream << std::endl flushes
static const string SERVICE_RESULT_VARIABLE("result_value");
static const string RESULT_STRUCT_SUFFIX("Result");
static const string RUST_RESERVED_WORDS[]
@@ -521,9 +520,9 @@
f_gen_.open(f_gen_name.c_str());
// header comment
- f_gen_ << "// " << autogen_summary() << endl;
- f_gen_ << "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING" << endl;
- f_gen_ << endl;
+ f_gen_ << "// " << autogen_summary() << '\n';
+ f_gen_ << "// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING" << '\n';
+ f_gen_ << '\n';
render_attributes_and_includes();
}
@@ -532,11 +531,11 @@
// turn off some compiler/clippy warnings
// code may not be used
- f_gen_ << "#![allow(dead_code)]" << endl;
+ f_gen_ << "#![allow(dead_code)]" << '\n';
// code always includes BTreeMap/BTreeSet/OrderedFloat
- f_gen_ << "#![allow(unused_imports)]" << endl;
+ f_gen_ << "#![allow(unused_imports)]" << '\n';
// code might not include imports from crates
- f_gen_ << "#![allow(unused_extern_crates)]" << endl;
+ f_gen_ << "#![allow(unused_extern_crates)]" << '\n';
// constructors take *all* struct parameters, which can trigger the "too many arguments" warning
// some auto-gen'd types can be deeply nested. clippy recommends factoring them out which is hard
// to autogen some methods may start with "is_"
@@ -548,38 +547,38 @@
// 2. When you define types out of order
f_gen_ << "#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box, "
"clippy::wrong_self_convention)]"
- << endl;
+ << '\n';
// prevent rustfmt from running against this file
// lines are too long, code is (thankfully!) not visual-indented, etc.
// can't use #[rustfmt::skip] see: https://github.com/rust-lang/rust/issues/54726
- f_gen_ << "#![cfg_attr(rustfmt, rustfmt_skip)]" << endl;
- f_gen_ << endl;
+ f_gen_ << "#![cfg_attr(rustfmt, rustfmt_skip)]" << '\n';
+ f_gen_ << '\n';
// add standard includes
- f_gen_ << "use std::cell::RefCell;" << endl;
- f_gen_ << "use std::collections::{BTreeMap, BTreeSet};" << endl;
- f_gen_ << "use std::convert::{From, TryFrom};" << endl;
- f_gen_ << "use std::default::Default;" << endl;
- f_gen_ << "use std::error::Error;" << endl;
- f_gen_ << "use std::fmt;" << endl;
- f_gen_ << "use std::fmt::{Display, Formatter};" << endl;
- f_gen_ << "use std::rc::Rc;" << endl;
- f_gen_ << endl;
- f_gen_ << "use thrift::OrderedFloat;" << endl;
+ f_gen_ << "use std::cell::RefCell;" << '\n';
+ f_gen_ << "use std::collections::{BTreeMap, BTreeSet};" << '\n';
+ f_gen_ << "use std::convert::{From, TryFrom};" << '\n';
+ f_gen_ << "use std::default::Default;" << '\n';
+ f_gen_ << "use std::error::Error;" << '\n';
+ f_gen_ << "use std::fmt;" << '\n';
+ f_gen_ << "use std::fmt::{Display, Formatter};" << '\n';
+ f_gen_ << "use std::rc::Rc;" << '\n';
+ f_gen_ << '\n';
+ f_gen_ << "use thrift::OrderedFloat;" << '\n';
f_gen_ << "use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, "
"ProtocolErrorKind, TThriftClient};"
- << endl;
+ << '\n';
f_gen_ << "use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, "
"TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSerializable, "
"TSetIdentifier, TStructIdentifier, TType};"
- << endl;
- f_gen_ << "use thrift::protocol::field_id;" << endl;
- f_gen_ << "use thrift::protocol::verify_expected_message_type;" << endl;
- f_gen_ << "use thrift::protocol::verify_expected_sequence_number;" << endl;
- f_gen_ << "use thrift::protocol::verify_expected_service_call;" << endl;
- f_gen_ << "use thrift::protocol::verify_required_field_exists;" << endl;
- f_gen_ << "use thrift::server::TProcessor;" << endl;
- f_gen_ << endl;
+ << '\n';
+ f_gen_ << "use thrift::protocol::field_id;" << '\n';
+ f_gen_ << "use thrift::protocol::verify_expected_message_type;" << '\n';
+ f_gen_ << "use thrift::protocol::verify_expected_sequence_number;" << '\n';
+ f_gen_ << "use thrift::protocol::verify_expected_service_call;" << '\n';
+ f_gen_ << "use thrift::protocol::verify_required_field_exists;" << '\n';
+ f_gen_ << "use thrift::server::TProcessor;" << '\n';
+ f_gen_ << '\n';
// add all the program includes
// NOTE: this is more involved than you would expect because of service extension
@@ -615,13 +614,13 @@
string_replace(module_namespace, ".", "::");
if (module_namespace.empty()) {
- f_gen_ << "use crate::" << rust_snake_case(module_name) << ";" << endl;
+ f_gen_ << "use crate::" << rust_snake_case(module_name) << ";" << '\n';
} else {
f_gen_ << "use crate::" << module_namespace << "::" << rust_snake_case(module_name) << ";"
- << endl;
+ << '\n';
}
}
- f_gen_ << endl;
+ f_gen_ << '\n';
}
}
@@ -673,8 +672,8 @@
f_gen_ << "pub const " << rust_upper_case(name) << ": " << to_rust_const_type(ttype) << " = ";
render_const_value(ttype, tvalue, false);
- f_gen_ << ";" << endl;
- f_gen_ << endl;
+ f_gen_ << ";" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_const_value_holder(const string& name,
@@ -686,19 +685,19 @@
string holder_name("Const" + rust_camel_case(name));
- f_gen_ << indent() << "pub struct " << holder_name << ";" << endl;
- f_gen_ << indent() << "impl " << holder_name << " {" << endl;
+ f_gen_ << indent() << "pub struct " << holder_name << ";" << '\n';
+ f_gen_ << indent() << "impl " << holder_name << " {" << '\n';
indent_up();
- f_gen_ << indent() << "pub fn const_value() -> " << to_rust_type(ttype) << " {" << endl;
+ f_gen_ << indent() << "pub fn const_value() -> " << to_rust_type(ttype) << " {" << '\n';
indent_up();
render_const_value(ttype, tvalue, true, false);
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_const_value(t_type* ttype,
@@ -748,10 +747,10 @@
} else if (ttype->is_typedef()) {
render_const_value(get_true_type(ttype), tvalue, is_owned, true);
} else if (ttype->is_enum()) {
- f_gen_ << "{" << endl;
+ f_gen_ << "{" << '\n';
indent_up();
f_gen_ << indent() << to_rust_type(ttype) << "::try_from(" << tvalue->get_integer()
- << ").expect(\"expecting valid const value\")" << endl;
+ << ").expect(\"expecting valid const value\")" << '\n';
indent_down();
f_gen_ << indent() << "}";
} else if (ttype->is_struct() || ttype->is_xception()) {
@@ -772,21 +771,21 @@
}
if (!is_inline) {
- f_gen_ << endl;
+ f_gen_ << '\n';
}
}
void t_rs_generator::render_const_struct(t_type* ttype, t_const_value*) {
if (((t_struct*)ttype)->is_union()) {
- f_gen_ << "{" << endl;
+ f_gen_ << "{" << '\n';
indent_up();
- f_gen_ << indent() << "unimplemented!()" << endl;
+ f_gen_ << indent() << "unimplemented!()" << '\n';
indent_down();
f_gen_ << indent() << "}";
} else {
- f_gen_ << "{" << endl;
+ f_gen_ << "{" << '\n';
indent_up();
- f_gen_ << indent() << "unimplemented!()" << endl;
+ f_gen_ << indent() << "unimplemented!()" << '\n';
indent_down();
f_gen_ << indent() << "}";
}
@@ -794,7 +793,7 @@
void t_rs_generator::render_const_list(t_type* ttype, t_const_value* tvalue) {
t_type* elem_type = ((t_list*)ttype)->get_elem_type();
- f_gen_ << "vec![" << endl;
+ f_gen_ << "vec![" << '\n';
indent_up();
const vector<t_const_value*>& elems = tvalue->get_list();
vector<t_const_value*>::const_iterator elem_iter;
@@ -802,7 +801,7 @@
f_gen_ << indent();
t_const_value* elem_value = (*elem_iter);
render_const_value(elem_type, elem_value);
- f_gen_ << "," << endl;
+ f_gen_ << "," << '\n';
}
indent_down();
f_gen_ << indent() << "]";
@@ -810,7 +809,7 @@
void t_rs_generator::render_const_set(t_type* ttype, t_const_value* tvalue) {
t_type* elem_type = ((t_set*)ttype)->get_elem_type();
- f_gen_ << "BTreeSet::from([" << endl;
+ f_gen_ << "BTreeSet::from([" << '\n';
indent_up();
const vector<t_const_value*>& elems = tvalue->get_list();
vector<t_const_value*>::const_iterator elem_iter;
@@ -818,7 +817,7 @@
f_gen_ << indent();
t_const_value* elem_value = (*elem_iter);
render_const_value(elem_type, elem_value);
- f_gen_ << "," << endl;
+ f_gen_ << "," << '\n';
}
indent_down();
f_gen_ << indent() << "])";
@@ -827,7 +826,7 @@
void t_rs_generator::render_const_map(t_type* ttype, t_const_value* tvalue) {
t_type* key_type = ((t_map*)ttype)->get_key_type();
t_type* val_type = ((t_map*)ttype)->get_val_type();
- f_gen_ << "BTreeMap::from([" << endl;
+ f_gen_ << "BTreeMap::from([" << '\n';
indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& elems
= tvalue->get_map();
@@ -836,16 +835,16 @@
t_const_value* key_value = elem_iter->first;
t_const_value* val_value = elem_iter->second;
- f_gen_ << indent() << "(" << endl;
+ f_gen_ << indent() << "(" << '\n';
indent_up();
f_gen_ << indent();
render_const_value(key_type, key_value);
- f_gen_ << "," << endl;
+ f_gen_ << "," << '\n';
f_gen_ << indent();
render_const_value(val_type, val_value);
- f_gen_ << "," << endl;
+ f_gen_ << "," << '\n';
indent_down();
- f_gen_ << indent() << ")," << endl;
+ f_gen_ << indent() << ")," << '\n';
}
indent_down();
f_gen_ << indent() << "])";
@@ -860,8 +859,8 @@
void t_rs_generator::generate_typedef(t_typedef* ttypedef) {
std::string actual_type = to_rust_type(ttypedef->get_type());
f_gen_ << "pub type " << rust_safe_name(ttypedef->get_symbolic()) << " = " << actual_type << ";"
- << endl;
- f_gen_ << endl;
+ << '\n';
+ f_gen_ << '\n';
}
//-----------------------------------------------------------------------------
@@ -879,13 +878,13 @@
void t_rs_generator::render_enum_definition(t_enum* tenum, const string& enum_name) {
render_rustdoc((t_doc*)tenum);
- f_gen_ << "#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl;
- f_gen_ << "pub struct " << enum_name << "(pub i32);" << endl;
- f_gen_ << endl;
+ f_gen_ << "#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << '\n';
+ f_gen_ << "pub struct " << enum_name << "(pub i32);" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_enum_impl(t_enum* tenum, const string& enum_name) {
- f_gen_ << "impl " << enum_name << " {" << endl;
+ f_gen_ << "impl " << enum_name << " {" << '\n';
indent_up();
vector<t_enum_value*> constants = tenum->get_constants();
@@ -898,114 +897,114 @@
render_rustdoc((t_doc*)val);
f_gen_ << indent() << "pub const " << rust_enum_variant_name(val->get_name()) << ": "
<< enum_name << " = " << enum_name << "(" << val->get_value() << ")"
- << ";" << endl;
+ << ";" << '\n';
}
}
// array containing all IDL-defined enum variants
{
- f_gen_ << indent() << "pub const ENUM_VALUES: &'static [Self] = &[" << endl;
+ f_gen_ << indent() << "pub const ENUM_VALUES: &'static [Self] = &[" << '\n';
indent_up();
vector<t_enum_value*>::iterator constants_iter;
for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) {
t_enum_value* val = (*constants_iter);
- f_gen_ << indent() << "Self::" << rust_enum_variant_name(val->get_name()) << "," << endl;
+ f_gen_ << indent() << "Self::" << rust_enum_variant_name(val->get_name()) << "," << '\n';
}
indent_down();
- f_gen_ << indent() << "];" << endl;
+ f_gen_ << indent() << "];" << '\n';
}
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
- f_gen_ << "impl TSerializable for " << enum_name << " {" << endl;
+ f_gen_ << "impl TSerializable for " << enum_name << " {" << '\n';
indent_up();
- f_gen_ << indent() << "#[allow(clippy::trivially_copy_pass_by_ref)]" << endl;
+ f_gen_ << indent() << "#[allow(clippy::trivially_copy_pass_by_ref)]" << '\n';
f_gen_
<< indent()
<< "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {"
- << endl;
+ << '\n';
indent_up();
- f_gen_ << indent() << "o_prot.write_i32(self.0)" << endl;
+ f_gen_ << indent() << "o_prot.write_i32(self.0)" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
f_gen_ << indent()
<< "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<"
- << enum_name << "> {" << endl;
+ << enum_name << "> {" << '\n';
indent_up();
- f_gen_ << indent() << "let enum_value = i_prot.read_i32()?;" << endl;
+ f_gen_ << indent() << "let enum_value = i_prot.read_i32()?;" << '\n';
f_gen_ << indent() << "Ok(" << enum_name << "::from(enum_value)"
- << ")" << endl;
+ << ")" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_enum_conversion(t_enum* tenum, const string& enum_name) {
// From trait: i32 -> ENUM_TYPE
- f_gen_ << "impl From<i32> for " << enum_name << " {" << endl;
+ f_gen_ << "impl From<i32> for " << enum_name << " {" << '\n';
indent_up();
- f_gen_ << indent() << "fn from(i: i32) -> Self {" << endl;
+ f_gen_ << indent() << "fn from(i: i32) -> Self {" << '\n';
indent_up();
- f_gen_ << indent() << "match i {" << endl;
+ f_gen_ << indent() << "match i {" << '\n';
indent_up();
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator constants_iter;
for (constants_iter = constants.begin(); constants_iter != constants.end(); ++constants_iter) {
t_enum_value* val = (*constants_iter);
f_gen_ << indent() << val->get_value() << " => " << enum_name
- << "::" << rust_enum_variant_name(val->get_name()) << "," << endl;
+ << "::" << rust_enum_variant_name(val->get_name()) << "," << '\n';
}
- f_gen_ << indent() << "_ => " << enum_name << "(i)" << endl;
+ f_gen_ << indent() << "_ => " << enum_name << "(i)" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
// From trait: &i32 -> ENUM_TYPE
- f_gen_ << "impl From<&i32> for " << enum_name << " {" << endl;
+ f_gen_ << "impl From<&i32> for " << enum_name << " {" << '\n';
indent_up();
- f_gen_ << indent() << "fn from(i: &i32) -> Self {" << endl;
+ f_gen_ << indent() << "fn from(i: &i32) -> Self {" << '\n';
indent_up();
- f_gen_ << indent() << enum_name << "::from(*i)" << endl;
+ f_gen_ << indent() << enum_name << "::from(*i)" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
// From trait: ENUM_TYPE -> int
- f_gen_ << "impl From<" << enum_name << "> for i32 {" << endl;
+ f_gen_ << "impl From<" << enum_name << "> for i32 {" << '\n';
indent_up();
- f_gen_ << indent() << "fn from(e: " << enum_name << ") -> i32 {" << endl;
+ f_gen_ << indent() << "fn from(e: " << enum_name << ") -> i32 {" << '\n';
indent_up();
- f_gen_ << indent() << "e.0" << endl;
+ f_gen_ << indent() << "e.0" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
// From trait: &ENUM_TYPE -> int
- f_gen_ << "impl From<&" << enum_name << "> for i32 {" << endl;
+ f_gen_ << "impl From<&" << enum_name << "> for i32 {" << '\n';
indent_up();
- f_gen_ << indent() << "fn from(e: &" << enum_name << ") -> i32 {" << endl;
+ f_gen_ << indent() << "fn from(e: &" << enum_name << ") -> i32 {" << '\n';
indent_up();
- f_gen_ << indent() << "e.0" << endl;
+ f_gen_ << indent() << "e.0" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
//-----------------------------------------------------------------------------
@@ -1056,8 +1055,8 @@
}
}
f_gen_ << "#[derive(Clone, Debug" << (need_default ? ", Default" : "")
- << ", Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl;
- f_gen_ << visibility_qualifier(struct_type) << "struct " << struct_name << " {" << endl;
+ << ", Eq, Hash, Ord, PartialEq, PartialOrd)]" << '\n';
+ f_gen_ << visibility_qualifier(struct_type) << "struct " << struct_name << " {" << '\n';
// render the members
if (!members.empty()) {
@@ -1072,53 +1071,53 @@
render_rustdoc((t_doc*)member);
f_gen_ << indent() << visibility_qualifier(struct_type) << rust_field_name(member) << ": "
- << rust_type << "," << endl;
+ << rust_type << "," << '\n';
}
indent_down();
}
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_exception_struct_error_trait_impls(const string& struct_name,
t_struct* tstruct) {
// error::Error trait
- f_gen_ << "impl Error for " << struct_name << " {}" << endl;
- f_gen_ << endl;
+ f_gen_ << "impl Error for " << struct_name << " {}" << '\n';
+ f_gen_ << '\n';
// convert::From trait
- f_gen_ << "impl From<" << struct_name << "> for thrift::Error {" << endl;
+ f_gen_ << "impl From<" << struct_name << "> for thrift::Error {" << '\n';
indent_up();
- f_gen_ << indent() << "fn from(e: " << struct_name << ") -> Self {" << endl;
+ f_gen_ << indent() << "fn from(e: " << struct_name << ") -> Self {" << '\n';
indent_up();
- f_gen_ << indent() << "thrift::Error::User(Box::new(e))" << endl;
+ f_gen_ << indent() << "thrift::Error::User(Box::new(e))" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
// fmt::Display trait
- f_gen_ << "impl Display for " << struct_name << " {" << endl;
+ f_gen_ << "impl Display for " << struct_name << " {" << '\n';
indent_up();
- f_gen_ << indent() << "fn fmt(&self, f: &mut Formatter) -> fmt::Result {" << endl;
+ f_gen_ << indent() << "fn fmt(&self, f: &mut Formatter) -> fmt::Result {" << '\n';
indent_up();
f_gen_ << indent() << "write!(f, "
<< "\"remote service threw " << tstruct->get_name() << "\"" // use *original* name
- << ")" << endl;
+ << ")" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_struct_impl(const string& struct_name,
t_struct* tstruct,
t_rs_generator::e_struct_type struct_type) {
- f_gen_ << "impl " << struct_name << " {" << endl;
+ f_gen_ << "impl " << struct_name << " {" << '\n';
indent_up();
if (struct_type == t_rs_generator::T_REGULAR || struct_type == t_rs_generator::T_EXCEPTION) {
@@ -1131,10 +1130,10 @@
if (struct_type == t_rs_generator::T_REGULAR || struct_type == t_rs_generator::T_EXCEPTION) {
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
- f_gen_ << "impl TSerializable for " << struct_name << " {" << endl;
+ f_gen_ << "impl TSerializable for " << struct_name << " {" << '\n';
indent_up();
}
@@ -1142,8 +1141,8 @@
render_struct_sync_write(tstruct, struct_type);
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_struct_constructor(const string& struct_name,
@@ -1213,13 +1212,13 @@
string visibility(visibility_qualifier(struct_type));
f_gen_ << indent() << visibility << "fn new" << type_parameter_string << "(" << arg_string
- << ") -> " << struct_name << " " << type_qualifier_string << "{" << endl;
+ << ") -> " << struct_name << " " << type_qualifier_string << "{" << '\n';
indent_up();
if (members.empty()) {
- f_gen_ << indent() << struct_name << " {}" << endl;
+ f_gen_ << indent() << struct_name << " {}" << '\n';
} else {
- f_gen_ << indent() << struct_name << " {" << endl;
+ f_gen_ << indent() << struct_name << " {" << '\n';
indent_up();
for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) {
@@ -1228,18 +1227,18 @@
string member_name(rust_field_name(member));
if (is_optional(member_req)) {
- f_gen_ << indent() << member_name << ": " << member_name << ".into()," << endl;
+ f_gen_ << indent() << member_name << ": " << member_name << ".into()," << '\n';
} else {
- f_gen_ << indent() << member_name << "," << endl;
+ f_gen_ << indent() << member_name << "," << '\n';
}
}
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_result_struct_to_result_method(t_struct* tstruct) {
@@ -1272,7 +1271,7 @@
// maintaining a rendered branch count (while a little ugly) got me the
// rendering I wanted with code that was reasonably understandable
- f_gen_ << indent() << "fn ok_or(self) -> thrift::Result<" << rust_return_type << "> {" << endl;
+ f_gen_ << indent() << "fn ok_or(self) -> thrift::Result<" << rust_return_type << "> {" << '\n';
indent_up();
int rendered_branch_count = 0;
@@ -1284,10 +1283,10 @@
string field_name("self." + rust_field_name(tfield));
string branch_statement = rendered_branch_count == 0 ? "if" : "} else if";
- f_gen_ << indent() << branch_statement << " " << field_name << ".is_some() {" << endl;
+ f_gen_ << indent() << branch_statement << " " << field_name << ".is_some() {" << '\n';
indent_up();
f_gen_ << indent() << "Err(thrift::Error::User(Box::new(" << field_name << ".unwrap())))"
- << endl;
+ << '\n';
indent_down();
rendered_branch_count++;
@@ -1299,35 +1298,35 @@
if (rendered_branch_count == 0) {
// we have the unit return and this service call has no user-defined
// exceptions. this means that we've a trivial return (happens with oneways)
- f_gen_ << indent() << "Ok(())" << endl;
+ f_gen_ << indent() << "Ok(())" << '\n';
} else {
// we have the unit return, but there are user-defined exceptions
// if we've gotten this far then we have the default return (i.e. call successful)
- f_gen_ << indent() << "} else {" << endl;
+ f_gen_ << indent() << "} else {" << '\n';
indent_up();
- f_gen_ << indent() << "Ok(())" << endl;
+ f_gen_ << indent() << "Ok(())" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
} else {
string branch_statement = rendered_branch_count == 0 ? "if" : "} else if";
f_gen_ << indent() << branch_statement << " self." << SERVICE_RESULT_VARIABLE << ".is_some() {"
- << endl;
+ << '\n';
indent_up();
- f_gen_ << indent() << "Ok(self." << SERVICE_RESULT_VARIABLE << ".unwrap())" << endl;
+ f_gen_ << indent() << "Ok(self." << SERVICE_RESULT_VARIABLE << ".unwrap())" << '\n';
indent_down();
- f_gen_ << indent() << "} else {" << endl;
+ f_gen_ << indent() << "} else {" << '\n';
indent_up();
// if we haven't found a valid return value *or* a user exception
// then we're in trouble; return a default error
render_thrift_error("Application", "ApplicationError", "ApplicationErrorKind::MissingResult",
"\"no result received for " + service_call_name + "\"");
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_union(t_struct* tstruct) {
@@ -1343,32 +1342,32 @@
throw "cannot generate rust enum with 0 members"; // may be valid thrift, but it's invalid rust
}
- f_gen_ << "#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << endl;
- f_gen_ << "pub enum " << union_name << " {" << endl;
+ f_gen_ << "#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]" << '\n';
+ f_gen_ << "pub enum " << union_name << " {" << '\n';
indent_up();
vector<t_field*>::const_iterator member_iter;
for (member_iter = members.begin(); member_iter != members.end(); ++member_iter) {
t_field* tfield = (*member_iter);
f_gen_ << indent() << rust_union_field_name(tfield) << "(" << to_rust_type(tfield->get_type())
- << ")," << endl;
+ << ")," << '\n';
}
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_union_impl(const string& union_name, t_struct* tstruct) {
- f_gen_ << "impl TSerializable for " << union_name << " {" << endl;
+ f_gen_ << "impl TSerializable for " << union_name << " {" << '\n';
indent_up();
render_union_sync_read(union_name, tstruct);
render_union_sync_write(union_name, tstruct);
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
//-----------------------------------------------------------------------------
@@ -1382,14 +1381,14 @@
f_gen_
<< indent()
<< "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {"
- << endl;
+ << '\n';
indent_up();
// write struct header to output protocol
// note: use the *original* struct name here
f_gen_ << indent()
- << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl;
- f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << endl;
+ << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << '\n';
+ f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << '\n';
// write struct members to output protocol
vector<t_field*> members = tstruct->get_sorted_members();
@@ -1404,30 +1403,30 @@
}
// write struct footer to output protocol
- f_gen_ << indent() << "o_prot.write_field_stop()?;" << endl;
- f_gen_ << indent() << "o_prot.write_struct_end()" << endl;
+ f_gen_ << indent() << "o_prot.write_field_stop()?;" << '\n';
+ f_gen_ << indent() << "o_prot.write_struct_end()" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_union_sync_write(const string& union_name, t_struct* tstruct) {
f_gen_
<< indent()
<< "fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {"
- << endl;
+ << '\n';
indent_up();
// write struct header to output protocol
// note: use the *original* struct name here
f_gen_ << indent()
- << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << endl;
- f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << endl;
+ << "let struct_ident = TStructIdentifier::new(\"" + tstruct->get_name() + "\");" << '\n';
+ f_gen_ << indent() << "o_prot.write_struct_begin(&struct_ident)?;" << '\n';
// write the enum field to the output protocol
vector<t_field*> members = tstruct->get_sorted_members();
if (!members.empty()) {
- f_gen_ << indent() << "match *self {" << endl;
+ f_gen_ << indent() << "match *self {" << '\n';
indent_up();
vector<t_field*>::iterator members_iter;
for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) {
@@ -1440,22 +1439,22 @@
}
string match_var((ttype->is_base_type() && !ttype->is_string()) ? "f" : "ref f");
f_gen_ << indent() << union_name << "::" << rust_union_field_name(member) << "(" << match_var
- << ") => {" << endl;
+ << ") => {" << '\n';
indent_up();
render_struct_field_sync_write("f", true, member, member_req);
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
}
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
// write struct footer to output protocol
- f_gen_ << indent() << "o_prot.write_field_stop()?;" << endl;
- f_gen_ << indent() << "o_prot.write_struct_end()" << endl;
+ f_gen_ << indent() << "o_prot.write_field_stop()?;" << '\n';
+ f_gen_ << indent() << "o_prot.write_struct_end()" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_struct_field_sync_write(const string& field_var,
@@ -1475,23 +1474,23 @@
if (is_optional(req)) {
string let_var((actual_type->is_base_type() && !actual_type->is_string()) ? "fld_var"
: "ref fld_var");
- f_gen_ << indent() << "if let Some(" << let_var << ") = " << field_var << " {" << endl;
+ f_gen_ << indent() << "if let Some(" << let_var << ") = " << field_var << " {" << '\n';
indent_up();
- f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << '\n';
render_type_sync_write("fld_var", true, field_type);
- f_gen_ << indent() << "o_prot.write_field_end()?" << endl;
+ f_gen_ << indent() << "o_prot.write_field_end()?" << '\n';
indent_down();
/* FIXME: rethink how I deal with OPT_IN_REQ_OUT
if (req == t_field::T_OPT_IN_REQ_OUT) {
- f_gen_ << indent() << "let field_ident = " << field_ident_string << ";" << endl;
- f_gen_ << indent() << "o_prot.write_field_begin(&field_ident)?;" << endl;
- f_gen_ << indent() << "o_prot.write_field_end()?;" << endl;
+ f_gen_ << indent() << "let field_ident = " << field_ident_string << ";" << '\n';
+ f_gen_ << indent() << "o_prot.write_field_begin(&field_ident)?;" << '\n';
+ f_gen_ << indent() << "o_prot.write_field_end()?;" << '\n';
}*/
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
} else {
- f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_field_begin(&" << field_ident_string << ")?;" << '\n';
render_type_sync_write(field_var, field_var_is_ref, tfield->get_type());
- f_gen_ << indent() << "o_prot.write_field_end()?;" << endl;
+ f_gen_ << indent() << "o_prot.write_field_end()?;" << '\n';
}
}
@@ -1506,32 +1505,32 @@
case t_base_type::TYPE_STRING: {
string ref(type_var_is_ref ? "" : "&");
if (tbase_type->is_binary()) {
- f_gen_ << indent() << "o_prot.write_bytes(" + ref + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_bytes(" + ref + type_var + ")?;" << '\n';
} else {
- f_gen_ << indent() << "o_prot.write_string(" + ref + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_string(" + ref + type_var + ")?;" << '\n';
}
return;
}
case t_base_type::TYPE_UUID:
- f_gen_ << indent() << "o_prot.write_uuid(&" + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_uuid(&" + type_var + ")?;" << '\n';
return;
case t_base_type::TYPE_BOOL:
- f_gen_ << indent() << "o_prot.write_bool(" + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_bool(" + type_var + ")?;" << '\n';
return;
case t_base_type::TYPE_I8:
- f_gen_ << indent() << "o_prot.write_i8(" + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_i8(" + type_var + ")?;" << '\n';
return;
case t_base_type::TYPE_I16:
- f_gen_ << indent() << "o_prot.write_i16(" + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_i16(" + type_var + ")?;" << '\n';
return;
case t_base_type::TYPE_I32:
- f_gen_ << indent() << "o_prot.write_i32(" + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_i32(" + type_var + ")?;" << '\n';
return;
case t_base_type::TYPE_I64:
- f_gen_ << indent() << "o_prot.write_i64(" + type_var + ")?;" << endl;
+ f_gen_ << indent() << "o_prot.write_i64(" + type_var + ")?;" << '\n';
return;
case t_base_type::TYPE_DOUBLE:
- f_gen_ << indent() << "o_prot.write_double(" + type_var + ".into())?;" << endl;
+ f_gen_ << indent() << "o_prot.write_double(" + type_var + ".into())?;" << '\n';
return;
default:
throw "compiler error: unhandled type";
@@ -1541,7 +1540,7 @@
render_type_sync_write(type_var, type_var_is_ref, ttypedef->get_type());
return;
} else if (ttype->is_enum() || ttype->is_struct() || ttype->is_xception()) {
- f_gen_ << indent() << type_var + ".write_to_out_protocol(o_prot)?;" << endl;
+ f_gen_ << indent() << type_var + ".write_to_out_protocol(o_prot)?;" << '\n';
return;
} else if (ttype->is_map()) {
render_map_sync_write(type_var, type_var_is_ref, (t_map*)ttype);
@@ -1566,15 +1565,15 @@
<< "&TListIdentifier::new(" << to_rust_field_type_enum(elem_type) << ", " << list_var
<< ".len() as i32"
<< ")"
- << ")?;" << endl;
+ << ")?;" << '\n';
string ref(list_var_is_ref ? "" : "&");
- f_gen_ << indent() << "for e in " << ref << list_var << " {" << endl;
+ f_gen_ << indent() << "for e in " << ref << list_var << " {" << '\n';
indent_up();
render_type_sync_write(string_container_write_variable(elem_type, "e"), true, elem_type);
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << indent() << "o_prot.write_list_end()?;" << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << indent() << "o_prot.write_list_end()?;" << '\n';
}
void t_rs_generator::render_set_sync_write(const string& set_var,
@@ -1586,15 +1585,15 @@
<< "&TSetIdentifier::new(" << to_rust_field_type_enum(elem_type) << ", " << set_var
<< ".len() as i32"
<< ")"
- << ")?;" << endl;
+ << ")?;" << '\n';
string ref(set_var_is_ref ? "" : "&");
- f_gen_ << indent() << "for e in " << ref << set_var << " {" << endl;
+ f_gen_ << indent() << "for e in " << ref << set_var << " {" << '\n';
indent_up();
render_type_sync_write(string_container_write_variable(elem_type, "e"), true, elem_type);
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << indent() << "o_prot.write_set_end()?;" << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << indent() << "o_prot.write_set_end()?;" << '\n';
}
void t_rs_generator::render_map_sync_write(const string& map_var,
@@ -1606,16 +1605,16 @@
f_gen_ << indent() << "o_prot.write_map_begin("
<< "&TMapIdentifier::new(" << to_rust_field_type_enum(key_type) << ", "
<< to_rust_field_type_enum(val_type) << ", " << map_var << ".len() as i32)"
- << ")?;" << endl;
+ << ")?;" << '\n';
string ref(map_var_is_ref ? "" : "&");
- f_gen_ << indent() << "for (k, v) in " << ref << map_var << " {" << endl;
+ f_gen_ << indent() << "for (k, v) in " << ref << map_var << " {" << '\n';
indent_up();
render_type_sync_write(string_container_write_variable(key_type, "k"), true, key_type);
render_type_sync_write(string_container_write_variable(val_type, "v"), true, val_type);
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << indent() << "o_prot.write_map_end()?;" << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << indent() << "o_prot.write_map_end()?;" << '\n';
}
string t_rs_generator::string_container_write_variable(t_type* ttype, const string& base_var) {
@@ -1651,11 +1650,11 @@
t_rs_generator::e_struct_type struct_type) {
f_gen_ << indent()
<< "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<"
- << struct_name << "> {" << endl;
+ << struct_name << "> {" << '\n';
indent_up();
- f_gen_ << indent() << "i_prot.read_struct_begin()?;" << endl;
+ f_gen_ << indent() << "i_prot.read_struct_begin()?;" << '\n';
// create temporary variables: one for each field in the struct
const vector<t_field*> members = tstruct->get_sorted_members();
@@ -1671,55 +1670,55 @@
} else {
f_gen_ << "None;";
}
- f_gen_ << endl;
+ f_gen_ << '\n';
}
// now loop through the fields we've received
- f_gen_ << indent() << "loop {" << endl; // start loop
+ f_gen_ << indent() << "loop {" << '\n'; // start loop
indent_up();
// break out if you've found the Stop field
- f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << endl;
- f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << endl;
+ f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << '\n';
+ f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << '\n';
indent_up();
- f_gen_ << indent() << "break;" << endl;
+ f_gen_ << indent() << "break;" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
// now read all the fields found
// avoid clippy::match_single_binding
if (members.empty()) {
- f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << endl;
+ f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << '\n';
} else {
- f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << endl;
- f_gen_ << indent() << "match field_id {" << endl; // start match
+ f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << '\n';
+ f_gen_ << indent() << "match field_id {" << '\n'; // start match
indent_up();
for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) {
t_field* tfield = (*members_iter);
- f_gen_ << indent() << rust_safe_field_id(tfield->get_key()) << " => {" << endl;
+ f_gen_ << indent() << rust_safe_field_id(tfield->get_key()) << " => {" << '\n';
indent_up();
render_type_sync_read("val", tfield->get_type());
- f_gen_ << indent() << struct_field_read_temp_variable(tfield) << " = Some(val);" << endl;
+ f_gen_ << indent() << struct_field_read_temp_variable(tfield) << " = Some(val);" << '\n';
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
}
// default case (skip fields)
- f_gen_ << indent() << "_ => {" << endl;
+ f_gen_ << indent() << "_ => {" << '\n';
indent_up();
- f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << endl;
+ f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << '\n';
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
indent_down();
- f_gen_ << indent() << "};" << endl; // finish match
+ f_gen_ << indent() << "};" << '\n'; // finish match
}
- f_gen_ << indent() << "i_prot.read_field_end()?;" << endl;
+ f_gen_ << indent() << "i_prot.read_field_end()?;" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl; // finish loop
- f_gen_ << indent() << "i_prot.read_struct_end()?;" << endl; // read message footer from the wire
+ f_gen_ << indent() << "}" << '\n'; // finish loop
+ f_gen_ << indent() << "i_prot.read_struct_end()?;" << '\n'; // read message footer from the wire
// verify that all required fields exist
for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) {
@@ -1729,15 +1728,15 @@
f_gen_ << indent() << "verify_required_field_exists("
<< "\"" << struct_name << "." << rust_field_name(tfield) << "\""
<< ", "
- << "&" << struct_field_read_temp_variable(tfield) << ")?;" << endl;
+ << "&" << struct_field_read_temp_variable(tfield) << ")?;" << '\n';
}
}
// construct the struct
if (members.size() == 0) {
- f_gen_ << indent() << "let ret = " << struct_name << " {};" << endl;
+ f_gen_ << indent() << "let ret = " << struct_name << " {};" << '\n';
} else {
- f_gen_ << indent() << "let ret = " << struct_name << " {" << endl;
+ f_gen_ << indent() << "let ret = " << struct_name << " {" << '\n';
indent_up();
for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) {
@@ -1746,109 +1745,109 @@
string field_name(rust_field_name(tfield));
string field_key = struct_field_read_temp_variable(tfield);
if (is_optional(req)) {
- f_gen_ << indent() << field_name << ": " << field_key << "," << endl;
+ f_gen_ << indent() << field_name << ": " << field_key << "," << '\n';
} else {
f_gen_ << indent() << field_name << ": " << field_key
<< ".expect(\"auto-generated code should have checked for presence of required "
"fields\")"
- << "," << endl;
+ << "," << '\n';
}
}
indent_down();
- f_gen_ << indent() << "};" << endl;
+ f_gen_ << indent() << "};" << '\n';
}
// return the constructed value
- f_gen_ << indent() << "Ok(ret)" << endl;
+ f_gen_ << indent() << "Ok(ret)" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_union_sync_read(const string& union_name, t_struct* tstruct) {
f_gen_ << indent()
<< "fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<"
- << union_name << "> {" << endl;
+ << union_name << "> {" << '\n';
indent_up();
// create temporary variables to hold the
// completed union as well as a count of fields read
- f_gen_ << indent() << "let mut ret: Option<" << union_name << "> = None;" << endl;
- f_gen_ << indent() << "let mut received_field_count = 0;" << endl;
+ f_gen_ << indent() << "let mut ret: Option<" << union_name << "> = None;" << '\n';
+ f_gen_ << indent() << "let mut received_field_count = 0;" << '\n';
// read the struct preamble
- f_gen_ << indent() << "i_prot.read_struct_begin()?;" << endl;
+ f_gen_ << indent() << "i_prot.read_struct_begin()?;" << '\n';
// now loop through the fields we've received
- f_gen_ << indent() << "loop {" << endl; // start loop
+ f_gen_ << indent() << "loop {" << '\n'; // start loop
indent_up();
// break out if you've found the Stop field
- f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << endl;
- f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << endl;
+ f_gen_ << indent() << "let field_ident = i_prot.read_field_begin()?;" << '\n';
+ f_gen_ << indent() << "if field_ident.field_type == TType::Stop {" << '\n';
indent_up();
- f_gen_ << indent() << "break;" << endl;
+ f_gen_ << indent() << "break;" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
// now read all the fields found
- f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << endl;
- f_gen_ << indent() << "match field_id {" << endl; // start match
+ f_gen_ << indent() << "let field_id = field_id(&field_ident)?;" << '\n';
+ f_gen_ << indent() << "match field_id {" << '\n'; // start match
indent_up();
const vector<t_field*> members = tstruct->get_sorted_members();
vector<t_field*>::const_iterator members_iter;
for (members_iter = members.begin(); members_iter != members.end(); ++members_iter) {
t_field* member = (*members_iter);
- f_gen_ << indent() << rust_safe_field_id(member->get_key()) << " => {" << endl;
+ f_gen_ << indent() << rust_safe_field_id(member->get_key()) << " => {" << '\n';
indent_up();
render_type_sync_read("val", member->get_type());
- f_gen_ << indent() << "if ret.is_none() {" << endl;
+ f_gen_ << indent() << "if ret.is_none() {" << '\n';
indent_up();
f_gen_ << indent() << "ret = Some(" << union_name << "::" << rust_union_field_name(member)
- << "(val));" << endl;
+ << "(val));" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << indent() << "received_field_count += 1;" << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << indent() << "received_field_count += 1;" << '\n';
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
}
// default case (skip fields)
- f_gen_ << indent() << "_ => {" << endl;
+ f_gen_ << indent() << "_ => {" << '\n';
indent_up();
- f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << endl;
- f_gen_ << indent() << "received_field_count += 1;" << endl;
+ f_gen_ << indent() << "i_prot.skip(field_ident.field_type)?;" << '\n';
+ f_gen_ << indent() << "received_field_count += 1;" << '\n';
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
indent_down();
- f_gen_ << indent() << "};" << endl; // finish match
- f_gen_ << indent() << "i_prot.read_field_end()?;" << endl;
+ f_gen_ << indent() << "};" << '\n'; // finish match
+ f_gen_ << indent() << "i_prot.read_field_end()?;" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl; // finish loop
- f_gen_ << indent() << "i_prot.read_struct_end()?;" << endl; // finish reading message from wire
+ f_gen_ << indent() << "}" << '\n'; // finish loop
+ f_gen_ << indent() << "i_prot.read_struct_end()?;" << '\n'; // finish reading message from wire
// return the value or an error
- f_gen_ << indent() << "if received_field_count == 0 {" << endl;
+ f_gen_ << indent() << "if received_field_count == 0 {" << '\n';
indent_up();
render_thrift_error("Protocol", "ProtocolError", "ProtocolErrorKind::InvalidData",
"\"received empty union from remote " + union_name + "\"");
indent_down();
- f_gen_ << indent() << "} else if received_field_count > 1 {" << endl;
+ f_gen_ << indent() << "} else if received_field_count > 1 {" << '\n';
indent_up();
render_thrift_error("Protocol", "ProtocolError", "ProtocolErrorKind::InvalidData",
"\"received multiple fields for union from remote " + union_name + "\"");
indent_down();
- f_gen_ << indent() << "} else {" << endl;
+ f_gen_ << indent() << "} else {" << '\n';
indent_up();
- f_gen_ << indent() << "Ok(ret.expect(\"return value should have been constructed\"))" << endl;
+ f_gen_ << indent() << "Ok(ret.expect(\"return value should have been constructed\"))" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
// Construct the rust representation of all supported types from the wire.
@@ -1860,32 +1859,32 @@
throw "cannot read field of type TYPE_VOID from input protocol";
case t_base_type::TYPE_STRING:
if (tbase_type->is_binary()) {
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_bytes()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_bytes()?;" << '\n';
} else {
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_string()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_string()?;" << '\n';
}
return;
case t_base_type::TYPE_UUID:
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_uuid()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_uuid()?;" << '\n';
return;
case t_base_type::TYPE_BOOL:
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_bool()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_bool()?;" << '\n';
return;
case t_base_type::TYPE_I8:
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_i8()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_i8()?;" << '\n';
return;
case t_base_type::TYPE_I16:
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_i16()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_i16()?;" << '\n';
return;
case t_base_type::TYPE_I32:
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_i32()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_i32()?;" << '\n';
return;
case t_base_type::TYPE_I64:
- f_gen_ << indent() << "let " << type_var << " = i_prot.read_i64()?;" << endl;
+ f_gen_ << indent() << "let " << type_var << " = i_prot.read_i64()?;" << '\n';
return;
case t_base_type::TYPE_DOUBLE:
f_gen_ << indent() << "let " << type_var << " = OrderedFloat::from(i_prot.read_double()?);"
- << endl;
+ << '\n';
return;
default:
throw "compiler error: unhandled type";
@@ -1905,7 +1904,7 @@
} else if (ttype->is_enum() || ttype->is_struct() || ttype->is_xception()) {
string read_call(to_rust_type(ttype) + "::read_from_in_protocol(i_prot)?");
read_call = is_boxed ? "Box::new(" + read_call + ")" : read_call;
- f_gen_ << indent() << "let " << type_var << " = " << read_call << ";" << endl;
+ f_gen_ << indent() << "let " << type_var << " = " << read_call << ";" << '\n';
return;
} else if (ttype->is_map()) {
render_map_sync_read((t_map*)ttype, type_var);
@@ -1925,42 +1924,42 @@
void t_rs_generator::render_list_sync_read(t_list* tlist, const string& list_var) {
t_type* elem_type = tlist->get_elem_type();
- f_gen_ << indent() << "let list_ident = i_prot.read_list_begin()?;" << endl;
+ f_gen_ << indent() << "let list_ident = i_prot.read_list_begin()?;" << '\n';
f_gen_ << indent() << "let mut " << list_var << ": " << to_rust_type((t_type*)tlist)
- << " = Vec::with_capacity(list_ident.size as usize);" << endl;
- f_gen_ << indent() << "for _ in 0..list_ident.size {" << endl;
+ << " = Vec::with_capacity(list_ident.size as usize);" << '\n';
+ f_gen_ << indent() << "for _ in 0..list_ident.size {" << '\n';
indent_up();
string list_elem_var = tmp("list_elem_");
render_type_sync_read(list_elem_var, elem_type);
- f_gen_ << indent() << list_var << ".push(" << list_elem_var << ");" << endl;
+ f_gen_ << indent() << list_var << ".push(" << list_elem_var << ");" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << indent() << "i_prot.read_list_end()?;" << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << indent() << "i_prot.read_list_end()?;" << '\n';
}
// Construct the rust representation of a set from the wire.
void t_rs_generator::render_set_sync_read(t_set* tset, const string& set_var) {
t_type* elem_type = tset->get_elem_type();
- f_gen_ << indent() << "let set_ident = i_prot.read_set_begin()?;" << endl;
+ f_gen_ << indent() << "let set_ident = i_prot.read_set_begin()?;" << '\n';
f_gen_ << indent() << "let mut " << set_var << ": " << to_rust_type((t_type*)tset)
- << " = BTreeSet::new();" << endl;
- f_gen_ << indent() << "for _ in 0..set_ident.size {" << endl;
+ << " = BTreeSet::new();" << '\n';
+ f_gen_ << indent() << "for _ in 0..set_ident.size {" << '\n';
indent_up();
string set_elem_var = tmp("set_elem_");
render_type_sync_read(set_elem_var, elem_type);
- f_gen_ << indent() << set_var << ".insert(" << set_elem_var << ");" << endl;
+ f_gen_ << indent() << set_var << ".insert(" << set_elem_var << ");" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << indent() << "i_prot.read_set_end()?;" << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << indent() << "i_prot.read_set_end()?;" << '\n';
}
// Construct the rust representation of a map from the wire.
@@ -1968,10 +1967,10 @@
t_type* key_type = tmap->get_key_type();
t_type* val_type = tmap->get_val_type();
- f_gen_ << indent() << "let map_ident = i_prot.read_map_begin()?;" << endl;
+ f_gen_ << indent() << "let map_ident = i_prot.read_map_begin()?;" << '\n';
f_gen_ << indent() << "let mut " << map_var << ": " << to_rust_type((t_type*)tmap)
- << " = BTreeMap::new();" << endl;
- f_gen_ << indent() << "for _ in 0..map_ident.size {" << endl;
+ << " = BTreeMap::new();" << '\n';
+ f_gen_ << indent() << "for _ in 0..map_ident.size {" << '\n';
indent_up();
@@ -1980,12 +1979,12 @@
string val_elem_var = tmp("map_val_");
render_type_sync_read(val_elem_var, val_type);
f_gen_ << indent() << map_var << ".insert(" << key_elem_var << ", " << val_elem_var << ");"
- << endl;
+ << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << indent() << "i_prot.read_map_end()?;" << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << indent() << "i_prot.read_map_end()?;" << '\n';
}
string t_rs_generator::struct_field_read_temp_variable(t_field* tfield) {
@@ -2036,7 +2035,7 @@
render_sync_client_definition_and_impl(client_impl_name);
render_sync_client_tthriftclient_impl(client_impl_name);
render_sync_client_marker_trait_impls(tservice, client_impl_name);
- f_gen_ << endl;
+ f_gen_ << '\n';
render_sync_client_process_impl(tservice);
}
@@ -2048,7 +2047,7 @@
}
render_rustdoc((t_doc*)tservice);
- f_gen_ << "pub trait " << rust_sync_client_trait_name(tservice) << extension << " {" << endl;
+ f_gen_ << "pub trait " << rust_sync_client_trait_name(tservice) << extension << " {" << '\n';
indent_up();
const std::vector<t_function*> functions = tservice->get_functions();
@@ -2060,25 +2059,25 @@
string func_return = to_rust_type(tfunc->get_returntype());
render_rustdoc((t_doc*)tfunc);
f_gen_ << indent() << "fn " << func_name << func_args << " -> thrift::Result<" << func_return
- << ">;" << endl;
+ << ">;" << '\n';
}
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_sync_client_marker_trait(t_service* tservice) {
f_gen_ << indent() << "pub trait " << rust_sync_client_marker_trait_name(tservice) << " {}"
- << endl;
- f_gen_ << endl;
+ << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_sync_client_marker_trait_impls(t_service* tservice,
const string& impl_struct_name) {
f_gen_ << indent() << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << rust_namespace(tservice)
<< rust_sync_client_marker_trait_name(tservice) << " for " << impl_struct_name
- << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {}" << endl;
+ << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {}" << '\n';
t_service* extends = tservice->get_extends();
if (extends) {
@@ -2090,64 +2089,64 @@
// render the definition for the client struct
f_gen_ << "pub struct " << client_impl_name << SYNC_CLIENT_GENERIC_BOUND_VARS << " "
- << SYNC_CLIENT_GENERIC_BOUNDS << " {" << endl;
+ << SYNC_CLIENT_GENERIC_BOUNDS << " {" << '\n';
indent_up();
- f_gen_ << indent() << "_i_prot: IP," << endl;
- f_gen_ << indent() << "_o_prot: OP," << endl;
- f_gen_ << indent() << "_sequence_number: i32," << endl;
+ f_gen_ << indent() << "_i_prot: IP," << '\n';
+ f_gen_ << indent() << "_o_prot: OP," << '\n';
+ f_gen_ << indent() << "_sequence_number: i32," << '\n';
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
// render the struct implementation
// this includes the new() function as well as the helper send/recv methods for each service call
f_gen_ << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << client_impl_name
- << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {" << endl;
+ << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS << " {" << '\n';
indent_up();
render_sync_client_lifecycle_functions(client_impl_name);
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_sync_client_lifecycle_functions(const string& client_struct) {
f_gen_ << indent() << "pub fn new(input_protocol: IP, output_protocol: OP) -> " << client_struct
- << SYNC_CLIENT_GENERIC_BOUND_VARS << " {" << endl;
+ << SYNC_CLIENT_GENERIC_BOUND_VARS << " {" << '\n';
indent_up();
f_gen_ << indent() << client_struct
- << " { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }" << endl;
+ << " { _i_prot: input_protocol, _o_prot: output_protocol, _sequence_number: 0 }" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_sync_client_tthriftclient_impl(const string& client_impl_name) {
f_gen_ << indent() << "impl " << SYNC_CLIENT_GENERIC_BOUND_VARS << " TThriftClient for "
<< client_impl_name << SYNC_CLIENT_GENERIC_BOUND_VARS << " " << SYNC_CLIENT_GENERIC_BOUNDS
- << " {" << endl;
+ << " {" << '\n';
indent_up();
f_gen_ << indent() << "fn i_prot_mut(&mut self) -> &mut dyn TInputProtocol { &mut self._i_prot }"
- << endl;
+ << '\n';
f_gen_ << indent() << "fn o_prot_mut(&mut self) -> &mut dyn TOutputProtocol { &mut self._o_prot }"
- << endl;
- f_gen_ << indent() << "fn sequence_number(&self) -> i32 { self._sequence_number }" << endl;
+ << '\n';
+ f_gen_ << indent() << "fn sequence_number(&self) -> i32 { self._sequence_number }" << '\n';
f_gen_ << indent()
<< "fn increment_sequence_number(&mut self) -> i32 { self._sequence_number += 1; "
"self._sequence_number }"
- << endl;
+ << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_sync_client_process_impl(t_service* tservice) {
string marker_extension = "" + sync_client_marker_traits_for_extension(tservice);
f_gen_ << "impl <C: TThriftClient + " << rust_sync_client_marker_trait_name(tservice)
- << marker_extension << "> " << rust_sync_client_trait_name(tservice) << " for C {" << endl;
+ << marker_extension << "> " << rust_sync_client_trait_name(tservice) << " for C {" << '\n';
indent_up();
const std::vector<t_function*> functions = tservice->get_functions();
@@ -2158,8 +2157,8 @@
}
indent_down();
- f_gen_ << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << "}" << '\n';
+ f_gen_ << '\n';
}
string t_rs_generator::sync_client_marker_traits_for_extension(t_service* tservice) {
@@ -2182,35 +2181,35 @@
string func_return = to_rust_type(tfunc->get_returntype());
f_gen_ << indent() << "fn " << func_name << func_decl_args << " -> thrift::Result<" << func_return
- << "> {" << endl;
+ << "> {" << '\n';
indent_up();
- f_gen_ << indent() << "(" << endl;
+ f_gen_ << indent() << "(" << '\n';
indent_up();
render_sync_send(tfunc);
indent_down();
- f_gen_ << indent() << ")?;" << endl;
+ f_gen_ << indent() << ")?;" << '\n';
if (tfunc->is_oneway()) {
- f_gen_ << indent() << "Ok(())" << endl;
+ f_gen_ << indent() << "Ok(())" << '\n';
} else {
render_sync_recv(tfunc);
}
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_sync_send(t_function* tfunc) {
- f_gen_ << indent() << "{" << endl;
+ f_gen_ << indent() << "{" << '\n';
indent_up();
// increment the sequence number and generate the call header
string message_type = tfunc->is_oneway() ? "TMessageType::OneWay" : "TMessageType::Call";
- f_gen_ << indent() << "self.increment_sequence_number();" << endl;
+ f_gen_ << indent() << "self.increment_sequence_number();" << '\n';
f_gen_ << indent() << "let message_ident = "
<< "TMessageIdentifier::new(\"" << tfunc->get_name() << "\", " // note: use *original* name
<< message_type << ", "
- << "self.sequence_number());" << endl;
+ << "self.sequence_number());" << '\n';
// pack the arguments into the containing struct that we'll write out over the wire
// note that this struct is generated even if we have 0 args
ostringstream struct_definition;
@@ -2226,50 +2225,50 @@
struct_fields = struct_fields.substr(0, struct_fields.size() - 2); // strip trailing comma
}
f_gen_ << indent() << "let call_args = " << service_call_args_struct_name(tfunc) << " { "
- << struct_fields << " };" << endl;
+ << struct_fields << " };" << '\n';
// write everything over the wire
- f_gen_ << indent() << "self.o_prot_mut().write_message_begin(&message_ident)?;" << endl;
+ f_gen_ << indent() << "self.o_prot_mut().write_message_begin(&message_ident)?;" << '\n';
f_gen_ << indent() << "call_args.write_to_out_protocol(self.o_prot_mut())?;"
- << endl; // written even if we have 0 args
- f_gen_ << indent() << "self.o_prot_mut().write_message_end()?;" << endl;
- f_gen_ << indent() << "self.o_prot_mut().flush()" << endl;
+ << '\n'; // written even if we have 0 args
+ f_gen_ << indent() << "self.o_prot_mut().write_message_end()?;" << '\n';
+ f_gen_ << indent() << "self.o_prot_mut().flush()" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_sync_recv(t_function* tfunc) {
- f_gen_ << indent() << "{" << endl;
+ f_gen_ << indent() << "{" << '\n';
indent_up();
- f_gen_ << indent() << "let message_ident = self.i_prot_mut().read_message_begin()?;" << endl;
+ f_gen_ << indent() << "let message_ident = self.i_prot_mut().read_message_begin()?;" << '\n';
f_gen_
<< indent()
<< "verify_expected_sequence_number(self.sequence_number(), message_ident.sequence_number)?;"
- << endl;
+ << '\n';
f_gen_ << indent() << "verify_expected_service_call(\"" << tfunc->get_name()
- << "\", &message_ident.name)?;" << endl; // note: use *original* name
+ << "\", &message_ident.name)?;" << '\n'; // note: use *original* name
// FIXME: replace with a "try" block
- f_gen_ << indent() << "if message_ident.message_type == TMessageType::Exception {" << endl;
+ f_gen_ << indent() << "if message_ident.message_type == TMessageType::Exception {" << '\n';
indent_up();
f_gen_ << indent()
<< "let remote_error = "
"thrift::Error::read_application_error_from_in_protocol(self.i_prot_mut())?;"
- << endl;
- f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << endl;
- f_gen_ << indent() << "return Err(thrift::Error::Application(remote_error))" << endl;
+ << '\n';
+ f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << '\n';
+ f_gen_ << indent() << "return Err(thrift::Error::Application(remote_error))" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
f_gen_ << indent()
<< "verify_expected_message_type(TMessageType::Reply, message_ident.message_type)?;"
- << endl;
+ << '\n';
f_gen_ << indent() << "let result = " << service_call_result_struct_name(tfunc)
- << "::read_from_in_protocol(self.i_prot_mut())?;" << endl;
- f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << endl;
- f_gen_ << indent() << "result.ok_or()" << endl;
+ << "::read_from_in_protocol(self.i_prot_mut())?;" << '\n';
+ f_gen_ << indent() << "self.i_prot_mut().read_message_end()?;" << '\n';
+ f_gen_ << indent() << "result.ok_or()" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
string t_rs_generator::rust_sync_service_call_declaration(t_function* tfunc, bool self_is_mutable) {
@@ -2400,7 +2399,7 @@
std::vector<t_function*>::const_iterator func_iter;
render_rustdoc((t_doc*)tservice);
- f_gen_ << "pub trait " << rust_sync_handler_trait_name(tservice) << extension << " {" << endl;
+ f_gen_ << "pub trait " << rust_sync_handler_trait_name(tservice) << extension << " {" << '\n';
indent_up();
for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) {
t_function* tfunc = (*func_iter);
@@ -2409,11 +2408,11 @@
string func_return = to_rust_type(tfunc->get_returntype());
render_rustdoc((t_doc*)tfunc);
f_gen_ << indent() << "fn " << func_name << func_args << " -> thrift::Result<" << func_return
- << ">;" << endl;
+ << ">;" << '\n';
}
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_sync_processor_definition_and_impl(t_service* tservice) {
@@ -2422,36 +2421,36 @@
// struct
f_gen_ << indent() << "pub struct " << service_processor_name << "<H: " << handler_trait_name
- << "> {" << endl;
+ << "> {" << '\n';
indent_up();
- f_gen_ << indent() << "handler: H," << endl;
+ f_gen_ << indent() << "handler: H," << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
// delegating impl
f_gen_ << indent() << "impl <H: " << handler_trait_name << "> " << service_processor_name
- << "<H> {" << endl;
+ << "<H> {" << '\n';
indent_up();
- f_gen_ << indent() << "pub fn new(handler: H) -> " << service_processor_name << "<H> {" << endl;
+ f_gen_ << indent() << "pub fn new(handler: H) -> " << service_processor_name << "<H> {" << '\n';
indent_up();
- f_gen_ << indent() << service_processor_name << " {" << endl;
+ f_gen_ << indent() << service_processor_name << " {" << '\n';
indent_up();
- f_gen_ << indent() << "handler," << endl;
+ f_gen_ << indent() << "handler," << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
render_sync_process_delegation_functions(tservice);
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
// actual impl
string service_actual_processor_name = rust_sync_processor_impl_name(tservice);
- f_gen_ << indent() << "pub struct " << service_actual_processor_name << ";" << endl;
- f_gen_ << endl;
- f_gen_ << indent() << "impl " << service_actual_processor_name << " {" << endl;
+ f_gen_ << indent() << "pub struct " << service_actual_processor_name << ";" << '\n';
+ f_gen_ << '\n';
+ f_gen_ << indent() << "impl " << service_actual_processor_name << " {" << '\n';
indent_up();
vector<t_function*> functions = tservice->get_functions();
@@ -2462,44 +2461,44 @@
}
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
// processor impl
f_gen_ << indent() << "impl <H: " << handler_trait_name << "> TProcessor for "
- << service_processor_name << "<H> {" << endl;
+ << service_processor_name << "<H> {" << '\n';
indent_up();
f_gen_ << indent()
<< "fn process(&self, i_prot: &mut dyn TInputProtocol, o_prot: &mut dyn TOutputProtocol) "
"-> thrift::Result<()> {"
- << endl;
+ << '\n';
indent_up();
- f_gen_ << indent() << "let message_ident = i_prot.read_message_begin()?;" << endl;
+ f_gen_ << indent() << "let message_ident = i_prot.read_message_begin()?;" << '\n';
f_gen_ << indent() << "let res = match &*message_ident.name {"
- << endl; // [sigh] explicit deref coercion
+ << '\n'; // [sigh] explicit deref coercion
indent_up();
render_process_match_statements(tservice);
- f_gen_ << indent() << "method => {" << endl;
+ f_gen_ << indent() << "method => {" << '\n';
indent_up();
render_thrift_error("Application", "ApplicationError", "ApplicationErrorKind::UnknownMethod",
"format!(\"unknown method {}\", method)");
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
indent_down();
- f_gen_ << indent() << "};" << endl;
+ f_gen_ << indent() << "};" << '\n';
f_gen_ << indent() << "thrift::server::handle_process_result(&message_ident, res, o_prot)"
- << endl;
+ << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
- f_gen_ << endl;
+ f_gen_ << indent() << "}" << '\n';
+ f_gen_ << '\n';
}
void t_rs_generator::render_sync_process_delegation_functions(t_service* tservice) {
@@ -2514,7 +2513,7 @@
<< "incoming_sequence_number: i32, "
<< "i_prot: &mut dyn TInputProtocol, "
<< "o_prot: &mut dyn TOutputProtocol) "
- << "-> thrift::Result<()> {" << endl;
+ << "-> thrift::Result<()> {" << '\n';
indent_up();
f_gen_ << indent() << actual_processor << "::" << function_name << "("
@@ -2522,10 +2521,10 @@
<< "incoming_sequence_number, "
<< "i_prot, "
<< "o_prot"
- << ")" << endl;
+ << ")" << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
t_service* extends = tservice->get_extends();
@@ -2540,12 +2539,12 @@
for (func_iter = functions.begin(); func_iter != functions.end(); ++func_iter) {
t_function* tfunc = (*func_iter);
f_gen_ << indent() << "\"" << tfunc->get_name() << "\""
- << " => {" << endl; // note: use *original* name
+ << " => {" << '\n'; // note: use *original* name
indent_up();
f_gen_ << indent() << "self.process_" << rust_snake_case(tfunc->get_name())
- << "(message_ident.sequence_number, i_prot, o_prot)" << endl;
+ << "(message_ident.sequence_number, i_prot, o_prot)" << '\n';
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
}
t_service* extends = tservice->get_extends();
@@ -2568,90 +2567,90 @@
<< "(handler: &H, " << sequence_number_param << ": i32, "
<< "i_prot: &mut dyn TInputProtocol, " << output_protocol_param
<< ": &mut dyn TOutputProtocol) "
- << "-> thrift::Result<()> {" << endl;
+ << "-> thrift::Result<()> {" << '\n';
indent_up();
// *always* read arguments from the input protocol
f_gen_ << indent() << "let " << (has_non_void_args(tfunc) ? "args" : "_") << " = "
- << service_call_args_struct_name(tfunc) << "::read_from_in_protocol(i_prot)?;" << endl;
+ << service_call_args_struct_name(tfunc) << "::read_from_in_protocol(i_prot)?;" << '\n';
f_gen_ << indent() << "match handler." << service_call_handler_function_name(tfunc)
- << rust_sync_service_call_invocation(tfunc, "args.") << " {" << endl; // start match
+ << rust_sync_service_call_invocation(tfunc, "args.") << " {" << '\n'; // start match
indent_up();
// handler succeeded
string handler_return_variable
= tfunc->is_oneway() || tfunc->get_returntype()->is_void() ? "_" : "handler_return";
- f_gen_ << indent() << "Ok(" << handler_return_variable << ") => {" << endl;
+ f_gen_ << indent() << "Ok(" << handler_return_variable << ") => {" << '\n';
indent_up();
render_sync_handler_succeeded(tfunc);
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
// handler failed
- f_gen_ << indent() << "Err(e) => {" << endl;
+ f_gen_ << indent() << "Err(e) => {" << '\n';
indent_up();
render_sync_handler_failed(tfunc);
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl; // end match
+ f_gen_ << indent() << "}" << '\n'; // end match
indent_down();
- f_gen_ << indent() << "}" << endl; // end function
+ f_gen_ << indent() << "}" << '\n'; // end function
}
void t_rs_generator::render_sync_handler_succeeded(t_function* tfunc) {
if (tfunc->is_oneway()) {
- f_gen_ << indent() << "Ok(())" << endl;
+ f_gen_ << indent() << "Ok(())" << '\n';
} else {
f_gen_ << indent() << "let message_ident = TMessageIdentifier::new("
<< "\"" << tfunc->get_name() << "\", " // note: use *original* name
<< "TMessageType::Reply, "
- << "incoming_sequence_number);" << endl;
- f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl;
- f_gen_ << indent() << "let ret = " << handler_successful_return_struct(tfunc) << ";" << endl;
- f_gen_ << indent() << "ret.write_to_out_protocol(o_prot)?;" << endl;
- f_gen_ << indent() << "o_prot.write_message_end()?;" << endl;
- f_gen_ << indent() << "o_prot.flush()" << endl;
+ << "incoming_sequence_number);" << '\n';
+ f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << '\n';
+ f_gen_ << indent() << "let ret = " << handler_successful_return_struct(tfunc) << ";" << '\n';
+ f_gen_ << indent() << "ret.write_to_out_protocol(o_prot)?;" << '\n';
+ f_gen_ << indent() << "o_prot.write_message_end()?;" << '\n';
+ f_gen_ << indent() << "o_prot.flush()" << '\n';
}
}
void t_rs_generator::render_sync_handler_failed(t_function* tfunc) {
string err_var("e");
- f_gen_ << indent() << "match " << err_var << " {" << endl;
+ f_gen_ << indent() << "match " << err_var << " {" << '\n';
indent_up();
// if there are any user-defined exceptions for this service call handle them first
if (tfunc->get_xceptions() != nullptr
&& tfunc->get_xceptions()->get_sorted_members().size() > 0) {
string user_err_var("usr_err");
- f_gen_ << indent() << "thrift::Error::User(" << user_err_var << ") => {" << endl;
+ f_gen_ << indent() << "thrift::Error::User(" << user_err_var << ") => {" << '\n';
indent_up();
render_sync_handler_failed_user_exception_branch(tfunc);
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
}
// application error
string app_err_var("app_err");
- f_gen_ << indent() << "thrift::Error::Application(" << app_err_var << ") => {" << endl;
+ f_gen_ << indent() << "thrift::Error::Application(" << app_err_var << ") => {" << '\n';
indent_up();
render_sync_handler_failed_application_exception_branch(tfunc, app_err_var);
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
// default case
- f_gen_ << indent() << "_ => {" << endl;
+ f_gen_ << indent() << "_ => {" << '\n';
indent_up();
render_sync_handler_failed_default_exception_branch(tfunc);
indent_down();
- f_gen_ << indent() << "}," << endl;
+ f_gen_ << indent() << "}," << '\n';
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function* tfunc) {
@@ -2670,11 +2669,11 @@
string if_statement(branches_rendered == 0 ? "if usr_err" : "} else if usr_err");
string exception_type(to_rust_type(xception_field->get_type()));
f_gen_ << indent() << if_statement << ".downcast_ref::<" << exception_type << ">().is_some() {"
- << endl;
+ << '\n';
indent_up();
f_gen_ << indent() << "let err = usr_err.downcast::<" << exception_type
- << ">().expect(\"downcast already checked\");" << endl;
+ << ">().expect(\"downcast already checked\");" << '\n';
// render the members of the return struct
ostringstream members;
@@ -2701,17 +2700,17 @@
// now write out the return struct
f_gen_ << indent() << "let ret_err = " << service_call_result_struct_name(tfunc) << "{ "
- << member_string << "};" << endl;
+ << member_string << "};" << '\n';
f_gen_ << indent() << "let message_ident = "
<< "TMessageIdentifier::new("
<< "\"" << tfunc->get_name() << "\", " // note: use *original* name
<< "TMessageType::Reply, "
- << "incoming_sequence_number);" << endl;
- f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl;
- f_gen_ << indent() << "ret_err.write_to_out_protocol(o_prot)?;" << endl;
- f_gen_ << indent() << "o_prot.write_message_end()?;" << endl;
- f_gen_ << indent() << "o_prot.flush()" << endl;
+ << "incoming_sequence_number);" << '\n';
+ f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << '\n';
+ f_gen_ << indent() << "ret_err.write_to_out_protocol(o_prot)?;" << '\n';
+ f_gen_ << indent() << "o_prot.write_message_end()?;" << '\n';
+ f_gen_ << indent() << "o_prot.flush()" << '\n';
indent_down();
@@ -2719,41 +2718,41 @@
}
// the catch all, if somehow it was a user exception that we don't support
- f_gen_ << indent() << "} else {" << endl;
+ f_gen_ << indent() << "} else {" << '\n';
indent_up();
// FIXME: same as default block below
- f_gen_ << indent() << "let ret_err = {" << endl;
+ f_gen_ << indent() << "let ret_err = {" << '\n';
indent_up();
render_thrift_error_struct("ApplicationError", "ApplicationErrorKind::Unknown",
"usr_err.to_string()");
indent_down();
- f_gen_ << indent() << "};" << endl;
+ f_gen_ << indent() << "};" << '\n';
render_sync_handler_send_exception_response(tfunc, "ret_err");
indent_down();
- f_gen_ << indent() << "}" << endl;
+ f_gen_ << indent() << "}" << '\n';
}
void t_rs_generator::render_sync_handler_failed_application_exception_branch(
t_function* tfunc,
const string& app_err_var) {
if (tfunc->is_oneway()) {
- f_gen_ << indent() << "Err(thrift::Error::Application(" << app_err_var << "))" << endl;
+ f_gen_ << indent() << "Err(thrift::Error::Application(" << app_err_var << "))" << '\n';
} else {
render_sync_handler_send_exception_response(tfunc, app_err_var);
}
}
void t_rs_generator::render_sync_handler_failed_default_exception_branch(t_function* tfunc) {
- f_gen_ << indent() << "let ret_err = {" << endl;
+ f_gen_ << indent() << "let ret_err = {" << '\n';
indent_up();
render_thrift_error_struct("ApplicationError", "ApplicationErrorKind::Unknown", "e.to_string()");
indent_down();
- f_gen_ << indent() << "};" << endl;
+ f_gen_ << indent() << "};" << '\n';
if (tfunc->is_oneway()) {
- f_gen_ << indent() << "Err(thrift::Error::Application(ret_err))" << endl;
+ f_gen_ << indent() << "Err(thrift::Error::Application(ret_err))" << '\n';
} else {
render_sync_handler_send_exception_response(tfunc, "ret_err");
}
@@ -2764,12 +2763,12 @@
f_gen_ << indent() << "let message_ident = TMessageIdentifier::new("
<< "\"" << tfunc->get_name() << "\", " // note: use *original* name
<< "TMessageType::Exception, "
- << "incoming_sequence_number);" << endl;
- f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << endl;
+ << "incoming_sequence_number);" << '\n';
+ f_gen_ << indent() << "o_prot.write_message_begin(&message_ident)?;" << '\n';
f_gen_ << indent() << "thrift::Error::write_application_error_to_out_protocol(&" << err_var
- << ", o_prot)?;" << endl;
- f_gen_ << indent() << "o_prot.write_message_end()?;" << endl;
- f_gen_ << indent() << "o_prot.flush()" << endl;
+ << ", o_prot)?;" << '\n';
+ f_gen_ << indent() << "o_prot.write_message_end()?;" << '\n';
+ f_gen_ << indent() << "o_prot.flush()" << '\n';
}
string t_rs_generator::handler_successful_return_struct(t_function* tfunc) {
@@ -2811,10 +2810,10 @@
//-----------------------------------------------------------------------------
void t_rs_generator::render_type_comment(const string& type_name) {
- f_gen_ << "//" << endl;
- f_gen_ << "// " << type_name << endl;
- f_gen_ << "//" << endl;
- f_gen_ << endl;
+ f_gen_ << "//" << '\n';
+ f_gen_ << "// " << type_name << '\n';
+ f_gen_ << "//" << '\n';
+ f_gen_ << '\n';
}
// NOTE: do *not* put in an extra newline after doc is generated.
@@ -2831,26 +2830,26 @@
const string& error_struct,
const string& sub_error_kind,
const string& error_message) {
- f_gen_ << indent() << "Err(" << endl;
+ f_gen_ << indent() << "Err(" << '\n';
indent_up();
- f_gen_ << indent() << "thrift::Error::" << error_kind << "(" << endl;
+ f_gen_ << indent() << "thrift::Error::" << error_kind << "(" << '\n';
indent_up();
render_thrift_error_struct(error_struct, sub_error_kind, error_message);
indent_down();
- f_gen_ << indent() << ")" << endl;
+ f_gen_ << indent() << ")" << '\n';
indent_down();
- f_gen_ << indent() << ")" << endl;
+ f_gen_ << indent() << ")" << '\n';
}
void t_rs_generator::render_thrift_error_struct(const string& error_struct,
const string& sub_error_kind,
const string& error_message) {
- f_gen_ << indent() << error_struct << "::new(" << endl;
+ f_gen_ << indent() << error_struct << "::new(" << '\n';
indent_up();
- f_gen_ << indent() << sub_error_kind << "," << endl;
- f_gen_ << indent() << error_message << endl;
+ f_gen_ << indent() << sub_error_kind << "," << '\n';
+ f_gen_ << indent() << error_message << '\n';
indent_down();
- f_gen_ << indent() << ")" << endl;
+ f_gen_ << indent() << ")" << '\n';
}
bool t_rs_generator::is_double(t_type* ttype) {
diff --git a/compiler/cpp/src/thrift/generate/t_st_generator.cc b/compiler/cpp/src/thrift/generate/t_st_generator.cc
index b141186..c1ad355 100644
--- a/compiler/cpp/src/thrift/generate/t_st_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_st_generator.cc
@@ -43,8 +43,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* Smalltalk code generator.
*
@@ -177,7 +175,7 @@
f_.open(f_name.c_str());
// Print header
- f_ << st_autogen_comment() << endl;
+ f_ << st_autogen_comment() << '\n';
st_class_def(f_, program_name_);
generate_class_side_definition();
@@ -219,10 +217,10 @@
void t_st_generator::generate_force_consts() {
f_ << prefix(class_name()) << " enums keysAndValuesDo: [:k :v | " << prefix(class_name())
- << " enums at: k put: v value].!" << endl;
+ << " enums at: k put: v value].!" << '\n';
f_ << prefix(class_name()) << " constants keysAndValuesDo: [:k :v | " << prefix(class_name())
- << " constants at: k put: v value].!" << endl;
+ << " constants at: k put: v value].!" << '\n';
}
void t_st_generator::close_generator() {
@@ -252,11 +250,11 @@
}
void t_st_generator::st_class_def(std::ostream& out, string name) {
- out << "Object subclass: #" << prefix(name) << endl;
+ out << "Object subclass: #" << prefix(name) << '\n';
indent_up();
- out << indent() << "instanceVariableNames: ''" << endl << indent() << "classVariableNames: ''"
- << endl << indent() << "poolDictionaries: ''" << endl << indent() << "category: '"
- << generated_category() << "'!" << endl << endl;
+ out << indent() << "instanceVariableNames: ''" << '\n' << indent() << "classVariableNames: ''"
+ << '\n' << indent() << "poolDictionaries: ''" << '\n' << indent() << "category: '"
+ << generated_category() << "'!" << '\n' << '\n';
}
void t_st_generator::st_method(std::ostream& out, string cls, string name) {
@@ -281,14 +279,14 @@
strftime(timestr, 50, "%m/%d/%Y %H:%M", tinfo);
out << "!" << prefix(cls) << " methodsFor: '" + category + "' stamp: 'thrift " << timestr
- << "'!\n" << name << endl;
+ << "'!\n" << name << '\n';
indent_up();
out << indent();
}
void t_st_generator::st_close_method(std::ostream& out) {
- out << "! !" << endl << endl;
+ out << "! !" << '\n' << '\n';
indent_down();
}
@@ -316,16 +314,16 @@
}
void t_st_generator::generate_class_side_definition() {
- f_ << prefix(class_name()) << " class" << endl << "\tinstanceVariableNames: 'constants enums'!"
- << endl << endl;
+ f_ << prefix(class_name()) << " class" << '\n' << "\tinstanceVariableNames: 'constants enums'!"
+ << '\n' << '\n';
st_accessors(f_, class_name() + " class", "enums");
st_accessors(f_, class_name() + " class", "constants");
- f_ << prefix(class_name()) << " enums: Dictionary new!" << endl;
- f_ << prefix(class_name()) << " constants: Dictionary new!" << endl;
+ f_ << prefix(class_name()) << " enums: Dictionary new!" << '\n';
+ f_ << prefix(class_name()) << " constants: Dictionary new!" << '\n';
- f_ << endl;
+ f_ << '\n';
}
/**
@@ -338,16 +336,16 @@
string cls_name = program_name_ + capitalize(tenum->get_name());
f_ << prefix(class_name()) << " enums at: '" << tenum->get_name() << "' put: ["
- << "(Dictionary new " << endl;
+ << "(Dictionary new " << '\n';
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
int value = (*c_iter)->get_value();
- f_ << "\tat: '" << (*c_iter)->get_name() << "' put: " << value << ";" << endl;
+ f_ << "\tat: '" << (*c_iter)->get_name() << "' put: " << value << ";" << '\n';
}
- f_ << "\tyourself)]!" << endl << endl;
+ f_ << "\tyourself)]!" << '\n' << '\n';
}
/**
@@ -359,7 +357,7 @@
t_const_value* value = tconst->get_value();
f_ << prefix(class_name()) << " constants at: '" << name << "' put: ["
- << render_const_value(type, value) << "]!" << endl << endl;
+ << render_const_value(type, value) << "]!" << '\n' << '\n';
}
/**
@@ -398,7 +396,7 @@
} else if (type->is_enum()) {
indent(out) << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
- out << "(" << capitalize(type->get_name()) << " new " << endl;
+ out << "(" << capitalize(type->get_name()) << " new " << '\n';
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
@@ -418,7 +416,7 @@
}
out << indent() << v_iter->first->get_string() << ": "
- << render_const_value(field_type, v_iter->second) << ";" << endl;
+ << render_const_value(field_type, v_iter->second) << ";" << '\n';
}
out << indent() << "yourself)";
@@ -426,7 +424,7 @@
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
- out << "(Dictionary new" << endl;
+ out << "(Dictionary new" << '\n';
indent_up();
indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
@@ -436,7 +434,7 @@
out << "at: " << render_const_value(ktype, v_iter->first);
out << " put: ";
out << render_const_value(vtype, v_iter->second);
- out << ";" << endl;
+ out << ";" << '\n';
}
out << indent() << indent() << "yourself)";
indent_down();
@@ -449,9 +447,9 @@
etype = ((t_set*)type)->get_elem_type();
}
if (type->is_set()) {
- out << "(Set new" << endl;
+ out << "(Set new" << '\n';
} else {
- out << "(OrderedCollection new" << endl;
+ out << "(OrderedCollection new" << '\n';
}
indent_up();
indent_up();
@@ -460,7 +458,7 @@
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << indent() << indent();
out << "add: " << render_const_value(etype, *v_iter);
- out << ";" << endl;
+ out << ";" << '\n';
}
out << indent() << indent() << "yourself)";
indent_down();
@@ -502,7 +500,7 @@
else
out << "Object";
- out << " subclass: #" << prefix(type_name(tstruct)) << endl << "\tinstanceVariableNames: '";
+ out << " subclass: #" << prefix(type_name(tstruct)) << '\n' << "\tinstanceVariableNames: '";
if (members.size() > 0) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -556,7 +554,7 @@
camelcase((*m_iter)->get_name()),
a_type((*m_iter)->get_type()));
}
- out << endl;
+ out << '\n';
}
}
@@ -583,17 +581,17 @@
out << "[oprot writeMapBegin: (TMap new keyType: " << type_to_enum(tmap->get_key_type())
<< "; valueType: " << type_to_enum(tmap->get_val_type()) << "; size: " << fname << " size)."
- << endl;
+ << '\n';
indent_up();
- out << indent() << fname << " keysAndValuesDo: [:" << key << " :" << val << " |" << endl;
+ out << indent() << fname << " keysAndValuesDo: [:" << key << " :" << val << " |" << '\n';
indent_up();
- out << indent() << write_val(tmap->get_key_type(), key) << "." << endl << indent()
+ out << indent() << write_val(tmap->get_key_type(), key) << "." << '\n' << indent()
<< write_val(tmap->get_val_type(), val);
indent_down();
- out << "]." << endl << indent() << "oprot writeMapEnd] value";
+ out << "]." << '\n' << indent() << "oprot writeMapEnd] value";
indent_down();
return out.str();
@@ -604,18 +602,18 @@
string desc = temp_name();
string val = temp_name();
- out << "[|" << desc << " " << val << "| " << endl;
+ out << "[|" << desc << " " << val << "| " << '\n';
indent_up();
- out << indent() << desc << " := iprot readMapBegin." << endl << indent() << val
- << " := Dictionary new." << endl << indent() << desc << " size timesRepeat: [" << endl;
+ out << indent() << desc << " := iprot readMapBegin." << '\n' << indent() << val
+ << " := Dictionary new." << '\n' << indent() << desc << " size timesRepeat: [" << '\n';
indent_up();
out << indent() << val << " at: " << read_val(tmap->get_key_type())
<< " put: " << read_val(tmap->get_val_type());
indent_down();
- out << "]." << endl << indent() << "iprot readMapEnd." << endl << indent() << val << "] value";
+ out << "]." << '\n' << indent() << "iprot readMapEnd." << '\n' << indent() << val << "] value";
indent_down();
return out.str();
@@ -626,16 +624,16 @@
string val = temp_name();
out << "[oprot writeListBegin: (TList new elemType: " << type_to_enum(tlist->get_elem_type())
- << "; size: " << fname << " size)." << endl;
+ << "; size: " << fname << " size)." << '\n';
indent_up();
- out << indent() << fname << " do: [:" << val << "|" << endl;
+ out << indent() << fname << " do: [:" << val << "|" << '\n';
indent_up();
- out << indent() << write_val(tlist->get_elem_type(), val) << endl;
+ out << indent() << write_val(tlist->get_elem_type(), val) << '\n';
indent_down();
- out << "]." << endl << indent() << "oprot writeListEnd] value";
+ out << "]." << '\n' << indent() << "oprot writeListEnd] value";
indent_down();
return out.str();
@@ -646,17 +644,17 @@
string desc = temp_name();
string val = temp_name();
- out << "[|" << desc << " " << val << "| " << desc << " := iprot readListBegin." << endl;
+ out << "[|" << desc << " " << val << "| " << desc << " := iprot readListBegin." << '\n';
indent_up();
- out << indent() << val << " := OrderedCollection new." << endl << indent() << desc
- << " size timesRepeat: [" << endl;
+ out << indent() << val << " := OrderedCollection new." << '\n' << indent() << desc
+ << " size timesRepeat: [" << '\n';
indent_up();
out << indent() << val << " add: " << read_val(tlist->get_elem_type());
indent_down();
- out << "]." << endl << indent() << "iprot readListEnd." << endl << indent() << val << "] value";
+ out << "]." << '\n' << indent() << "iprot readListEnd." << '\n' << indent() << val << "] value";
indent_down();
return out.str();
@@ -667,16 +665,16 @@
string val = temp_name();
out << "[oprot writeSetBegin: (TSet new elemType: " << type_to_enum(tset->get_elem_type())
- << "; size: " << fname << " size)." << endl;
+ << "; size: " << fname << " size)." << '\n';
indent_up();
- out << indent() << fname << " do: [:" << val << "|" << endl;
+ out << indent() << fname << " do: [:" << val << "|" << '\n';
indent_up();
- out << indent() << write_val(tset->get_elem_type(), val) << endl;
+ out << indent() << write_val(tset->get_elem_type(), val) << '\n';
indent_down();
- out << "]." << endl << indent() << "oprot writeSetEnd] value";
+ out << "]." << '\n' << indent() << "oprot writeSetEnd] value";
indent_down();
return out.str();
@@ -687,17 +685,17 @@
string desc = temp_name();
string val = temp_name();
- out << "[|" << desc << " " << val << "| " << desc << " := iprot readSetBegin." << endl;
+ out << "[|" << desc << " " << val << "| " << desc << " := iprot readSetBegin." << '\n';
indent_up();
- out << indent() << val << " := Set new." << endl << indent() << desc << " size timesRepeat: ["
- << endl;
+ out << indent() << val << " := Set new." << '\n' << indent() << desc << " size timesRepeat: ["
+ << '\n';
indent_up();
out << indent() << val << " add: " << read_val(tset->get_elem_type());
indent_down();
- out << "]." << endl << indent() << "iprot readSetEnd." << endl << indent() << val << "] value";
+ out << "]." << '\n' << indent() << "iprot readSetEnd." << '\n' << indent() << val << "] value";
indent_down();
return out.str();
@@ -709,7 +707,7 @@
vector<t_field*>::const_iterator fld_iter;
out << "[oprot writeStructBegin: "
- << "(TStruct new name: '" + tstruct->get_name() + "')." << endl;
+ << "(TStruct new name: '" + tstruct->get_name() + "')." << '\n';
indent_up();
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
@@ -718,15 +716,15 @@
string accessor = sname + " " + camelcase(fname);
if (optional) {
- out << indent() << accessor << " ifNotNil: [" << endl;
+ out << indent() << accessor << " ifNotNil: [" << '\n';
indent_up();
}
out << indent() << "oprot writeFieldBegin: (TField new name: '" << fname
<< "'; type: " << type_to_enum((*fld_iter)->get_type())
- << "; id: " << (*fld_iter)->get_key() << ")." << endl;
+ << "; id: " << (*fld_iter)->get_key() << ")." << '\n';
- out << indent() << write_val((*fld_iter)->get_type(), accessor) << "." << endl << indent()
+ out << indent() << write_val((*fld_iter)->get_type(), accessor) << "." << '\n' << indent()
<< "oprot writeFieldEnd";
if (optional) {
@@ -734,7 +732,7 @@
indent_down();
}
- out << "." << endl;
+ out << "." << '\n';
}
out << indent() << "oprot writeFieldStop; writeStructEnd] value";
@@ -755,33 +753,33 @@
clsName = tstruct->get_name();
}
- out << "[|" << desc << " " << val << "|" << endl;
+ out << "[|" << desc << " " << val << "|" << '\n';
indent_up();
// This is nasty, but without it we'll break things by prefixing TResult.
string name = ((capitalize(clsName) == "TResult") ? capitalize(clsName) : prefix(clsName));
- out << indent() << val << " := " << name << " new." << endl;
+ out << indent() << val << " := " << name << " new." << '\n';
- out << indent() << "iprot readStructBegin." << endl << indent() << "[" << desc
- << " := iprot readFieldBegin." << endl << indent() << desc
- << " type = TType stop] whileFalse: [|" << found << "|" << endl;
+ out << indent() << "iprot readStructBegin." << '\n' << indent() << "[" << desc
+ << " := iprot readFieldBegin." << '\n' << indent() << desc
+ << " type = TType stop] whileFalse: [|" << found << "|" << '\n';
indent_up();
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
- out << indent() << desc << " id = " << (*fld_iter)->get_key() << " ifTrue: [" << endl;
+ out << indent() << desc << " id = " << (*fld_iter)->get_key() << " ifTrue: [" << '\n';
indent_up();
- out << indent() << found << " := true." << endl << indent() << val << " "
+ out << indent() << found << " := true." << '\n' << indent() << val << " "
<< camelcase((*fld_iter)->get_name()) << ": " << read_val((*fld_iter)->get_type());
indent_down();
- out << "]." << endl;
+ out << "]." << '\n';
}
- out << indent() << found << " ifNil: [iprot skip: " << desc << " type]]." << endl;
+ out << indent() << found << " ifNil: [iprot skip: " << desc << " type]]." << '\n';
indent_down();
- out << indent() << "oprot readStructEnd." << endl << indent() << val << "] value";
+ out << indent() << "oprot readStructEnd." << '\n' << indent() << val << "] value";
indent_down();
return out.str();
@@ -847,32 +845,32 @@
vector<t_field*>::const_iterator fld_iter;
st_method(f_, client_class_name(), "send" + capitalize(signature));
- f_ << "oprot writeMessageBegin:" << endl;
+ f_ << "oprot writeMessageBegin:" << '\n';
indent_up();
- f_ << indent() << "(TCallMessage new" << endl;
+ f_ << indent() << "(TCallMessage new" << '\n';
indent_up();
- f_ << indent() << "name: '" << funname << "'; " << endl << indent() << "seqid: self nextSeqid)."
- << endl;
+ f_ << indent() << "name: '" << funname << "'; " << '\n' << indent() << "seqid: self nextSeqid)."
+ << '\n';
indent_down();
indent_down();
f_ << indent() << "oprot writeStructBegin: "
- << "(TStruct new name: '" + capitalize(camelcase(funname)) + "_args')." << endl;
+ << "(TStruct new name: '" + capitalize(camelcase(funname)) + "_args')." << '\n';
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
string fname = camelcase((*fld_iter)->get_name());
f_ << indent() << "oprot writeFieldBegin: (TField new name: '" << fname
<< "'; type: " << type_to_enum((*fld_iter)->get_type()) << "; id: " << (*fld_iter)->get_key()
- << ")." << endl;
+ << ")." << '\n';
- f_ << indent() << write_val((*fld_iter)->get_type(), fname) << "." << endl << indent()
- << "oprot writeFieldEnd." << endl;
+ f_ << indent() << write_val((*fld_iter)->get_type(), fname) << "." << '\n' << indent()
+ << "oprot writeFieldEnd." << '\n';
}
- f_ << indent() << "oprot writeFieldStop; writeStructEnd; writeMessageEnd." << endl;
+ f_ << indent() << "oprot writeFieldStop; writeStructEnd; writeMessageEnd." << '\n';
f_ << indent() << "oprot transport flush";
st_close_method(f_);
@@ -897,11 +895,11 @@
}
st_method(f_, client_class_name(), "recv" + capitalize(funname));
- f_ << "| f msg res | " << endl << indent() << "msg := oprot readMessageBegin." << endl << indent()
- << "self validateRemoteMessage: msg." << endl << indent()
- << "res := " << struct_reader(&result) << "." << endl << indent() << "oprot readMessageEnd."
- << endl << indent() << "oprot transport flush." << endl << indent()
- << "res exception ifNotNil: [res exception signal]." << endl << indent() << "^ res";
+ f_ << "| f msg res | " << '\n' << indent() << "msg := oprot readMessageBegin." << '\n' << indent()
+ << "self validateRemoteMessage: msg." << '\n' << indent()
+ << "res := " << struct_reader(&result) << "." << '\n' << indent() << "oprot readMessageEnd."
+ << '\n' << indent() << "oprot transport flush." << '\n' << indent()
+ << "res exception ifNotNil: [res exception signal]." << '\n' << indent() << "^ res";
st_close_method(f_);
}
@@ -940,7 +938,7 @@
extends_client = extends + "Client";
}
- f_ << extends_client << " subclass: #" << prefix(client_class_name()) << endl
+ f_ << extends_client << " subclass: #" << prefix(client_class_name()) << '\n'
<< "\tinstanceVariableNames: ''\n"
<< "\tclassVariableNames: ''\n"
<< "\tpoolDictionaries: ''\n"
@@ -951,11 +949,11 @@
string signature = function_signature(*f_iter);
st_method(f_, client_class_name(), signature);
- f_ << function_types_comment(*f_iter) << endl << indent() << "self send"
- << capitalize(signature) << "." << endl;
+ f_ << function_types_comment(*f_iter) << '\n' << indent() << "self send"
+ << capitalize(signature) << "." << '\n';
if (!(*f_iter)->is_oneway()) {
- f_ << indent() << "^ self recv" << capitalize(funname) << " success " << endl;
+ f_ << indent() << "^ self recv" << capitalize(funname) << " success " << '\n';
}
st_close_method(f_);
diff --git a/compiler/cpp/src/thrift/generate/t_swift_generator.cc b/compiler/cpp/src/thrift/generate/t_swift_generator.cc
index fab1413..98b19ec 100644
--- a/compiler/cpp/src/thrift/generate/t_swift_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_swift_generator.cc
@@ -37,8 +37,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* Swift 3 code generator.
*
@@ -51,7 +49,7 @@
const string& option_string)
: t_oop_generator(program) {
update_keywords_for_validation();
-
+
(void)option_string;
map<string, string>::const_iterator iter;
@@ -226,14 +224,14 @@
private:
void block_open(ostream& out) {
- out << " {" << endl;
+ out << " {" << '\n';
indent_up();
}
void block_close(ostream& out, bool end_line=true) {
indent_down();
indent(out) << "}";
- if (end_line) out << endl;
+ if (end_line) out << '\n';
}
bool field_is_optional(t_field* tfield) {
@@ -320,18 +318,18 @@
string f_decl_fullname = module_path + "/" + f_decl_name;
f_decl_.open(f_decl_fullname.c_str());
- f_decl_ << autogen_comment() << endl;
+ f_decl_ << autogen_comment() << '\n';
- f_decl_ << swift_imports() << swift_thrift_imports() << endl;
+ f_decl_ << swift_imports() << swift_thrift_imports() << '\n';
// ...and a .swift implementation extensions file
string f_impl_name = name + "+Exts.swift";
string f_impl_fullname = module_path + "/" + f_impl_name;
f_impl_.open(f_impl_fullname.c_str());
- f_impl_ << autogen_comment() << endl;
+ f_impl_ << autogen_comment() << '\n';
- f_impl_ << swift_imports() << swift_thrift_imports() << endl;
+ f_impl_ << swift_imports() << swift_thrift_imports() << '\n';
}
@@ -349,16 +347,16 @@
vector<string>::const_iterator i_iter;
for (i_iter=includes_list.begin(); i_iter!=includes_list.end(); ++i_iter) {
- includes << "import " << *i_iter << endl;
+ includes << "import " << *i_iter << '\n';
}
if (namespaced_) {
const vector<t_program*>& program_includes = program_->get_includes();
for (auto program_include : program_includes) {
- includes << ("import " + get_real_swift_module(program_include)) << endl;
+ includes << ("import " + get_real_swift_module(program_include)) << '\n';
}
}
- includes << endl;
+ includes << '\n';
return includes.str();
}
@@ -381,10 +379,10 @@
vector<string>::const_iterator i_iter;
for (i_iter=includes_list.begin(); i_iter!=includes_list.end(); ++i_iter) {
- includes << "import " << *i_iter << endl;
+ includes << "import " << *i_iter << '\n';
}
- includes << endl;
+ includes << '\n';
return includes.str();
}
@@ -395,7 +393,7 @@
void t_swift_generator::close_generator() {
// stick our constants declarations at the end of the header file
// since they refer to things we are defining.
- f_decl_ << constants_declarations_ << endl;
+ f_decl_ << constants_declarations_ << '\n';
}
/**
@@ -405,8 +403,8 @@
*/
void t_swift_generator::generate_typedef(t_typedef* ttypedef) {
f_decl_ << indent() << "public typealias " << ttypedef->get_symbolic()
- << " = " << type_name(ttypedef->get_type()) << endl;
- f_decl_ << endl;
+ << " = " << type_name(ttypedef->get_type()) << '\n';
+ f_decl_ << '\n';
}
@@ -430,80 +428,80 @@
vector<t_enum_value*>::iterator c_iter;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
- f_decl_ << indent() << "case " << enum_case_name((*c_iter), true) << endl;
+ f_decl_ << indent() << "case " << enum_case_name((*c_iter), true) << '\n';
}
// unknown associated value case for safety and similar behavior to other languages
if (safe_enums_) {
- f_decl_ << indent() << "case unknown(Int32)" << endl;
+ f_decl_ << indent() << "case unknown(Int32)" << '\n';
}
- f_decl_ << endl;
+ f_decl_ << '\n';
// TSerializable read(from:)
f_decl_ << indent() << "public static func read(from proto: TProtocol) throws -> "
<< tenum->get_name();
block_open(f_decl_);
- f_decl_ << indent() << "let raw: Int32 = try proto.read()" << endl;
- f_decl_ << indent() << "let new = " << tenum->get_name() << "(rawValue: raw)" << endl;
+ f_decl_ << indent() << "let raw: Int32 = try proto.read()" << '\n';
+ f_decl_ << indent() << "let new = " << tenum->get_name() << "(rawValue: raw)" << '\n';
- f_decl_ << indent() << "if let unwrapped = new {" << endl;
+ f_decl_ << indent() << "if let unwrapped = new {" << '\n';
indent_up();
- f_decl_ << indent() << "return unwrapped" << endl;
+ f_decl_ << indent() << "return unwrapped" << '\n';
indent_down();
- f_decl_ << indent() << "} else {" << endl;
+ f_decl_ << indent() << "} else {" << '\n';
indent_up();
- f_decl_ << indent() << "throw TProtocolError(error: .invalidData," << endl;
+ f_decl_ << indent() << "throw TProtocolError(error: .invalidData," << '\n';
f_decl_ << indent() << " message: \"Invalid enum value (\\(raw)) for \\("
- << tenum->get_name() << ".self)\")" << endl;
+ << tenum->get_name() << ".self)\")" << '\n';
indent_down();
- f_decl_ << indent() << "}" << endl;
+ f_decl_ << indent() << "}" << '\n';
block_close(f_decl_);
// empty init for TSerializable
- f_decl_ << endl;
+ f_decl_ << '\n';
f_decl_ << indent() << "public init()";
block_open(f_decl_);
- f_decl_ << indent() << "self = ." << enum_case_name(constants.front(), false) << endl;
+ f_decl_ << indent() << "self = ." << enum_case_name(constants.front(), false) << '\n';
block_close(f_decl_);
- f_decl_ << endl;
+ f_decl_ << '\n';
// rawValue getter
f_decl_ << indent() << "public var rawValue: Int32";
block_open(f_decl_);
- f_decl_ << indent() << "switch self {" << endl;
+ f_decl_ << indent() << "switch self {" << '\n';
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
f_decl_ << indent() << "case ." << enum_case_name((*c_iter), true)
- << ": return " << (*c_iter)->get_value() << endl;
+ << ": return " << (*c_iter)->get_value() << '\n';
}
if (safe_enums_) {
- f_decl_ << indent() << "case .unknown(let value): return value" << endl;
+ f_decl_ << indent() << "case .unknown(let value): return value" << '\n';
}
- f_decl_ << indent() << "}" << endl;
+ f_decl_ << indent() << "}" << '\n';
block_close(f_decl_);
- f_decl_ << endl;
+ f_decl_ << '\n';
// convenience rawValue initalizer
f_decl_ << indent() << "public init?(rawValue: Int32)";
block_open(f_decl_);
- f_decl_ << indent() << "switch rawValue {" << endl;;
+ f_decl_ << indent() << "switch rawValue {" << '\n';;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
f_decl_ << indent() << "case " << (*c_iter)->get_value()
- << ": self = ." << enum_case_name((*c_iter), true) << endl;
+ << ": self = ." << enum_case_name((*c_iter), true) << '\n';
}
if (!safe_enums_) {
- f_decl_ << indent() << "default: return nil" << endl;
+ f_decl_ << indent() << "default: return nil" << '\n';
} else {
- f_decl_ << indent() << "default: self = .unknown(rawValue)" << endl;
+ f_decl_ << indent() << "default: self = .unknown(rawValue)" << '\n';
}
- f_decl_ << indent() << "}" << endl;
+ f_decl_ << indent() << "}" << '\n';
block_close(f_decl_);
block_close(f_decl_);
- f_decl_ << endl;
+ f_decl_ << '\n';
}
/**
@@ -521,36 +519,36 @@
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
f_decl_ << indent() << "case " << (*c_iter)->get_name()
- << " = " << (*c_iter)->get_value() << endl;
+ << " = " << (*c_iter)->get_value() << '\n';
}
- f_decl_ << endl;
- f_decl_ << indent() << "public init() { self.init(rawValue: " << constants.front()->get_value() << ")! }" << endl;
+ f_decl_ << '\n';
+ f_decl_ << indent() << "public init() { self.init(rawValue: " << constants.front()->get_value() << ")! }" << '\n';
block_close(f_decl_);
- f_decl_ << endl;
+ f_decl_ << '\n';
f_impl_ << indent() << "extension " << tenum->get_name() << " : TEnum";
block_open(f_impl_);
- f_impl_ << endl;
+ f_impl_ << '\n';
f_impl_ << indent() << "public static func readValueFromProtocol(proto: TProtocol) throws -> " << tenum->get_name();
block_open(f_impl_);
- f_impl_ << indent() << "var raw = Int32()" << endl
- << indent() << "try proto.readI32(&raw)" << endl
- << indent() << "return " << tenum->get_name() << "(rawValue: raw)!" << endl;
+ f_impl_ << indent() << "var raw = Int32()" << '\n'
+ << indent() << "try proto.readI32(&raw)" << '\n'
+ << indent() << "return " << tenum->get_name() << "(rawValue: raw)!" << '\n';
block_close(f_impl_);
- f_impl_ << endl;
+ f_impl_ << '\n';
f_impl_ << indent() << "public static func writeValue(value: " << tenum->get_name() << ", toProtocol proto: TProtocol) throws";
block_open(f_impl_);
- f_impl_ << indent() << "try proto.writeI32(value.rawValue)" << endl;
+ f_impl_ << indent() << "try proto.writeI32(value.rawValue)" << '\n';
block_close(f_impl_);
- f_impl_ << endl;
+ f_impl_ << '\n';
block_close(f_impl_);
- f_impl_ << endl;
+ f_impl_ << '\n';
}
string t_swift_generator::enum_case_name(t_enum_value* tenum_case, bool declaration) {
@@ -593,7 +591,7 @@
t_type* type = (*c_iter)->get_type();
const_interface << "public let " << capitalize((*c_iter)->get_name()) << " : " << type_name(type) << " = ";
render_const_value(const_interface, type, (*c_iter)->get_value());
- const_interface << endl << endl;
+ const_interface << '\n' << '\n';
}
// this gets spit into the header file in ::close_generator
@@ -647,7 +645,7 @@
vector<string>::const_iterator d_iter;
for (d_iter = strings.begin(); d_iter != strings.end(); ++d_iter) {
if ((*d_iter) != "") {
- out << indent() << "/// " << (*d_iter) << endl;
+ out << indent() << "/// " << (*d_iter) << '\n';
}
}
}
@@ -685,12 +683,12 @@
out << indent() << "public enum " << tstruct->get_name();
block_open(out);
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- out << endl;
+ out << '\n';
string doc = (*m_iter)->get_doc();
generate_docstring(out, doc);
out << indent() << "case "
<< maybe_escape_identifier((*m_iter)->get_name()) << "(val: "
- << type_name((*m_iter)->get_type(), false) << ")" << endl;
+ << type_name((*m_iter)->get_type(), false) << ")" << '\n';
}
} else {
// Normal structs
@@ -707,20 +705,20 @@
vector<t_field*> sorted = members;
sort(sorted.begin(), sorted.end(), [](t_field *a, t_field *b) { return (a->get_key() < b->get_key()); } );
for (m_iter = sorted.begin(); m_iter != sorted.end(); ++m_iter) {
- out << endl;
+ out << '\n';
// TODO: Defaults
string doc = (*m_iter)->get_doc();
generate_docstring(out, doc);
- out << indent() << declare_property(*m_iter, is_private) << endl;
+ out << indent() << declare_property(*m_iter, is_private) << '\n';
}
- out << endl;
- out << endl;
+ out << '\n';
+ out << '\n';
if (!struct_has_required_fields(tstruct)) {
- indent(out) << visibility << " init() { }" << endl;
+ indent(out) << visibility << " init() { }" << '\n';
}
if (struct_has_required_fields(tstruct)) {
generate_swift_struct_init(out, tstruct, false, is_private);
@@ -732,7 +730,7 @@
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -761,11 +759,11 @@
vector<t_field*>::const_iterator m_iter;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- out << endl;
- out << indent() << declare_property(*m_iter, is_private) << endl;
+ out << '\n';
+ out << indent() << declare_property(*m_iter, is_private) << '\n';
}
- out << endl;
+ out << '\n';
// init
@@ -773,7 +771,7 @@
block_open(out);
block_close(out);
- out << endl;
+ out << '\n';
if (struct_has_required_fields(tstruct)) {
generate_swift_struct_init(out, tstruct, false, is_private);
@@ -784,7 +782,7 @@
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -831,20 +829,20 @@
should_set = should_set || !field_is_optional((*m_iter));
if (should_set) {
out << indent() << "self." << maybe_escape_identifier((*m_iter)->get_name()) << " = "
- << maybe_escape_identifier((*m_iter)->get_name()) << endl;
+ << maybe_escape_identifier((*m_iter)->get_name()) << '\n';
}
} else {
/** legacy Swift2/Cocoa */
if (all || (*m_iter)->get_req() == t_field::T_REQUIRED || (*m_iter)->get_req() == t_field::T_OPT_IN_REQ_OUT) {
out << indent() << "self." << maybe_escape_identifier((*m_iter)->get_name()) << " = "
- << maybe_escape_identifier((*m_iter)->get_name()) << endl;
+ << maybe_escape_identifier((*m_iter)->get_name()) << '\n';
}
}
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -861,7 +859,7 @@
string visibility = is_private ? (gen_cocoa_ ? "private" : "fileprivate") : "public";
indent(out) << "extension " << tstruct->get_name() << " : Hashable";
block_open(out);
- out << endl;
+ out << '\n';
indent(out) << visibility << " func hash(into hasher: inout Hasher)";
block_open(out);
@@ -872,21 +870,21 @@
if (!tstruct->is_union()) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* tfield = *m_iter;
- indent(out) << "hasher.combine(" << maybe_escape_identifier(tfield->get_name()) << ")" << endl;
+ indent(out) << "hasher.combine(" << maybe_escape_identifier(tfield->get_name()) << ")" << '\n';
}
} else {
- indent(out) << "switch self {" << endl;
+ indent(out) << "switch self {" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); m_iter++) {
t_field *tfield = *m_iter;
- indent(out) << "case ." << tfield->get_name() << "(let val): hasher.combine(val)" << endl;
+ indent(out) << "case ." << tfield->get_name() << "(let val): hasher.combine(val)" << '\n';
}
- indent(out) << "}" << endl << endl;
+ indent(out) << "}" << '\n' << '\n';
}
}
block_close(out);
- out << endl;
+ out << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -912,7 +910,7 @@
if (members.size()) {
if (!tstruct->is_union()) {
- out << endl;
+ out << '\n';
indent_up();
for (m_iter = members.begin(); m_iter != members.end();) {
@@ -922,30 +920,30 @@
if (++m_iter != members.end()) {
out << " &&";
}
- out << endl;
+ out << '\n';
}
indent_down();
} else {
block_open(out);
- indent(out) << "switch (lhs, rhs) {" << endl;
+ indent(out) << "switch (lhs, rhs) {" << '\n';
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_field* tfield = *m_iter;
indent(out) << "case (." << tfield->get_name() << "(let lval), ."
<< tfield->get_name() << "(let rval)): return lval == rval"
- << endl;
+ << '\n';
}
- indent(out) << "default: return false" << endl;
- indent(out) << "}" << endl;
+ indent(out) << "default: return false" << '\n';
+ indent(out) << "}" << '\n';
indent_down();
- indent(out) << "}()" << endl;
+ indent(out) << "}()" << '\n';
}
}
else {
- out << " true" << endl;
+ out << " true" << '\n';
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -972,7 +970,7 @@
generate_swift_struct_hashable_extension(out, tstruct, is_private);
generate_swift_struct_thrift_extension(out, tstruct, is_result, is_private);
- out << endl << endl;
+ out << '\n' << '\n';
}
/**
@@ -993,7 +991,7 @@
block_open(out);
- out << endl;
+ out << '\n';
if (!gen_cocoa_) {
/** Swift 3, no writer we just write field ID's */
string access = (is_private) ? (gen_cocoa_ ? "private" : "fileprivate") : "public";
@@ -1012,11 +1010,11 @@
// pad a colon
out << ":";
}
- out << "]" << endl;
+ out << "]" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
out << indent() << access << " static var structName: String { return \""
- << tstruct->get_name() << "\" }" << endl << endl;
+ << tstruct->get_name() << "\" }" << '\n' << '\n';
if (tstruct->is_union()) {
generate_swift_union_reader(out, tstruct);
@@ -1037,24 +1035,24 @@
}
block_close(out);
- out << endl;
+ out << '\n';
}
void t_swift_generator::generate_swift_union_reader(ostream& out, t_struct* tstruct) {
indent(out) << "public static func read(from proto: TProtocol) throws -> "
<< tstruct->get_name();
block_open(out);
- indent(out) << "_ = try proto.readStructBegin()" << endl;
+ indent(out) << "_ = try proto.readStructBegin()" << '\n';
indent(out) << "var ret: " << tstruct->get_name() << "?";
- out << endl;
+ out << '\n';
indent(out) << "fields: while true";
block_open(out);
- out << endl;
- indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << endl << endl;
+ out << '\n';
+ indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << '\n' << '\n';
indent(out) << "switch (fieldID, fieldType)";
block_open(out);
- indent(out) << "case (_, .stop): break fields" << endl;
+ indent(out) << "case (_, .stop): break fields" << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -1094,28 +1092,28 @@
indent(out) << padding << "ret = " << tstruct->get_name() << "."
<< (*f_iter)->get_name() << "(val: " << "try "
<< type_name((*f_iter)->get_type(), false, false)
- << ".read(from: proto))" << endl;
+ << ".read(from: proto))" << '\n';
}
- indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << endl;
+ indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << '\n';
block_close(out);
- indent(out) << "try proto.readFieldEnd()" << endl;
+ indent(out) << "try proto.readFieldEnd()" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
- indent(out) << "try proto.readStructEnd()" << endl;
+ indent(out) << "try proto.readStructEnd()" << '\n';
indent(out) << "if let ret = ret";
block_open(out);
- indent(out) << "return ret" << endl;
+ indent(out) << "return ret" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
indent(out) << "throw TProtocolError(error: .unknown, message: \"Missing required value for type: "
<< tstruct->get_name() << "\")";
block_close(out);
- out << endl;
+ out << '\n';
}
@@ -1139,7 +1137,7 @@
<< tstruct->get_name();
block_open(out);
- indent(out) << "_ = try proto.readStructBegin()" << endl;
+ indent(out) << "_ = try proto.readStructBegin()" << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -1147,20 +1145,20 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool optional = field_is_optional(*f_iter);
indent(out) << "var " << maybe_escape_identifier((*f_iter)->get_name()) << ": "
- << type_name((*f_iter)->get_type(), optional, !optional) << endl;
+ << type_name((*f_iter)->get_type(), optional, !optional) << '\n';
}
- out << endl;
+ out << '\n';
// Loop over reading in fields
indent(out) << "fields: while true";
block_open(out);
- out << endl;
+ out << '\n';
- indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << endl << endl;
+ indent(out) << "let (_, fieldType, fieldID) = try proto.readFieldBegin()" << '\n' << '\n';
indent(out) << "switch (fieldID, fieldType)";
block_open(out);
- indent(out) << "case (_, .stop): break fields" << endl;
+ indent(out) << "case (_, .stop): break fields" << '\n';
// Generate deserialization code for known cases
@@ -1198,33 +1196,33 @@
}
out << padding << maybe_escape_identifier((*f_iter)->get_name()) << " = try "
- << type_name((*f_iter)->get_type(), false, false) << ".read(from: proto)" << endl;
+ << type_name((*f_iter)->get_type(), false, false) << ".read(from: proto)" << '\n';
}
- indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << endl;
+ indent(out) << "case let (_, unknownType): try proto.skip(type: unknownType)" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
// Read field end marker
- indent(out) << "try proto.readFieldEnd()" << endl;
+ indent(out) << "try proto.readFieldEnd()" << '\n';
block_close(out);
- out << endl;
- indent(out) << "try proto.readStructEnd()" << endl;
+ out << '\n';
+ indent(out) << "try proto.readStructEnd()" << '\n';
if (struct_has_required_fields(tstruct)) {
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "// Required fields" << endl;
+ indent(out) << "// Required fields" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (field_is_optional(*f_iter)) {
continue;
}
indent(out) << "try proto.validateValue(" << maybe_escape_identifier((*f_iter)->get_name()) << ", "
- << "named: \"" << (*f_iter)->get_name() << "\")" << endl;
+ << "named: \"" << (*f_iter)->get_name() << "\")" << '\n';
}
}
- out << endl;
+ out << '\n';
indent(out) << "return " << tstruct->get_name() << "(";
for (f_iter = fields.begin(); f_iter != fields.end();) {
@@ -1242,8 +1240,8 @@
<< tstruct->get_name();
block_open(out);
- out << endl;
- indent(out) << "try __proto.readStructBegin()" << endl << endl;
+ out << '\n';
+ indent(out) << "try __proto.readStructBegin()" << '\n' << '\n';
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@@ -1251,66 +1249,66 @@
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool optional = field_is_optional(*f_iter);
indent(out) << "var " << maybe_escape_identifier((*f_iter)->get_name()) << " : "
- << type_name((*f_iter)->get_type(), optional, !optional) << endl;
+ << type_name((*f_iter)->get_type(), optional, !optional) << '\n';
}
- out << endl;
+ out << '\n';
// Loop over reading in fields
indent(out) << "fields: while true";
block_open(out);
- out << endl;
+ out << '\n';
- indent(out) << "let (_, fieldType, fieldID) = try __proto.readFieldBegin()" << endl << endl;
+ indent(out) << "let (_, fieldType, fieldID) = try __proto.readFieldBegin()" << '\n' << '\n';
indent(out) << "switch (fieldID, fieldType)";
block_open(out);
- indent(out) << "case (_, .STOP):" << endl;
+ indent(out) << "case (_, .STOP):" << '\n';
indent_up();
- indent(out) << "break fields" << endl << endl;
+ indent(out) << "break fields" << '\n' << '\n';
indent_down();
// Generate deserialization code for known cases
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
- indent(out) << "case (" << (*f_iter)->get_key() << ", " << type_to_enum((*f_iter)->get_type()) << "):" << endl;
+ indent(out) << "case (" << (*f_iter)->get_key() << ", " << type_to_enum((*f_iter)->get_type()) << "):" << '\n';
indent_up();
indent(out) << maybe_escape_identifier((*f_iter)->get_name()) << " = try __proto.readValue() as "
- << type_name((*f_iter)->get_type()) << endl << endl;
+ << type_name((*f_iter)->get_type()) << '\n' << '\n';
indent_down();
}
- indent(out) << "case let (_, unknownType):" << endl;
+ indent(out) << "case let (_, unknownType):" << '\n';
indent_up();
- indent(out) << "try __proto.skipType(unknownType)" << endl;
+ indent(out) << "try __proto.skipType(unknownType)" << '\n';
indent_down();
block_close(out);
- out << endl;
+ out << '\n';
// Read field end marker
- indent(out) << "try __proto.readFieldEnd()" << endl;
+ indent(out) << "try __proto.readFieldEnd()" << '\n';
block_close(out);
- out << endl;
- indent(out) << "try __proto.readStructEnd()" << endl;
- out << endl;
+ out << '\n';
+ indent(out) << "try __proto.readStructEnd()" << '\n';
+ out << '\n';
if (struct_has_required_fields(tstruct)) {
// performs various checks (e.g. check that all required fields are set)
- indent(out) << "// Required fields" << endl;
+ indent(out) << "// Required fields" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (field_is_optional(*f_iter)) {
continue;
}
indent(out) << "try __proto.validateValue(" << (*f_iter)->get_name() << ", "
- << "named: \"" << (*f_iter)->get_name() << "\")" << endl;
+ << "named: \"" << (*f_iter)->get_name() << "\")" << '\n';
}
}
- out << endl;
+ out << '\n';
indent(out) << "return " << tstruct->get_name() << "(";
for (f_iter = fields.begin(); f_iter != fields.end();) {
@@ -1320,11 +1318,11 @@
}
}
}
- out << ")" << endl;
+ out << ")" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1344,14 +1342,14 @@
indent(out) << visibility << " static func writeValue(__value: " << tstruct->get_name()
<< ", toProtocol __proto: TProtocol) throws";
block_open(out);
- out << endl;
+ out << '\n';
string name = tstruct->get_name();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << endl;
- out << endl;
+ indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << '\n';
+ out << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field *tfield = *f_iter;
@@ -1367,19 +1365,19 @@
<< (optional ? "" : "__value.") << maybe_escape_identifier(tfield->get_name()) << ", "
<< "name: \"" << tfield->get_name() << "\", "
<< "type: " << type_to_enum(tfield->get_type()) << ", "
- << "id: " << tfield->get_key() << ")" << endl;
+ << "id: " << tfield->get_key() << ")" << '\n';
if (optional) {
block_close(out);
}
- out << endl;
+ out << '\n';
}
- indent(out) << "try __proto.writeFieldStop()" << endl << endl;
- indent(out) << "try __proto.writeStructEnd()" << endl;
+ indent(out) << "try __proto.writeFieldStop()" << '\n' << '\n';
+ indent(out) << "try __proto.writeStructEnd()" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1396,12 +1394,12 @@
indent(out) << "private static func writeValue(__value: " << tstruct->get_name()
<< ", toProtocol __proto: TProtocol) throws";
block_open(out);
- out << endl;
+ out << '\n';
string name = tstruct->get_name();
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
- indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << endl;
- out << endl;
+ indent(out) << "try __proto.writeStructBeginWithName(\"" << name << "\")" << '\n';
+ out << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
t_field *tfield = *f_iter;
@@ -1413,15 +1411,15 @@
indent(out) << "try __proto.writeFieldValue(result, "
<< "name: \"" << tfield->get_name() << "\", "
<< "type: " << type_to_enum(tfield->get_type()) << ", "
- << "id: " << tfield->get_key() << ")" << endl;
+ << "id: " << tfield->get_key() << ")" << '\n';
block_close(out);
}
// Write the struct map
- indent(out) << "try __proto.writeFieldStop()" << endl << endl;
- indent(out) << "try __proto.writeStructEnd()" << endl;
+ indent(out) << "try __proto.writeFieldStop()" << '\n' << '\n';
+ indent(out) << "try __proto.writeStructEnd()" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1440,50 +1438,50 @@
<< (debug_descriptions_ ? "CustomDebugStringConvertible" : "CustomStringConvertible");
block_open(out);
- out << endl;
+ out << '\n';
indent(out) << "public var description : String";
block_open(out);
indent(out) << "var desc = \"" << tstruct->get_name();
if (!gen_cocoa_) {
if (!tstruct->is_union()) {
- out << "(\"" << endl;
+ out << "(\"" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end();) {
indent(out) << "desc += \"" << (*f_iter)->get_name()
<< "=\\(String(describing: self." << maybe_escape_identifier((*f_iter)->get_name()) << "))";
if (++f_iter != fields.end()) {
out << ", ";
}
- out << "\"" << endl;
+ out << "\"" << '\n';
}
} else {
- out << ".\"" << endl;
- indent(out) << "switch self {" << endl;
+ out << ".\"" << '\n';
+ indent(out) << "switch self {" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end();f_iter++) {
indent(out) << "case ." << (*f_iter)->get_name() << "(let val): "
<< "desc += \"" << (*f_iter)->get_name() << "(val: \\(val))\""
- << endl;
+ << '\n';
}
- indent(out) << "}" << endl;
+ indent(out) << "}" << '\n';
}
} else {
- out << "(\"" << endl;
+ out << "(\"" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end();) {
indent(out) << "desc += \"" << (*f_iter)->get_name()
<< "=\\(self." << maybe_escape_identifier((*f_iter)->get_name()) << ")";
if (++f_iter != fields.end()) {
out << ", ";
}
- out << "\"" << endl;
+ out << "\"" << '\n';
}
- indent(out) << "desc += \")\"" << endl;
+ indent(out) << "desc += \")\"" << '\n';
}
- indent(out) << "return desc" << endl;
+ indent(out) << "return desc" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1606,14 +1604,14 @@
out << " : " << parent->get_name();
}
block_open(out);
- out << endl;
+ out << '\n';
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
function_docstring(out, *f_iter);
- indent(out) << function_signature(*f_iter) << endl << endl;
+ indent(out) << function_signature(*f_iter) << '\n' << '\n';
}
} else {
@@ -1624,7 +1622,7 @@
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- out << endl;
+ out << '\n';
indent(out) << function_signature(*f_iter) << " // exceptions: ";
t_struct* xs = (*f_iter)->get_xceptions();
const vector<t_field*>& xceptions = xs->get_members();
@@ -1632,11 +1630,11 @@
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
out << type_name((*x_iter)->get_type()) + ", ";
}
- out << endl;
+ out << '\n';
}
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1652,7 +1650,7 @@
indent(out) << "public protocol " << tservice->get_name() << "Async";
block_open(out);
- if (!gen_cocoa_) { out << endl; }
+ if (!gen_cocoa_) { out << '\n'; }
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
@@ -1660,20 +1658,20 @@
if (!gen_cocoa_) {
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
async_function_docstring(out, *f_iter);
- indent(out) << async_function_signature(*f_iter) << endl << endl;
+ indent(out) << async_function_signature(*f_iter) << '\n' << '\n';
}
} else {
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
- out << endl;
- indent(out) << async_function_signature(*f_iter) << endl;
+ out << '\n';
+ indent(out) << async_function_signature(*f_iter) << '\n';
if (promise_kit_) {
- indent(out) << promise_function_signature(*f_iter) << endl;
+ indent(out) << promise_function_signature(*f_iter) << '\n';
} //
- out << endl;
+ out << '\n';
}
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1690,33 +1688,33 @@
out << " : " << ((parent == nullptr) ? "TClient" : parent->get_name() + "Client");
out << " /* , " << tservice->get_name() << " */";
block_open(out);
- out << endl;
+ out << '\n';
} else {
// a
indent(out) << "public class " << tservice->get_name() << "Client /* : " << tservice->get_name() << " */";
block_open(out);
- out << endl;
+ out << '\n';
- indent(out) << "let __inProtocol : TProtocol" << endl << endl;
- indent(out) << "let __outProtocol : TProtocol" << endl << endl;
+ indent(out) << "let __inProtocol : TProtocol" << '\n' << '\n';
+ indent(out) << "let __outProtocol : TProtocol" << '\n' << '\n';
indent(out) << "public init(inoutProtocol: TProtocol)";
block_open(out);
- indent(out) << "__inProtocol = inoutProtocol" << endl;
- indent(out) << "__outProtocol = inoutProtocol" << endl;
+ indent(out) << "__inProtocol = inoutProtocol" << '\n';
+ indent(out) << "__outProtocol = inoutProtocol" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
indent(out) << "public init(inProtocol: TProtocol, outProtocol: TProtocol)";
block_open(out);
- indent(out) << "__inProtocol = inProtocol" << endl;
- indent(out) << "__outProtocol = outProtocol" << endl;
+ indent(out) << "__inProtocol = inProtocol" << '\n';
+ indent(out) << "__outProtocol = outProtocol" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1736,24 +1734,24 @@
out << " /* , " << tservice->get_name() << " */";
block_open(out);
- out << endl;
+ out << '\n';
} else {
indent(out) << "public class " << tservice->get_name() << "AsyncClient /* : " << tservice->get_name() << " */";
block_open(out);
- out << endl;
+ out << '\n';
- indent(out) << "let __protocolFactory : TProtocolFactory" << endl << endl;
- indent(out) << "let __transportFactory : TAsyncTransportFactory" << endl << endl;
+ indent(out) << "let __protocolFactory : TProtocolFactory" << '\n' << '\n';
+ indent(out) << "let __transportFactory : TAsyncTransportFactory" << '\n' << '\n';
indent(out) << "public init(protocolFactory: TProtocolFactory, transportFactory: TAsyncTransportFactory)";
block_open(out);
- indent(out) << "__protocolFactory = protocolFactory" << endl;
- indent(out) << "__transportFactory = transportFactory" << endl;
+ indent(out) << "__protocolFactory = protocolFactory" << '\n';
+ indent(out) << "__transportFactory = transportFactory" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1767,34 +1765,34 @@
indent(out) << "open class " << tservice->get_name() << "Processor /* " << tservice->get_name() << " */";
block_open(out);
- out << endl;
+ out << '\n';
out << indent() << "typealias ProcessorHandlerDictionary = "
- << "[String: (Int32, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << endl
- << endl
- << indent() << "public var service: " << tservice->get_name() << endl
- << endl
+ << "[String: (Int32, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << '\n'
+ << '\n'
+ << indent() << "public var service: " << tservice->get_name() << '\n'
+ << '\n'
<< indent() << "public required init(service: " << tservice->get_name() << ")";
} else {
indent(out) << "public class " << tservice->get_name() << "Processor : NSObject /* "
<< tservice->get_name() << " */";
block_open(out);
- out << endl;
+ out << '\n';
out << indent() << "typealias ProcessorHandlerDictionary = "
- << "[String: (Int, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << endl
- << endl
- << indent() << "let service : " << tservice->get_name() << endl
- << endl
+ << "[String: (Int, TProtocol, TProtocol, " << tservice->get_name() << ") throws -> Void]" << '\n'
+ << '\n'
+ << indent() << "let service : " << tservice->get_name() << '\n'
+ << '\n'
<< indent() << "public init(service: " << tservice->get_name() << ")";
}
block_open(out);
- indent(out) << "self.service = service" << endl;
+ indent(out) << "self.service = service" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1831,7 +1829,7 @@
// Serialize the request
indent(out) << "try outProtocol.writeMessageBegin(name: \"" << funname << "\", "
<< "type: " << (tfunction->is_oneway() ? ".oneway" : ".call") << ", "
- << "sequenceID: 0)" << endl;
+ << "sequenceID: 0)" << '\n';
indent(out) << "let args = " << argsname << "(";
@@ -1847,18 +1845,18 @@
out << ", ";
}
}
- out << ")" << endl;
- indent(out) << "try args.write(to: outProtocol)" << endl;
- indent(out) << "try outProtocol.writeMessageEnd()" << endl;
+ out << ")" << '\n';
+ indent(out) << "try args.write(to: outProtocol)" << '\n';
+ indent(out) << "try outProtocol.writeMessageEnd()" << '\n';
} else {
- out << endl;
+ out << '\n';
// Serialize the request
indent(out) << "try __outProtocol.writeMessageBeginWithName(\"" << funname << "\", "
<< "type: " << (tfunction->is_oneway() ? ".ONEWAY" : ".CALL") << ", "
- << "sequenceID: 0)" << endl;
+ << "sequenceID: 0)" << '\n';
- out << endl;
+ out << '\n';
indent(out) << "let __args = " << argsname << "(";
@@ -1874,13 +1872,13 @@
out << ", ";
}
}
- out << ")" << endl;
- indent(out) << "try " << argsname << ".writeValue(__args, toProtocol: __outProtocol)" << endl << endl;
- indent(out) << "try __outProtocol.writeMessageEnd()" << endl;
+ out << ")" << '\n';
+ indent(out) << "try " << argsname << ".writeValue(__args, toProtocol: __outProtocol)" << '\n' << '\n';
+ indent(out) << "try __outProtocol.writeMessageEnd()" << '\n';
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -1913,7 +1911,7 @@
// check for an exception
- indent(out) << "try inProtocol.readResultMessageBegin() " << endl;
+ indent(out) << "try inProtocol.readResultMessageBegin() " << '\n';
string resultname = function_result_helper_struct_type(tservice, tfunction);
indent(out);
@@ -1924,15 +1922,15 @@
}
string return_type_name = type_name(tfunction->get_returntype());
- out << "try " << resultname << ".read(from: inProtocol)" << endl;
+ out << "try " << resultname << ".read(from: inProtocol)" << '\n';
- indent(out) << "try inProtocol.readMessageEnd()" << endl << endl;
+ indent(out) << "try inProtocol.readMessageEnd()" << '\n' << '\n';
// Careful, only return _result if not a void function
if (!tfunction->get_returntype()->is_void()) {
indent(out) << "if let success = result.success";
block_open(out);
- indent(out) << "return success" << endl;
+ indent(out) << "return success" << '\n';
block_close(out);
}
@@ -1943,14 +1941,14 @@
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
indent(out) << "if let " << (*x_iter)->get_name() << " = result." << (*x_iter)->get_name();
block_open(out);
- indent(out) << "throw " << (*x_iter)->get_name() << endl;
+ indent(out) << "throw " << (*x_iter)->get_name() << '\n';
block_close(out);
}
// If you get here it's an exception, unless a void function
if (!tfunction->get_returntype()->is_void()) {
indent(out) << "throw TApplicationError(error: .missingResult(methodName: \""
- << tfunction->get_name() << "\"))" << endl;
+ << tfunction->get_name() << "\"))" << '\n';
}
} else {
if (needs_protocol) {
@@ -1966,22 +1964,22 @@
block_open(out);
// check for an exception
- out << endl;
- indent(out) << "try __inProtocol.readResultMessageBegin() " << endl << endl;
+ out << '\n';
+ indent(out) << "try __inProtocol.readResultMessageBegin() " << '\n' << '\n';
string resultname = function_result_helper_struct_type(tservice, tfunction);
indent(out);
if (!tfunction->get_returntype()->is_void() || !tfunction->get_xceptions()->get_members().empty()) {
out << "let __result = ";
}
- out << "try " << resultname << ".readValueFromProtocol(__inProtocol)" << endl << endl;
+ out << "try " << resultname << ".readValueFromProtocol(__inProtocol)" << '\n' << '\n';
- indent(out) << "try __inProtocol.readMessageEnd()" << endl << endl;
+ indent(out) << "try __inProtocol.readMessageEnd()" << '\n' << '\n';
// Careful, only return _result if not a void function
if (!tfunction->get_returntype()->is_void()) {
indent(out) << "if let __success = __result.success";
block_open(out);
- indent(out) << "return __success" << endl;
+ indent(out) << "return __success" << '\n';
block_close(out);
}
@@ -1992,24 +1990,24 @@
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
indent(out) << "if let " << (*x_iter)->get_name() << " = __result." << (*x_iter)->get_name();
block_open(out);
- indent(out) << "throw " << (*x_iter)->get_name() << endl;
+ indent(out) << "throw " << (*x_iter)->get_name() << '\n';
block_close(out);
}
// If you get here it's an exception, unless a void function
if (!tfunction->get_returntype()->is_void()) {
- indent(out) << "throw NSError(" << endl;
+ indent(out) << "throw NSError(" << '\n';
indent_up();
- indent(out) << "domain: TApplicationErrorDomain, " << endl;
- indent(out) << "code: Int(TApplicationError.MissingResult.rawValue)," << endl;
- indent(out) << "userInfo: [TApplicationErrorMethodKey: \"" << tfunction->get_name() << "\"])" << endl;
+ indent(out) << "domain: TApplicationErrorDomain, " << '\n';
+ indent(out) << "code: Int(TApplicationError.MissingResult.rawValue)," << '\n';
+ indent(out) << "userInfo: [TApplicationErrorMethodKey: \"" << tfunction->get_name() << "\"])" << '\n';
indent_down();
}
}
// Close function
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -2035,7 +2033,7 @@
}
}
- out << ")" << endl;
+ out << ")" << '\n';
}
/**
@@ -2061,7 +2059,7 @@
out << ", " << (*f_iter)->get_name() << ": " << (*f_iter)->get_name();
}
- out << ")" << endl;
+ out << ")" << '\n';
}
/**
@@ -2075,7 +2073,7 @@
string name = tservice->get_name() + "Client";
indent(out) << "extension " << name << " : " << tservice->get_name();
block_open(out);
- out << endl;
+ out << '\n';
// generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -2092,28 +2090,28 @@
indent(out) << "public " << function_signature(*f_iter);
block_open(out);
- if (gen_cocoa_) { out << endl; }
+ if (gen_cocoa_) { out << '\n'; }
generate_swift_service_client_send_function_invocation(out, *f_iter);
if (!gen_cocoa_) {
- indent(out) << "try outProtocol.transport.flush()" << endl;
+ indent(out) << "try outProtocol.transport.flush()" << '\n';
} else {
- out << endl;
- indent(out) << "try __outProtocol.transport().flush()" << endl << endl;
+ out << '\n';
+ indent(out) << "try __outProtocol.transport().flush()" << '\n' << '\n';
}
if (!(*f_iter)->is_oneway()) {
if ((*f_iter)->get_returntype()->is_void()) {
- indent(out) << "try recv_" << (*f_iter)->get_name() << "()" << endl;
+ indent(out) << "try recv_" << (*f_iter)->get_name() << "()" << '\n';
} else {
- indent(out) << "return try recv_" << (*f_iter)->get_name() << "()" << endl;
+ indent(out) << "return try recv_" << (*f_iter)->get_name() << "()" << '\n';
}
}
block_close(out);
- out << endl;
+ out << '\n';
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -2131,7 +2129,7 @@
indent(out) << "extension " << name << " : " << protocol_name;
block_open(out);
- out << endl;
+ out << '\n';
// generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -2146,10 +2144,10 @@
indent(out) << "public " << async_function_signature(*f_iter);
block_open(out);
- out << endl;
- out << indent() << "let transport = factory.newTransport()" << endl
- << indent() << "let proto = Protocol(on: transport)" << endl
- << endl;
+ out << '\n';
+ out << indent() << "let transport = factory.newTransport()" << '\n'
+ << indent() << "let proto = Protocol(on: transport)" << '\n'
+ << '\n';
out << indent() << "do";
block_open(out);
@@ -2157,12 +2155,12 @@
generate_swift_service_client_send_async_function_invocation(out, *f_iter);
indent_down();
- out << indent() << "} catch let error {" << endl;
+ out << indent() << "} catch let error {" << '\n';
indent_up();
- out << indent() << "completion(.error(error))" << endl;
+ out << indent() << "completion(.error(error))" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
bool ret_is_void = (*f_iter)->get_returntype()->is_void();
bool is_oneway = (*f_iter)->is_oneway();
@@ -2170,10 +2168,10 @@
string error_completion_call = "completion(.error(error))";
indent(out) << "transport.flush";
block_open(out);
- out << indent() << "(trans, error) in" << endl << endl;
+ out << indent() << "(trans, error) in" << '\n' << '\n';
out << indent() << "if let error = error";
block_open(out);
- out << indent() << error_completion_call << endl;
+ out << indent() << error_completion_call << '\n';
block_close(out);
if (!is_oneway) {
@@ -2183,24 +2181,24 @@
if (!ret_is_void) {
out << "let result = ";
}
- out << "try self.recv_" << (*f_iter)->get_name() << "(on: proto)" << endl;
+ out << "try self.recv_" << (*f_iter)->get_name() << "(on: proto)" << '\n';
- out << indent() << (ret_is_void ? "completion(.success(Void()))" : "completion(.success(result))") << endl;
+ out << indent() << (ret_is_void ? "completion(.success(Void()))" : "completion(.success(result))") << '\n';
indent_down();
- out << indent() << "} catch let error {" << endl;
+ out << indent() << "} catch let error {" << '\n';
indent_up();
- out << indent() << error_completion_call << endl;
+ out << indent() << error_completion_call << '\n';
block_close(out);
} else {
- out << indent() << "completion(.success(Void()))" << endl;
+ out << indent() << "completion(.success(Void()))" << '\n';
}
block_close(out);
block_close(out);
}
block_close(out);
- out << endl;
+ out << '\n';
}
void t_swift_generator::generate_old_swift_service_client_async_implementation(ostream& out,
@@ -2211,7 +2209,7 @@
indent(out) << "extension " << name << " : " << protocol_name;
block_open(out);
- out << endl;
+ out << '\n';
// generate client method implementations
vector<t_function*> functions = tservice->get_functions();
@@ -2226,19 +2224,19 @@
indent(out) << "public " << async_function_signature(*f_iter);
block_open(out);
- out << endl;
+ out << '\n';
- out << indent() << "let __transport = __transportFactory.newTransport()" << endl
- << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << endl
- << endl;
+ out << indent() << "let __transport = __transportFactory.newTransport()" << '\n'
+ << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << '\n'
+ << '\n';
generate_swift_service_client_send_async_function_invocation(out, *f_iter);
- out << endl;
+ out << '\n';
indent(out) << "__transport.flushWithCompletion(";
if ((*f_iter)->is_oneway()) {
- out << "success, failure: failure)" << endl;
+ out << "success, failure: failure)" << '\n';
}
else {
block_open(out);
@@ -2249,25 +2247,25 @@
if (!(*f_iter)->get_returntype()->is_void()) {
out << "let result = ";
}
- out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << endl;
+ out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << '\n';
out << indent() << "success(";
if (!(*f_iter)->get_returntype()->is_void()) {
out << "result";
}
- out << ")" << endl;
+ out << ")" << '\n';
block_close(out);
indent(out) << "catch let error";
block_open(out);
- indent(out) << "failure(error as NSError)" << endl;
+ indent(out) << "failure(error as NSError)" << '\n';
block_close(out);
block_close(out);
- indent(out) << ", failure: failure)" << endl;
+ indent(out) << ", failure: failure)" << '\n';
}
block_close(out);
- out << endl;
+ out << '\n';
// Promise function
if (promise_kit_) {
@@ -2275,17 +2273,17 @@
indent(out) << "public " << promise_function_signature(*f_iter);
block_open(out);
- out << indent() << "let (__promise, __fulfill, __reject) = Promise<" << type_name((*f_iter)->get_returntype()) << ">.pendingPromise()" << endl << endl
- << indent() << "let __transport = __transportFactory.newTransport()" << endl
- << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << endl
- << endl;
+ out << indent() << "let (__promise, __fulfill, __reject) = Promise<" << type_name((*f_iter)->get_returntype()) << ">.pendingPromise()" << '\n' << '\n'
+ << indent() << "let __transport = __transportFactory.newTransport()" << '\n'
+ << indent() << "let __protocol = __protocolFactory.newProtocolOnTransport(__transport)" << '\n'
+ << '\n';
generate_swift_service_client_send_async_function_invocation(out, *f_iter);
- out << endl;
+ out << '\n';
indent(out) << "__transport.flushWithCompletion(";
if ((*f_iter)->is_oneway()) {
- out << "{ __fulfill() }, failure: { __reject($0) })" << endl;
+ out << "{ __fulfill() }, failure: { __reject($0) })" << '\n';
}
else {
block_open(out);
@@ -2296,37 +2294,37 @@
if (!(*f_iter)->get_returntype()->is_void()) {
out << "let result = ";
}
- out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << endl;
+ out << "try self.recv_" << (*f_iter)->get_name() << "(__protocol)" << '\n';
out << indent() << "__fulfill(";
if (!(*f_iter)->get_returntype()->is_void()) {
out << "result";
}
- out << ")" << endl;
+ out << ")" << '\n';
block_close(out);
indent(out) << "catch let error";
block_open(out);
- indent(out) << "__reject(error)" << endl;
+ indent(out) << "__reject(error)" << '\n';
block_close(out);
block_close(out);
- indent(out) << ", failure: { error in " << endl;
+ indent(out) << ", failure: { error in " << '\n';
indent_up();
- indent(out) << "__reject(error)" << endl;
+ indent(out) << "__reject(error)" << '\n';
indent_down();
- indent(out) << "})" << endl;
+ indent(out) << "})" << '\n';
}
- indent(out) << "return __promise" << endl;
+ indent(out) << "return __promise" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
}
}
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -2345,12 +2343,12 @@
indent(out) << "extension " << name << " : TProcessor";
block_open(out);
- out << endl;
+ out << '\n';
indent(out) << "static let processorHandlers" << (gen_cocoa_ ? " " : "") << ": ProcessorHandlerDictionary =";
block_open(out);
- out << endl;
- out << indent() << "var processorHandlers = ProcessorHandlerDictionary()" << endl << endl;
+ out << '\n';
+ out << indent() << "var processorHandlers = ProcessorHandlerDictionary()" << '\n' << '\n';
// generate method map for routing incoming calls
vector<t_function*> functions = tservice->get_functions();
@@ -2361,25 +2359,25 @@
string args_type = function_args_helper_struct_type(tservice, *f_iter);
- out << indent() << "processorHandlers[\"" << tfunction->get_name() << "\"] = { sequenceID, inProtocol, outProtocol, handler in" << endl
- << endl;
+ out << indent() << "processorHandlers[\"" << tfunction->get_name() << "\"] = { sequenceID, inProtocol, outProtocol, handler in" << '\n'
+ << '\n';
indent_up();
if (!gen_cocoa_) {
- out << indent() << "let args = try " << args_type << ".read(from: inProtocol)" << endl
- << endl
- << indent() << "try inProtocol.readMessageEnd()" << endl
- << endl;
+ out << indent() << "let args = try " << args_type << ".read(from: inProtocol)" << '\n'
+ << '\n'
+ << indent() << "try inProtocol.readMessageEnd()" << '\n'
+ << '\n';
} else {
- out << indent() << "let args = try " << args_type << ".readValueFromProtocol(inProtocol)" << endl
- << endl
- << indent() << "try inProtocol.readMessageEnd()" << endl
- << endl;
+ out << indent() << "let args = try " << args_type << ".readValueFromProtocol(inProtocol)" << '\n'
+ << '\n'
+ << indent() << "try inProtocol.readMessageEnd()" << '\n'
+ << '\n';
}
if (!tfunction->is_oneway() ) {
string result_type = function_result_helper_struct_type(tservice, tfunction);
- indent(out) << "var result = " << result_type << "()" << endl;
+ indent(out) << "var result = " << result_type << "()" << '\n';
indent(out) << "do";
block_open(out);
@@ -2406,7 +2404,7 @@
}
}
- out << ")" << endl;
+ out << ")" << '\n';
block_close(out);
t_struct* xs = tfunction->get_xceptions();
@@ -2423,37 +2421,37 @@
}
out << (*x_iter)->get_type()->get_name();
- out << " { result." << (*x_iter)->get_name() << " = error }" << endl;
+ out << " { result." << (*x_iter)->get_name() << " = error }" << '\n';
}
- indent(out) << "catch let error { throw error }" << endl;
- out << endl;
+ indent(out) << "catch let error { throw error }" << '\n';
+ out << '\n';
if (!tfunction->is_oneway()) {
- out << indent() << "try outProtocol.writeMessageBegin(name: \"" << tfunction->get_name() << "\", type: .reply, sequenceID: sequenceID)" << endl
- << indent() << "try result.write(to: outProtocol)" << endl
- << indent() << "try outProtocol.writeMessageEnd()" << endl
- << indent() << "try outProtocol.transport.flush()" << endl;
+ out << indent() << "try outProtocol.writeMessageBegin(name: \"" << tfunction->get_name() << "\", type: .reply, sequenceID: sequenceID)" << '\n'
+ << indent() << "try result.write(to: outProtocol)" << '\n'
+ << indent() << "try outProtocol.writeMessageEnd()" << '\n'
+ << indent() << "try outProtocol.transport.flush()" << '\n';
}
} else {
for (x_iter = xfields.begin(); x_iter != xfields.end(); ++x_iter) {
indent(out) << "catch let error as " << (*x_iter)->get_type()->get_name();
block_open(out);
- indent(out) << "result." << (*x_iter)->get_name() << " = error" << endl;
+ indent(out) << "result." << (*x_iter)->get_name() << " = error" << '\n';
block_close(out);
}
indent(out) << "catch let error";
block_open(out);
- out << indent() << "throw error" << endl;
+ out << indent() << "throw error" << '\n';
block_close(out);
- out << endl;
+ out << '\n';
if (!tfunction->is_oneway()) {
- out << indent() << "try outProtocol.writeMessageBeginWithName(\"" << tfunction->get_name() << "\", type: .REPLY, sequenceID: sequenceID)" << endl
- << indent() << "try " << result_type << ".writeValue(result, toProtocol: outProtocol)" << endl
- << indent() << "try outProtocol.writeMessageEnd()" << endl;
+ out << indent() << "try outProtocol.writeMessageBeginWithName(\"" << tfunction->get_name() << "\", type: .REPLY, sequenceID: sequenceID)" << '\n'
+ << indent() << "try " << result_type << ".writeValue(result, toProtocol: outProtocol)" << '\n'
+ << indent() << "try outProtocol.writeMessageEnd()" << '\n';
}
}
}
@@ -2461,11 +2459,11 @@
}
- indent(out) << "return processorHandlers" << endl;
+ indent(out) << "return processorHandlers" << '\n';
block_close(out,false);
- out << "()" << endl;
- out << endl;
+ out << "()" << '\n';
+ out << '\n';
if (!gen_cocoa_) {
indent(out) << "public func process(on inProtocol: TProtocol, outProtocol: TProtocol) throws";
@@ -2474,47 +2472,47 @@
}
block_open(out);
- out << endl;
- out << indent() << "let (messageName, _, sequenceID) = try inProtocol.readMessageBegin()" << endl
- << endl
+ out << '\n';
+ out << indent() << "let (messageName, _, sequenceID) = try inProtocol.readMessageBegin()" << '\n'
+ << '\n'
<< indent() << "if let processorHandler = " << name << ".processorHandlers[messageName]";
block_open(out);
out << indent() << "do";
block_open(out);
- out << indent() << "try processorHandler(sequenceID, inProtocol, outProtocol, service)" << endl;
+ out << indent() << "try processorHandler(sequenceID, inProtocol, outProtocol, service)" << '\n';
block_close(out);
if (!gen_cocoa_) {
out << indent() << "catch let error as TApplicationError";
block_open(out);
- out << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: error)" << endl
- << indent() << "try outProtocol.transport.flush()" << endl;
+ out << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: error)" << '\n'
+ << indent() << "try outProtocol.transport.flush()" << '\n';
block_close(out);
block_close(out);
out << indent() << "else";
block_open(out);
- out << indent() << "try inProtocol.skip(type: .struct)" << endl
- << indent() << "try inProtocol.readMessageEnd()" << endl
- << indent() << "let ex = TApplicationError(error: .unknownMethod(methodName: messageName))" << endl
- << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: ex)" << endl
- << indent() << "try outProtocol.transport.flush()" << endl;
+ out << indent() << "try inProtocol.skip(type: .struct)" << '\n'
+ << indent() << "try inProtocol.readMessageEnd()" << '\n'
+ << indent() << "let ex = TApplicationError(error: .unknownMethod(methodName: messageName))" << '\n'
+ << indent() << "try outProtocol.writeException(messageName: messageName, sequenceID: sequenceID, ex: ex)" << '\n'
+ << indent() << "try outProtocol.transport.flush()" << '\n';
} else {
out << indent() << "catch let error as NSError";
block_open(out);
- out << indent() << "try outProtocol.writeExceptionForMessageName(messageName, sequenceID: sequenceID, ex: error)" << endl;
+ out << indent() << "try outProtocol.writeExceptionForMessageName(messageName, sequenceID: sequenceID, ex: error)" << '\n';
block_close(out);
block_close(out);
out << indent() << "else";
block_open(out);
- out << indent() << "try inProtocol.skipType(.STRUCT)" << endl
- << indent() << "try inProtocol.readMessageEnd()" << endl
- << indent() << "try outProtocol.writeExceptionForMessageName(messageName," << endl;
+ out << indent() << "try inProtocol.skipType(.STRUCT)" << '\n'
+ << indent() << "try inProtocol.readMessageEnd()" << '\n'
+ << indent() << "try outProtocol.writeExceptionForMessageName(messageName," << '\n';
indent_up();
- out << indent() << "sequenceID: sequenceID," << endl
- << indent() << "ex: NSError(" << endl;
+ out << indent() << "sequenceID: sequenceID," << '\n'
+ << indent() << "ex: NSError(" << '\n';
indent_up();
- out << indent() << "domain: TApplicationErrorDomain, " << endl
- << indent() << "code: Int(TApplicationError.UnknownMethod.rawValue), " << endl
- << indent() << "userInfo: [TApplicationErrorMethodKey: messageName]))" << endl;
+ out << indent() << "domain: TApplicationErrorDomain, " << '\n'
+ << indent() << "code: Int(TApplicationError.UnknownMethod.rawValue), " << '\n'
+ << indent() << "userInfo: [TApplicationErrorMethodKey: messageName]))" << '\n';
indent_down();
indent_down();
}
@@ -2522,7 +2520,7 @@
block_close(out);
block_close(out);
block_close(out);
- out << endl;
+ out << '\n';
}
/**
@@ -2812,27 +2810,27 @@
// Description
string doc = tfunction->get_doc();
generate_docstring(out, doc);
- indent(out) << "///" << endl;
+ indent(out) << "///" << '\n';
// Parameters
const vector<t_field*>& fields = tfunction->get_arglist()->get_members();
vector<t_field*>::const_iterator f_iter;
if (!fields.empty()) {
- indent(out) << "/// - Parameters:" << endl;
+ indent(out) << "/// - Parameters:" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent(out) << "/// - " << (*f_iter)->get_name() << ": ";
string doc = (*f_iter)->get_doc();
if (!doc.empty() && doc[doc.length()-1] == '\n') {
doc.erase(doc.length()-1);
}
- out << doc << endl;
+ out << doc << '\n';
}
}
// Returns
t_type* ttype = tfunction->get_returntype();
if (!ttype->is_void()) {
- indent(out) << "/// - Returns: " << type_name(ttype) << endl;
+ indent(out) << "/// - Returns: " << type_name(ttype) << '\n';
}
// Throws
@@ -2845,7 +2843,7 @@
if (*x_iter != xceptions.back()) {
out << ", ";
} }
- out << endl;
+ out << '\n';
}
/**
@@ -2865,20 +2863,20 @@
// Description
string doc = tfunction->get_doc();
generate_docstring(out, doc);
- indent(out) << "///" << endl;
+ indent(out) << "///" << '\n';
// Parameters
const vector<t_field*>& fields = tfunction->get_arglist()->get_members();
vector<t_field*>::const_iterator f_iter;
if (!fields.empty()) {
- indent(out) << "/// - Parameters:" << endl;
+ indent(out) << "/// - Parameters:" << '\n';
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent(out) << "/// - " << (*f_iter)->get_name() << ": ";
string doc = (*f_iter)->get_doc();
if (!doc.empty() && doc[doc.length()-1] == '\n') {
doc.erase(doc.length()-1);
}
- out << doc << endl;
+ out << doc << '\n';
}
}
@@ -2894,7 +2892,7 @@
out << ", ";
}
}
- out << endl;
+ out << '\n';
}
/**
diff --git a/compiler/cpp/src/thrift/generate/t_xml_generator.cc b/compiler/cpp/src/thrift/generate/t_xml_generator.cc
index 68675cf..86c2718 100644
--- a/compiler/cpp/src/thrift/generate/t_xml_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_xml_generator.cc
@@ -39,9 +39,6 @@
using std::stack;
using std::set;
-static const string endl = "\n";
-static const string quot = "\"";
-
static const string default_ns_prefix = "http://thrift.apache.org/xml/ns/";
/**
@@ -196,7 +193,7 @@
close_top_element();
// TODO: indent any EOLs that may occur with msg
// TODO: proper msg escaping needed?
- f_xml_ << indent() << "<!-- " << msg << " -->" << endl;
+ f_xml_ << indent() << "<!-- " << msg << " -->" << '\n';
top_element_is_empty = false;
}
@@ -204,7 +201,7 @@
if( top_element_is_open) {
top_element_is_open = false;
if (elements_.size() > 0 && top_element_is_empty) {
- f_xml_ << ">" << endl;
+ f_xml_ << ">" << '\n';
}
}
}
@@ -224,9 +221,9 @@
void t_xml_generator::write_element_end() {
indent_down();
if (top_element_is_empty && top_element_is_open) {
- f_xml_ << " />" << endl;
+ f_xml_ << " />" << '\n';
} else {
- f_xml_ << indent() << "</" << elements_.top() << ">" << endl;
+ f_xml_ << indent() << "</" << elements_.top() << ">" << '\n';
}
top_element_is_empty = false;
elements_.pop();
@@ -248,7 +245,7 @@
top_element_is_empty = false;
f_xml_ << indent()
<< "<" << name << ">" << escape_xml_string(val) << "</" << name << ">"
- << endl;
+ << '\n';
}
string t_xml_generator::escape_xml_string(const string& input) {
@@ -511,7 +508,7 @@
default:
indent_up();
- f_xml_ << indent() << "<null />" << endl;
+ f_xml_ << indent() << "<null />" << '\n';
indent_down();
break;
}
diff --git a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
index 1f58f3a..8dd84f0 100644
--- a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
@@ -36,8 +36,6 @@
using std::stringstream;
using std::vector;
-static const string endl = "\n"; // avoid ostream << std::endl flushes
-
/**
* XSD generator, creates an XSD for the base types etc.
*
@@ -121,22 +119,22 @@
string f_php_name = get_out_dir() + program_->get_name() + "_xsd.php";
f_php_.open(f_php_name.c_str());
- f_php_ << "<?php" << endl
- << autogen_comment() << endl;
+ f_php_ << "<?php" << '\n'
+ << autogen_comment() << '\n';
}
void t_xsd_generator::close_generator() {
- f_php_ << "?>" << endl;
+ f_php_ << "?>" << '\n';
f_php_.close();
}
void t_xsd_generator::generate_typedef(t_typedef* ttypedef) {
- indent(s_xsd_types_) << "<xsd:simpleType name=\"" << ttypedef->get_name() << "\">" << endl;
+ indent(s_xsd_types_) << "<xsd:simpleType name=\"" << ttypedef->get_name() << "\">" << '\n';
indent_up();
indent(s_xsd_types_) << "<xsd:restriction base=\"" << type_name(ttypedef->get_type()) << "\" />"
- << endl;
+ << '\n';
indent_down();
- indent(s_xsd_types_) << "</xsd:simpleType>" << endl << endl;
+ indent(s_xsd_types_) << "</xsd:simpleType>" << '\n' << '\n';
}
void t_xsd_generator::generate_struct(t_struct* tstruct) {
@@ -144,12 +142,12 @@
const vector<t_field*>& members = tstruct->get_members();
bool xsd_all = tstruct->get_xsd_all();
- indent(s_xsd_types_) << "<xsd:complexType name=\"" << tstruct->get_name() << "\">" << endl;
+ indent(s_xsd_types_) << "<xsd:complexType name=\"" << tstruct->get_name() << "\">" << '\n';
indent_up();
if (xsd_all) {
- indent(s_xsd_types_) << "<xsd:all>" << endl;
+ indent(s_xsd_types_) << "<xsd:all>" << '\n';
} else {
- indent(s_xsd_types_) << "<xsd:sequence>" << endl;
+ indent(s_xsd_types_) << "<xsd:sequence>" << '\n';
}
indent_up();
@@ -164,12 +162,12 @@
indent_down();
if (xsd_all) {
- indent(s_xsd_types_) << "</xsd:all>" << endl;
+ indent(s_xsd_types_) << "</xsd:all>" << '\n';
} else {
- indent(s_xsd_types_) << "</xsd:sequence>" << endl;
+ indent(s_xsd_types_) << "</xsd:sequence>" << '\n';
}
indent_down();
- indent(s_xsd_types_) << "</xsd:complexType>" << endl << endl;
+ indent(s_xsd_types_) << "</xsd:complexType>" << '\n' << '\n';
}
void t_xsd_generator::generate_element(ostream& out,
@@ -185,15 +183,15 @@
string snillable = nillable ? " nillable=\"true\"" : "";
if (ttype->is_void() || ttype->is_list()) {
- indent(out) << "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">" << endl;
+ indent(out) << "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">" << '\n';
indent_up();
if (attrs == nullptr && ttype->is_void()) {
- indent(out) << "<xsd:complexType />" << endl;
+ indent(out) << "<xsd:complexType />" << '\n';
} else {
- indent(out) << "<xsd:complexType>" << endl;
+ indent(out) << "<xsd:complexType>" << '\n';
indent_up();
if (ttype->is_list()) {
- indent(out) << "<xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">" << endl;
+ indent(out) << "<xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">" << '\n';
indent_up();
string subname;
t_type* subtype = ((t_list*)ttype)->get_elem_type();
@@ -203,55 +201,55 @@
subname = type_name(subtype);
}
f_php_ << "$GLOBALS['" << program_->get_name() << "_xsd_elt_" << name << "'] = '" << subname
- << "';" << endl;
+ << "';" << '\n';
generate_element(out, subname, subtype, nullptr, false, false, true);
indent_down();
- indent(out) << "</xsd:sequence>" << endl;
- indent(out) << "<xsd:attribute name=\"list\" type=\"xsd:boolean\" />" << endl;
+ indent(out) << "</xsd:sequence>" << '\n';
+ indent(out) << "<xsd:attribute name=\"list\" type=\"xsd:boolean\" />" << '\n';
}
if (attrs != nullptr) {
const vector<t_field*>& members = attrs->get_members();
vector<t_field*>::const_iterator a_iter;
for (a_iter = members.begin(); a_iter != members.end(); ++a_iter) {
indent(out) << "<xsd:attribute name=\"" << (*a_iter)->get_name() << "\" type=\""
- << type_name((*a_iter)->get_type()) << "\" />" << endl;
+ << type_name((*a_iter)->get_type()) << "\" />" << '\n';
}
}
indent_down();
- indent(out) << "</xsd:complexType>" << endl;
+ indent(out) << "</xsd:complexType>" << '\n';
}
indent_down();
- indent(out) << "</xsd:element>" << endl;
+ indent(out) << "</xsd:element>" << '\n';
} else {
if (attrs == nullptr) {
indent(out) << "<xsd:element name=\"" << name << "\""
<< " type=\"" << type_name(ttype) << "\"" << soptional << snillable << " />"
- << endl;
+ << '\n';
} else {
// Wow, all this work for a SIMPLE TYPE with attributes?!?!?!
indent(out) << "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">"
- << endl;
+ << '\n';
indent_up();
- indent(out) << "<xsd:complexType>" << endl;
+ indent(out) << "<xsd:complexType>" << '\n';
indent_up();
- indent(out) << "<xsd:complexContent>" << endl;
+ indent(out) << "<xsd:complexContent>" << '\n';
indent_up();
- indent(out) << "<xsd:extension base=\"" << type_name(ttype) << "\">" << endl;
+ indent(out) << "<xsd:extension base=\"" << type_name(ttype) << "\">" << '\n';
indent_up();
const vector<t_field*>& members = attrs->get_members();
vector<t_field*>::const_iterator a_iter;
for (a_iter = members.begin(); a_iter != members.end(); ++a_iter) {
indent(out) << "<xsd:attribute name=\"" << (*a_iter)->get_name() << "\" type=\""
- << type_name((*a_iter)->get_type()) << "\" />" << endl;
+ << type_name((*a_iter)->get_type()) << "\" />" << '\n';
}
indent_down();
- indent(out) << "</xsd:extension>" << endl;
+ indent(out) << "</xsd:extension>" << '\n';
indent_down();
- indent(out) << "</xsd:complexContent>" << endl;
+ indent(out) << "</xsd:complexContent>" << '\n';
indent_down();
- indent(out) << "</xsd:complexType>" << endl;
+ indent(out) << "</xsd:complexType>" << '\n';
indent_down();
- indent(out) << "</xsd:element>" << endl;
+ indent(out) << "</xsd:element>" << '\n';
}
}
}
@@ -274,10 +272,10 @@
}
// Print the XSD header
- f_xsd_ << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl
- << "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" << ns << ">" << endl
+ f_xsd_ << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << '\n'
+ << "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" << ns << ">" << '\n'
<< xml_autogen_comment()
- << endl;
+ << '\n';
// Print out the type definitions
indent(f_xsd_) << s_xsd_types_.str();
@@ -292,7 +290,7 @@
string elemname = (*f_iter)->get_name() + "_response";
t_type* returntype = (*f_iter)->get_returntype();
generate_element(f_xsd_, elemname, returntype);
- f_xsd_ << endl;
+ f_xsd_ << '\n';
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
@@ -308,7 +306,7 @@
}
// Close the XSD document
- f_xsd_ << endl << "</xsd:schema>" << endl;
+ f_xsd_ << '\n' << "</xsd:schema>" << '\n';
f_xsd_.close();
}
diff --git a/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc b/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc
index 6acedc0..348ac9f 100644
--- a/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc
+++ b/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc
@@ -5,9 +5,9 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -36,7 +36,8 @@
"using System.Threading;\n"
"using System.Threading.Tasks;\n"
"using Thrift;\n"
- "using Thrift.Collections;\n" + endl;
+ "using Thrift.Collections;\n"
+ "\n";
t_program* program = new t_program(path, name);
t_netstd_generator* gen = new t_netstd_generator(program, parsed_options, option_string);
@@ -65,7 +66,8 @@
"using Thrift;\n"
"using Thrift.Collections;\n"
"using System.ServiceModel;\n"
- "using System.Runtime.Serialization;\n" + endl;
+ "using System.Runtime.Serialization;\n"
+ "\n";
t_program* program = new t_program(path, name);
t_netstd_generator* gen = new t_netstd_generator(program, parsed_options, option_string);
diff --git a/contrib/fb303/TClientInfo.cpp b/contrib/fb303/TClientInfo.cpp
index a4b00cf..c30b42b 100644
--- a/contrib/fb303/TClientInfo.cpp
+++ b/contrib/fb303/TClientInfo.cpp
@@ -149,7 +149,7 @@
char addrBuf[INET6_ADDRSTRLEN];
const char* addrStr = info->getAddr(addrBuf, sizeof addrBuf);
if (addrStr == nullptr) {
- // cerr << "no addr!" << endl;
+ // cerr << "no addr!" << '\n';
continue;
}
@@ -160,7 +160,7 @@
char buf[256];
snprintf(buf, sizeof buf, "%d %s %s %.3f %llu", i, addrStr, callStr, secs,
(uint64_t)info->getNCalls());
-
+
result.push_back(buf);
}
}
diff --git a/contrib/fb303/cpp/ServiceTracker.cpp b/contrib/fb303/cpp/ServiceTracker.cpp
index a2e670c..43e8847 100644
--- a/contrib/fb303/cpp/ServiceTracker.cpp
+++ b/contrib/fb303/cpp/ServiceTracker.cpp
@@ -344,7 +344,7 @@
break;
}
cout << '[' << level_string << "] [" << now_pretty << "] "
- << message << endl;
+ << message << '\n';
}
}
diff --git a/contrib/thrift_dump.cpp b/contrib/thrift_dump.cpp
index 59c8ac8..01864d0 100644
--- a/contrib/thrift_dump.cpp
+++ b/contrib/thrift_dump.cpp
@@ -80,12 +80,12 @@
}
}
} catch (TProtocolException exn) {
- cout << "Protocol Exception: " << exn.what() << endl;
+ cout << "Protocol Exception: " << exn.what() << '\n';
} catch (...) {
oprot->getTransport()->flush();
}
- cout << endl;
+ cout << '\n';
return 0;
}
diff --git a/contrib/zeromq/test-client.cpp b/contrib/zeromq/test-client.cpp
index 159c250..f2bd213 100644
--- a/contrib/zeromq/test-client.cpp
+++ b/contrib/zeromq/test-client.cpp
@@ -33,7 +33,7 @@
usleep(50000);
} else {
int value = client.get();
- std::cout << value << std::endl;
+ std::cout << value << '\n';
}
return 0;
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index 77daf3d..5e0c894 100644
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -51,7 +51,6 @@
using namespace thrift::test;
using std::cout;
-using std::endl;
using std::fixed;
using std::make_pair;
using std::map;
@@ -76,51 +75,51 @@
TestHandler() = default;
void testVoid() override {
- cout << "[C -> C++] testVoid()" << endl;
+ cout << "[C -> C++] testVoid()" << '\n';
}
void testString(string& out, const string &thing) override {
- cout << "[C -> C++] testString(\"" << thing << "\")" << endl;
+ cout << "[C -> C++] testString(\"" << thing << "\")" << '\n';
out = thing;
}
bool testBool(const bool thing) override {
- cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << endl;
+ cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << '\n';
return thing;
}
int8_t testByte(const int8_t thing) override {
- cout << "[C -> C++] testByte(" << (int)thing << ")" << endl;
+ cout << "[C -> C++] testByte(" << (int)thing << ")" << '\n';
return thing;
}
int32_t testI32(const int32_t thing) override {
- cout << "[C -> C++] testI32(" << thing << ")" << endl;
+ cout << "[C -> C++] testI32(" << thing << ")" << '\n';
return thing;
}
int64_t testI64(const int64_t thing) override {
- cout << "[C -> C++] testI64(" << thing << ")" << endl;
+ cout << "[C -> C++] testI64(" << thing << ")" << '\n';
return thing;
}
double testDouble(const double thing) override {
cout.precision(6);
- cout << "[C -> C++] testDouble(" << fixed << thing << ")" << endl;
+ cout << "[C -> C++] testDouble(" << fixed << thing << ")" << '\n';
return thing;
}
void testBinary(string& out, const string &thing) override {
- cout << "[C -> C++] testBinary(\"" << thing << "\")" << endl;
+ cout << "[C -> C++] testBinary(\"" << thing << "\")" << '\n';
out = thing;
}
void testStruct(Xtruct& out, const Xtruct &thing) override {
- cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << endl;
+ cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << '\n';
out = thing;
}
void testNest(Xtruct2& out, const Xtruct2& nest) override {
const Xtruct &thing = nest.struct_thing;
- cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << endl;
+ cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << '\n';
out = nest;
}
@@ -136,7 +135,7 @@
}
cout << m_iter->first << " => " << m_iter->second;
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
@@ -152,7 +151,7 @@
}
cout << "\"" << m_iter->first << "\" => \"" << m_iter->second << "\"";
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
@@ -169,7 +168,7 @@
}
cout << *s_iter;
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
@@ -185,21 +184,21 @@
}
cout << *l_iter;
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
Numberz::type testEnum(const Numberz::type thing) override {
- cout << "[C -> C++] testEnum(" << thing << ")" << endl;
+ cout << "[C -> C++] testEnum(" << thing << ")" << '\n';
return thing;
}
UserId testTypedef(const UserId thing) override {
- cout << "[C -> C++] testTypedef(" << thing << ")" << endl;
+ cout << "[C -> C++] testTypedef(" << thing << ")" << '\n';
return thing; }
void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) override {
- cout << "[C -> C++] testMapMap(" << hello << ")" << endl;
+ cout << "[C -> C++] testMapMap(" << hello << ")" << '\n';
map<int32_t,int32_t> pos;
map<int32_t,int32_t> neg;
@@ -216,7 +215,7 @@
void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) override {
THRIFT_UNUSED_VARIABLE (argument);
- cout << "[C -> C++] testInsanity()" << endl;
+ cout << "[C -> C++] testInsanity()" << '\n';
Xtruct hello;
hello.string_thing = "Hello2";
@@ -278,7 +277,7 @@
}
cout << "}, ";
}
- cout << "}" << endl;
+ cout << "}" << '\n';
}
@@ -288,7 +287,7 @@
THRIFT_UNUSED_VARIABLE (arg4);
THRIFT_UNUSED_VARIABLE (arg5);
- cout << "[C -> C++] testMulti()" << endl;
+ cout << "[C -> C++] testMulti()" << '\n';
hello.string_thing = "Hello2";
hello.byte_thing = arg0;
@@ -299,7 +298,7 @@
void testException(const std::string &arg)
noexcept(false) override
{
- cout << "[C -> C++] testException(" << arg << ")" << endl;
+ cout << "[C -> C++] testException(" << arg << ")" << '\n';
if (arg.compare("Xception") == 0) {
Xception e;
e.errorCode = 1001;
@@ -317,7 +316,7 @@
void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) noexcept(false) override {
- cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << endl;
+ cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << '\n';
if (arg0.compare("Xception") == 0) {
Xception e;
@@ -336,9 +335,9 @@
}
void testOneway(int sleepFor) override {
- cout << "testOneway(" << sleepFor << "): Sleeping..." << endl;
+ cout << "testOneway(" << sleepFor << "): Sleeping..." << '\n';
sleep(sleepFor);
- cout << "testOneway(" << sleepFor << "): done sleeping!" << endl;
+ cout << "testOneway(" << sleepFor << "): done sleeping!" << '\n';
}
};
diff --git a/lib/c_glib/test/testthrifttestzlibclient.cpp b/lib/c_glib/test/testthrifttestzlibclient.cpp
index 5c4b931..307fd4f 100644
--- a/lib/c_glib/test/testthrifttestzlibclient.cpp
+++ b/lib/c_glib/test/testthrifttestzlibclient.cpp
@@ -46,7 +46,6 @@
using namespace thrift::test;
using std::cout;
-using std::endl;
using std::fixed;
using std::make_pair;
using std::map;
@@ -71,51 +70,51 @@
TestHandler() = default;
void testVoid() override {
- cout << "[C -> C++] testVoid()" << endl;
+ cout << "[C -> C++] testVoid()" << '\n';
}
void testString(string& out, const string &thing) override {
- cout << "[C -> C++] testString(\"" << thing << "\")" << endl;
+ cout << "[C -> C++] testString(\"" << thing << "\")" << '\n';
out = thing;
}
bool testBool(const bool thing) override {
- cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << endl;
+ cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << '\n';
return thing;
}
int8_t testByte(const int8_t thing) override {
- cout << "[C -> C++] testByte(" << (int)thing << ")" << endl;
+ cout << "[C -> C++] testByte(" << (int)thing << ")" << '\n';
return thing;
}
int32_t testI32(const int32_t thing) override {
- cout << "[C -> C++] testI32(" << thing << ")" << endl;
+ cout << "[C -> C++] testI32(" << thing << ")" << '\n';
return thing;
}
int64_t testI64(const int64_t thing) override {
- cout << "[C -> C++] testI64(" << thing << ")" << endl;
+ cout << "[C -> C++] testI64(" << thing << ")" << '\n';
return thing;
}
double testDouble(const double thing) override {
cout.precision(6);
- cout << "[C -> C++] testDouble(" << fixed << thing << ")" << endl;
+ cout << "[C -> C++] testDouble(" << fixed << thing << ")" << '\n';
return thing;
}
void testBinary(string& out, const string &thing) override {
- cout << "[C -> C++] testBinary(\"" << thing << "\")" << endl;
+ cout << "[C -> C++] testBinary(\"" << thing << "\")" << '\n';
out = thing;
}
void testStruct(Xtruct& out, const Xtruct &thing) override {
- cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << endl;
+ cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << '\n';
out = thing;
}
void testNest(Xtruct2& out, const Xtruct2& nest) override {
const Xtruct &thing = nest.struct_thing;
- cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << endl;
+ cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << '\n';
out = nest;
}
@@ -131,7 +130,7 @@
}
cout << m_iter->first << " => " << m_iter->second;
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
@@ -147,7 +146,7 @@
}
cout << "\"" << m_iter->first << "\" => \"" << m_iter->second << "\"";
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
@@ -164,7 +163,7 @@
}
cout << *s_iter;
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
@@ -180,21 +179,21 @@
}
cout << *l_iter;
}
- cout << "})" << endl;
+ cout << "})" << '\n';
out = thing;
}
Numberz::type testEnum(const Numberz::type thing) override {
- cout << "[C -> C++] testEnum(" << thing << ")" << endl;
+ cout << "[C -> C++] testEnum(" << thing << ")" << '\n';
return thing;
}
UserId testTypedef(const UserId thing) override {
- cout << "[C -> C++] testTypedef(" << thing << ")" << endl;
+ cout << "[C -> C++] testTypedef(" << thing << ")" << '\n';
return thing; }
void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) override {
- cout << "[C -> C++] testMapMap(" << hello << ")" << endl;
+ cout << "[C -> C++] testMapMap(" << hello << ")" << '\n';
map<int32_t,int32_t> pos;
map<int32_t,int32_t> neg;
@@ -211,7 +210,7 @@
void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) override {
THRIFT_UNUSED_VARIABLE (argument);
- cout << "[C -> C++] testInsanity()" << endl;
+ cout << "[C -> C++] testInsanity()" << '\n';
Xtruct hello;
hello.string_thing = "Hello2";
@@ -273,7 +272,7 @@
}
cout << "}, ";
}
- cout << "}" << endl;
+ cout << "}" << '\n';
}
@@ -283,7 +282,7 @@
THRIFT_UNUSED_VARIABLE (arg4);
THRIFT_UNUSED_VARIABLE (arg5);
- cout << "[C -> C++] testMulti()" << endl;
+ cout << "[C -> C++] testMulti()" << '\n';
hello.string_thing = "Hello2";
hello.byte_thing = arg0;
@@ -294,7 +293,7 @@
void testException(const std::string &arg)
throw(Xception, apache::thrift::TException) override
{
- cout << "[C -> C++] testException(" << arg << ")" << endl;
+ cout << "[C -> C++] testException(" << arg << ")" << '\n';
if (arg.compare("Xception") == 0) {
Xception e;
e.errorCode = 1001;
@@ -312,7 +311,7 @@
void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) override {
- cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << endl;
+ cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << '\n';
if (arg0.compare("Xception") == 0) {
Xception e;
@@ -331,9 +330,9 @@
}
void testOneway(int sleepFor) override {
- cout << "testOneway(" << sleepFor << "): Sleeping..." << endl;
+ cout << "testOneway(" << sleepFor << "): Sleeping..." << '\n';
sleep(sleepFor);
- cout << "testOneway(" << sleepFor << "): done sleeping!" << endl;
+ cout << "testOneway(" << sleepFor << "): done sleeping!" << '\n';
}
};
diff --git a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
index 7656596..43d4034 100644
--- a/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
+++ b/lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
@@ -147,8 +147,7 @@
self->finish(req);
} catch (std::exception& e) {
// don't propagate a C++ exception in C code (e.g. libevent)
- std::cerr << "TEvhttpClientChannel::response exception thrown (ignored): " << e.what()
- << std::endl;
+ std::cerr << "TEvhttpClientChannel::response exception thrown (ignored): " << e.what() << '\n';
}
}
}
diff --git a/lib/cpp/src/thrift/async/TEvhttpServer.cpp b/lib/cpp/src/thrift/async/TEvhttpServer.cpp
index 7d2cf21..bea9001 100644
--- a/lib/cpp/src/thrift/async/TEvhttpServer.cpp
+++ b/lib/cpp/src/thrift/async/TEvhttpServer.cpp
@@ -127,13 +127,13 @@
int rv = evhttp_add_header(ctx->req->output_headers, "Content-Type", "application/x-thrift");
if (rv != 0) {
// TODO: Log an error.
- std::cerr << "evhttp_add_header failed " << __FILE__ << ":" << __LINE__ << std::endl;
+ std::cerr << "evhttp_add_header failed " << __FILE__ << ":" << __LINE__ << '\n';
}
struct evbuffer* buf = evbuffer_new();
if (buf == nullptr) {
// TODO: Log an error.
- std::cerr << "evbuffer_new failed " << __FILE__ << ":" << __LINE__ << std::endl;
+ std::cerr << "evbuffer_new failed " << __FILE__ << ":" << __LINE__ << '\n';
} else {
uint8_t* obuf;
uint32_t sz;
@@ -141,8 +141,7 @@
int ret = evbuffer_add(buf, obuf, sz);
if (ret != 0) {
// TODO: Log an error.
- std::cerr << "evhttp_add failed with " << ret << " " << __FILE__ << ":" << __LINE__
- << std::endl;
+ std::cerr << "evhttp_add failed with " << ret << " " << __FILE__ << ":" << __LINE__ << '\n';
}
}
diff --git a/lib/cpp/src/thrift/transport/TFileTransport.cpp b/lib/cpp/src/thrift/transport/TFileTransport.cpp
index dd7d229..3f4d812 100644
--- a/lib/cpp/src/thrift/transport/TFileTransport.cpp
+++ b/lib/cpp/src/thrift/transport/TFileTransport.cpp
@@ -55,8 +55,6 @@
using std::shared_ptr;
using std::cerr;
-using std::cout;
-using std::endl;
using std::string;
using namespace apache::thrift::protocol;
using namespace apache::thrift::concurrency;
@@ -1032,7 +1030,7 @@
break;
}
} catch (TException& te) {
- cerr << te.what() << endl;
+ cerr << te.what() << '\n';
break;
}
}
@@ -1060,7 +1058,7 @@
} catch (TEOFException&) {
break;
} catch (TException& te) {
- cerr << te.what() << endl;
+ cerr << te.what() << '\n';
break;
}
}
diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp
index 97a5317..ba8c345 100644
--- a/lib/cpp/test/Benchmark.cpp
+++ b/lib/cpp/test/Benchmark.cpp
@@ -53,7 +53,6 @@
using namespace apache::thrift::transport;
using namespace apache::thrift::protocol;
using std::cout;
- using std::endl;
OneOfEach ooe;
ooe.im_true = true;
@@ -84,7 +83,7 @@
ooe.write(&prot);
}
elapsed = timer.frame();
- cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
buf->getBuffer(&data, &datasize);
@@ -100,7 +99,7 @@
ooe2.read(&prot);
}
elapsed = timer.frame();
- cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -113,7 +112,7 @@
ooe.write(&prot);
}
elapsed = timer.frame();
- cout << "Write little endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << "Write little endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -127,7 +126,7 @@
ooe2.read(&prot);
}
elapsed = timer.frame();
- cout << " Read little endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << " Read little endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -140,7 +139,7 @@
ooe.write(&prot);
}
elapsed = timer.frame();
- cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << "Write big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -154,7 +153,7 @@
ooe2.read(&prot);
}
elapsed = timer.frame();
- cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << " Read big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
@@ -177,7 +176,7 @@
listDoublePerf.write(&prot);
elapsed = timer.frame();
- cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
buf->getBuffer(&data, &datasize);
@@ -191,7 +190,7 @@
listDoublePerf2.read(&prot);
elapsed = timer.frame();
- cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -202,7 +201,7 @@
listDoublePerf.write(&prot);
elapsed = timer.frame();
- cout << "Double write little endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << "Double write little endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -214,7 +213,7 @@
listDoublePerf2.read(&prot);
elapsed = timer.frame();
- cout << " Double read little endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << " Double read little endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -225,7 +224,7 @@
listDoublePerf.write(&prot);
elapsed = timer.frame();
- cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << "Double write big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
{
@@ -237,7 +236,7 @@
listDoublePerf2.read(&prot);
elapsed = timer.frame();
- cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << endl;
+ cout << " Double read big endian: " << num / (1000 * elapsed) << " kHz" << '\n';
}
diff --git a/lib/cpp/test/OneWayHTTPTest.cpp b/lib/cpp/test/OneWayHTTPTest.cpp
index 7823482..8789c2c 100644
--- a/lib/cpp/test/OneWayHTTPTest.cpp
+++ b/lib/cpp/test/OneWayHTTPTest.cpp
@@ -55,9 +55,6 @@
using apache::thrift::transport::TSocket;
using apache::thrift::transport::TTransportException;
using std::shared_ptr;
-using std::cout;
-using std::cerr;
-using std::endl;
using std::string;
namespace utf = boost::unit_test;
@@ -70,12 +67,12 @@
void roundTripRPC() override {
#ifdef ENABLE_STDERR_LOGGING
- cerr << "roundTripRPC()" << endl;
+ cerr << "roundTripRPC()" << '\n';
#endif
}
void oneWayRPC() override {
#ifdef ENABLE_STDERR_LOGGING
- cerr << "oneWayRPC()" << std::endl ;
+ cerr << "oneWayRPC()" << '\n';
#endif
}
};
@@ -201,7 +198,7 @@
int port = ss->getPort() ;
#ifdef ENABLE_STDERR_LOGGING
- cerr << "port " << port << endl ;
+ cerr << "port " << port << '\n';
#endif
{
diff --git a/lib/cpp/test/TMemoryBufferTest.cpp b/lib/cpp/test/TMemoryBufferTest.cpp
index 2f1aea6..53e5d15 100644
--- a/lib/cpp/test/TMemoryBufferTest.cpp
+++ b/lib/cpp/test/TMemoryBufferTest.cpp
@@ -36,8 +36,6 @@
using apache::thrift::transport::TMemoryBuffer;
using apache::thrift::transport::TTransportException;
using std::shared_ptr;
-using std::cout;
-using std::endl;
using std::string;
BOOST_AUTO_TEST_CASE(test_read_write_grow) {
diff --git a/lib/cpp/test/TServerSocketTest.cpp b/lib/cpp/test/TServerSocketTest.cpp
index 929defa..0860242 100644
--- a/lib/cpp/test/TServerSocketTest.cpp
+++ b/lib/cpp/test/TServerSocketTest.cpp
@@ -43,7 +43,7 @@
accepted->close();
sock1.close();
- std::cout << "An error message from getaddrinfo on the console is expected:" << std::endl;
+ std::cout << "An error message from getaddrinfo on the console is expected:" << '\n';
TServerSocket sock2("257.258.259.260", 0);
BOOST_CHECK_THROW(sock2.listen(), TTransportException);
sock2.close();
diff --git a/lib/cpp/test/ThrifttReadCheckTests.cpp b/lib/cpp/test/ThrifttReadCheckTests.cpp
index eb4ca01..481185e 100644
--- a/lib/cpp/test/ThrifttReadCheckTests.cpp
+++ b/lib/cpp/test/ThrifttReadCheckTests.cpp
@@ -55,8 +55,6 @@
using apache::thrift::transport::TBufferedTransport;
using apache::thrift::transport::TFramedTransport;
using std::shared_ptr;
-using std::cout;
-using std::endl;
using std::string;
using std::memset;
using namespace apache::thrift;
diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp
index 45054a9..67de789 100644
--- a/lib/cpp/test/concurrency/Tests.cpp
+++ b/lib/cpp/test/concurrency/Tests.cpp
@@ -51,52 +51,52 @@
ThreadFactoryTests threadFactoryTests;
- std::cout << "ThreadFactory tests..." << std::endl;
+ std::cout << "ThreadFactory tests..." << '\n';
const int reapLoops = 2 * WEIGHT;
const int reapCount = 100 * WEIGHT;
const size_t floodLoops = 3;
const size_t floodCount = 500 * WEIGHT;
- std::cout << "\t\tThreadFactory reap N threads test: N = " << reapLoops << "x" << reapCount << std::endl;
+ std::cout << "\t\tThreadFactory reap N threads test: N = " << reapLoops << "x" << reapCount << '\n';
if (!threadFactoryTests.reapNThreads(reapLoops, reapCount)) {
- std::cerr << "\t\ttThreadFactory reap N threads FAILED" << std::endl;
+ std::cerr << "\t\ttThreadFactory reap N threads FAILED" << '\n';
return 1;
}
- std::cout << "\t\tThreadFactory flood N threads test: N = " << floodLoops << "x" << floodCount << std::endl;
+ std::cout << "\t\tThreadFactory flood N threads test: N = " << floodLoops << "x" << floodCount << '\n';
if (!threadFactoryTests.floodNTest(floodLoops, floodCount)) {
- std::cerr << "\t\ttThreadFactory flood N threads FAILED" << std::endl;
+ std::cerr << "\t\ttThreadFactory flood N threads FAILED" << '\n';
return 1;
}
- std::cout << "\t\tThreadFactory synchronous start test" << std::endl;
+ std::cout << "\t\tThreadFactory synchronous start test" << '\n';
if (!threadFactoryTests.synchStartTest()) {
- std::cerr << "\t\ttThreadFactory synchronous start FAILED" << std::endl;
+ std::cerr << "\t\ttThreadFactory synchronous start FAILED" << '\n';
return 1;
}
- std::cout << "\t\tThreadFactory monitor timeout test" << std::endl;
+ std::cout << "\t\tThreadFactory monitor timeout test" << '\n';
if (!threadFactoryTests.monitorTimeoutTest()) {
- std::cerr << "\t\ttThreadFactory monitor timeout FAILED" << std::endl;
+ std::cerr << "\t\ttThreadFactory monitor timeout FAILED" << '\n';
return 1;
}
}
if (runAll || args[0].compare("util") == 0) {
- std::cout << "Util tests..." << std::endl;
+ std::cout << "Util tests..." << '\n';
- std::cout << "\t\tUtil minimum time" << std::endl;
+ std::cout << "\t\tUtil minimum time" << '\n';
int64_t time00 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
int64_t time01 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
- std::cout << "\t\t\tMinimum time: " << time01 - time00 << "ms" << std::endl;
+ std::cout << "\t\t\tMinimum time: " << time01 - time00 << "ms" << '\n';
time00 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
time01 = time00;
@@ -107,54 +107,54 @@
time01 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
}
- std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << std::endl;
+ std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << '\n';
}
if (runAll || args[0].compare("timer-manager") == 0) {
- std::cout << "TimerManager tests..." << std::endl;
+ std::cout << "TimerManager tests..." << '\n';
- std::cout << "\t\tTimerManager test00" << std::endl;
+ std::cout << "\t\tTimerManager test00" << '\n';
TimerManagerTests timerManagerTests;
if (!timerManagerTests.test00()) {
- std::cerr << "\t\tTimerManager tests FAILED" << std::endl;
+ std::cerr << "\t\tTimerManager tests FAILED" << '\n';
return 1;
}
- std::cout << "\t\tTimerManager test01" << std::endl;
+ std::cout << "\t\tTimerManager test01" << '\n';
if (!timerManagerTests.test01()) {
- std::cerr << "\t\tTimerManager tests FAILED" << std::endl;
+ std::cerr << "\t\tTimerManager tests FAILED" << '\n';
return 1;
}
- std::cout << "\t\tTimerManager test02" << std::endl;
+ std::cout << "\t\tTimerManager test02" << '\n';
if (!timerManagerTests.test02()) {
- std::cerr << "\t\tTimerManager tests FAILED" << std::endl;
+ std::cerr << "\t\tTimerManager tests FAILED" << '\n';
return 1;
}
- std::cout << "\t\tTimerManager test03" << std::endl;
+ std::cout << "\t\tTimerManager test03" << '\n';
if (!timerManagerTests.test03()) {
- std::cerr << "\t\tTimerManager tests FAILED" << std::endl;
+ std::cerr << "\t\tTimerManager tests FAILED" << '\n';
return 1;
}
- std::cout << "\t\tTimerManager test04" << std::endl;
+ std::cout << "\t\tTimerManager test04" << '\n';
if (!timerManagerTests.test04()) {
- std::cerr << "\t\tTimerManager tests FAILED" << std::endl;
+ std::cerr << "\t\tTimerManager tests FAILED" << '\n';
return 1;
}
}
if (runAll || args[0].compare("thread-manager") == 0) {
- std::cout << "ThreadManager tests..." << std::endl;
+ std::cout << "ThreadManager tests..." << '\n';
{
size_t workerCount = 10 * WEIGHT;
@@ -163,26 +163,26 @@
ThreadManagerTests threadManagerTests;
- std::cout << "\t\tThreadManager api test:" << std::endl;
+ std::cout << "\t\tThreadManager api test:" << '\n';
if (!threadManagerTests.apiTest()) {
- std::cerr << "\t\tThreadManager apiTest FAILED" << std::endl;
+ std::cerr << "\t\tThreadManager apiTest FAILED" << '\n';
return 1;
}
std::cout << "\t\tThreadManager load test: worker count: " << workerCount
- << " task count: " << taskCount << " delay: " << delay << std::endl;
+ << " task count: " << taskCount << " delay: " << delay << '\n';
if (!threadManagerTests.loadTest(taskCount, delay, workerCount)) {
- std::cerr << "\t\tThreadManager loadTest FAILED" << std::endl;
+ std::cerr << "\t\tThreadManager loadTest FAILED" << '\n';
return 1;
}
std::cout << "\t\tThreadManager block test: worker count: " << workerCount
- << " delay: " << delay << std::endl;
+ << " delay: " << delay << '\n';
if (!threadManagerTests.blockTest(delay, workerCount)) {
- std::cerr << "\t\tThreadManager blockTest FAILED" << std::endl;
+ std::cerr << "\t\tThreadManager blockTest FAILED" << '\n';
return 1;
}
}
@@ -190,7 +190,7 @@
if (runAll || args[0].compare("thread-manager-benchmark") == 0) {
- std::cout << "ThreadManager benchmark tests..." << std::endl;
+ std::cout << "ThreadManager benchmark tests..." << '\n';
{
@@ -207,19 +207,19 @@
size_t taskCount = workerCount * tasksPerWorker;
std::cout << "\t\tThreadManager load test: worker count: " << workerCount
- << " task count: " << taskCount << " delay: " << delay << std::endl;
+ << " task count: " << taskCount << " delay: " << delay << '\n';
ThreadManagerTests threadManagerTests;
if (!threadManagerTests.loadTest(taskCount, delay, workerCount))
{
- std::cerr << "\t\tThreadManager loadTest FAILED" << std::endl;
+ std::cerr << "\t\tThreadManager loadTest FAILED" << '\n';
return 1;
}
}
}
}
- std::cout << "ALL TESTS PASSED" << std::endl;
+ std::cout << "ALL TESTS PASSED" << '\n';
return 0;
}
diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h
index 23e46e3..a2d55fe 100644
--- a/lib/cpp/test/concurrency/ThreadFactoryTests.h
+++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h
@@ -53,7 +53,7 @@
void run() override {
Synchronized s(_monitor);
-
+
if (--_count == 0) {
_monitor.notify();
}
@@ -82,7 +82,7 @@
threadFactory.newThread(shared_ptr<Runnable>(new ReapNTask(*monitor, activeCount))));
} catch (SystemResourceException& e) {
std::cout << "\t\t\tfailed to create " << lix* count + tix << " thread " << e.what()
- << std::endl;
+ << '\n';
throw;
}
}
@@ -96,7 +96,7 @@
(*thread)->start();
} catch (SystemResourceException& e) {
std::cout << "\t\t\tfailed to start " << lix* count + tix << " thread " << e.what()
- << std::endl;
+ << '\n';
throw;
}
}
@@ -107,11 +107,11 @@
monitor->wait(1000);
}
}
-
- std::cout << "\t\t\treaped " << lix* count << " threads" << std::endl;
+
+ std::cout << "\t\t\treaped " << lix* count << " threads" << '\n';
}
- std::cout << "\t\t\tSuccess!" << std::endl;
+ std::cout << "\t\t\tSuccess!" << '\n';
return true;
}
@@ -202,7 +202,7 @@
bool success = true;
- std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "!" << std::endl;
+ std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "!" << '\n';
return true;
}
@@ -239,7 +239,7 @@
std::cout << "\t\t\t" << (success ? "Success" : "Failure")
<< ": minimum required time to elapse " << count * timeout
<< "ms; actual elapsed time " << endTime - startTime << "ms"
- << std::endl;
+ << '\n';
return success;
}
@@ -250,14 +250,14 @@
~FloodTask() override {
if (_id % 10000 == 0) {
Synchronized sync(_mon);
- std::cout << "\t\tthread " << _id << " done" << std::endl;
+ std::cout << "\t\tthread " << _id << " done" << '\n';
}
}
void run() override {
if (_id % 10000 == 0) {
Synchronized sync(_mon);
- std::cout << "\t\tthread " << _id << " started" << std::endl;
+ std::cout << "\t\tthread " << _id << " started" << '\n';
}
}
const size_t _id;
@@ -270,7 +270,7 @@
bool success = false;
Monitor mon;
-
+
for (size_t lix = 0; lix < loop; lix++) {
ThreadFactory threadFactory = ThreadFactory();
@@ -287,14 +287,14 @@
} catch (TException& e) {
std::cout << "\t\t\tfailed to start " << lix* count + tix << " thread " << e.what()
- << std::endl;
+ << '\n';
return success;
}
}
Synchronized sync(mon);
- std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl;
+ std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << '\n';
success = true;
}
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
index fee7c7c..b33fc27 100644
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -76,7 +76,7 @@
{
Synchronized s(_monitor);
- // std::cout << "Thread " << _count << " completed " << std::endl;
+ // std::cout << "Thread " << _count << " completed " << '\n';
_count--;
if (_count % 10000 == 0) {
@@ -131,13 +131,13 @@
threadManager->add(*ix);
}
- std::cout << "\t\t\t\tloaded " << count << " tasks to execute" << std::endl;
+ std::cout << "\t\t\t\tloaded " << count << " tasks to execute" << '\n';
{
Synchronized s(monitor);
while (activeCount > 0) {
- std::cout << "\t\t\t\tactiveCount = " << activeCount << std::endl;
+ std::cout << "\t\t\t\tactiveCount = " << activeCount << '\n';
monitor.wait();
}
}
@@ -184,13 +184,13 @@
std::cout << "\t\t\tfirst start: " << firstTime << " Last end: " << lastTime
<< " min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime
- << "ms" << std::endl;
+ << "ms" << '\n';
bool success = (time01 - time00) >= ((int64_t)count * timeout) / (int64_t)workerCount;
std::cout << "\t\t\t" << (success ? "Success" : "Failure")
<< "! expected time: " << ((int64_t)count * timeout) / (int64_t)workerCount << "ms elapsed time: " << time01 - time00
- << "ms" << std::endl;
+ << "ms" << '\n';
return success;
}
@@ -307,7 +307,7 @@
}
std::cout << "\t\t\t"
- << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
+ << "Pending tasks " << threadManager->pendingTaskCount() << '\n';
{
Synchronized s(blockMonitor);
@@ -323,18 +323,18 @@
}
std::cout << "\t\t\t"
- << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
+ << "Pending tasks " << threadManager->pendingTaskCount() << '\n';
try {
threadManager->add(extraTask, 1);
} catch (TimedOutException&) {
std::cout << "\t\t\t"
- << "add timed out unexpectedly" << std::endl;
+ << "add timed out unexpectedly" << '\n';
throw TException("Unexpected timeout adding task");
} catch (TooManyPendingTasksException&) {
std::cout << "\t\t\t"
- << "add encountered too many pending exepctions" << std::endl;
+ << "add encountered too many pending exepctions" << '\n';
throw TException("Unexpected timeout adding task");
}
@@ -375,10 +375,10 @@
}
} catch (TException& e) {
- std::cout << "ERROR: " << e.what() << std::endl;
+ std::cout << "ERROR: " << e.what() << '\n';
}
- std::cout << "\t\t\t" << (success ? "Success" : "Failure") << std::endl;
+ std::cout << "\t\t\t" << (success ? "Success" : "Failure") << '\n';
return success;
}
@@ -390,7 +390,7 @@
sleep_(100);
int64_t b = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
if (b - a < 50 || b - a > 150) {
- std::cerr << "\t\t\texpected 100ms gap, found " << (b-a) << "ms gap instead." << std::endl;
+ std::cerr << "\t\t\texpected 100ms gap, found " << (b-a) << "ms gap instead." << '\n';
return false;
}
@@ -403,18 +403,18 @@
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(1);
threadManager->threadFactory(threadFactory);
- std::cout << "\t\t\t\tstarting.. " << std::endl;
+ std::cout << "\t\t\t\tstarting.. " << '\n';
threadManager->start();
threadManager->setExpireCallback(expiredNotifier); // std::bind(&ThreadManagerTests::expiredNotifier, this));
-#define EXPECT(FUNC, COUNT) { size_t c = FUNC; if (c != COUNT) { std::cerr << "expected " #FUNC" to be " #COUNT ", but was " << c << std::endl; return false; } }
+#define EXPECT(FUNC, COUNT) { size_t c = FUNC; if (c != COUNT) { std::cerr << "expected " #FUNC" to be " #COUNT ", but was " << c << '\n'; return false; } }
EXPECT(threadManager->workerCount(), 1);
EXPECT(threadManager->idleWorkerCount(), 1);
EXPECT(threadManager->pendingTaskCount(), 0);
- std::cout << "\t\t\t\tadd 2nd worker.. " << std::endl;
+ std::cout << "\t\t\t\tadd 2nd worker.. " << '\n';
threadManager->addWorker();
@@ -422,7 +422,7 @@
EXPECT(threadManager->idleWorkerCount(), 2);
EXPECT(threadManager->pendingTaskCount(), 0);
- std::cout << "\t\t\t\tremove 2nd worker.. " << std::endl;
+ std::cout << "\t\t\t\tremove 2nd worker.. " << '\n';
threadManager->removeWorker();
@@ -430,7 +430,7 @@
EXPECT(threadManager->idleWorkerCount(), 1);
EXPECT(threadManager->pendingTaskCount(), 0);
- std::cout << "\t\t\t\tremove 1st worker.. " << std::endl;
+ std::cout << "\t\t\t\tremove 1st worker.. " << '\n';
threadManager->removeWorker();
@@ -438,7 +438,7 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 0);
- std::cout << "\t\t\t\tadd blocking task.. " << std::endl;
+ std::cout << "\t\t\t\tadd blocking task.. " << '\n';
// We're going to throw a blocking task into the mix
Monitor entryMonitor; // signaled when task is running
@@ -454,7 +454,7 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 1);
- std::cout << "\t\t\t\tadd other task.. " << std::endl;
+ std::cout << "\t\t\t\tadd other task.. " << '\n';
shared_ptr<ThreadManagerTests::Task> otherTask(
new ThreadManagerTests::Task(doneMonitor, activeCount, 0));
@@ -465,7 +465,7 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 2);
- std::cout << "\t\t\t\tremove blocking task specifically.. " << std::endl;
+ std::cout << "\t\t\t\tremove blocking task specifically.. " << '\n';
threadManager->remove(blockingTask);
@@ -473,11 +473,11 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 1);
- std::cout << "\t\t\t\tremove next pending task.." << std::endl;
+ std::cout << "\t\t\t\tremove next pending task.." << '\n';
shared_ptr<Runnable> nextTask = threadManager->removeNextPending();
if (nextTask != otherTask) {
- std::cerr << "\t\t\t\t\texpected removeNextPending to return otherTask" << std::endl;
+ std::cerr << "\t\t\t\t\texpected removeNextPending to return otherTask" << '\n';
return false;
}
@@ -485,15 +485,15 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 0);
- std::cout << "\t\t\t\tremove next pending task (none left).." << std::endl;
+ std::cout << "\t\t\t\tremove next pending task (none left).." << '\n';
nextTask = threadManager->removeNextPending();
if (nextTask) {
- std::cerr << "\t\t\t\t\texpected removeNextPending to return an empty Runnable" << std::endl;
+ std::cerr << "\t\t\t\t\texpected removeNextPending to return an empty Runnable" << '\n';
return false;
}
- std::cout << "\t\t\t\tadd 2 expired tasks and 1 not.." << std::endl;
+ std::cout << "\t\t\t\tadd 2 expired tasks and 1 not.." << '\n';
shared_ptr<ThreadManagerTests::Task> expiredTask(
new ThreadManagerTests::Task(doneMonitor, activeCount, 0));
@@ -509,28 +509,28 @@
EXPECT(threadManager->pendingTaskCount(), 3);
EXPECT(threadManager->expiredTaskCount(), 0);
- std::cout << "\t\t\t\tremove expired tasks.." << std::endl;
+ std::cout << "\t\t\t\tremove expired tasks.." << '\n';
if (!m_expired.empty()) {
- std::cerr << "\t\t\t\t\texpected m_expired to be empty" << std::endl;
+ std::cerr << "\t\t\t\t\texpected m_expired to be empty" << '\n';
return false;
}
threadManager->removeExpiredTasks();
if (m_expired.size() != 2) {
- std::cerr << "\t\t\t\t\texpected m_expired to be set" << std::endl;
+ std::cerr << "\t\t\t\t\texpected m_expired to be set" << '\n';
return false;
}
if (m_expired.front() != expiredTask) {
- std::cerr << "\t\t\t\t\texpected m_expired[0] to be the expired task" << std::endl;
+ std::cerr << "\t\t\t\t\texpected m_expired[0] to be the expired task" << '\n';
return false;
}
m_expired.pop_front();
if (m_expired.front() != expiredTask) {
- std::cerr << "\t\t\t\t\texpected m_expired[1] to be the expired task" << std::endl;
+ std::cerr << "\t\t\t\t\texpected m_expired[1] to be the expired task" << '\n';
return false;
}
@@ -543,23 +543,23 @@
EXPECT(threadManager->pendingTaskCount(), 0);
EXPECT(threadManager->expiredTaskCount(), 2);
- std::cout << "\t\t\t\tadd expired task (again).." << std::endl;
+ std::cout << "\t\t\t\tadd expired task (again).." << '\n';
threadManager->add(expiredTask, 0, 1); // expires in 1ms
sleep_(50); // make sure enough time elapses for it to expire - the shortest expiration time is 1ms
- std::cout << "\t\t\t\tadd worker to consume expired task.." << std::endl;
+ std::cout << "\t\t\t\tadd worker to consume expired task.." << '\n';
threadManager->addWorker();
sleep_(100); // make sure it has time to spin up and expire the task
if (m_expired.empty()) {
- std::cerr << "\t\t\t\t\texpected m_expired to be set" << std::endl;
+ std::cerr << "\t\t\t\t\texpected m_expired to be set" << '\n';
return false;
}
if (m_expired.front() != expiredTask) {
- std::cerr << "\t\t\t\t\texpected m_expired to be the expired task" << std::endl;
+ std::cerr << "\t\t\t\t\texpected m_expired to be the expired task" << '\n';
return false;
}
@@ -570,16 +570,16 @@
EXPECT(threadManager->pendingTaskCount(), 0);
EXPECT(threadManager->expiredTaskCount(), 3);
- std::cout << "\t\t\t\ttry to remove too many workers" << std::endl;
+ std::cout << "\t\t\t\ttry to remove too many workers" << '\n';
try {
threadManager->removeWorker(2);
- std::cerr << "\t\t\t\t\texpected InvalidArgumentException" << std::endl;
+ std::cerr << "\t\t\t\t\texpected InvalidArgumentException" << '\n';
return false;
} catch (const InvalidArgumentException&) {
/* expected */
}
- std::cout << "\t\t\t\tremove worker.. " << std::endl;
+ std::cout << "\t\t\t\tremove worker.. " << '\n';
threadManager->removeWorker();
@@ -588,7 +588,7 @@
EXPECT(threadManager->pendingTaskCount(), 0);
EXPECT(threadManager->expiredTaskCount(), 3);
- std::cout << "\t\t\t\tadd blocking task.. " << std::endl;
+ std::cout << "\t\t\t\tadd blocking task.. " << '\n';
threadManager->add(blockingTask);
@@ -596,7 +596,7 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 1);
- std::cout << "\t\t\t\tadd worker.. " << std::endl;
+ std::cout << "\t\t\t\tadd worker.. " << '\n';
threadManager->addWorker();
{
@@ -610,7 +610,7 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 0);
- std::cout << "\t\t\t\tunblock task and remove worker.. " << std::endl;
+ std::cout << "\t\t\t\tunblock task and remove worker.. " << '\n';
{
Synchronized s(blockMonitor);
@@ -623,7 +623,7 @@
EXPECT(threadManager->idleWorkerCount(), 0);
EXPECT(threadManager->pendingTaskCount(), 0);
- std::cout << "\t\t\t\tcleanup.. " << std::endl;
+ std::cout << "\t\t\t\tcleanup.. " << '\n';
blockingTask.reset();
threadManager.reset();
diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h
index 2d1a262..9a53232 100644
--- a/lib/cpp/test/concurrency/TimerManagerTests.h
+++ b/lib/cpp/test/concurrency/TimerManagerTests.h
@@ -46,7 +46,7 @@
_success(false),
_done(false) {}
- ~Task() override { std::cerr << this << std::endl; }
+ ~Task() override { std::cerr << this << '\n'; }
void run() override {
@@ -84,7 +84,7 @@
timerManager.threadFactory(shared_ptr<ThreadFactory>(new ThreadFactory()));
timerManager.start();
if (timerManager.state() != TimerManager::STARTED) {
- std::cerr << "timerManager is not in the STARTED state, but should be" << std::endl;
+ std::cerr << "timerManager is not in the STARTED state, but should be" << '\n';
return false;
}
@@ -104,15 +104,15 @@
}
if (!task->_done) {
- std::cerr << "task is not done, but it should have executed" << std::endl;
+ std::cerr << "task is not done, but it should have executed" << '\n';
return false;
}
- std::cout << "\t\t\t" << (task->_success ? "Success" : "Failure") << "!" << std::endl;
+ std::cout << "\t\t\t" << (task->_success ? "Success" : "Failure") << "!" << '\n';
}
if (orphanTask->_done) {
- std::cerr << "orphan task is done, but it should not have executed" << std::endl;
+ std::cerr << "orphan task is done, but it should not have executed" << '\n';
return false;
}
diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp
index 79a708e..a424620 100644
--- a/test/cpp/src/StressTest.cpp
+++ b/test/cpp/src/StressTest.cpp
@@ -155,7 +155,7 @@
loopEchoString();
break;
default:
- cerr << "Unexpected loop type" << _loopType << endl;
+ cerr << "Unexpected loop type" << _loopType << '\n';
break;
}
@@ -280,23 +280,23 @@
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
"[--clients=<client-count>] [--loop=<loop-count>] "
- "[--client-type=<client-type>]" << endl
+ "[--client-type=<client-type>]" << '\n'
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
- "server only. Default is " << clientCount << endl
- << "\thelp Prints this help text." << endl
- << "\tcall Service method to call. Default is " << callName << endl
- << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << endl
+ "server only. Default is " << clientCount << '\n'
+ << "\thelp Prints this help text." << '\n'
+ << "\tcall Service method to call. Default is " << callName << '\n'
+ << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << '\n'
<< "\tport The port the server and clients should bind to "
- "for thrift network connections. Default is " << port << endl
- << "\tserver Run the Thrift server in this process. Default is " << runServer << endl
- << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << endl
- << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << endl
- << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << endl
- << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl
+ "for thrift network connections. Default is " << port << '\n'
+ << "\tserver Run the Thrift server in this process. Default is " << runServer << '\n'
+ << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << '\n'
+ << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << '\n'
+ << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << '\n'
+ << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << '\n'
<< "\tworkers Number of thread pools workers. Only valid "
- "for thread-pool server type. Default is " << workerCount << endl
- << "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << endl
- << endl;
+ "for thread-pool server type. Default is " << workerCount << '\n'
+ << "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << '\n'
+ << '\n';
map<string, string> args;
@@ -386,7 +386,7 @@
}
} catch (std::exception& e) {
- cerr << e.what() << endl;
+ cerr << e.what() << '\n';
cerr << usage.str();
}
@@ -468,7 +468,7 @@
server->setServerEventHandler(observer);
std::shared_ptr<Thread> serverThread = threadFactory->newThread(server);
- cerr << "Starting the server on port " << port << endl;
+ cerr << "Starting the server on port " << port << '\n';
serverThread->start();
observer->waitForService();
@@ -538,7 +538,7 @@
Synchronized s(monitor);
threadCount = clientCount;
- cerr << "Launch " << clientCount << " " << clientType << " client threads" << endl;
+ cerr << "Launch " << clientCount << " " << clientType << " client threads" << '\n';
time00 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
@@ -591,14 +591,14 @@
averageTime /= clientCount;
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
- << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+ << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << '\n';
count_map count = serviceHandler->getCount();
count_map::iterator iter;
for (iter = count.begin(); iter != count.end(); ++iter) {
printf("%s => %d\n", iter->first, iter->second);
}
- cerr << "done." << endl;
+ cerr << "done." << '\n';
}
return 0;
diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp
index e94ecb2..d9d9ae6 100644
--- a/test/cpp/src/StressTestNonBlocking.cpp
+++ b/test/cpp/src/StressTestNonBlocking.cpp
@@ -152,7 +152,7 @@
loopEchoString();
break;
default:
- cerr << "Unexpected loop type" << _loopType << endl;
+ cerr << "Unexpected loop type" << _loopType << '\n';
break;
}
@@ -253,24 +253,20 @@
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
- "[--clients=<client-count>] [--loop=<loop-count>]" << endl
+ "[--clients=<client-count>] [--loop=<loop-count>]" << '\n'
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
- "server only. Default is " << clientCount << endl
- << "\thelp Prints this help text." << endl
- << "\tcall Service method to call. Default is " << callName << endl
- << "\tloop The number of remote thrift calls each client makes. Default is "
- << loopCount << endl << "\tport The port the server and clients should bind to "
- "for thrift network connections. Default is " << port << endl
- << "\tserver Run the Thrift server in this process. Default is " << runServer
- << endl << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is "
- << serverType << endl
- << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is "
- << protocolType << endl
- << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests
- << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
- << replayRequests << endl << "\tworkers Number of thread pools workers. Only valid "
- "for thread-pool server type. Default is " << workerCount
- << endl;
+ "server only. Default is " << clientCount << '\n'
+ << "\thelp Prints this help text." << '\n'
+ << "\tcall Service method to call. Default is " << callName << '\n'
+ << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << '\n'
+ << "\tport The port the server and clients should bind to for thrift network "
+ "connections. Default is " << port << '\n'
+ << "\tserver Run the Thrift server in this process. Default is " << runServer << '\n'
+ << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << '\n'
+ << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << '\n'
+ << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << '\n'
+ << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << '\n'
+ << "\tworkers Number of thread pools workers. Only valid for thread-pool server type. Default is " << workerCount << '\n';
map<string, string> args;
@@ -338,7 +334,7 @@
}
} catch (std::exception& e) {
- cerr << e.what() << endl;
+ cerr << e.what() << '\n';
cerr << usage.str();
}
@@ -416,7 +412,7 @@
new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager)));
}
- cerr << "Starting the server on port " << port << " and " << (port + 1) << endl;
+ cerr << "Starting the server on port " << port << " and " << (port + 1) << '\n';
serverThread->start();
serverThread2->start();
@@ -475,7 +471,7 @@
Synchronized s(monitor);
threadCount = clientCount;
- cerr << "Launch " << clientCount << " client threads" << endl;
+ cerr << "Launch " << clientCount << " client threads" << '\n';
time00 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
@@ -528,14 +524,14 @@
averageTime /= clientCount;
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
- << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+ << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << '\n';
count_map count = serviceHandler->getCount();
count_map::iterator iter;
for (iter = count.begin(); iter != count.end(); ++iter) {
printf("%s => %d\n", iter->first, iter->second);
}
- cerr << "done." << endl;
+ cerr << "done." << '\n';
}
return 0;
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index fd04ed8..c15281a 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -98,7 +98,7 @@
ss << "ERROR: send request with seqid " << m_last_seqid << " and got reply with seqid " << seqid;
throw std::logic_error(ss.str());
} /* else {
- std::cout << "verified seqid " << m_last_seqid << " round trip OK" << std::endl;
+ std::cout << "verified seqid " << m_last_seqid << " round trip OK" << '\n';
} */
return result;
}
@@ -127,9 +127,9 @@
std::ostringstream os;
os << "test" << testNr;
const bool ok = (s == os.str());
- cout << "testString: " << s << " " << ((ok) ? "ok" : "failed") << endl;
+ cout << "testString: " << s << " " << ((ok) ? "ok" : "failed") << '\n';
} catch (TException& exn) {
- cout << "Error: " << exn.what() << endl;
+ cout << "Error: " << exn.what() << '\n';
}
if (testNr == 9)
@@ -139,7 +139,7 @@
static void testVoid_clientReturn(event_base* base, ThriftTestCobClient* client) {
try {
client->recv_testVoid();
- cout << "testVoid" << endl;
+ cout << "testVoid" << '\n';
for (int testNr = 0; testNr < 10; ++testNr) {
std::ostringstream os;
@@ -151,16 +151,16 @@
os.str());
}
} catch (TException& exn) {
- cout << "Error: " << exn.what() << endl;
+ cout << "Error: " << exn.what() << '\n';
}
}
// Workaround for absense of C++11 "auto" keyword.
template <typename T>
bool print_eq(T expected, T actual) {
- cout << "(" << actual << ")" << endl;
+ cout << "(" << actual << ")" << '\n';
if (expected != actual) {
- cout << "*** FAILED ***" << endl << "Expected: " << expected << " but got: " << actual << endl;
+ cout << "*** FAILED ***" << '\n' << "Expected: " << expected << " but got: " << actual << '\n';
return false;
}
return true;
@@ -174,7 +174,7 @@
} catch (TTransportException&) { \
throw; \
} catch (exception & ex) { \
- cout << "*** FAILED ***" << endl << ex.what() << endl; \
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; \
return_code |= ERR_BASETYPES; \
}
@@ -186,7 +186,7 @@
} catch (TTransportException&) { \
throw; \
} catch (exception & ex) { \
- cout << "*** FAILED ***" << endl << ex.what() << endl; \
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n'; \
return_code |= ERR_BASETYPES; \
}
@@ -258,7 +258,7 @@
boost::program_options::notify(vm);
if (vm.count("help")) {
- cout << desc << endl;
+ cout << desc << '\n';
return ERR_UNKNOWN;
}
@@ -290,8 +290,8 @@
}
} catch (exception& e) {
- cerr << e.what() << endl;
- cout << desc << endl;
+ cerr << e.what() << '\n';
+ cout << desc << '\n';
return ERR_UNKNOWN;
}
@@ -319,9 +319,9 @@
std::shared_ptr<TProtocol> protocol2; // SecondService for multiplexed
if (ssl) {
- cout << "Client Certificate File: " << certPath << endl;
- cout << "Client Key File: " << keyPath << endl;
- cout << "CA File: " << caPath << endl;
+ cout << "Client Certificate File: " << certPath << '\n';
+ cout << "Client Key File: " << keyPath << '\n';
+ cout << "CA File: " << caPath << '\n';
factory = std::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
@@ -386,14 +386,14 @@
if (port != 0) {
cout << host << ":" << port;
}
- cout << endl;
+ cout << '\n';
if (transport_type.compare("evhttp") == 0) {
event_base* base = event_base_new();
- cout << "Libevent Version: " << event_get_version() << endl;
- cout << "Libevent Method: " << event_base_get_method(base) << endl;
+ cout << "Libevent Version: " << event_get_version() << '\n';
+ cout << "Libevent Method: " << event_base_get_method(base) << '\n';
#if LIBEVENT_VERSION_NUMBER >= 0x02000000
- cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl;
+ cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << '\n';
#endif
std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
@@ -421,7 +421,7 @@
try {
transport->open();
} catch (TTransportException& ex) {
- cout << "Connect failed: " << ex.what() << endl;
+ cout << "Connect failed: " << ex.what() << '\n';
return ERR_UNKNOWN;
}
@@ -438,12 +438,12 @@
try {
cout << "testVoid()" << flush;
testClient.testVoid();
- cout << " = void" << endl;
+ cout << " = void" << '\n';
} catch (TTransportException&) {
// Stop here if transport got broken
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_BASETYPES;
}
@@ -453,9 +453,9 @@
cout << "testString(\"Test\")" << flush;
string s;
testClient.testString(s, "Test");
- cout << " = " << s << endl;
+ cout << " = " << s << '\n';
if (s != "Test") {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_BASETYPES;
}
@@ -471,9 +471,9 @@
cout << "secondService.secondTestString(\"foo\") => " << flush;
std::string result;
ssc.secondtestString(result, "foo");
- cout << "{" << result << "}" << endl;
+ cout << "{" << result << "}" << '\n';
} catch (std::exception& e) {
- cout << " *** FAILED *** " << e.what() << endl;
+ cout << " *** FAILED *** " << e.what() << '\n';
return_code |= ERR_EXCEPTIONS;
}
}
@@ -514,16 +514,16 @@
#endif
cout << "testString(" << str << ") = " << flush;
testClient.testString(s, str);
- cout << s << endl;
+ cout << s << '\n';
if (s != str) {
cout.imbue(locale("en_US.UTF8"));
- cout << "*** FAILED ***" << endl << "Expected string: " << str << " but got: " << s << endl << "CLEAR";
+ cout << "*** FAILED ***" << '\n' << "Expected string: " << str << " but got: " << s << '\n' << "CLEAR";
return_code |= ERR_BASETYPES;
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_BASETYPES;
return return_code;
}
@@ -537,11 +537,11 @@
" char-to-test-json-parsing: ]] \"]] \\\" }}}{ [[[ ");
cout << "testString(" << str << ") = " << flush;
testClient.testString(s, str);
- cout << s << endl;
+ cout << s << '\n';
if (s != str) {
cout.imbue(locale("en_US.UTF8"));
- cout << "*** FAILED ***" << endl
- << "Expected string: " << str << " but got: " << s << endl
+ cout << "*** FAILED ***" << '\n'
+ << "Expected string: " << str << " but got: " << s << '\n'
<< "CLEAR";
;
return_code |= ERR_BASETYPES;
@@ -549,7 +549,7 @@
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_BASETYPES;
return return_code;
}
@@ -614,15 +614,15 @@
double expected = pow(static_cast<double>(10), 307);
cout << "testDouble(" << expected << ") = " << flush;
double actual = testClient.testDouble(expected);
- cout << "(" << actual << ")" << endl;
+ cout << "(" << actual << ")" << '\n';
if (expected - actual > pow(static_cast<double>(10), 292)) {
- cout << "*** FAILED ***" << endl
- << "Expected: " << expected << " but got: " << actual << endl;
+ cout << "*** FAILED ***" << '\n'
+ << "Expected: " << expected << " but got: " << actual << '\n';
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_BASETYPES;
}
@@ -630,15 +630,15 @@
double expected = pow(static_cast<double>(10), -292);
cout << "testDouble(" << expected << ") = " << flush;
double actual = testClient.testDouble(expected);
- cout << "(" << actual << ")" << endl;
+ cout << "(" << actual << ")" << '\n';
if (expected - actual > pow(static_cast<double>(10), -307)) {
- cout << "*** FAILED ***" << endl
- << "Expected: " << expected << " but got: " << actual << endl;
+ cout << "*** FAILED ***" << '\n'
+ << "Expected: " << expected << " but got: " << actual << '\n';
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_BASETYPES;
}
@@ -677,7 +677,7 @@
in.i32_thing,
in.i64_thing);
if (in != out) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
@@ -700,7 +700,7 @@
in.i64_thing,
in2.i32_thing);
if (in2 != out2) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
@@ -735,9 +735,9 @@
}
cout << m_iter->first << " => " << m_iter->second;
}
- cout << "}" << endl;
+ cout << "}" << '\n';
if (mapin != mapout) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_CONTAINERS;
}
@@ -760,15 +760,15 @@
first = false;
cout << it->first << " => " << it->second;
}
- cout << "}" << endl;
+ cout << "}" << '\n';
if (smapin != smapout) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_CONTAINERS;
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_CONTAINERS;
}
@@ -803,9 +803,9 @@
}
cout << *s_iter;
}
- cout << "}" << endl;
+ cout << "}" << '\n';
if (setin != setout) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_CONTAINERS;
}
@@ -817,14 +817,14 @@
vector<int32_t> listout;
testClient.testList(listout, vector<int32_t>());
if (!listout.empty()) {
- cout << "*** FAILED ***" << endl;
- cout << "invalid length: " << listout.size() << endl;
+ cout << "*** FAILED ***" << '\n';
+ cout << "invalid length: " << listout.size() << '\n';
return_code |= ERR_CONTAINERS;
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_CONTAINERS;
}
try {
@@ -856,15 +856,15 @@
}
cout << *l_iter;
}
- cout << "}" << endl;
+ cout << "}" << '\n';
if (listin != listout) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_CONTAINERS;
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_CONTAINERS;
}
@@ -873,41 +873,41 @@
*/
cout << "testEnum(ONE)" << flush;
Numberz::type ret = testClient.testEnum(Numberz::ONE);
- cout << " = " << ret << endl;
+ cout << " = " << ret << '\n';
if (ret != Numberz::ONE) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
cout << "testEnum(TWO)" << flush;
ret = testClient.testEnum(Numberz::TWO);
- cout << " = " << ret << endl;
+ cout << " = " << ret << '\n';
if (ret != Numberz::TWO) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
cout << "testEnum(THREE)" << flush;
ret = testClient.testEnum(Numberz::THREE);
- cout << " = " << ret << endl;
+ cout << " = " << ret << '\n';
if (ret != Numberz::THREE) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
cout << "testEnum(FIVE)" << flush;
ret = testClient.testEnum(Numberz::FIVE);
- cout << " = " << ret << endl;
+ cout << " = " << ret << '\n';
if (ret != Numberz::FIVE) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
cout << "testEnum(EIGHT)" << flush;
ret = testClient.testEnum(Numberz::EIGHT);
- cout << " = " << ret << endl;
+ cout << " = " << ret << '\n';
if (ret != Numberz::EIGHT) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
@@ -916,9 +916,9 @@
*/
cout << "testTypedef(309858235082523)" << flush;
UserId uid = testClient.testTypedef(309858235082523LL);
- cout << " = " << uid << endl;
+ cout << " = " << uid << '\n';
if (uid != 309858235082523LL) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
@@ -938,7 +938,7 @@
}
cout << "}, ";
}
- cout << "}" << endl;
+ cout << "}" << '\n';
if (mm.size() != 2 ||
mm[-4][-4] != -4 ||
mm[-4][-3] != -3 ||
@@ -948,7 +948,7 @@
mm[4][3] != 3 ||
mm[4][2] != 2 ||
mm[4][1] != 1) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_CONTAINERS;
}
@@ -1005,7 +1005,7 @@
}
cout << "}, ";
}
- cout << "}" << endl;
+ cout << "}" << '\n';
bool failed = false;
map<UserId, map<Numberz::type, Insanity> >::const_iterator it1 = whoa.find(UserId(1));
if (whoa.size() != 2) {
@@ -1033,7 +1033,7 @@
}
}
if (failed) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
}
@@ -1041,7 +1041,7 @@
/**
* MULTI TEST
*/
- cout << "testMulti()" << endl;
+ cout << "testMulti()" << '\n';
try {
map<int16_t, string> mul_map;
Xtruct mul_result;
@@ -1054,13 +1054,13 @@
xxs.i32_thing = 4242;
xxs.i64_thing = 424242;
if (mul_result != xxs) {
- cout << "*** FAILED ***" << endl;
+ cout << "*** FAILED ***" << '\n';
return_code |= ERR_STRUCTS;
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_STRUCTS;
}
@@ -1069,7 +1069,7 @@
try {
cout << "testClient.testException(\"Xception\") =>" << flush;
testClient.testException("Xception");
- cout << " void\n*** FAILED ***" << endl;
+ cout << " void\n*** FAILED ***" << '\n';
return_code |= ERR_EXCEPTIONS;
} catch (Xception& e) {
@@ -1079,19 +1079,19 @@
try {
cout << "testClient.testException(\"TException\") =>" << flush;
testClient.testException("TException");
- cout << " void\n*** FAILED ***" << endl;
+ cout << " void\n*** FAILED ***" << '\n';
return_code |= ERR_EXCEPTIONS;
} catch (const TException&) {
- cout << " Caught TException" << endl;
+ cout << " Caught TException" << '\n';
}
try {
cout << "testClient.testException(\"success\") =>" << flush;
testClient.testException("success");
- cout << " void" << endl;
+ cout << " void" << '\n';
} catch (exception & ex) { \
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_EXCEPTIONS;
}
@@ -1101,7 +1101,7 @@
cout << "testClient.testMultiException(\"Xception\", \"test 1\") =>" << flush;
Xtruct result;
testClient.testMultiException(result, "Xception", "test 1");
- cout << " result\n*** FAILED ***" << endl;
+ cout << " result\n*** FAILED ***" << '\n';
return_code |= ERR_EXCEPTIONS;
} catch (Xception& e) {
printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
@@ -1111,7 +1111,7 @@
cout << "testClient.testMultiException(\"Xception2\", \"test 2\") =>" << flush;
Xtruct result;
testClient.testMultiException(result, "Xception2", "test 2");
- cout << " result\n*** FAILED ***" << endl;
+ cout << " result\n*** FAILED ***" << '\n';
return_code |= ERR_EXCEPTIONS;
} catch (Xception2& e) {
@@ -1124,7 +1124,7 @@
testClient.testMultiException(result, "success", "test 3");
printf(" {{\"%s\"}}\n", result.string_thing.c_str());
} catch (exception & ex) { \
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return_code |= ERR_EXCEPTIONS;
}
@@ -1155,16 +1155,16 @@
*/
cout << "re-test testI32(-1)" << flush;
int i32 = testClient.testI32(-1);
- cout << " = " << i32 << endl;
+ cout << " = " << i32 << '\n';
if (i32 != -1)
return_code |= ERR_BASETYPES;
- cout << endl << "All tests done." << endl << flush;
+ cout << '\n' << "All tests done." << '\n' << flush;
uint64_t stop = now();
uint64_t tot = stop - start;
- cout << "Total time: " << stop - start << " us" << endl;
+ cout << "Total time: " << stop - start << " us" << '\n';
time_tot += tot;
if (time_min == 0 || tot < time_min) {
@@ -1181,9 +1181,9 @@
uint64_t time_avg = time_tot / numTests;
- cout << "Min time: " << time_min << " us" << endl;
- cout << "Max time: " << time_max << " us" << endl;
- cout << "Avg time: " << time_avg << " us" << endl;
+ cout << "Min time: " << time_min << " us" << '\n';
+ cout << "Max time: " << time_max << " us" << '\n';
+ cout << "Avg time: " << time_avg << " us" << '\n';
return return_code;
}
@@ -1225,26 +1225,26 @@
string bin_request;
string bin_result;
- cout << "testBinary(siz = " << siz << ")" << endl;
+ cout << "testBinary(siz = " << siz << ")" << '\n';
binary_fill(bin_request, siz);
try {
testClient.testBinary(bin_result, bin_request);
if (bin_request.size() != bin_result.size()) {
- cout << "*** FAILED: request size " << bin_request.size() << "; result size " << bin_result.size() << endl;
+ cout << "*** FAILED: request size " << bin_request.size() << "; result size " << bin_result.size() << '\n';
return ERR_BASETYPES;
}
for (string::size_type i = 0; i < siz; ++i) {
if (bin_request.at(i) != bin_result.at(i)) {
- cout << "*** FAILED: at position " << i << " request[i] is h" << hex << bin_request.at(i) << " result[i] is h" << hex << bin_result.at(i) << endl;
+ cout << "*** FAILED: at position " << i << " request[i] is h" << hex << bin_request.at(i) << " result[i] is h" << hex << bin_result.at(i) << '\n';
return ERR_BASETYPES;
}
}
} catch (TTransportException&) {
throw;
} catch (exception& ex) {
- cout << "*** FAILED ***" << endl << ex.what() << endl;
+ cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
return ERR_BASETYPES;
}
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 6c61f40..afd2938 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -394,7 +394,7 @@
}
void communicate(const char* event, void* ctx, const char* fn_name) {
- std::cout << event << ": " << *static_cast<std::string*>(ctx) << " = " << fn_name << std::endl;
+ std::cout << event << ": " << *static_cast<std::string*>(ctx) << " = " << fn_name << '\n';
}
};
@@ -655,7 +655,7 @@
}
} catch (std::exception& e) {
- cerr << e.what() << endl;
+ cerr << e.what() << '\n';
cout << desc << "\n";
return 1;
}
@@ -767,7 +767,7 @@
if (port != 0) {
cout << port;
}
- cout << endl;
+ cout << '\n';
// Multiplexed Processor if needed
if (boost::starts_with(protocol_type, "multi")) {
@@ -823,7 +823,7 @@
: new transport::TNonblockingServerSocket(port));
server.reset(new TNonblockingServer(testProcessor, protocolFactory, nbSocket));
} else {
- cerr << "server-type nonblocking requires transport of http or framed" << endl;
+ cerr << "server-type nonblocking requires transport of http or framed" << '\n';
exit(1);
}
}
@@ -857,6 +857,6 @@
server.reset();
}
- cout << "done." << endl;
+ cout << "done." << '\n';
return 0;
}
diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp
index 5208411..02e7b17 100644
--- a/tutorial/cpp/CppClient.cpp
+++ b/tutorial/cpp/CppClient.cpp
@@ -43,9 +43,9 @@
transport->open();
client.ping();
- cout << "ping()" << endl;
+ cout << "ping()" << '\n';
- cout << "1 + 1 = " << client.add(1, 1) << endl;
+ cout << "1 + 1 = " << client.add(1, 1) << '\n';
Work work;
work.op = Operation::DIVIDE;
@@ -54,27 +54,27 @@
try {
client.calculate(1, work);
- cout << "Whoa? We can divide by zero!" << endl;
+ cout << "Whoa? We can divide by zero!" << '\n';
} catch (InvalidOperation& io) {
- cout << "InvalidOperation: " << io.why << endl;
- // or using generated operator<<: cout << io << endl;
- // or by using std::exception native method what(): cout << io.what() << endl;
+ cout << "InvalidOperation: " << io.why << '\n';
+ // or using generated operator<<: cout << io << '\n';
+ // or by using std::exception native method what(): cout << io.what() << '\n';
}
work.op = Operation::SUBTRACT;
work.num1 = 15;
work.num2 = 10;
int32_t diff = client.calculate(1, work);
- cout << "15 - 10 = " << diff << endl;
+ cout << "15 - 10 = " << diff << '\n';
// Note that C++ uses return by reference for complex types to avoid
// costly copy construction
SharedStruct ss;
client.getStruct(ss, 1);
- cout << "Received log: " << ss << endl;
+ cout << "Received log: " << ss << '\n';
transport->close();
} catch (TException& tx) {
- cout << "ERROR: " << tx.what() << endl;
+ cout << "ERROR: " << tx.what() << '\n';
}
}
diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp
index 635afef..4c66cb8 100644
--- a/tutorial/cpp/CppServer.cpp
+++ b/tutorial/cpp/CppServer.cpp
@@ -48,15 +48,15 @@
public:
CalculatorHandler() = default;
- void ping() override { cout << "ping()" << endl; }
+ void ping() override { cout << "ping()" << '\n'; }
int32_t add(const int32_t n1, const int32_t n2) override {
- cout << "add(" << n1 << ", " << n2 << ")" << endl;
+ cout << "add(" << n1 << ", " << n2 << ")" << '\n';
return n1 + n2;
}
int32_t calculate(const int32_t logid, const Work& work) override {
- cout << "calculate(" << logid << ", " << work << ")" << endl;
+ cout << "calculate(" << logid << ", " << work << ")" << '\n';
int32_t val;
switch (work.op) {
@@ -95,11 +95,11 @@
}
void getStruct(SharedStruct& ret, const int32_t logid) override {
- cout << "getStruct(" << logid << ")" << endl;
+ cout << "getStruct(" << logid << ")" << '\n';
ret = log[logid];
}
- void zip() override { cout << "zip()" << endl; }
+ void zip() override { cout << "zip()" << '\n'; }
protected:
map<int32_t, SharedStruct> log;
@@ -172,8 +172,8 @@
threadManager);
*/
- cout << "Starting the server..." << endl;
+ cout << "Starting the server..." << '\n';
server.serve();
- cout << "Done." << endl;
+ cout << "Done." << '\n';
return 0;
}