You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/18 11:34:25 UTC

[33/37] thrift git commit: Revert "THRIFT-2729: C++ - .clang-format created and applied"

http://git-wip-us.apache.org/repos/asf/thrift/blob/240120c8/compiler/cpp/src/generate/t_cpp_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index 05ac216..42fe9e2 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -40,19 +40,21 @@ using std::ostream;
 using std::string;
 using std::vector;
 
-static const string endl = "\n"; // avoid ostream << std::endl flushes
+static const string endl = "\n";  // avoid ostream << std::endl flushes
 
 /**
  * C++ code generator. This is legitimacy incarnate.
  *
  */
 class t_cpp_generator : public t_oop_generator {
-public:
-  t_cpp_generator(t_program* program,
-                  const std::map<std::string, std::string>& parsed_options,
-                  const std::string& option_string)
-    : t_oop_generator(program) {
-    (void)option_string;
+ public:
+  t_cpp_generator(
+      t_program* program,
+      const std::map<std::string, std::string>& parsed_options,
+      const std::string& option_string)
+    : t_oop_generator(program)
+  {
+    (void) option_string;
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("pure_enums");
@@ -76,7 +78,8 @@ public:
     iter = parsed_options.find("templates");
     gen_templates_ = (iter != parsed_options.end());
 
-    gen_templates_only_ = (iter != parsed_options.end() && iter->second == "only");
+    gen_templates_only_ =
+      (iter != parsed_options.end() && iter->second == "only");
 
     out_dir_base_ = "gen-cpp";
   }
@@ -97,106 +100,115 @@ public:
   void generate_typedef(t_typedef* ttypedef);
   void generate_enum(t_enum* tenum);
   void generate_forward_declaration(t_struct* tstruct);
-  void generate_struct(t_struct* tstruct) { generate_cpp_struct(tstruct, false); }
-  void generate_xception(t_struct* txception) { generate_cpp_struct(txception, true); }
+  void generate_struct(t_struct* tstruct) {
+    generate_cpp_struct(tstruct, false);
+  }
+  void generate_xception(t_struct* txception) {
+    generate_cpp_struct(txception, true);
+  }
   void generate_cpp_struct(t_struct* tstruct, bool is_exception);
 
   void generate_service(t_service* tservice);
 
   void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
-  std::string render_const_value(std::ofstream& out,
-                                 std::string name,
-                                 t_type* type,
-                                 t_const_value* value);
-
-  void generate_struct_declaration(std::ofstream& out,
-                                   t_struct* tstruct,
-                                   bool is_exception = false,
-                                   bool pointers = false,
-                                   bool read = true,
-                                   bool write = true,
-                                   bool swap = false);
-  void generate_struct_definition(std::ofstream& out,
-                                  std::ofstream& force_cpp_out,
-                                  t_struct* tstruct,
-                                  bool setters = true);
-  void generate_copy_constructor(std::ofstream& out, t_struct* tstruct, bool is_exception);
-  void generate_assignment_operator(std::ofstream& out, t_struct* tstruct);
-  void generate_struct_fingerprint(std::ofstream& out, t_struct* tstruct, bool is_definition);
-  void generate_struct_reader(std::ofstream& out, t_struct* tstruct, bool pointers = false);
-  void generate_struct_writer(std::ofstream& out, t_struct* tstruct, bool pointers = false);
-  void generate_struct_result_writer(std::ofstream& out, t_struct* tstruct, bool pointers = false);
-  void generate_struct_swap(std::ofstream& out, t_struct* tstruct);
+  std::string render_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
+
+  void generate_struct_declaration    (std::ofstream& out, t_struct* tstruct,
+                                      bool is_exception=false,
+                                      bool pointers=false,
+                                      bool read=true,
+                                      bool write=true,
+                                      bool swap=false);
+  void generate_struct_definition   (std::ofstream& out, std::ofstream& force_cpp_out, t_struct* tstruct, bool setters=true);
+  void generate_copy_constructor     (std::ofstream& out, t_struct* tstruct, bool is_exception);
+  void generate_assignment_operator  (std::ofstream& out, t_struct* tstruct);
+  void generate_struct_fingerprint   (std::ofstream& out, t_struct* tstruct, bool is_definition);
+  void generate_struct_reader        (std::ofstream& out, t_struct* tstruct, bool pointers=false);
+  void generate_struct_writer        (std::ofstream& out, t_struct* tstruct, bool pointers=false);
+  void generate_struct_result_writer (std::ofstream& out, t_struct* tstruct, bool pointers=false);
+  void generate_struct_swap          (std::ofstream& out, t_struct* tstruct);
   void generate_struct_ostream_operator(std::ofstream& out, t_struct* tstruct);
 
   /**
    * Service-level generation functions
    */
 
-  void generate_service_interface(t_service* tservice, string style);
-  void generate_service_interface_factory(t_service* tservice, string style);
-  void generate_service_null(t_service* tservice, string style);
-  void generate_service_multiface(t_service* tservice);
-  void generate_service_helpers(t_service* tservice);
-  void generate_service_client(t_service* tservice, string style);
-  void generate_service_processor(t_service* tservice, string style);
-  void generate_service_skeleton(t_service* tservice);
-  void generate_process_function(t_service* tservice,
-                                 t_function* tfunction,
-                                 string style,
-                                 bool specialized = false);
-  void generate_function_helpers(t_service* tservice, t_function* tfunction);
-  void generate_service_async_skeleton(t_service* tservice);
+  void generate_service_interface (t_service* tservice, string style);
+  void generate_service_interface_factory (t_service* tservice, string style);
+  void generate_service_null      (t_service* tservice, string style);
+  void generate_service_multiface (t_service* tservice);
+  void generate_service_helpers   (t_service* tservice);
+  void generate_service_client    (t_service* tservice, string style);
+  void generate_service_processor (t_service* tservice, string style);
+  void generate_service_skeleton  (t_service* tservice);
+  void generate_process_function  (t_service* tservice, t_function* tfunction,
+                                   string style, bool specialized=false);
+  void generate_function_helpers  (t_service* tservice, t_function* tfunction);
+  void generate_service_async_skeleton (t_service* tservice);
 
   /**
    * Serialization constructs
    */
 
-  void generate_deserialize_field(std::ofstream& out,
-                                  t_field* tfield,
-                                  std::string prefix = "",
-                                  std::string suffix = "");
-
-  void generate_deserialize_struct(std::ofstream& out,
-                                   t_struct* tstruct,
-                                   std::string prefix = "",
-                                   bool pointer = false);
-
-  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
-
-  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
-
-  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
-
-  void generate_deserialize_list_element(std::ofstream& out,
-                                         t_list* tlist,
-                                         std::string prefix,
-                                         bool push_back,
-                                         std::string index);
-
-  void generate_serialize_field(std::ofstream& out,
-                                t_field* tfield,
-                                std::string prefix = "",
-                                std::string suffix = "");
-
-  void generate_serialize_struct(std::ofstream& out,
-                                 t_struct* tstruct,
-                                 std::string prefix = "",
-                                 bool pointer = false);
-
-  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
-
-  void generate_serialize_map_element(std::ofstream& out, t_map* tmap, std::string iter);
-
-  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
-
-  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
-
-  void generate_function_call(ostream& out,
-                              t_function* tfunction,
-                              string target,
-                              string iface,
-                              string arg_prefix);
+  void generate_deserialize_field        (std::ofstream& out,
+                                          t_field*    tfield,
+                                          std::string prefix="",
+                                          std::string suffix="");
+
+  void generate_deserialize_struct       (std::ofstream& out,
+                                          t_struct*   tstruct,
+                                          std::string prefix="",
+                                          bool pointer=false);
+
+  void generate_deserialize_container    (std::ofstream& out,
+                                          t_type*     ttype,
+                                          std::string prefix="");
+
+  void generate_deserialize_set_element  (std::ofstream& out,
+                                          t_set*      tset,
+                                          std::string prefix="");
+
+  void generate_deserialize_map_element  (std::ofstream& out,
+                                          t_map*      tmap,
+                                          std::string prefix="");
+
+  void generate_deserialize_list_element (std::ofstream& out,
+                                          t_list*     tlist,
+                                          std::string prefix,
+                                          bool push_back,
+                                          std::string index);
+
+  void generate_serialize_field          (std::ofstream& out,
+                                          t_field*    tfield,
+                                          std::string prefix="",
+                                          std::string suffix="");
+
+  void generate_serialize_struct         (std::ofstream& out,
+                                          t_struct*   tstruct,
+                                          std::string prefix="",
+                                          bool pointer=false);
+
+  void generate_serialize_container      (std::ofstream& out,
+                                          t_type*     ttype,
+                                          std::string prefix="");
+
+  void generate_serialize_map_element    (std::ofstream& out,
+                                          t_map*      tmap,
+                                          std::string iter);
+
+  void generate_serialize_set_element    (std::ofstream& out,
+                                          t_set*      tmap,
+                                          std::string iter);
+
+  void generate_serialize_list_element   (std::ofstream& out,
+                                          t_list*     tlist,
+                                          std::string iter);
+
+  void generate_function_call            (ostream& out,
+                                          t_function* tfunction,
+                                          string target,
+                                          string iface,
+                                          string arg_prefix);
   /*
    * Helper rendering functions
    */
@@ -204,23 +216,14 @@ public:
   std::string namespace_prefix(std::string ns);
   std::string namespace_open(std::string ns);
   std::string namespace_close(std::string ns);
-  std::string type_name(t_type* ttype, bool in_typedef = false, bool arg = false);
+  std::string type_name(t_type* ttype, bool in_typedef=false, bool arg=false);
   std::string base_type_name(t_base_type::t_base tbase);
-  std::string declare_field(t_field* tfield,
-                            bool init = false,
-                            bool pointer = false,
-                            bool constant = false,
-                            bool reference = false);
-  std::string function_signature(t_function* tfunction,
-                                 std::string style,
-                                 std::string prefix = "",
-                                 bool name_params = true);
-  std::string cob_function_signature(t_function* tfunction,
-                                     std::string prefix = "",
-                                     bool name_params = true);
-  std::string argument_list(t_struct* tstruct, bool name_params = true, bool start_comma = false);
+  std::string declare_field(t_field* tfield, bool init=false, bool pointer=false, bool constant=false, bool reference=false);
+  std::string function_signature(t_function* tfunction, std::string style, std::string prefix="", bool name_params=true);
+  std::string cob_function_signature(t_function* tfunction, std::string prefix="", bool name_params=true);
+  std::string argument_list(t_struct* tstruct, bool name_params=true, bool start_comma=false);
   std::string type_to_enum(t_type* ttype);
-  std::string local_reflection_name(const char*, t_type* ttype, bool external = false);
+  std::string local_reflection_name(const char*, t_type* ttype, bool external=false);
 
   void generate_enum_constant_list(std::ofstream& f,
                                    const vector<t_enum_value*>& constants,
@@ -234,19 +237,25 @@ public:
   void generate_local_reflection(std::ofstream& out, t_type* ttype, bool is_definition);
   void generate_local_reflection_pointer(std::ofstream& out, t_type* ttype);
 
-  bool is_reference(t_field* tfield) { return tfield->get_reference(); }
+  bool is_reference(t_field* tfield) {
+    return tfield->get_reference();
+  }
 
   bool is_complex_type(t_type* ttype) {
     ttype = get_true_type(ttype);
 
-    return ttype->is_container() || ttype->is_struct() || ttype->is_xception()
-           || (ttype->is_base_type()
-               && (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING));
+    return
+      ttype->is_container() ||
+      ttype->is_struct() ||
+      ttype->is_xception() ||
+      (ttype->is_base_type() && (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING));
   }
 
-  void set_use_include_prefix(bool use_include_prefix) { use_include_prefix_ = use_include_prefix; }
+  void set_use_include_prefix(bool use_include_prefix) {
+    use_include_prefix_ = use_include_prefix;
+  }
 
-private:
+ private:
   /**
    * Returns the include prefix to use for a file generated by program, or the
    * empty string if no include prefix should be used.
@@ -337,48 +346,60 @@ void t_cpp_generator::init_generator() {
   MKDIR(get_out_dir().c_str());
 
   // Make output file
-  string f_types_name = get_out_dir() + program_name_ + "_types.h";
+  string f_types_name = get_out_dir()+program_name_+"_types.h";
   f_types_.open(f_types_name.c_str());
 
-  string f_types_impl_name = get_out_dir() + program_name_ + "_types.cpp";
+  string f_types_impl_name = get_out_dir()+program_name_+"_types.cpp";
   f_types_impl_.open(f_types_impl_name.c_str());
 
   if (gen_templates_) {
     // If we don't open the stream, it appears to just discard data,
     // which is fine.
-    string f_types_tcc_name = get_out_dir() + program_name_ + "_types.tcc";
+    string f_types_tcc_name = get_out_dir()+program_name_+"_types.tcc";
     f_types_tcc_.open(f_types_tcc_name.c_str());
   }
 
   // Print header
-  f_types_ << autogen_comment();
-  f_types_impl_ << autogen_comment();
-  f_types_tcc_ << autogen_comment();
+  f_types_ <<
+    autogen_comment();
+  f_types_impl_ <<
+    autogen_comment();
+  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" << endl <<
+    "#define " << program_name_ << "_TYPES_H" << endl <<
+    endl;
+  f_types_tcc_ <<
+    "#ifndef " << program_name_ << "_TYPES_TCC" << endl <<
+    "#define " << program_name_ << "_TYPES_TCC" << endl <<
+    endl;
 
   // Include base types
-  f_types_ << "#include <iosfwd>" << endl << endl << "#include <thrift/Thrift.h>" << endl
-           << "#include <thrift/TApplicationException.h>" << endl
-           << "#include <thrift/protocol/TProtocol.h>" << endl
-           << "#include <thrift/transport/TTransport.h>" << endl << endl;
+  f_types_ <<
+    "#include <iosfwd>" << endl << endl <<
+    "#include <thrift/Thrift.h>" << endl <<
+    "#include <thrift/TApplicationException.h>" << endl <<
+    "#include <thrift/protocol/TProtocol.h>" << endl <<
+    "#include <thrift/transport/TTransport.h>" << endl <<
+    endl;
   // Include C++xx compatibility header
   f_types_ << "#include <thrift/cxxfunctional.h>" << endl;
 
   // Include other Thrift includes
   const vector<t_program*>& includes = program_->get_includes();
   for (size_t i = 0; i < includes.size(); ++i) {
-    f_types_ << "#include \"" << get_include_prefix(*(includes[i])) << includes[i]->get_name()
-             << "_types.h\"" << endl;
+    f_types_ <<
+      "#include \"" << get_include_prefix(*(includes[i])) <<
+      includes[i]->get_name() << "_types.h\"" << endl;
 
     // 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(*(includes[i])) << includes[i]->get_name()
-                 << "_types.tcc\"" << endl;
+    f_types_tcc_ <<
+      "#include \"" << get_include_prefix(*(includes[i])) <<
+      includes[i]->get_name() << "_types.tcc\"" << endl;
   }
   f_types_ << endl;
 
@@ -386,23 +407,32 @@ void t_cpp_generator::init_generator() {
   const vector<string>& cpp_includes = program_->get_cpp_includes();
   for (size_t i = 0; i < cpp_includes.size(); ++i) {
     if (cpp_includes[i][0] == '<') {
-      f_types_ << "#include " << cpp_includes[i] << endl;
+      f_types_ <<
+        "#include " << cpp_includes[i] << endl;
     } else {
-      f_types_ << "#include \"" << cpp_includes[i] << "\"" << endl;
+      f_types_ <<
+        "#include \"" << cpp_includes[i] << "\"" << endl;
     }
   }
-  f_types_ << endl;
+  f_types_ <<
+    endl;
 
   // Include the types file
-  f_types_impl_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
-                << "_types.h\"" << endl << endl;
-  f_types_tcc_ << "#include \"" << get_include_prefix(*get_program()) << program_name_
-               << "_types.h\"" << endl << endl;
+  f_types_impl_ <<
+    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
+    "_types.h\"" << endl <<
+    endl;
+  f_types_tcc_ <<
+    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
+    "_types.h\"" << endl <<
+    endl;
 
   // If we are generating local reflection metadata, we need to include
   // the definition of TypeSpec.
   if (gen_dense_) {
-    f_types_impl_ << "#include <thrift/TReflectionLocal.h>" << endl << endl;
+    f_types_impl_ <<
+      "#include <thrift/TReflectionLocal.h>" << endl <<
+      endl;
   }
 
   // The swap() code needs <algorithm> for std::swap()
@@ -415,11 +445,17 @@ void t_cpp_generator::init_generator() {
   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_ << endl <<
+    endl;
 
-  f_types_impl_ << ns_open_ << endl << endl;
+  f_types_impl_ <<
+    ns_open_ << endl <<
+    endl;
 
-  f_types_tcc_ << ns_open_ << endl << endl;
+  f_types_tcc_ <<
+    ns_open_ << endl <<
+    endl;
 }
 
 /**
@@ -427,21 +463,30 @@ void t_cpp_generator::init_generator() {
  */
 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_ << endl <<
+    endl;
+  f_types_impl_ <<
+    ns_close_ << endl;
+  f_types_tcc_ <<
+    ns_close_ << endl <<
+    endl;
 
   // 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;
+    f_types_ <<
+      "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
+      "_types.tcc\"" << endl <<
+      endl;
   }
 
   // Close ifndef
-  f_types_ << "#endif" << endl;
-  f_types_tcc_ << "#endif" << endl;
+  f_types_ <<
+    "#endif" << endl;
+  f_types_tcc_ <<
+    "#endif" << endl;
 
   // Close output file
   f_types_.close();
@@ -455,10 +500,12 @@ void t_cpp_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_cpp_generator::generate_typedef(t_typedef* ttypedef) {
-  f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " "
-           << ttypedef->get_symbolic() << ";" << endl << endl;
+  f_types_ <<
+    indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << ttypedef->get_symbolic() << ";" << endl <<
+    endl;
 }
 
+
 void t_cpp_generator::generate_enum_constant_list(std::ofstream& f,
                                                   const vector<t_enum_value*>& constants,
                                                   const char* prefix,
@@ -475,7 +522,8 @@ void t_cpp_generator::generate_enum_constant_list(std::ofstream& f,
     } else {
       f << "," << endl;
     }
-    indent(f) << prefix << (*c_iter)->get_name() << suffix;
+    indent(f)
+      << prefix << (*c_iter)->get_name() << suffix;
     if (include_values) {
       f << " = " << (*c_iter)->get_value();
     }
@@ -498,10 +546,12 @@ void t_cpp_generator::generate_enum(t_enum* tenum) {
   std::string enum_name = tenum->get_name();
   if (!gen_pure_enums_) {
     enum_name = "type";
-    f_types_ << indent() << "struct " << tenum->get_name() << " {" << endl;
+    f_types_ <<
+      indent() << "struct " << tenum->get_name() << " {" << endl;
     indent_up();
   }
-  f_types_ << indent() << "enum " << enum_name;
+  f_types_ <<
+    indent() << "enum " << enum_name;
 
   generate_enum_constant_list(f_types_, constants, "", "", true);
 
@@ -520,20 +570,24 @@ void t_cpp_generator::generate_enum(t_enum* tenum) {
     prefix = tenum->get_name() + "::";
   }
 
-  f_types_impl_ << indent() << "int _k" << tenum->get_name() << "Values[] =";
+  f_types_impl_ <<
+    indent() << "int _k" << tenum->get_name() << "Values[] =";
   generate_enum_constant_list(f_types_impl_, constants, prefix.c_str(), "", false);
 
-  f_types_impl_ << indent() << "const char* _k" << tenum->get_name() << "Names[] =";
+  f_types_impl_ <<
+    indent() << "const char* _k" << tenum->get_name() << "Names[] =";
   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;
+  f_types_ <<
+    indent() << "extern const std::map<int, const char*> _" <<
+    tenum->get_name() << "_VALUES_TO_NAMES;" << endl << endl;
 
-  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, NULL, NULL));" << endl << endl;
+  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, NULL, NULL));" << endl << endl;
 
   generate_local_reflection(f_types_, tenum, false);
   generate_local_reflection(f_types_impl_, tenum, true);
@@ -543,41 +597,59 @@ void t_cpp_generator::generate_enum(t_enum* tenum) {
  * Generates a class that holds all the constants.
  */
 void t_cpp_generator::generate_consts(std::vector<t_const*> consts) {
-  string f_consts_name = get_out_dir() + program_name_ + "_constants.h";
+  string f_consts_name = get_out_dir()+program_name_+"_constants.h";
   ofstream f_consts;
   f_consts.open(f_consts_name.c_str());
 
-  string f_consts_impl_name = get_out_dir() + program_name_ + "_constants.cpp";
+  string f_consts_impl_name = get_out_dir()+program_name_+"_constants.cpp";
   ofstream f_consts_impl;
   f_consts_impl.open(f_consts_impl_name.c_str());
 
   // Print header
-  f_consts << autogen_comment();
-  f_consts_impl << autogen_comment();
+  f_consts <<
+    autogen_comment();
+  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_impl << "#include \"" << get_include_prefix(*get_program()) << program_name_
-                << "_constants.h\"" << endl << endl << ns_open_ << endl << endl;
-
-  f_consts << "class " << program_name_ << "Constants {" << endl << " public:" << endl << "  "
-           << program_name_ << "Constants();" << endl << endl;
+  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_impl <<
+    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
+    "_constants.h\"" << endl <<
+    endl <<
+    ns_open_ << endl <<
+    endl;
+
+  f_consts <<
+    "class " << program_name_ << "Constants {" << endl <<
+    " public:" << endl <<
+    "  " << program_name_ << "Constants();" << endl <<
+    endl;
   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 << ";" << endl;
   }
   indent_down();
-  f_consts << "};" << endl;
+  f_consts <<
+    "};" << endl;
 
-  f_consts_impl << "const " << program_name_ << "Constants g_" << program_name_ << "_constants;"
-                << endl << endl << program_name_ << "Constants::" << program_name_
-                << "Constants() {" << endl;
+  f_consts_impl <<
+    "const " << program_name_ << "Constants g_" << program_name_ << "_constants;" << endl <<
+    endl <<
+    program_name_ << "Constants::" << program_name_ << "Constants() {" << endl;
   indent_up();
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
     print_const_value(f_consts_impl,
@@ -586,13 +658,22 @@ void t_cpp_generator::generate_consts(std::vector<t_const*> consts) {
                       (*c_iter)->get_value());
   }
   indent_down();
-  indent(f_consts_impl) << "}" << endl;
-
-  f_consts << endl << "extern const " << program_name_ << "Constants g_" << program_name_
-           << "_constants;" << endl << endl << ns_close_ << endl << endl << "#endif" << endl;
+  indent(f_consts_impl) <<
+    "}" << endl;
+
+  f_consts <<
+    endl <<
+    "extern const " << program_name_ << "Constants g_" << program_name_ << "_constants;" << endl <<
+    endl <<
+    ns_close_ << endl <<
+    endl <<
+    "#endif" << endl;
   f_consts.close();
 
-  f_consts_impl << endl << ns_close_ << endl << endl;
+  f_consts_impl <<
+    endl <<
+    ns_close_ << endl <<
+    endl;
 }
 
 /**
@@ -600,17 +681,15 @@ void t_cpp_generator::generate_consts(std::vector<t_const*> consts) {
  * is NOT performed in this function as it is always run beforehand using the
  * validate_types method in main.cc
  */
-void t_cpp_generator::print_const_value(ofstream& out,
-                                        string name,
-                                        t_type* type,
-                                        t_const_value* value) {
+void t_cpp_generator::print_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
   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 << ";" << endl <<
+      endl;
   } else if (type->is_enum()) {
-    indent(out) << name << " = (" << type_name(type) << ")" << value->get_integer() << ";" << endl
-                << endl;
+    indent(out) << name << " = (" << type_name(type) << ")" << value->get_integer() << ";" << endl <<
+      endl;
   } 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;
@@ -631,8 +710,8 @@ void t_cpp_generator::print_const_value(ofstream& out,
       }
       string val = render_const_value(out, name, field_type, v_iter->second);
       indent(out) << name << "." << v_iter->first->get_string() << " = " << val << ";" << endl;
-      if (is_nonrequired_field) {
-        indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << endl;
+      if(is_nonrequired_field) {
+          indent(out) << name << ".__isset." << v_iter->first->get_string() << " = true;" << endl;
       }
     }
     out << endl;
@@ -673,11 +752,8 @@ void t_cpp_generator::print_const_value(ofstream& out,
 /**
  *
  */
-string t_cpp_generator::render_const_value(ofstream& out,
-                                           string name,
-                                           t_type* type,
-                                           t_const_value* value) {
-  (void)name;
+string t_cpp_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
+  (void) name;
   std::ostringstream render;
 
   if (type->is_base_type()) {
@@ -721,7 +797,9 @@ string t_cpp_generator::render_const_value(ofstream& out,
 
 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() << ";" << endl <<
+    endl;
 }
 
 /**
@@ -732,7 +810,8 @@ void t_cpp_generator::generate_forward_declaration(t_struct* tstruct) {
  * @param tstruct The struct definition
  */
 void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) {
-  generate_struct_declaration(f_types_, tstruct, is_exception, false, true, true, true);
+  generate_struct_declaration(f_types_, tstruct, is_exception,
+                             false, true, true, true);
   generate_struct_definition(f_types_impl_, f_types_impl_, tstruct);
   generate_struct_fingerprint(f_types_impl_, tstruct, true);
   generate_local_reflection(f_types_, tstruct, false);
@@ -748,13 +827,15 @@ void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception)
   generate_struct_ostream_operator(f_types_impl_, tstruct);
 }
 
-void t_cpp_generator::generate_copy_constructor(ofstream& out,
-                                                t_struct* tstruct,
-                                                bool is_exception) {
+void t_cpp_generator::generate_copy_constructor(
+  ofstream& out,
+  t_struct* tstruct,
+  bool is_exception) {
   std::string tmp_name = tmp("other");
 
-  indent(out) << tstruct->get_name() << "::" << tstruct->get_name() << "(const "
-              << tstruct->get_name() << "& " << tmp_name << ") ";
+  indent(out) << tstruct->get_name() << "::" <<
+    tstruct->get_name() << "(const " << tstruct->get_name() <<
+    "& " << tmp_name << ") ";
   if (is_exception)
     out << ": TException() ";
   out << "{" << endl;
@@ -771,8 +852,8 @@ void t_cpp_generator::generate_copy_constructor(ofstream& out,
   for (f_iter = members.begin(); f_iter != members.end(); ++f_iter) {
     if ((*f_iter)->get_req() != t_field::T_REQUIRED)
       has_nonrequired_fields = true;
-    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." << (*f_iter)->get_name() << ";"
-                << endl;
+    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." <<
+      (*f_iter)->get_name() << ";" << endl;
   }
 
   if (has_nonrequired_fields)
@@ -782,12 +863,14 @@ void t_cpp_generator::generate_copy_constructor(ofstream& out,
   indent(out) << "}" << endl;
 }
 
-void t_cpp_generator::generate_assignment_operator(ofstream& out, t_struct* tstruct) {
+void t_cpp_generator::generate_assignment_operator(
+  ofstream& out,
+  t_struct* tstruct) {
   std::string tmp_name = tmp("other");
 
   indent(out) << tstruct->get_name() << "& " << tstruct->get_name() << "::"
-                                                                       "operator=(const "
-              << tstruct->get_name() << "& " << tmp_name << ") {" << endl;
+    "operator=(const " << tstruct->get_name() <<
+    "& " << tmp_name << ") {" << endl;
   indent_up();
 
   const vector<t_field*>& members = tstruct->get_members();
@@ -801,8 +884,8 @@ void t_cpp_generator::generate_assignment_operator(ofstream& out, t_struct* tstr
   for (f_iter = members.begin(); f_iter != members.end(); ++f_iter) {
     if ((*f_iter)->get_req() != t_field::T_REQUIRED)
       has_nonrequired_fields = true;
-    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." << (*f_iter)->get_name() << ";"
-                << endl;
+    indent(out) << (*f_iter)->get_name() << " = " << tmp_name << "." <<
+      (*f_iter)->get_name() << ";" << endl;
   }
   if (has_nonrequired_fields)
     indent(out) << "__isset = " << tmp_name << ".__isset;" << endl;
@@ -819,12 +902,12 @@ void t_cpp_generator::generate_assignment_operator(ofstream& out, t_struct* tstr
  * @param tstruct The struct
  */
 void t_cpp_generator::generate_struct_declaration(ofstream& out,
-                                                  t_struct* tstruct,
-                                                  bool is_exception,
-                                                  bool pointers,
-                                                  bool read,
-                                                  bool write,
-                                                  bool swap) {
+                                                 t_struct* tstruct,
+                                                 bool is_exception,
+                                                 bool pointers,
+                                                 bool read,
+                                                 bool write,
+                                                 bool swap) {
   string extends = "";
   if (is_exception) {
     extends = " : public ::apache::thrift::TException";
@@ -847,10 +930,12 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
 
   if (has_nonrequired_fields && (!pointers || read)) {
 
-    out << indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << endl;
+    out <<
+      indent() << "typedef struct _" << tstruct->get_name() << "__isset {" << endl;
     indent_up();
 
-    indent(out) << "_" << tstruct->get_name() << "__isset() ";
+    indent(out) <<
+      "_" << tstruct->get_name() << "__isset() ";
     bool first = true;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if ((*m_iter)->get_req() == t_field::T_REQUIRED) {
@@ -859,28 +944,34 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
       string isSet = ((*m_iter)->get_value() != NULL) ? "true" : "false";
       if (first) {
         first = false;
-        out << ": " << (*m_iter)->get_name() << "(" << isSet << ")";
+        out <<
+          ": " << (*m_iter)->get_name() << "(" << isSet << ")";
       } else {
-        out << ", " << (*m_iter)->get_name() << "(" << isSet << ")";
+        out <<
+          ", " << (*m_iter)->get_name() << "(" << isSet << ")";
       }
     }
     out << " {}" << endl;
 
     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;" << endl;
+        }
       }
-    }
 
-    indent_down();
-    indent(out) << "} _" << tstruct->get_name() << "__isset;" << endl;
-  }
+      indent_down();
+      indent(out) <<
+        "} _" << tstruct->get_name() << "__isset;" << endl;
+    }
 
   out << endl;
 
   // Open struct def
-  out << indent() << "class " << tstruct->get_name() << extends << " {" << endl << indent()
-      << " public:" << endl << endl;
+  out <<
+    indent() << "class " << tstruct->get_name() << extends << " {" << endl <<
+    indent() << " public:" << endl <<
+    endl;
   indent_up();
 
   // Put the fingerprint up top for all to see.
@@ -888,14 +979,16 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
 
   if (!pointers) {
     // Copy constructor
-    indent(out) << tstruct->get_name() << "(const " << tstruct->get_name() << "&);" << endl;
+    indent(out) <<
+      tstruct->get_name() << "(const " << tstruct->get_name() << "&);" << endl;
 
     // Assignment Operator
-    indent(out) << tstruct->get_name() << "& operator=(const " << tstruct->get_name() << "&);"
-                << endl;
+    indent(out) << tstruct->get_name() << "& operator=(const " << tstruct->get_name() << "&);" << endl;
 
     // Default constructor
-    indent(out) << tstruct->get_name() << "()";
+    indent(out) <<
+      tstruct->get_name() << "()";
+
 
     bool init_ctor = false;
 
@@ -938,26 +1031,29 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
   }
 
   if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
-    out << endl << indent() << "virtual ~" << tstruct->get_name() << "() throw();" << endl;
+    out <<
+      endl <<
+      indent() << "virtual ~" << tstruct->get_name() << "() throw();" << endl;
   }
 
   // Pointer to this structure's reflection local typespec.
   if (gen_dense_) {
-    indent(out) << "static ::apache::thrift::reflection::local::TypeSpec* local_reflection;" << endl
-                << endl;
+    indent(out) <<
+      "static ::apache::thrift::reflection::local::TypeSpec* local_reflection;" <<
+      endl << endl;
   }
 
   // Declare all fields
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) << declare_field(*m_iter,
-                                 false,
-                                 (pointers && !(*m_iter)->get_type()->is_xception()),
-                                 !read) << endl;
+    indent(out) <<
+      declare_field(*m_iter, false, (pointers && !(*m_iter)->get_type()->is_xception()), !read) << endl;
   }
 
   // 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 <<
+      endl <<
+      indent() << "_" << tstruct->get_name() << "__isset __isset;" << endl;
   }
 
   // Create a setter function for each field
@@ -966,12 +1062,16 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
       continue;
     }
     if (is_reference((*m_iter))) {
-      out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "(boost::shared_ptr<"
-          << type_name((*m_iter)->get_type(), false, false) << ">";
+      out <<
+        endl <<
+        indent() << "void __set_" << (*m_iter)->get_name() <<
+        "(boost::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">";
       out << " val);" << endl;
     } else {
-      out << endl << indent() << "void __set_" << (*m_iter)->get_name() << "("
-          << type_name((*m_iter)->get_type(), false, true);
+      out <<
+        endl <<
+        indent() << "void __set_" << (*m_iter)->get_name() <<
+        "(" << type_name((*m_iter)->get_type(), false, true);
       out << " val);" << endl;
     }
   }
@@ -982,53 +1082,65 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
     if (!gen_no_default_operators_) {
       // Generate an equality testing operator.  Make it inline since the compiler
       // will do a better job than we would when deciding whether to inline it.
-      out << indent() << "bool operator == (const " << tstruct->get_name() << " & "
-          << (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl;
+      out <<
+        indent() << "bool operator == (const " << tstruct->get_name() << " & " <<
+        (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl;
       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;
+          out <<
+            indent() << "if (!(" << (*m_iter)->get_name()
+                     << " == rhs." << (*m_iter)->get_name() << "))" << endl <<
+            indent() << "  return false;" << endl;
         } else {
-          out << indent() << "if (__isset." << (*m_iter)->get_name() << " != rhs.__isset."
-              << (*m_iter)->get_name() << ")" << endl << indent() << "  return false;" << endl
-              << indent() << "else if (__isset." << (*m_iter)->get_name() << " && !("
-              << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name() << "))" << endl
-              << indent() << "  return false;" << endl;
+          out <<
+            indent() << "if (__isset." << (*m_iter)->get_name()
+                     << " != rhs.__isset." << (*m_iter)->get_name() << ")" << endl <<
+            indent() << "  return false;" << endl <<
+            indent() << "else if (__isset." << (*m_iter)->get_name() << " && !("
+                     << (*m_iter)->get_name() << " == rhs." << (*m_iter)->get_name()
+                     << "))" << endl <<
+            indent() << "  return false;" << endl;
         }
       }
       indent(out) << "return true;" << endl;
       scope_down(out);
-      out << indent() << "bool operator != (const " << tstruct->get_name() << " &rhs) const {"
-          << endl << indent() << "  return !(*this == rhs);" << endl << indent() << "}" << endl
-          << endl;
+      out <<
+        indent() << "bool operator != (const " << tstruct->get_name() << " &rhs) const {" << endl <<
+        indent() << "  return !(*this == rhs);" << endl <<
+        indent() << "}" << endl << endl;
 
       // 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;" << endl << endl;
     }
   }
 
   if (read) {
     if (gen_templates_) {
-      out << indent() << "template <class Protocol_>" << endl << indent()
-          << "uint32_t read(Protocol_* iprot);" << endl;
+      out <<
+        indent() << "template <class Protocol_>" << endl <<
+        indent() << "uint32_t read(Protocol_* iprot);" << endl;
     } else {
-      out << indent() << "uint32_t read("
-          << "::apache::thrift::protocol::TProtocol* iprot);" << endl;
+      out <<
+        indent() << "uint32_t read(" <<
+        "::apache::thrift::protocol::TProtocol* iprot);" << endl;
     }
   }
   if (write) {
     if (gen_templates_) {
-      out << indent() << "template <class Protocol_>" << endl << indent()
-          << "uint32_t write(Protocol_* oprot) const;" << endl;
+      out <<
+        indent() << "template <class Protocol_>" << endl <<
+        indent() << "uint32_t write(Protocol_* oprot) const;" << endl;
     } else {
-      out << indent() << "uint32_t write("
-          << "::apache::thrift::protocol::TProtocol* oprot) const;" << endl;
+      out <<
+        indent() << "uint32_t write(" <<
+        "::apache::thrift::protocol::TProtocol* oprot) const;" << endl;
     }
   }
   out << endl;
@@ -1039,12 +1151,16 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
   out << ";" << endl;
 
   indent_down();
-  indent(out) << "};" << endl << endl;
+  indent(out) <<
+    "};" << endl <<
+    endl;
 
   if (swap) {
     // Generate a namespace-scope swap() function
-    out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name()
-        << " &b);" << endl << endl;
+    out <<
+      indent() << "void swap(" << tstruct->get_name() << " &a, " <<
+      tstruct->get_name() << " &b);" << endl <<
+      endl;
   }
 }
 
@@ -1056,10 +1172,12 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
   vector<t_field*>::const_iterator m_iter;
   const vector<t_field*>& members = tstruct->get_members();
 
+
   // Destructor
   if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
-    force_cpp_out << endl << indent() << tstruct->get_name() << "::~" << tstruct->get_name()
-                  << "() throw() {" << endl;
+    force_cpp_out <<
+      endl <<
+      indent() << tstruct->get_name() << "::~" << tstruct->get_name() << "() throw() {" << endl;
     indent_up();
 
     indent_down();
@@ -1071,13 +1189,16 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if (is_reference((*m_iter))) {
         std::string type = type_name((*m_iter)->get_type());
-        out << endl << indent() << "void " << tstruct->get_name() << "::__set_"
-            << (*m_iter)->get_name() << "(boost::shared_ptr<"
-            << type_name((*m_iter)->get_type(), false, false) << ">";
+        out <<
+          endl <<
+          indent() << "void " << tstruct->get_name() << "::__set_" << (*m_iter)->get_name() <<
+          "(boost::shared_ptr<" << type_name((*m_iter)->get_type(), false, false) << ">";
         out << " val) {" << endl;
       } else {
-        out << endl << indent() << "void " << tstruct->get_name() << "::__set_"
-            << (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type(), false, true);
+        out <<
+          endl <<
+          indent() << "void " << tstruct->get_name() << "::__set_" << (*m_iter)->get_name() <<
+          "(" << type_name((*m_iter)->get_type(), false, true);
         out << " val) {" << endl;
       }
       indent_up();
@@ -1088,9 +1209,12 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
       // 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;" << endl;
       }
-      out << indent() << "}" << endl;
+      out <<
+        indent()<< "}" << endl;
     }
   }
   out << endl;
@@ -1115,13 +1239,16 @@ void t_cpp_generator::generate_struct_fingerprint(ofstream& out,
     comment = "; // ";
   }
 
-  if (!tstruct->has_fingerprint()) {
-    tstruct->generate_fingerprint(); // lazy fingerprint generation
+  if (! tstruct->has_fingerprint()) {
+    tstruct->generate_fingerprint();  // lazy fingerprint generation
   }
   if (tstruct->has_fingerprint()) {
-    out << indent() << stat << "const char* " << nspace << "ascii_fingerprint" << comment << "= \""
-        << tstruct->get_ascii_fingerprint() << "\";" << endl << indent() << stat << "const uint8_t "
-        << nspace << "binary_fingerprint[" << t_type::fingerprint_len << "]" << comment << "= {";
+    out <<
+      indent() << stat << "const char* " << nspace
+        << "ascii_fingerprint" << comment << "= \"" <<
+        tstruct->get_ascii_fingerprint() << "\";" << endl <<
+      indent() << stat << "const uint8_t " << nspace <<
+        "binary_fingerprint[" << t_type::fingerprint_len << "]" << comment << "= {";
     const char* comma = "";
     for (int i = 0; i < t_type::fingerprint_len; i++) {
       out << comma << "0x" << t_struct::byte_to_hex(tstruct->get_binary_fingerprint()[i]);
@@ -1142,7 +1269,7 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
   }
   ttype = get_true_type(ttype);
   string key = ttype->get_ascii_fingerprint() + (is_definition ? "-defn" : "-decl");
-  assert(ttype->has_fingerprint()); // test AFTER get due to lazy fingerprint generation
+  assert(ttype->has_fingerprint());  // test AFTER get due to lazy fingerprint generation
 
   // Note that we have generated this fingerprint.  If we already did, bail out.
   if (!reflected_fingerprints_.insert(key).second) {
@@ -1176,34 +1303,40 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
 
     // For definitions of structures, do the arrays of metas and field specs also.
     if (is_definition) {
-      out << indent() << "::apache::thrift::reflection::local::FieldMeta" << endl << indent()
-          << local_reflection_name("metas", ttype) << "[] = {" << endl;
+      out <<
+        indent() << "::apache::thrift::reflection::local::FieldMeta" << endl <<
+        indent() << local_reflection_name("metas", ttype) <<"[] = {" << endl;
       indent_up();
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        indent(out) << "{ " << (*m_iter)->get_key() << ", "
-                    << (((*m_iter)->get_req() == t_field::T_OPTIONAL) ? "true" : "false") << " },"
-                    << endl;
+        indent(out) << "{ " << (*m_iter)->get_key() << ", " <<
+          (((*m_iter)->get_req() == t_field::T_OPTIONAL) ? "true" : "false") <<
+          " }," << endl;
       }
       // Zero for the T_STOP marker.
       indent(out) << "{ 0, false }" << endl << "};" << endl;
       indent_down();
 
-      out << indent() << "::apache::thrift::reflection::local::TypeSpec*" << endl << indent()
-          << local_reflection_name("specs", ttype) << "[] = {" << endl;
+      out <<
+        indent() << "::apache::thrift::reflection::local::TypeSpec*" << endl <<
+        indent() << local_reflection_name("specs", ttype) <<"[] = {" << endl;
       indent_up();
       for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-        indent(out) << "&" << local_reflection_name("typespec", (*m_iter)->get_type(), true) << ","
-                    << endl;
+        indent(out) << "&" <<
+          local_reflection_name("typespec", (*m_iter)->get_type(), true) << "," << endl;
       }
-      indent(out) << "&" << local_reflection_name("typespec", g_type_void) << "," << endl;
+      indent(out) << "&" <<
+        local_reflection_name("typespec", g_type_void) << "," << endl;
       indent_down();
       indent(out) << "};" << endl;
     }
   }
 
-  out << indent() << "// " << ttype->get_fingerprint_material() << endl << indent()
-      << (is_definition ? "" : "extern ") << "::apache::thrift::reflection::local::TypeSpec" << endl
-      << local_reflection_name("typespec", ttype) << (is_definition ? "(" : ";") << endl;
+  out <<
+    indent() << "// " << ttype->get_fingerprint_material() << endl <<
+    indent() << (is_definition ? "" : "extern ") <<
+      "::apache::thrift::reflection::local::TypeSpec" << endl <<
+      local_reflection_name("typespec", ttype) <<
+      (is_definition ? "(" : ";") << endl;
 
   if (!is_definition) {
     out << endl;
@@ -1219,22 +1352,22 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
   }
 
   if (ttype->is_struct()) {
-    out << "," << endl << indent() << type_name(ttype) << "::binary_fingerprint," << endl
-        << indent() << local_reflection_name("metas", ttype) << "," << endl << indent()
-        << local_reflection_name("specs", ttype);
+    out << "," << endl <<
+      indent() << type_name(ttype) << "::binary_fingerprint," << endl <<
+      indent() << local_reflection_name("metas", ttype) << "," << endl <<
+      indent() << local_reflection_name("specs", ttype);
   } else if (ttype->is_list()) {
-    out << "," << endl << indent() << "&"
-        << local_reflection_name("typespec", ((t_list*)ttype)->get_elem_type(), true) << "," << endl
-        << indent() << "NULL";
+    out << "," << endl <<
+      indent() << "&" << local_reflection_name("typespec", ((t_list*)ttype)->get_elem_type(), true) << "," << endl <<
+      indent() << "NULL";
   } else if (ttype->is_set()) {
-    out << "," << endl << indent() << "&"
-        << local_reflection_name("typespec", ((t_set*)ttype)->get_elem_type(), true) << "," << endl
-        << indent() << "NULL";
+    out << "," << endl <<
+      indent() << "&" << local_reflection_name("typespec", ((t_set*)ttype)->get_elem_type(), true) << "," << endl <<
+      indent() << "NULL";
   } else if (ttype->is_map()) {
-    out << "," << endl << indent() << "&"
-        << local_reflection_name("typespec", ((t_map*)ttype)->get_key_type(), true) << "," << endl
-        << indent() << "&"
-        << local_reflection_name("typespec", ((t_map*)ttype)->get_val_type(), true);
+    out << "," << endl <<
+      indent() << "&" << local_reflection_name("typespec", ((t_map*)ttype)->get_key_type(), true) << "," << endl <<
+      indent() << "&" << local_reflection_name("typespec", ((t_map*)ttype)->get_val_type(), true);
   }
 
   out << ");" << endl << endl;
@@ -1246,13 +1379,16 @@ void t_cpp_generator::generate_local_reflection(std::ofstream& out,
  * Writes the structure's static pointer to its local reflection typespec
  * into the implementation file.
  */
-void t_cpp_generator::generate_local_reflection_pointer(std::ofstream& out, t_type* ttype) {
+void t_cpp_generator::generate_local_reflection_pointer(std::ofstream& out,
+                                                        t_type* ttype) {
   if (!gen_dense_) {
     return;
   }
-  indent(out) << "::apache::thrift::reflection::local::TypeSpec* " << ttype->get_name()
-              << "::local_reflection = " << endl << indent() << "  &"
-              << local_reflection_name("typespec", ttype) << ";" << endl << endl;
+  indent(out) <<
+    "::apache::thrift::reflection::local::TypeSpec* " <<
+      ttype->get_name() << "::local_reflection = " << endl <<
+    indent() << "  &" << local_reflection_name("typespec", ttype) << ";" <<
+    endl << endl;
 }
 
 /**
@@ -1261,13 +1397,18 @@ void t_cpp_generator::generate_local_reflection_pointer(std::ofstream& out, t_ty
  * @param out Stream to write to
  * @param tstruct The struct
  */
-void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, bool pointers) {
+void t_cpp_generator::generate_struct_reader(ofstream& 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_>" << endl <<
+      indent() << "uint32_t " << tstruct->get_name() <<
+      "::read(Protocol_* iprot) {" << endl;
   } else {
-    indent(out) << "uint32_t " << tstruct->get_name()
-                << "::read(::apache::thrift::protocol::TProtocol* iprot) {" << endl;
+    indent(out) <<
+      "uint32_t " << tstruct->get_name() <<
+      "::read(::apache::thrift::protocol::TProtocol* iprot) {" << endl;
   }
   indent_up();
 
@@ -1275,11 +1416,17 @@ void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, b
   vector<t_field*>::const_iterator f_iter;
 
   // Declare stack tmp variables
-  out << 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 <<
+    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;
 
   // 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) {
@@ -1288,34 +1435,44 @@ void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, b
   }
   out << endl;
 
+
   // Loop over reading in fields
-  indent(out) << "while (true)" << endl;
-  scope_up(out);
+  indent(out) <<
+    "while (true)" << endl;
+    scope_up(out);
 
-  // Read beginning field marker
-  indent(out) << "xfer += iprot->readFieldBegin(fname, ftype, fid);" << endl;
+    // Read beginning field marker
+    indent(out) <<
+      "xfer += iprot->readFieldBegin(fname, ftype, fid);" << endl;
 
-  // Check for field STOP marker
-  out << indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << endl << indent()
-      << "  break;" << endl << indent() << "}" << endl;
+    // Check for field STOP marker
+    out <<
+      indent() << "if (ftype == ::apache::thrift::protocol::T_STOP) {" << endl <<
+      indent() << "  break;" << endl <<
+      indent() << "}" << endl;
 
-  if (fields.empty()) {
-    out << indent() << "xfer += iprot->skip(ftype);" << endl;
-  } else {
-    // Switch statement on the field we are reading
-    indent(out) << "switch (fid)" << endl;
+    if(fields.empty()) {
+      out <<
+        indent() << "xfer += iprot->skip(ftype);" << endl;
+    }
+    else {
+      // Switch statement on the field we are reading
+      indent(out) <<
+        "switch (fid)" << endl;
 
-    scope_up(out);
+        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_up();
-      indent(out) << "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
-      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_up();
+          indent(out) <<
+            "if (ftype == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+          indent_up();
 
-      const char* isset_prefix = ((*f_iter)->get_req() != t_field::T_REQUIRED) ? "this->__isset."
-                                                                               : "isset_";
+          const char *isset_prefix =
+            ((*f_iter)->get_req() != t_field::T_REQUIRED) ? "this->__isset." : "isset_";
 
 #if 0
           // This code throws an exception if the same field is encountered twice.
@@ -1327,34 +1484,42 @@ void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, b
             indent() << "  throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
 #endif
 
-      if (pointers && !(*f_iter)->get_type()->is_xception()) {
-        generate_deserialize_field(out, *f_iter, "(*(this->", "))");
-      } else {
-        generate_deserialize_field(out, *f_iter, "this->");
+          if (pointers && !(*f_iter)->get_type()->is_xception()) {
+            generate_deserialize_field(out, *f_iter, "(*(this->", "))");
+          } else {
+            generate_deserialize_field(out, *f_iter, "this->");
+          }
+          out <<
+            indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << endl;
+          indent_down();
+          out <<
+            indent() << "} else {" << endl <<
+            indent() << "  xfer += iprot->skip(ftype);" << endl <<
+            // 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_down();
       }
-      out << indent() << isset_prefix << (*f_iter)->get_name() << " = true;" << endl;
-      indent_down();
-      out << indent() << "} else {" << endl << indent() << "  xfer += iprot->skip(ftype);" << endl
-          <<
-          // 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_down();
-    }
 
-    // In the default case we skip the field
-    out << indent() << "default:" << endl << indent() << "  xfer += iprot->skip(ftype);" << endl
-        << indent() << "  break;" << endl;
+      // In the default case we skip the field
+      out <<
+        indent() << "default:" << endl <<
+        indent() << "  xfer += iprot->skip(ftype);" << endl <<
+        indent() << "  break;" << endl;
 
-    scope_down(out);
-  } //!fields.empty()
-  // Read field end marker
-  indent(out) << "xfer += iprot->readFieldEnd();" << endl;
+      scope_down(out);
+    } //!fields.empty()
+    // Read field end marker
+    indent(out) <<
+      "xfer += iprot->readFieldEnd();" << endl;
 
-  scope_down(out);
+    scope_down(out);
 
-  out << endl << indent() << "xfer += iprot->readStructEnd();" << endl;
+  out <<
+    endl <<
+    indent() << "xfer += iprot->readStructEnd();" << endl;
 
   // Throw if any required fields are missing.
   // We do this after reading the struct end so that
@@ -1362,14 +1527,16 @@ void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, b
   out << endl;
   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() << ')' << endl <<
+        indent() << "  throw TProtocolException(TProtocolException::INVALID_DATA);" << endl;
   }
 
   indent(out) << "return xfer;" << endl;
 
   indent_down();
-  indent(out) << "}" << endl << endl;
+  indent(out) <<
+    "}" << endl << endl;
 }
 
 /**
@@ -1378,28 +1545,35 @@ void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, b
  * @param out Stream to write to
  * @param tstruct The struct
  */
-void t_cpp_generator::generate_struct_writer(ofstream& out, t_struct* tstruct, bool pointers) {
+void t_cpp_generator::generate_struct_writer(ofstream& out,
+                                             t_struct* tstruct,
+                                             bool pointers) {
   string name = tstruct->get_name();
   const vector<t_field*>& fields = tstruct->get_sorted_members();
   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_>" << endl <<
+      indent() << "uint32_t " << tstruct->get_name() <<
+      "::write(Protocol_* oprot) const {" << endl;
   } else {
-    indent(out) << "uint32_t " << tstruct->get_name()
-                << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
+    indent(out) <<
+      "uint32_t " << tstruct->get_name() <<
+      "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
   }
   indent_up();
 
-  out << indent() << "uint32_t xfer = 0;" << endl;
+  out <<
+    indent() << "uint32_t xfer = 0;" << endl;
 
   indent(out) << "oprot->incrementRecursionDepth();" << endl;
-  indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
+  indent(out) <<
+    "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
 
   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();
+    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;
       indent_up();
@@ -1408,9 +1582,11 @@ void t_cpp_generator::generate_struct_writer(ofstream& out, t_struct* tstruct, b
     }
 
     // Write field header
-    out << indent() << "xfer += oprot->writeFieldBegin("
-        << "\"" << (*f_iter)->get_name() << "\", " << type_to_enum((*f_iter)->get_type()) << ", "
-        << (*f_iter)->get_key() << ");" << endl;
+    out <<
+      indent() << "xfer += oprot->writeFieldBegin(" <<
+      "\"" << (*f_iter)->get_name() << "\", " <<
+      type_to_enum((*f_iter)->get_type()) << ", " <<
+      (*f_iter)->get_key() << ");" << endl;
     // Write field contents
     if (pointers && !(*f_iter)->get_type()->is_xception()) {
       generate_serialize_field(out, *f_iter, "(*(this->", "))");
@@ -1418,7 +1594,8 @@ void t_cpp_generator::generate_struct_writer(ofstream& out, t_struct* tstruct, b
       generate_serialize_field(out, *f_iter, "this->");
     }
     // Write field closer
-    indent(out) << "xfer += oprot->writeFieldEnd();" << endl;
+    indent(out) <<
+      "xfer += oprot->writeFieldEnd();" << endl;
     if (check_if_set) {
       indent_down();
       indent(out) << '}';
@@ -1428,12 +1605,16 @@ void t_cpp_generator::generate_struct_writer(ofstream& out, t_struct* tstruct, b
   out << endl;
 
   // Write the struct map
-  out << indent() << "xfer += oprot->writeFieldStop();" << endl << indent()
-      << "xfer += oprot->writeStructEnd();" << endl << indent()
-      << "oprot->decrementRecursionDepth();" << endl << indent() << "return xfer;" << endl;
+  out <<
+    indent() << "xfer += oprot->writeFieldStop();" << endl <<
+    indent() << "xfer += oprot->writeStructEnd();" << endl <<
+    indent() << "oprot->decrementRecursionDepth();" << endl <<
+    indent() << "return xfer;" << endl;
 
   indent_down();
-  indent(out) << "}" << endl << endl;
+  indent(out) <<
+    "}" << endl <<
+    endl;
 }
 
 /**
@@ -1452,25 +1633,35 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
   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_>" << endl <<
+      indent() << "uint32_t " << tstruct->get_name() <<
+      "::write(Protocol_* oprot) const {" << endl;
   } else {
-    indent(out) << "uint32_t " << tstruct->get_name()
-                << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
+    indent(out) <<
+      "uint32_t " << tstruct->get_name() <<
+      "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl;
   }
   indent_up();
 
-  out << endl << indent() << "uint32_t xfer = 0;" << endl << endl;
+  out <<
+    endl <<
+    indent() << "uint32_t xfer = 0;" << endl <<
+    endl;
 
-  indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
+  indent(out) <<
+    "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl;
 
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      out << endl << indent() << "if ";
+      out <<
+        endl <<
+        indent() << "if ";
     } else {
-      out << " else if ";
+      out <<
+        " else if ";
     }
 
     out << "(this->__isset." << (*f_iter)->get_name() << ") {" << endl;
@@ -1478,9 +1669,11 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
     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;
+    out <<
+      indent() << "xfer += oprot->writeFieldBegin(" <<
+      "\"" << (*f_iter)->get_name() << "\", " <<
+      type_to_enum((*f_iter)->get_type()) << ", " <<
+      (*f_iter)->get_key() << ");" << endl;
     // Write field contents
     if (pointers) {
       generate_serialize_field(out, *f_iter, "(*(this->", "))");
@@ -1495,11 +1688,16 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
   }
 
   // Write the struct map
-  out << endl << indent() << "xfer += oprot->writeFieldStop();" << endl << indent()
-      << "xfer += oprot->writeStructEnd();" << endl << indent() << "return xfer;" << endl;
+  out <<
+    endl <<
+    indent() << "xfer += oprot->writeFieldStop();" << endl <<
+    indent() << "xfer += oprot->writeStructEnd();" << endl <<
+    indent() << "return xfer;" << endl;
 
   indent_down();
-  indent(out) << "}" << endl << endl;
+  indent(out) <<
+    "}" << endl <<
+    endl;
 }
 
 /**
@@ -1509,76 +1707,93 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out,
  * @param tstruct The struct
  */
 void t_cpp_generator::generate_struct_swap(ofstream& out, t_struct* tstruct) {
-  out << indent() << "void swap(" << tstruct->get_name() << " &a, " << tstruct->get_name()
-      << " &b) {" << endl;
+  out <<
+    indent() << "void swap(" << tstruct->get_name() << " &a, " <<
+    tstruct->get_name() << " &b) {" << endl;
   indent_up();
 
   // 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;" << endl;
 
   bool has_nonrequired_fields = false;
   const vector<t_field*>& fields = tstruct->get_members();
-  for (vector<t_field*>::const_iterator f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    t_field* tfield = *f_iter;
+  for (vector<t_field*>::const_iterator f_iter = fields.begin();
+       f_iter != fields.end();
+       ++f_iter) {
+    t_field *tfield = *f_iter;
 
     if (tfield->get_req() != t_field::T_REQUIRED) {
       has_nonrequired_fields = true;
     }
 
-    out << indent() << "swap(a." << tfield->get_name() << ", b." << tfield->get_name() << ");"
-        << endl;
+    out <<
+      indent() << "swap(a." << tfield->get_name() <<
+      ", b." << tfield->get_name() << ");" << endl;
   }
 
   if (has_nonrequired_fields) {
-    out << indent() << "swap(a.__isset, b.__isset);" << endl;
+    out <<
+      indent() << "swap(a.__isset, b.__isset);" << endl;
   }
 
   // handle empty structs
   if (fields.size() == 0) {
-    out << indent() << "(void) a;" << endl;
-    out << indent() << "(void) b;" << endl;
+    out <<
+      indent() << "(void) a;" << endl;
+    out <<
+      indent() << "(void) b;" << endl;
   }
 
   scope_down(out);
   out << endl;
 }
 
-void t_cpp_generator::generate_struct_ostream_operator_decl(std::ofstream& out, t_struct* tstruct) {
-  out << "std::ostream& operator<<(std::ostream& out, const " << tstruct->get_name() << "& obj)";
+void t_cpp_generator::generate_struct_ostream_operator_decl(std::ofstream& out,
+                                                            t_struct* tstruct) {
+  out << "std::ostream& operator<<(std::ostream& out, const "
+      << tstruct->get_name() << "& obj)";
 }
 
-namespace struct_ostream_operator_generator {
-void generate_required_field_value(std::ofstream& out, const t_field* field) {
+namespace struct_ostream_operator_generator
+{
+void generate_required_field_value(std::ofstream& out, const t_field* field)
+{
   out << " << to_string(obj." << field->get_name() << ")";
 }
 
-void generate_optional_field_value(std::ofstream& out, const t_field* field) {
+void generate_optional_field_value(std::ofstream& out, const t_field* field)
+{
   out << "; (obj.__isset." << field->get_name() << " ? (out";
   generate_required_field_value(out, field);
   out << ") : (out << \"<null>\"))";
 }
 
-void generate_field_value(std::ofstream& out, const t_field* field) {
+void generate_field_value(std::ofstream& out, const t_field* field)
+{
   if (field->get_req() == t_field::T_OPTIONAL)
     generate_optional_field_value(out, field);
   else
     generate_required_field_value(out, field);
 }
 
-void generate_field_name(std::ofstream& out, const t_field* field) {
+void generate_field_name(std::ofstream& out, const t_field* field)
+{
   out << "\"" << field->get_name() << "=\"";
 }
 
-void generate_field(std::ofstream& out, const t_field* field) {
+void generate_field(std::ofstream& out, const t_field* field)
+{
   generate_field_name(out, field);
   generate_field_value(out, field);
 }
 
 void generate_fields(std::ofstream& out,
                      const vector<t_field*>& fields,
-                     const std::string& indent) {
+                     const std::string& indent)
+{
   const vector<t_field*>::const_iterator beg = fields.begin();
   const vector<t_field*>::const_iterator end = fields.end();
 
@@ -1593,35 +1808,45 @@ void generate_fields(std::ofstream& out,
     out << ";" << endl;
   }
 }
+
+
 }
 
 /**
  * Generates operator<<
  */
-void t_cpp_generator::generate_struct_ostream_operator(std::ofstream& out, t_struct* tstruct) {
+void t_cpp_generator::generate_struct_ostream_operator(std::ofstream& out,
+                                                       t_struct* tstruct) {
   out << indent();
   generate_struct_ostream_operator_decl(out, tstruct);
   out << " {" << endl;
 
   indent_up();
 
-  out << indent() << "using apache::thrift::to_string;" << endl;
+  out <<
+    indent() << "using apache::thrift::to_string;" << endl;
 
   // eliminate compiler unused warning
   const vector<t_field*>& fields = tstruct->get_members();
   if (fields.empty())
     out << indent() << "(void) obj;" << endl;
 
-  out << indent() << "out << \"" << tstruct->get_name() << "(\";" << endl;
+  out <<
+    indent() << "out << \"" << tstruct->get_name() << "(\";" << endl;
 
-  struct_ostream_operator_generator::generate_fields(out, fields, indent());
+  struct_ostream_operator_generator::generate_fields(out,
+                                                     fields,
+                                                     indent());
 
-  out << indent() << "out << \")\";" << endl << indent() << "return out;" << endl;
+  out <<
+    indent() << "out << \")\";" << endl <<
+    indent() << "return out;" << endl;
 
   indent_down();
   out << "}" << endl << endl;
 }
 
+
 /**
  * Generates a thrift service. In C++, this comprises an entirely separate
  * header and source file. The header file defines the methods and includes
@@ -1634,62 +1859,85 @@ void t_cpp_generator::generate_service(t_service* tservice) {
   string svcname = tservice->get_name();
 
   // Make output files
-  string f_header_name = get_out_dir() + svcname + ".h";
+  string f_header_name = get_out_dir()+svcname+".h";
   f_header_.open(f_header_name.c_str());
 
   // Print header file includes
-  f_header_ << autogen_comment();
-  f_header_ << "#ifndef " << svcname << "_H" << endl << "#define " << svcname << "_H" << endl
-            << endl;
+  f_header_ <<
+    autogen_comment();
+  f_header_ <<
+    "#ifndef " << svcname << "_H" << endl <<
+    "#define " << svcname << "_H" << endl <<
+    endl;
   if (gen_cob_style_) {
-    f_header_ << "#include <thrift/transport/TBufferTransports.h>" << endl << // TMemoryBuffer
-        "#include <thrift/cxxfunctional.h>" << endl
-              << "namespace apache { namespace thrift { namespace async {" << endl
-              << "class TAsyncChannel;" << endl << "}}}" << endl;
-  }
-  f_header_ << "#include <thrift/TDispatchProcessor.h>" << endl;
+    f_header_ <<
+      "#include <thrift/transport/TBufferTransports.h>" << endl << // TMemoryBuffer
+      "#include <thrift/cxxfunctional.h>" << endl <<
+      "namespace apache { namespace thrift { namespace async {" << endl <<
+      "class TAsyncChannel;" << endl <<
+      "}}}" << endl;
+  }
+  f_header_ <<
+    "#include <thrift/TDispatchProcessor.h>" << endl;
   if (gen_cob_style_) {
-    f_header_ << "#include <thrift/async/TAsyncDispatchProcessor.h>" << endl;
+    f_header_ <<
+      "#include <thrift/async/TAsyncDispatchProcessor.h>" << endl;
   }
-  f_header_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ << "_types.h\""
-            << endl;
+  f_header_ <<
+    "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
+    "_types.h\"" << endl;
 
   t_service* extends_service = tservice->get_extends();
   if (extends_service != NULL) {
-    f_header_ << "#include \"" << get_include_prefix(*(extends_service->get_program()))
-              << extends_service->get_name() << ".h\"" << endl;
+    f_header_ <<
+      "#include \"" << get_include_prefix(*(extends_service->get_program())) <<
+      extends_service->get_name() << ".h\"" << endl;
   }
 
-  f_header_ << endl << ns_open_ << endl << endl;
+  f_header_ <<
+    endl <<
+    ns_open_ << endl <<
+    endl;
 
   // Service implementation file includes
-  string f_service_name = get_out_dir() + svcname + ".cpp";
+  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_ <<
+    autogen_comment();
+  f_service_ <<
+    "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl;
   if (gen_cob_style_) {
-    f_service_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl;
+    f_service_ <<
+      "#include \"thrift/async/TAsyncChannel.h\"" << endl;
   }
   if (gen_templates_) {
-    f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\""
-               << endl;
+    f_service_ <<
+      "#include \"" << get_include_prefix(*get_program()) << svcname <<
+      ".tcc\"" << endl;
 
-    string f_service_tcc_name = get_out_dir() + svcname + ".tcc";
+    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;
+    f_service_tcc_ <<
+      autogen_comment();
+    f_service_tcc_ <<
+      "#include \"" << get_include_prefix(*get_program()) << svcname <<
+      ".h\"" << endl;
 
-    f_service_tcc_ << "#ifndef " << svcname << "_TCC" << endl << "#define " << svcname << "_TCC"
-                   << endl << endl;
+    f_service_tcc_ <<
+      "#ifndef " << svcname << "_TCC" << endl <<
+      "#define " << svcname << "_TCC" << endl <<
+      endl;
 
     if (gen_cob_style_) {
-      f_service_tcc_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl;
+      f_service_tcc_ <<
+        "#include \"thrift/async/TAsyncChannel.h\"" << endl;
     }
   }
 
-  f_service_ << endl << ns_open_ << endl << endl;
-  f_service_tcc_ << endl << ns_open_ << endl << endl;
+  f_service_ <<
+    endl << ns_open_ << endl << endl;
+  f_service_tcc_ <<
+    endl << ns_open_ << endl << endl;
 
   // Generate all the components
   generate_service_interface(tservice, "");
@@ -1713,19 +1961,30 @@ void t_cpp_generator::generate_service(t_service* tservice) {
   }
 
   // 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_ << endl <<
+    endl;
+  f_service_tcc_ <<
+    ns_close_ << endl <<
+    endl;
+  f_header_ <<
+    ns_close_ << endl <<
+    endl;
 
   // TODO(simpkins): Make this a separate option
   if (gen_templates_) {
-    f_header_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".tcc\"" << endl
-              << "#include \"" << get_include_prefix(*get_program()) << program_name_
-              << "_types.tcc\"" << endl << endl;
+    f_header_ <<
+      "#include \"" << get_include_prefix(*get_program()) << svcname <<
+      ".tcc\"" << endl <<
+      "#include \"" << get_include_prefix(*get_program()) << program_name_ <<
+      "_types.tcc\"" << endl <<
+      endl;
   }
 
-  f_header_ << "#endif" << endl;
-  f_service_tcc_ << "#endif" << endl;
+  f_header_ <<
+    "#endif" << endl;
+  f_service_tcc_ <<
+    "#endif" << endl;
 
   // Close the files
   f_service_tcc_.close();
@@ -1778,14 +2037,17 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty
     if (gen_templates_) {
       client_name += "T";
       service_if_name += "T";
-      indent(f_header_) << "template <class Protocol_>" << endl;
+      indent(f_header_) <<
+        "template <class Protocol_>" << endl;
     }
-    indent(f_header_) << "class " << client_name << ";" << endl << endl;
+    indent(f_header_) << "class " << client_name << ";" <<
+      endl << endl;
   }
 
   string extends = "";
   if (tservice->get_extends() != NULL) {
-    extends = " : virtual public " + type_name(tservice->get_extends()) + style + "If";
+    extends = " : virtual public " + type_name(tservice->get_extends()) +
+      style + "If";
     if (style == "CobCl" && gen_templates_) {
       // TODO(simpkins): If gen_templates_ is enabled, we currently assume all
       // parent services were also generated with templates enabled.
@@ -1796,26 +2058,33 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty
   if (style == "CobCl" && gen_templates_) {
     f_header_ << "template <class Protocol_>" << endl;
   }
-  f_header_ << "class " << service_if_name << extends << " {" << endl << " public:" << endl;
+  f_header_ <<
+    "class " << service_if_name << extends << " {" << endl <<
+    " public:" << endl;
   indent_up();
-  f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << endl;
+  f_header_ <<
+    indent() << "virtual ~" << service_if_name << "() {}" << endl;
 
   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;
+    if ((*f_iter)->has_doc()) f_header_ << endl;
     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;" << endl;
   }
   indent_down();
-  f_header_ << "};" << endl << endl;
+  f_header_ <<
+    "};" << endl << endl;
 
   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;
+    f_header_ <<
+      "typedef " << service_if_name <<
+      "< ::apache::thrift::protocol::TProtocol> " <<
+      service_name_ << style << "If;" <<
+      endl << endl;
   }
 }
 
@@ -1824,7 +2093,8 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty
  *
  * @param tservice The service to generate an interface factory for.
  */
-void t_cpp_generator::generate_service_interface_factory(t_service* tservice, string style) {
+void t_cpp_generator::generate_service_interface_factory(t_service* tservice,
+                                                         string style) {
   string service_if_name = service_name_ + style + "If";
 
   // Figure out the name of the upper-most parent class.
@@ -1855,38 +2125,56 @@ void t_cpp_generator::generate_service_interface_factory(t_service* tservice, st
   string factory_name = service_if_name + "Factory";
   string extends;
   if (tservice->get_extends() != NULL) {
-    extends = " : virtual public " + type_name(tservice->get_extends()) + style + "IfFactory";
+    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 << " {" << endl <<
+    " public:" << endl;
   indent_up();
-  f_header_ << indent() << "typedef " << service_if_name << " Handler;" << endl << endl << indent()
-            << "virtual ~" << factory_name << "() {}" << endl << endl << indent() << "virtual "
-            << service_if_name << "* getHandler("
-            << "const ::apache::thrift::TConnectionInfo& connInfo) = 0;" << endl << indent()
-            << "virtual void releaseHandler(" << base_if_name << "* /* handler */) = 0;" << endl;
+  f_header_ <<
+    indent() << "typedef " << service_if_name << " Handler;" << endl <<
+    endl <<
+    indent() << "virtual ~" << factory_name << "() {}" << endl <<
+    endl <<
+    indent() << "virtual " << service_if_name << "* getHandler(" <<
+      "const ::apache::thrift::TConnectionInfo& connInfo) = 0;" <<
+    endl <<
+    indent() << "virtual void releaseHandler(" << base_if_name <<
+    "* /* handler */) = 0;" << endl;
 
   indent_down();
-  f_header_ << "};" << endl << endl;
+  f_header_ <<
+    "};" << endl << endl;
 
   // 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;
+  f_header_ <<
+    "class " << singleton_factory_name <<
+    " : virtual public " << factory_name << " {" << endl <<
+    " public:" << endl;
   indent_up();
-  f_header_ << indent() << singleton_factory_name << "(const boost::shared_ptr<" << service_if_name
-            << ">& iface) : iface_(iface) {}" << endl << indent() << "virtual ~"
-            << singleton_factory_name << "() {}" << endl << endl << indent() << "virtual "
-            << service_if_name << "* getHandler("
-            << "const ::apache::thrift::TConnectionInfo&) {" << endl << indent()
-            << "  return iface_.get();" << endl << indent() << "}" << endl << indent()
-            << "virtual void releaseHandler(" << base_if_name << "* /* handler */) {}" << endl;
-
-  f_header_ << endl << " protected:" << endl << indent() << "boost::shared_ptr<" << service_if_name
-            << "> iface_;" << endl;
+  f_header_ <<
+    indent() << singleton_factory_name << "(const boost::shared_ptr<" <<
+    service_if_name << ">& iface) : iface_(iface) {}" << endl <<
+    indent() << "virtual ~" << singleton_factory_name << "() {}" << endl <<

<TRUNCATED>