You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by th...@apache.org on 2021/03/29 06:35:17 UTC

[avro] branch master updated: AVRO-3051: Reformatted C++ sources to make them consistent (#1154)

This is an automated email from the ASF dual-hosted git repository.

thiru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 39de1e2  AVRO-3051: Reformatted C++ sources to make them consistent (#1154)
39de1e2 is described below

commit 39de1e2049008415a01004dfefe7a875afbd66bd
Author: Thiruvalluvan M G <th...@apache.org>
AuthorDate: Mon Mar 29 12:05:08 2021 +0530

    AVRO-3051: Reformatted C++ sources to make them consistent (#1154)
    
    * Reformatted code to make the style consistent
    
    * Some more reformatting
    
    * Reformatted the code
    
    * Reformatted the code
    
    * Reformatted the code
    
    * Reformatted the code
    
    * Added license information for .clang-format
    
    Co-authored-by: Thiruvalluvan M G <th...@startsmartlabs.com>
---
 lang/c++/.clang-format                             |   84 +
 lang/c++/api/AvroParse.hh                          |   29 +-
 lang/c++/api/AvroSerialize.hh                      |   16 +-
 lang/c++/api/AvroTraits.hh                         |   32 +-
 lang/c++/api/Config.hh                             |   13 +-
 lang/c++/api/DataFile.hh                           |   31 +-
 lang/c++/api/Decoder.hh                            |    6 +-
 lang/c++/api/Encoder.hh                            |    6 +-
 lang/c++/api/Exception.hh                          |    3 +-
 lang/c++/api/Generic.hh                            |   11 +-
 lang/c++/api/GenericDatum.hh                       |   65 +-
 lang/c++/api/Layout.hh                             |    6 +-
 lang/c++/api/LogicalType.hh                        |    2 +-
 lang/c++/api/Node.hh                               |   20 +-
 lang/c++/api/NodeConcepts.hh                       |   25 +-
 lang/c++/api/NodeImpl.hh                           |  162 +-
 lang/c++/api/Parser.hh                             |    9 +-
 lang/c++/api/Reader.hh                             |   17 +-
 lang/c++/api/Resolver.hh                           |    6 +-
 lang/c++/api/ResolvingReader.hh                    |   11 +-
 lang/c++/api/Schema.hh                             |    2 -
 lang/c++/api/Serializer.hh                         |    9 +-
 lang/c++/api/Specific.hh                           |   21 +-
 lang/c++/api/Stream.hh                             |   15 +-
 lang/c++/api/Types.hh                              |   44 +-
 lang/c++/api/ValidSchema.hh                        |    4 +-
 lang/c++/api/Validator.hh                          |   18 +-
 lang/c++/api/Writer.hh                             |   10 +-
 lang/c++/api/Zigzag.hh                             |    3 +-
 lang/c++/api/buffer/Buffer.hh                      |  117 +-
 lang/c++/api/buffer/BufferPrint.hh                 |   26 +-
 lang/c++/api/buffer/BufferReader.hh                |   94 +-
 lang/c++/api/buffer/BufferStream.hh                |   30 +-
 lang/c++/api/buffer/BufferStreambuf.hh             |   91 +-
 lang/c++/api/buffer/detail/BufferDetail.hh         |  184 +-
 lang/c++/api/buffer/detail/BufferDetail.hh.rej     |   28 +-
 lang/c++/api/buffer/detail/BufferDetailIterator.hh |   57 +-
 lang/c++/build.sh                                  |    6 +-
 lang/c++/impl/BinaryDecoder.cc                     |   10 +-
 lang/c++/impl/BinaryEncoder.cc                     |    2 +-
 lang/c++/impl/Compiler.cc                          |   94 +-
 lang/c++/impl/DataFile.cc                          |  254 ++-
 lang/c++/impl/FileStream.cc                        |   73 +-
 lang/c++/impl/Generic.cc                           |  106 +-
 lang/c++/impl/GenericDatum.cc                      |   62 +-
 lang/c++/impl/LogicalType.cc                       |   30 +-
 lang/c++/impl/Node.cc                              |    9 +-
 lang/c++/impl/NodeImpl.cc                          |  138 +-
 lang/c++/impl/Resolver.cc                          |  201 +-
 lang/c++/impl/ResolverSchema.cc                    |    6 +-
 lang/c++/impl/Schema.cc                            |   37 +-
 lang/c++/impl/Stream.cc                            |   65 +-
 lang/c++/impl/Types.cc                             |   23 +-
 lang/c++/impl/ValidSchema.cc                       |   25 +-
 lang/c++/impl/Validator.cc                         |   88 +-
 lang/c++/impl/Zigzag.cc                            |    1 -
 lang/c++/impl/avrogencpp.cc                        |  613 +++---
 lang/c++/impl/json/JsonDom.cc                      |  147 +-
 lang/c++/impl/json/JsonDom.hh                      |   79 +-
 lang/c++/impl/json/JsonIO.cc                       |  391 ++--
 lang/c++/impl/json/JsonIO.hh                       |  142 +-
 lang/c++/impl/parsing/JsonCodec.cc                 |  404 ++--
 lang/c++/impl/parsing/ResolvingDecoder.cc          |  565 +++---
 lang/c++/impl/parsing/Symbol.cc                    |   25 +-
 lang/c++/impl/parsing/Symbol.hh                    |  486 +++--
 lang/c++/impl/parsing/ValidatingCodec.cc           |  298 ++-
 lang/c++/impl/parsing/ValidatingCodec.hh           |   18 +-
 lang/c++/test/AvrogencppTestReservedWords.cc       |   35 +-
 lang/c++/test/AvrogencppTests.cc                   |  104 +-
 lang/c++/test/CodecTests.cc                        | 1944 ++++++++++----------
 lang/c++/test/CompilerTests.cc                     |   14 +-
 lang/c++/test/DataFileTests.cc                     |  416 ++---
 lang/c++/test/JsonTests.cc                         |  131 +-
 lang/c++/test/LargeSchemaTests.cc                  |   16 +-
 lang/c++/test/SchemaTests.cc                       |  167 +-
 lang/c++/test/SpecificTests.cc                     |   86 +-
 lang/c++/test/StreamTests.cc                       |  121 +-
 lang/c++/test/buffertest.cc                        |  391 ++--
 lang/c++/test/precompile.cc                        |    8 +-
 lang/c++/test/testgentest.cc                       |  202 +-
 lang/c++/test/testparser.cc                        |    6 +-
 lang/c++/test/unittest.cc                          |  306 ++-
 82 files changed, 4453 insertions(+), 5199 deletions(-)

diff --git a/lang/c++/.clang-format b/lang/c++/.clang-format
new file mode 100644
index 0000000..368b39a
--- /dev/null
+++ b/lang/c++/.clang-format
@@ -0,0 +1,84 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# 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
+#
+#     https://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 KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Generated from CLion C/C++ Code Style settings
+BasedOnStyle: LLVM
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignOperands: false
+AllowAllArgumentsOnNextLine: false
+AllowAllConstructorInitializersOnNextLine: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: Always
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Always
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterReturnType: None
+AlwaysBreakTemplateDeclarations: Yes
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterCaseLabel: false
+  AfterClass: false
+  AfterControlStatement: Never
+  AfterEnum: false
+  AfterFunction: false
+  AfterNamespace: false
+  AfterUnion: false
+  BeforeCatch: false
+  BeforeElse: false
+  IndentBraces: false
+  SplitEmptyFunction: false
+  SplitEmptyRecord: true
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+ColumnLimit: 0
+CompactNamespaces: false
+ContinuationIndentWidth: 4
+IndentCaseLabels: true
+IndentPPDirectives: None
+IndentWidth: 4
+KeepEmptyLinesAtTheStartOfBlocks: true
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: false
+PointerAlignment: Right
+ReflowComments: false
+SpaceAfterCStyleCast: true
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+TabWidth: 4
+UseTab: Never
diff --git a/lang/c++/api/AvroParse.hh b/lang/c++/api/AvroParse.hh
index dd2b98c..b0333e8 100644
--- a/lang/c++/api/AvroParse.hh
+++ b/lang/c++/api/AvroParse.hh
@@ -19,8 +19,8 @@
 #ifndef avro_AvroParse_hh__
 #define avro_AvroParse_hh__
 
-#include "Config.hh"
 #include "AvroTraits.hh"
+#include "Config.hh"
 #include "ResolvingReader.hh"
 
 /// \file
@@ -32,29 +32,25 @@ namespace avro {
 /// The main parse entry point function.  Takes a parser (either validating or
 /// plain) and the object that should receive the parsed data.
 
-template <typename Reader, typename T>
-void parse(Reader &p, T& val)
-{
+template<typename Reader, typename T>
+void parse(Reader &p, T &val) {
     parse(p, val, is_serializable<T>());
 }
 
-template <typename T>
-void parse(ResolvingReader &p, T& val)
-{
+template<typename T>
+void parse(ResolvingReader &p, T &val) {
     translatingParse(p, val, is_serializable<T>());
 }
 
 /// Type trait should be set to is_serializable in otherwise force the compiler to complain.
 
-template <typename Reader, typename T>
-void parse(Reader &p, T& val, const std::false_type &)
-{
+template<typename Reader, typename T>
+void parse(Reader &p, T &val, const std::false_type &) {
     static_assert(sizeof(T) == 0, "Not a valid type to parse");
 }
 
-template <typename Reader, typename T>
-void translatingParse(Reader &p, T& val, const std::false_type &)
-{
+template<typename Reader, typename T>
+void translatingParse(Reader &p, T &val, const std::false_type &) {
     static_assert(sizeof(T) == 0, "Not a valid type to parse");
 }
 
@@ -62,19 +58,18 @@ void translatingParse(Reader &p, T& val, const std::false_type &)
 
 /// The remainder of the file includes default implementations for serializable types.
 
-
-template <typename Reader, typename T>
+template<typename Reader, typename T>
 void parse(Reader &p, T &val, const std::true_type &) {
     p.readValue(val);
 }
 
-template <typename Reader>
+template<typename Reader>
 void parse(Reader &p, std::vector<uint8_t> &val, const std::true_type &) {
     p.readBytes(val);
 }
 
 template<typename T>
-void translatingParse(ResolvingReader &p, T& val, const std::true_type &) {
+void translatingParse(ResolvingReader &p, T &val, const std::true_type &) {
     p.parse(val);
 }
 
diff --git a/lang/c++/api/AvroSerialize.hh b/lang/c++/api/AvroSerialize.hh
index 9495940..0bc6047 100644
--- a/lang/c++/api/AvroSerialize.hh
+++ b/lang/c++/api/AvroSerialize.hh
@@ -19,8 +19,8 @@
 #ifndef avro_AvroSerialize_hh__
 #define avro_AvroSerialize_hh__
 
-#include "Config.hh"
 #include "AvroTraits.hh"
+#include "Config.hh"
 
 /// \file
 ///
@@ -31,17 +31,15 @@ namespace avro {
 /// The main serializer entry point function.  Takes a serializer (either validating or
 /// plain) and the object that should be serialized.
 
-template <typename Writer, typename T>
-void serialize(Writer &s, const T& val)
-{
+template<typename Writer, typename T>
+void serialize(Writer &s, const T &val) {
     serialize(s, val, is_serializable<T>());
 }
 
 /// Type trait should be set to is_serializable in otherwise force the compiler to complain.
 
-template <typename Writer, typename T>
-void serialize(Writer &s, const T& val, const std::false_type &)
-{
+template<typename Writer, typename T>
+void serialize(Writer &s, const T &val, const std::false_type &) {
     static_assert(sizeof(T) == 0, "Not a valid type to serialize");
 }
 
@@ -49,12 +47,12 @@ void serialize(Writer &s, const T& val, const std::false_type &)
 
 // @{
 
-template <typename Writer, typename T>
+template<typename Writer, typename T>
 void serialize(Writer &s, T val, const std::true_type &) {
     s.writeValue(val);
 }
 
-template <typename Writer>
+template<typename Writer>
 void serialize(Writer &s, const std::vector<uint8_t> &val, const std::true_type &) {
     s.writeBytes(val.data(), val.size());
 }
diff --git a/lang/c++/api/AvroTraits.hh b/lang/c++/api/AvroTraits.hh
index 474c6f6..7b5a636 100644
--- a/lang/c++/api/AvroTraits.hh
+++ b/lang/c++/api/AvroTraits.hh
@@ -60,7 +60,7 @@ struct is_defined {
     typedef char no[2];
 
     template<class U>
-    static yes &test(char(*)[sizeof(U)]) { throw 0; };
+    static yes &test(char (*)[sizeof(U)]) { throw 0; };
 
     template<class U>
     static no &test(...) { throw 0; };
@@ -82,7 +82,7 @@ struct is_not_defined {
     typedef char no[2];
 
     template<class U>
-    static yes &test(char(*)[sizeof(U)]) { throw 0; };
+    static yes &test(char (*)[sizeof(U)]) { throw 0; };
 
     template<class U>
     static no &test(...) { throw 0; };
@@ -90,20 +90,20 @@ struct is_not_defined {
     static const bool value = sizeof(test<T>(0)) == sizeof(no);
 };
 
-#define DEFINE_PRIMITIVE(CTYPE, AVROTYPE) \
-template <> \
-struct is_serializable<CTYPE> : public std::true_type{}; \
-\
-template <> \
-struct type_to_avro<CTYPE> { \
-    static const Type type = AVROTYPE; \
-};
-
-#define DEFINE_PROMOTABLE_PRIMITIVE(CTYPE, AVROTYPE) \
-template <> \
-struct is_promotable<CTYPE> : public std::true_type{}; \
-\
-DEFINE_PRIMITIVE(CTYPE, AVROTYPE)
+#define DEFINE_PRIMITIVE(CTYPE, AVROTYPE)                     \
+    template<>                                                \
+    struct is_serializable<CTYPE> : public std::true_type {}; \
+                                                              \
+    template<>                                                \
+    struct type_to_avro<CTYPE> {                              \
+        static const Type type = AVROTYPE;                    \
+    };
+
+#define DEFINE_PROMOTABLE_PRIMITIVE(CTYPE, AVROTYPE)        \
+    template<>                                              \
+    struct is_promotable<CTYPE> : public std::true_type {}; \
+                                                            \
+    DEFINE_PRIMITIVE(CTYPE, AVROTYPE)
 
 DEFINE_PROMOTABLE_PRIMITIVE(int32_t, AVRO_INT)
 DEFINE_PROMOTABLE_PRIMITIVE(int64_t, AVRO_LONG)
diff --git a/lang/c++/api/Config.hh b/lang/c++/api/Config.hh
index f09afec..dd2438d 100644
--- a/lang/c++/api/Config.hh
+++ b/lang/c++/api/Config.hh
@@ -22,23 +22,22 @@
 // Windows DLL support
 
 #ifdef _WIN32
-#pragma warning (disable: 4275 4251)
+#pragma warning(disable : 4275 4251)
 
 #if defined(AVRO_DYN_LINK)
 #ifdef AVRO_SOURCE
-# define AVRO_DECL __declspec(dllexport)
+#define AVRO_DECL __declspec(dllexport)
 #else
-# define AVRO_DECL __declspec(dllimport)
-#endif  // AVRO_SOURCE
-#endif  // AVRO_DYN_LINK
+#define AVRO_DECL __declspec(dllimport)
+#endif // AVRO_SOURCE
+#endif // AVRO_DYN_LINK
 
 #include <intsafe.h>
 using ssize_t = SSIZE_T;
-#endif  // _WIN32
+#endif // _WIN32
 
 #ifndef AVRO_DECL
 #define AVRO_DECL
 #endif
 
 #endif
-
diff --git a/lang/c++/api/DataFile.hh b/lang/c++/api/DataFile.hh
index c4b1027..94a1dab 100644
--- a/lang/c++/api/DataFile.hh
+++ b/lang/c++/api/DataFile.hh
@@ -21,10 +21,10 @@
 
 #include "Config.hh"
 #include "Encoder.hh"
-#include "buffer/Buffer.hh"
-#include "ValidSchema.hh"
 #include "Specific.hh"
 #include "Stream.hh"
+#include "ValidSchema.hh"
+#include "buffer/Buffer.hh"
 
 #include <map>
 #include <string>
@@ -70,7 +70,7 @@ class AVRO_DECL DataFileWriterBase : boost::noncopyable {
     const DataFileSync sync_;
     int64_t objectCount_;
 
-    typedef std::map<std::string, std::vector<uint8_t> > Metadata;
+    typedef std::map<std::string, std::vector<uint8_t>> Metadata;
 
     Metadata metadata_;
     int64_t lastSync_;
@@ -146,17 +146,16 @@ public:
 template<typename T>
 class DataFileWriter : boost::noncopyable {
     std::unique_ptr<DataFileWriterBase> base_;
+
 public:
     /**
      * Constructs a new data file.
      */
     DataFileWriter(const char *filename, const ValidSchema &schema,
-                   size_t syncInterval = 16 * 1024, Codec codec = NULL_CODEC) :
-        base_(new DataFileWriterBase(filename, schema, syncInterval, codec)) {}
+                   size_t syncInterval = 16 * 1024, Codec codec = NULL_CODEC) : base_(new DataFileWriterBase(filename, schema, syncInterval, codec)) {}
 
     DataFileWriter(std::unique_ptr<OutputStream> outputStream, const ValidSchema &schema,
-                   size_t syncInterval = 16 * 1024, Codec codec = NULL_CODEC) :
-        base_(new DataFileWriterBase(std::move(outputStream), schema, syncInterval, codec)) {}
+                   size_t syncInterval = 16 * 1024, Codec codec = NULL_CODEC) : base_(new DataFileWriterBase(std::move(outputStream), schema, syncInterval, codec)) {}
 
     /**
      * Writes the given piece of data into the file.
@@ -206,7 +205,7 @@ class AVRO_DECL DataFileReaderBase : boost::noncopyable {
     ValidSchema dataSchema_;
     DecoderPtr dataDecoder_;
     std::unique_ptr<InputStream> dataStream_;
-    typedef std::map<std::string, std::vector<uint8_t> > Metadata;
+    typedef std::map<std::string, std::vector<uint8_t>> Metadata;
 
     Metadata metadata_;
     DataFileSync sync_{};
@@ -219,6 +218,7 @@ class AVRO_DECL DataFileReaderBase : boost::noncopyable {
 
     void readDataBlock();
     void doSeek(int64_t position);
+
 public:
     /**
      * Returns the current decoder for this reader.
@@ -305,18 +305,17 @@ public:
 template<typename T>
 class DataFileReader : boost::noncopyable {
     std::unique_ptr<DataFileReaderBase> base_;
+
 public:
     /**
      * Constructs the reader for the given file and the reader is
      * expected to use the given schema.
      */
-    DataFileReader(const char *filename, const ValidSchema &readerSchema) :
-        base_(new DataFileReaderBase(filename)) {
+    DataFileReader(const char *filename, const ValidSchema &readerSchema) : base_(new DataFileReaderBase(filename)) {
         base_->init(readerSchema);
     }
 
-    DataFileReader(std::unique_ptr<InputStream> inputStream, const ValidSchema &readerSchema) :
-        base_(new DataFileReaderBase(std::move(inputStream))) {
+    DataFileReader(std::unique_ptr<InputStream> inputStream, const ValidSchema &readerSchema) : base_(new DataFileReaderBase(std::move(inputStream))) {
         base_->init(readerSchema);
     }
 
@@ -324,13 +323,11 @@ public:
      * Constructs the reader for the given file and the reader is
      * expected to use the schema that is used with data.
      */
-    explicit DataFileReader(const char *filename) :
-        base_(new DataFileReaderBase(filename)) {
+    explicit DataFileReader(const char *filename) : base_(new DataFileReaderBase(filename)) {
         base_->init();
     }
 
-    explicit DataFileReader(std::unique_ptr<InputStream> inputStream) :
-        base_(new DataFileReaderBase(std::move(inputStream))) {
+    explicit DataFileReader(std::unique_ptr<InputStream> inputStream) : base_(new DataFileReaderBase(std::move(inputStream))) {
         base_->init();
     }
 
@@ -414,5 +411,5 @@ public:
     int64_t previousSync() { return base_->previousSync(); }
 };
 
-}   // namespace avro
+} // namespace avro
 #endif
diff --git a/lang/c++/api/Decoder.hh b/lang/c++/api/Decoder.hh
index 0cacada..77b3f94 100644
--- a/lang/c++/api/Decoder.hh
+++ b/lang/c++/api/Decoder.hh
@@ -21,12 +21,12 @@
 
 #include "Config.hh"
 #include <cstdint>
+#include <memory>
 #include <string>
 #include <vector>
-#include <memory>
 
-#include "ValidSchema.hh"
 #include "Stream.hh"
+#include "ValidSchema.hh"
 
 /// \file
 ///
@@ -220,6 +220,6 @@ AVRO_DECL DecoderPtr jsonDecoder(const ValidSchema &schema);
 AVRO_DECL ResolvingDecoderPtr resolvingDecoder(const ValidSchema &writer,
                                                const ValidSchema &reader, const DecoderPtr &base);
 
-}   // namespace avro
+} // namespace avro
 
 #endif
diff --git a/lang/c++/api/Encoder.hh b/lang/c++/api/Encoder.hh
index 8e2e41f..4ba5fa7 100644
--- a/lang/c++/api/Encoder.hh
+++ b/lang/c++/api/Encoder.hh
@@ -21,12 +21,12 @@
 
 #include "Config.hh"
 #include <cstdint>
+#include <memory>
 #include <string>
 #include <vector>
-#include <memory>
 
-#include "ValidSchema.hh"
 #include "Stream.hh"
+#include "ValidSchema.hh"
 
 /// \file
 ///
@@ -168,6 +168,6 @@ AVRO_DECL EncoderPtr jsonEncoder(const ValidSchema &schema);
  */
 AVRO_DECL EncoderPtr jsonPrettyEncoder(const ValidSchema &schema);
 
-}   // namespace avro
+} // namespace avro
 
 #endif
diff --git a/lang/c++/api/Exception.hh b/lang/c++/api/Exception.hh
index 4ab7323..691869b 100644
--- a/lang/c++/api/Exception.hh
+++ b/lang/c++/api/Exception.hh
@@ -20,8 +20,8 @@
 #define avro_Exception_hh__
 
 #include "Config.hh"
-#include <stdexcept>
 #include <boost/format.hpp>
+#include <stdexcept>
 
 namespace avro {
 
@@ -30,7 +30,6 @@ namespace avro {
 
 class AVRO_DECL Exception : public virtual std::runtime_error {
 public:
-
     explicit Exception(const std::string &msg) : std::runtime_error(msg) {}
 
     explicit Exception(const boost::format &msg) : std::runtime_error(boost::str(msg)) {}
diff --git a/lang/c++/api/Generic.hh b/lang/c++/api/Generic.hh
index 764950a..f35e8cf 100644
--- a/lang/c++/api/Generic.hh
+++ b/lang/c++/api/Generic.hh
@@ -22,10 +22,10 @@
 #include <boost/utility.hpp>
 
 #include "Config.hh"
-#include "Types.hh"
-#include "Encoder.hh"
 #include "Decoder.hh"
+#include "Encoder.hh"
 #include "GenericDatum.hh"
+#include "Types.hh"
 
 namespace avro {
 /**
@@ -37,6 +37,7 @@ class AVRO_DECL GenericReader : boost::noncopyable {
     const DecoderPtr decoder_;
 
     static void read(GenericDatum &datum, Decoder &d, bool isResolving);
+
 public:
     /**
      * Constructs a reader for the given schema using the given decoder.
@@ -83,6 +84,7 @@ class AVRO_DECL GenericWriter : boost::noncopyable {
     const EncoderPtr encoder_;
 
     static void write(const GenericDatum &datum, Encoder &e);
+
 public:
     /**
      * Constructs a writer for the given schema using the given encoder.
@@ -117,7 +119,7 @@ struct codec_traits;
  * cleaner codec_traits<GenericDatum> instead.
  */
 template<>
-struct codec_traits<std::pair<ValidSchema, GenericDatum> > {
+struct codec_traits<std::pair<ValidSchema, GenericDatum>> {
     /** Encodes */
     static void encode(Encoder &e,
                        const std::pair<ValidSchema, GenericDatum> &p) {
@@ -146,6 +148,5 @@ struct codec_traits<GenericDatum> {
     }
 };
 
-}   // namespace avro
+} // namespace avro
 #endif
-
diff --git a/lang/c++/api/GenericDatum.hh b/lang/c++/api/GenericDatum.hh
index 357bc83..378d215 100644
--- a/lang/c++/api/GenericDatum.hh
+++ b/lang/c++/api/GenericDatum.hh
@@ -20,9 +20,9 @@
 #define avro_GenericDatum_hh__
 
 #include <cstdint>
-#include <vector>
 #include <map>
 #include <string>
+#include <vector>
 
 #if __cplusplus >= 201703L
 #include <any>
@@ -79,6 +79,7 @@ protected:
         : type_(t), logicalType_(logicalType), value_(v) {}
 
     void init(const NodePtr &schema);
+
 public:
     /**
      * The avro data type this datum holds.
@@ -170,8 +171,7 @@ public:
     /// std::vector<uint8_t>.
     /// We don't make this explicit constructor because we want to allow automatic conversion
     // NOLINTNEXTLINE(google-explicit-constructor)
-    GenericDatum(const std::vector<uint8_t> &v) :
-        type_(AVRO_BYTES), logicalType_(LogicalType::NONE), value_(v) {}
+    GenericDatum(const std::vector<uint8_t> &v) : type_(AVRO_BYTES), logicalType_(LogicalType::NONE), value_(v) {}
 
     /**
      * Constructs a datum corresponding to the given avro type.
@@ -190,8 +190,7 @@ public:
      * \param v The value for this type.
      */
     template<typename T>
-    GenericDatum(const NodePtr &schema, const T &v) :
-        type_(schema->type()), logicalType_(schema->logicalType()) {
+    GenericDatum(const NodePtr &schema, const T &v) : type_(schema->type()), logicalType_(schema->logicalType()) {
         init(schema);
 #if __cplusplus >= 201703L
         *std::any_cast<T>(&value_) = v;
@@ -215,6 +214,7 @@ public:
 class AVRO_DECL GenericContainer {
     NodePtr schema_;
     static void assertType(const NodePtr &schema, Type type);
+
 protected:
     /**
      * Constructs a container corresponding to the given schema.
@@ -243,8 +243,7 @@ public:
      * and the given value. The schema should be of Avro type union
      * and the value should correspond to one of the branches of the union.
      */
-    explicit GenericUnion(const NodePtr &schema) :
-        GenericContainer(AVRO_UNION, schema), curBranch_(schema->leaves()) {
+    explicit GenericUnion(const NodePtr &schema) : GenericContainer(AVRO_UNION, schema), curBranch_(schema->leaves()) {
         selectBranch(0);
     }
 
@@ -286,6 +285,7 @@ public:
  */
 class AVRO_DECL GenericRecord : public GenericContainer {
     std::vector<GenericDatum> fields_;
+
 public:
     /**
      * Constructs a generic record corresponding to the given schema \p schema,
@@ -389,6 +389,7 @@ public:
     Value &value() {
         return value_;
     }
+
 private:
     Value value_;
 };
@@ -401,7 +402,7 @@ public:
     /**
      * The contents type for the map.
      */
-    typedef std::vector<std::pair<std::string, GenericDatum> > Value;
+    typedef std::vector<std::pair<std::string, GenericDatum>> Value;
 
     /**
      * Constructs a generic map corresponding to the given schema \p schema,
@@ -423,6 +424,7 @@ public:
     Value &value() {
         return value_;
     }
+
 private:
     Value value_;
 };
@@ -446,12 +448,10 @@ public:
      * Constructs a generic enum corresponding to the given schema \p schema,
      * which should be of Avro type enum.
      */
-    explicit GenericEnum(const NodePtr &schema) :
-        GenericContainer(AVRO_ENUM, schema), value_(0) {
+    explicit GenericEnum(const NodePtr &schema) : GenericContainer(AVRO_ENUM, schema), value_(0) {
     }
 
-    GenericEnum(const NodePtr &schema, const std::string &symbol) :
-        GenericContainer(AVRO_ENUM, schema), value_(index(schema, symbol)) {
+    GenericEnum(const NodePtr &schema, const std::string &symbol) : GenericContainer(AVRO_ENUM, schema), value_(index(schema, symbol)) {
     }
 
     /**
@@ -511,6 +511,7 @@ public:
  */
 class AVRO_DECL GenericFixed : public GenericContainer {
     std::vector<uint8_t> value_;
+
 public:
     /**
      * Constructs a generic enum corresponding to the given schema \p schema,
@@ -539,12 +540,14 @@ public:
 
 inline Type GenericDatum::type() const {
     return (type_ == AVRO_UNION) ?
-           #if __cplusplus >= 201703L
-           std::any_cast<GenericUnion>(&value_)->datum().type() :
-           #else
-           boost::any_cast<GenericUnion>(&value_)->datum().type() :
-           #endif
-           type_;
+#if __cplusplus >= 201703L
+                                 std::any_cast<GenericUnion>(&value_)->datum().type()
+                                 :
+#else
+                                 boost::any_cast<GenericUnion>(&value_)->datum().type()
+                                 :
+#endif
+                                 type_;
 }
 
 inline LogicalType GenericDatum::logicalType() const {
@@ -554,24 +557,24 @@ inline LogicalType GenericDatum::logicalType() const {
 template<typename T>
 T &GenericDatum::value() {
     return (type_ == AVRO_UNION) ?
-           #if __cplusplus >= 201703L
-           std::any_cast<GenericUnion>(&value_)->datum().value<T>() :
-        *std::any_cast<T>(&value_);
-           #else
-           boost::any_cast<GenericUnion>(&value_)->datum().value<T>() :
-           *boost::any_cast<T>(&value_);
+#if __cplusplus >= 201703L
+                                 std::any_cast<GenericUnion>(&value_)->datum().value<T>()
+                                 : *std::any_cast<T>(&value_);
+#else
+                                 boost::any_cast<GenericUnion>(&value_)->datum().value<T>()
+                                 : *boost::any_cast<T>(&value_);
 #endif
 }
 
 template<typename T>
 const T &GenericDatum::value() const {
     return (type_ == AVRO_UNION) ?
-           #if __cplusplus >= 201703L
-           std::any_cast<GenericUnion>(&value_)->datum().value<T>() :
-        *std::any_cast<T>(&value_);
-           #else
-           boost::any_cast<GenericUnion>(&value_)->datum().value<T>() :
-           *boost::any_cast<T>(&value_);
+#if __cplusplus >= 201703L
+                                 std::any_cast<GenericUnion>(&value_)->datum().value<T>()
+                                 : *std::any_cast<T>(&value_);
+#else
+                                 boost::any_cast<GenericUnion>(&value_)->datum().value<T>()
+                                 : *boost::any_cast<T>(&value_);
 #endif
 }
 
@@ -591,5 +594,5 @@ inline void GenericDatum::selectBranch(size_t branch) {
 #endif
 }
 
-}   // namespace avro
+} // namespace avro
 #endif // avro_GenericDatum_hh__
diff --git a/lang/c++/api/Layout.hh b/lang/c++/api/Layout.hh
index a71cf3e..56d2c1d 100644
--- a/lang/c++/api/Layout.hh
+++ b/lang/c++/api/Layout.hh
@@ -19,8 +19,8 @@
 #ifndef avro_Layout_hh__
 #define avro_Layout_hh__
 
-#include <boost/noncopyable.hpp>
 #include "Config.hh"
+#include <boost/noncopyable.hpp>
 
 /// \file Layout.hh
 ///
@@ -49,7 +49,6 @@ public:
 class AVRO_DECL CompoundLayout : public Layout {
 
 public:
-
     explicit CompoundLayout(size_t offset = 0) : Layout(offset) {}
 
     void add(std::unique_ptr<Layout> &layout) {
@@ -61,8 +60,7 @@ public:
     }
 
 private:
-
-    std::vector<std::unique_ptr<Layout> > layouts_;
+    std::vector<std::unique_ptr<Layout>> layouts_;
 };
 
 } // namespace avro
diff --git a/lang/c++/api/LogicalType.hh b/lang/c++/api/LogicalType.hh
index c21fafb..4d06e74 100644
--- a/lang/c++/api/LogicalType.hh
+++ b/lang/c++/api/LogicalType.hh
@@ -60,6 +60,6 @@ private:
     int scale_;
 };
 
-}  // namespace avro
+} // namespace avro
 
 #endif
diff --git a/lang/c++/api/Node.hh b/lang/c++/api/Node.hh
index f6693cc..3c9389d 100644
--- a/lang/c++/api/Node.hh
+++ b/lang/c++/api/Node.hh
@@ -21,15 +21,15 @@
 
 #include "Config.hh"
 
+#include <boost/noncopyable.hpp>
 #include <cassert>
 #include <memory>
-#include <boost/noncopyable.hpp>
 #include <utility>
 
 #include "Exception.hh"
 #include "LogicalType.hh"
-#include "Types.hh"
 #include "SchemaResolution.hh"
+#include "Types.hh"
 
 namespace avro {
 
@@ -41,6 +41,7 @@ using NodePtr = std::shared_ptr<Node>;
 class AVRO_DECL Name {
     std::string ns_;
     std::string simpleName_;
+
 public:
     Name() = default;
     explicit Name(const std::string &fullname);
@@ -67,8 +68,7 @@ public:
     }
 };
 
-inline
-std::ostream &operator<<(std::ostream &os, const Name &n) {
+inline std::ostream &operator<<(std::ostream &os, const Name &n) {
     return os << n.fullname();
 }
 
@@ -89,11 +89,9 @@ std::ostream &operator<<(std::ostream &os, const Name &n) {
 
 class AVRO_DECL Node : private boost::noncopyable {
 public:
-
-    explicit Node(Type type) :
-        type_(type),
-        logicalType_(LogicalType::NONE),
-        locked_(false) {}
+    explicit Node(Type type) : type_(type),
+                               logicalType_(LogicalType::NONE),
+                               locked_(false) {}
 
     virtual ~Node();
 
@@ -171,7 +169,6 @@ public:
                                     size_t depth) const = 0;
 
 protected:
-
     void checkLock() const {
         if (locked()) {
             throw Exception("Cannot modify locked schema");
@@ -190,7 +187,6 @@ protected:
     virtual void doSetFixedSize(size_t size) = 0;
 
 private:
-
     const Type type_;
     LogicalType logicalType_;
     bool locked_;
@@ -203,6 +199,6 @@ inline std::ostream &operator<<(std::ostream &os, const avro::Node &n) {
     n.printJson(os, 0);
     return os;
 }
-}
+} // namespace std
 
 #endif
diff --git a/lang/c++/api/NodeConcepts.hh b/lang/c++/api/NodeConcepts.hh
index 3203a94..155c8ed 100644
--- a/lang/c++/api/NodeConcepts.hh
+++ b/lang/c++/api/NodeConcepts.hh
@@ -21,13 +21,12 @@
 
 #include "Config.hh"
 
-#include <vector>
-#include <map>
 #include "Exception.hh"
+#include <map>
+#include <vector>
 
 namespace avro {
 
-
 ///
 /// The concept classes are used to simplify NodeImpl.  Since different types
 /// of avro types carry different attributes, such as names, or field names for
@@ -55,7 +54,7 @@ struct NoAttribute {
         return 0;
     }
 
-    void add(const Attribute &/* attr */) {
+    void add(const Attribute & /* attr */) {
         // There must be an add function for the generic NodeImpl, but the
         // Node APIs ensure that it is never called, the throw here is
         // just in case
@@ -75,7 +74,6 @@ struct NoAttribute {
         // just in case
         throw Exception("This type does not have attribute");
     }
-
 };
 
 template<typename Attribute>
@@ -86,12 +84,10 @@ struct SingleAttribute {
 
     explicit SingleAttribute(const Attribute &a) : attr_(a) {}
     // copy constructing from another single attribute is allowed
-    SingleAttribute(const SingleAttribute<Attribute> &rhs) :
-        attr_(rhs.attr_) {}
+    SingleAttribute(const SingleAttribute<Attribute> &rhs) : attr_(rhs.attr_) {}
 
     // copy constructing from a no attribute is allowed
-    explicit SingleAttribute(const NoAttribute<Attribute> &rhs) :
-        attr_() {}
+    explicit SingleAttribute(const NoAttribute<Attribute> &rhs) : attr_() {}
 
     size_t size() const {
         return 1;
@@ -116,8 +112,8 @@ struct SingleAttribute {
     }
 
 private:
-    template<typename T> friend
-    struct MultiAttribute;
+    template<typename T>
+    friend struct MultiAttribute;
     Attribute attr_;
 };
 
@@ -136,8 +132,7 @@ struct MultiAttribute {
         attrs_.push_back(rhs.attr_);
     }
 
-    MultiAttribute(const MultiAttribute<Attribute> &rhs) :
-        attrs_(rhs.attrs_) {}
+    MultiAttribute(const MultiAttribute<Attribute> &rhs) : attrs_(rhs.attrs_) {}
 
     explicit MultiAttribute(const NoAttribute<Attribute> &rhs) {}
 
@@ -158,7 +153,6 @@ struct MultiAttribute {
     }
 
 private:
-
     std::vector<Attribute> attrs_;
 };
 
@@ -175,7 +169,7 @@ struct NameIndexConcept {
 };
 
 template<>
-struct NameIndexConcept<MultiAttribute<std::string> > {
+struct NameIndexConcept<MultiAttribute<std::string>> {
     using IndexMap = std::map<std::string, size_t>;
 
     bool lookup(const std::string &name, size_t &index) const {
@@ -198,7 +192,6 @@ struct NameIndexConcept<MultiAttribute<std::string> > {
     }
 
 private:
-
     IndexMap map_;
 };
 
diff --git a/lang/c++/api/NodeImpl.hh b/lang/c++/api/NodeImpl.hh
index 2e1cbe6..c74d39e 100644
--- a/lang/c++/api/NodeImpl.hh
+++ b/lang/c++/api/NodeImpl.hh
@@ -22,12 +22,12 @@
 #include "Config.hh"
 #include "GenericDatum.hh"
 
-#include <limits>
-#include <set>
 #include <iomanip>
 #include <iostream>
-#include <sstream>
+#include <limits>
 #include <memory>
+#include <set>
+#include <sstream>
 #include <utility>
 
 #include "Node.hh"
@@ -38,36 +38,31 @@ namespace avro {
 /// Implementation details for Node.  NodeImpl represents all the avro types,
 /// whose properties are enabled and disabled by selecting concept classes.
 
-template
-    <
-        class NameConcept,
-        class LeavesConcept,
-        class LeafNamesConcept,
-        class SizeConcept
-    >
+template<
+    class NameConcept,
+    class LeavesConcept,
+    class LeafNamesConcept,
+    class SizeConcept>
 class NodeImpl : public Node {
 
 protected:
-
-    explicit NodeImpl(Type type) :
-        Node(type),
-        nameAttribute_(),
-        docAttribute_(),
-        leafAttributes_(),
-        leafNameAttributes_(),
-        sizeAttribute_() {}
+    explicit NodeImpl(Type type) : Node(type),
+                                   nameAttribute_(),
+                                   docAttribute_(),
+                                   leafAttributes_(),
+                                   leafNameAttributes_(),
+                                   sizeAttribute_() {}
 
     NodeImpl(Type type,
              const NameConcept &name,
              const LeavesConcept &leaves,
              const LeafNamesConcept &leafNames,
-             const SizeConcept &size) :
-        Node(type),
-        nameAttribute_(name),
-        docAttribute_(),
-        leafAttributes_(leaves),
-        leafNameAttributes_(leafNames),
-        sizeAttribute_(size) {}
+             const SizeConcept &size) : Node(type),
+                                        nameAttribute_(name),
+                                        docAttribute_(),
+                                        leafAttributes_(leaves),
+                                        leafNameAttributes_(leafNames),
+                                        sizeAttribute_(size) {}
 
     // Ctor with "doc"
     NodeImpl(Type type,
@@ -75,13 +70,12 @@ protected:
              const concepts::SingleAttribute<std::string> &doc,
              const LeavesConcept &leaves,
              const LeafNamesConcept &leafNames,
-             const SizeConcept &size) :
-        Node(type),
-        nameAttribute_(name),
-        docAttribute_(doc),
-        leafAttributes_(leaves),
-        leafNameAttributes_(leafNames),
-        sizeAttribute_(size) {}
+             const SizeConcept &size) : Node(type),
+                                        nameAttribute_(name),
+                                        docAttribute_(doc),
+                                        leafAttributes_(leaves),
+                                        leafNameAttributes_(leafNames),
+                                        sizeAttribute_(size) {}
 
     void swap(NodeImpl &impl) {
         std::swap(nameAttribute_, impl.nameAttribute_);
@@ -232,9 +226,7 @@ using NodeImplFixed = NodeImpl<HasName, NoLeaves, NoLeafNames, HasSize>;
 
 class AVRO_DECL NodePrimitive : public NodeImplPrimitive {
 public:
-
-    explicit NodePrimitive(Type type) :
-        NodeImplPrimitive(type) {}
+    explicit NodePrimitive(Type type) : NodeImplPrimitive(type) {}
 
     SchemaResolution resolve(const Node &reader) const override;
 
@@ -251,15 +243,11 @@ class AVRO_DECL NodeSymbolic : public NodeImplSymbolic {
     using NodeWeakPtr = std::weak_ptr<Node>;
 
 public:
+    NodeSymbolic() : NodeImplSymbolic(AVRO_SYMBOLIC) {}
 
-    NodeSymbolic() :
-        NodeImplSymbolic(AVRO_SYMBOLIC) {}
-
-    explicit NodeSymbolic(const HasName &name) :
-        NodeImplSymbolic(AVRO_SYMBOLIC, name, NoLeaves(), NoLeafNames(), NoSize()) {}
+    explicit NodeSymbolic(const HasName &name) : NodeImplSymbolic(AVRO_SYMBOLIC, name, NoLeaves(), NoLeafNames(), NoSize()) {}
 
-    NodeSymbolic(const HasName &name, const NodePtr &n) :
-        NodeImplSymbolic(AVRO_SYMBOLIC, name, NoLeaves(), NoLeafNames(), NoSize()), actualNode_(n) {}
+    NodeSymbolic(const HasName &name, const NodePtr &n) : NodeImplSymbolic(AVRO_SYMBOLIC, name, NoLeaves(), NoLeafNames(), NoSize()), actualNode_(n) {}
     SchemaResolution resolve(const Node &reader) const override;
 
     void printJson(std::ostream &os, size_t depth) const override;
@@ -287,13 +275,12 @@ public:
     }
 
 protected:
-
     NodeWeakPtr actualNode_;
-
 };
 
 class AVRO_DECL NodeRecord : public NodeImplRecord {
     std::vector<GenericDatum> defaultValues;
+
 public:
     NodeRecord() : NodeImplRecord(AVRO_RECORD) {}
     NodeRecord(const HasName &name, const MultiLeaves &fields,
@@ -302,14 +289,13 @@ public:
 
     NodeRecord(const HasName &name, const HasDoc &doc, const MultiLeaves &fields,
                const LeafNames &fieldsNames,
-               std::vector<GenericDatum> dv) :
-        NodeImplRecord(AVRO_RECORD, name, doc, fields, fieldsNames, NoSize()),
-        defaultValues(std::move(dv)) {
+               std::vector<GenericDatum> dv) : NodeImplRecord(AVRO_RECORD, name, doc, fields, fieldsNames, NoSize()),
+                                               defaultValues(std::move(dv)) {
         for (size_t i = 0; i < leafNameAttributes_.size(); ++i) {
             if (!nameIndex_.add(leafNameAttributes_.get(i), i)) {
                 throw Exception(boost::format(
-                    "Cannot add duplicate field: %1%") %
-                    leafNameAttributes_.get(i));
+                                    "Cannot add duplicate field: %1%")
+                                % leafNameAttributes_.get(i));
             }
         }
     }
@@ -324,8 +310,7 @@ public:
     void printJson(std::ostream &os, size_t depth) const override;
 
     bool isValid() const override {
-        return ((nameAttribute_.size() == 1) &&
-            (leafAttributes_.size() == leafNameAttributes_.size()));
+        return ((nameAttribute_.size() == 1) && (leafAttributes_.size() == leafNameAttributes_.size()));
     }
 
     const GenericDatum &defaultValueAt(size_t index) override {
@@ -337,12 +322,9 @@ public:
 
 class AVRO_DECL NodeEnum : public NodeImplEnum {
 public:
+    NodeEnum() : NodeImplEnum(AVRO_ENUM) {}
 
-    NodeEnum() :
-        NodeImplEnum(AVRO_ENUM) {}
-
-    NodeEnum(const HasName &name, const LeafNames &symbols) :
-        NodeImplEnum(AVRO_ENUM, name, NoLeaves(), symbols, NoSize()) {
+    NodeEnum(const HasName &name, const LeafNames &symbols) : NodeImplEnum(AVRO_ENUM, name, NoLeaves(), symbols, NoSize()) {
         for (size_t i = 0; i < leafNameAttributes_.size(); ++i) {
             if (!nameIndex_.add(leafNameAttributes_.get(i), i)) {
                 throw Exception(boost::format("Cannot add duplicate enum: %1%") % leafNameAttributes_.get(i));
@@ -356,9 +338,7 @@ public:
 
     bool isValid() const override {
         return (
-            (nameAttribute_.size() == 1) &&
-                (leafNameAttributes_.size() > 0)
-        );
+            (nameAttribute_.size() == 1) && (leafNameAttributes_.size() > 0));
     }
 
     void printDefaultToJson(const GenericDatum &g, std::ostream &os, size_t depth) const override;
@@ -366,12 +346,9 @@ public:
 
 class AVRO_DECL NodeArray : public NodeImplArray {
 public:
+    NodeArray() : NodeImplArray(AVRO_ARRAY) {}
 
-    NodeArray() :
-        NodeImplArray(AVRO_ARRAY) {}
-
-    explicit NodeArray(const SingleLeaf &items) :
-        NodeImplArray(AVRO_ARRAY, NoName(), items, NoLeafNames(), NoSize()) {}
+    explicit NodeArray(const SingleLeaf &items) : NodeImplArray(AVRO_ARRAY, NoName(), items, NoLeafNames(), NoSize()) {}
 
     SchemaResolution resolve(const Node &reader) const override;
 
@@ -386,11 +363,9 @@ public:
 
 class AVRO_DECL NodeMap : public NodeImplMap {
 public:
-
     NodeMap();
 
-    explicit NodeMap(const SingleLeaf &values) :
-        NodeImplMap(AVRO_MAP, NoName(), MultiLeaves(values), NoLeafNames(), NoSize()) {
+    explicit NodeMap(const SingleLeaf &values) : NodeImplMap(AVRO_MAP, NoName(), MultiLeaves(values), NoLeafNames(), NoSize()) {
         // need to add the key for the map too
         NodePtr key(new NodePrimitive(AVRO_STRING));
         doAddLeaf(key);
@@ -412,12 +387,9 @@ public:
 
 class AVRO_DECL NodeUnion : public NodeImplUnion {
 public:
+    NodeUnion() : NodeImplUnion(AVRO_UNION) {}
 
-    NodeUnion() :
-        NodeImplUnion(AVRO_UNION) {}
-
-    explicit NodeUnion(const MultiLeaves &types) :
-        NodeImplUnion(AVRO_UNION, NoName(), types, NoLeafNames(), NoSize()) {}
+    explicit NodeUnion(const MultiLeaves &types) : NodeImplUnion(AVRO_UNION, NoName(), types, NoLeafNames(), NoSize()) {}
 
     SchemaResolution resolve(const Node &reader) const override;
 
@@ -430,33 +402,44 @@ public:
                 std::string name;
                 const NodePtr &n = leafAttributes_.get(i);
                 switch (n->type()) {
-                    case AVRO_STRING:name = "string";
+                    case AVRO_STRING:
+                        name = "string";
                         break;
-                    case AVRO_BYTES:name = "bytes";
+                    case AVRO_BYTES:
+                        name = "bytes";
                         break;
-                    case AVRO_INT:name = "int";
+                    case AVRO_INT:
+                        name = "int";
                         break;
-                    case AVRO_LONG:name = "long";
+                    case AVRO_LONG:
+                        name = "long";
                         break;
-                    case AVRO_FLOAT:name = "float";
+                    case AVRO_FLOAT:
+                        name = "float";
                         break;
-                    case AVRO_DOUBLE:name = "double";
+                    case AVRO_DOUBLE:
+                        name = "double";
                         break;
-                    case AVRO_BOOL:name = "bool";
+                    case AVRO_BOOL:
+                        name = "bool";
                         break;
-                    case AVRO_NULL:name = "null";
+                    case AVRO_NULL:
+                        name = "null";
                         break;
-                    case AVRO_ARRAY:name = "array";
+                    case AVRO_ARRAY:
+                        name = "array";
                         break;
-                    case AVRO_MAP:name = "map";
+                    case AVRO_MAP:
+                        name = "map";
                         break;
                     case AVRO_RECORD:
                     case AVRO_ENUM:
                     case AVRO_UNION:
                     case AVRO_FIXED:
-                    case AVRO_SYMBOLIC:name = n->name().fullname();
+                    case AVRO_SYMBOLIC:
+                        name = n->name().fullname();
                         break;
-                    default:return false;
+                    default: return false;
                 }
                 if (seen.find(name) != seen.end()) {
                     return false;
@@ -473,12 +456,9 @@ public:
 
 class AVRO_DECL NodeFixed : public NodeImplFixed {
 public:
+    NodeFixed() : NodeImplFixed(AVRO_FIXED) {}
 
-    NodeFixed() :
-        NodeImplFixed(AVRO_FIXED) {}
-
-    NodeFixed(const HasName &name, const HasSize &size) :
-        NodeImplFixed(AVRO_FIXED, name, NoLeaves(), NoLeafNames(), size) {}
+    NodeFixed(const HasName &name, const HasSize &size) : NodeImplFixed(AVRO_FIXED, name, NoLeaves(), NoLeafNames(), size) {}
 
     SchemaResolution resolve(const Node &reader) const override;
 
@@ -486,9 +466,7 @@ public:
 
     bool isValid() const override {
         return (
-            (nameAttribute_.size() == 1) &&
-                (sizeAttribute_.size() == 1)
-        );
+            (nameAttribute_.size() == 1) && (sizeAttribute_.size() == 1));
     }
 
     void printDefaultToJson(const GenericDatum &g, std::ostream &os, size_t depth) const override;
diff --git a/lang/c++/api/Parser.hh b/lang/c++/api/Parser.hh
index 3901fc1..f6bc748 100644
--- a/lang/c++/api/Parser.hh
+++ b/lang/c++/api/Parser.hh
@@ -35,14 +35,11 @@ template<class Reader>
 class Parser : private boost::noncopyable {
 
 public:
-
     // Constructor only works with Writer
-    explicit Parser(const InputBuffer &in) :
-        reader_(in) {}
+    explicit Parser(const InputBuffer &in) : reader_(in) {}
 
     /// Constructor only works with ValidatingWriter
-    Parser(const ValidSchema &schema, const InputBuffer &in) :
-        reader_(schema, in) {}
+    Parser(const ValidSchema &schema, const InputBuffer &in) : reader_(schema, in) {}
 
     void readNull() {
         Null null;
@@ -122,13 +119,11 @@ public:
     }
 
 private:
-
     friend Type nextType(Parser<ValidatingReader> &p);
     friend bool currentRecordName(Parser<ValidatingReader> &p, std::string &name);
     friend bool nextFieldName(Parser<ValidatingReader> &p, std::string &name);
 
     Reader reader_;
-
 };
 
 inline Type nextType(Parser<ValidatingReader> &p) {
diff --git a/lang/c++/api/Reader.hh b/lang/c++/api/Reader.hh
index 0d9763a..ca6a719 100644
--- a/lang/c++/api/Reader.hh
+++ b/lang/c++/api/Reader.hh
@@ -19,15 +19,15 @@
 #ifndef avro_Reader_hh__
 #define avro_Reader_hh__
 
-#include <cstdint>
-#include <vector>
 #include <array>
 #include <boost/noncopyable.hpp>
+#include <cstdint>
+#include <vector>
 
 #include "Config.hh"
-#include "Zigzag.hh"
 #include "Types.hh"
 #include "Validator.hh"
+#include "Zigzag.hh"
 #include "buffer/BufferReader.hh"
 
 namespace avro {
@@ -41,13 +41,10 @@ template<class ValidatorType>
 class ReaderImpl : private boost::noncopyable {
 
 public:
+    explicit ReaderImpl(const InputBuffer &buffer) : reader_(buffer) {}
 
-    explicit ReaderImpl(const InputBuffer &buffer) :
-        reader_(buffer) {}
-
-    ReaderImpl(const ValidSchema &schema, const InputBuffer &buffer) :
-        validator_(schema),
-        reader_(buffer) {}
+    ReaderImpl(const ValidSchema &schema, const InputBuffer &buffer) : validator_(schema),
+                                                                       reader_(buffer) {}
 
     void readValue(Null &) {
         validator_.checkTypeExpected(AVRO_NULL);
@@ -165,7 +162,6 @@ public:
     }
 
 private:
-
     uint64_t readVarInt() {
         uint64_t encoded = 0;
         uint8_t val = 0;
@@ -195,7 +191,6 @@ private:
 
     ValidatorType validator_;
     BufferReader reader_;
-
 };
 
 using Reader = ReaderImpl<NullValidator>;
diff --git a/lang/c++/api/Resolver.hh b/lang/c++/api/Resolver.hh
index 7fbf4cd..06c33e7 100644
--- a/lang/c++/api/Resolver.hh
+++ b/lang/c++/api/Resolver.hh
@@ -19,9 +19,9 @@
 #ifndef avro_Resolver_hh__
 #define avro_Resolver_hh__
 
-#include <memory>
 #include <boost/noncopyable.hpp>
 #include <cstdint>
+#include <memory>
 
 #include "Config.hh"
 #include "Reader.hh"
@@ -38,14 +38,12 @@ class AVRO_DECL Resolver : private boost::noncopyable {
 public:
     virtual void parse(Reader &reader, uint8_t *address) const = 0;
     virtual ~Resolver() = default;
-
 };
 
 std::unique_ptr<Resolver> constructResolver(
     const ValidSchema &writerSchema,
     const ValidSchema &readerSchema,
-    const Layout &readerLayout
-);
+    const Layout &readerLayout);
 
 } // namespace avro
 
diff --git a/lang/c++/api/ResolvingReader.hh b/lang/c++/api/ResolvingReader.hh
index dc79e0d..c7aed39 100644
--- a/lang/c++/api/ResolvingReader.hh
+++ b/lang/c++/api/ResolvingReader.hh
@@ -19,22 +19,20 @@
 #ifndef avro_ResolvingReader_hh__
 #define avro_ResolvingReader_hh__
 
-#include <stdint.h>
 #include <boost/noncopyable.hpp>
+#include <stdint.h>
 
 #include "Config.hh"
-#include "ResolverSchema.hh"
 #include "Reader.hh"
+#include "ResolverSchema.hh"
 
 namespace avro {
 
 class AVRO_DECL ResolvingReader : private boost::noncopyable {
 
 public:
-
-    ResolvingReader(const ResolverSchema &schema, const InputBuffer &in) :
-        reader_(in),
-        schema_(schema) {}
+    ResolvingReader(const ResolverSchema &schema, const InputBuffer &in) : reader_(in),
+                                                                           schema_(schema) {}
 
     template<typename T>
     void parse(T &object) {
@@ -42,7 +40,6 @@ public:
     }
 
 private:
-
     Reader reader_;
     ResolverSchema schema_;
 };
diff --git a/lang/c++/api/Schema.hh b/lang/c++/api/Schema.hh
index c12d214..abd646f 100644
--- a/lang/c++/api/Schema.hh
+++ b/lang/c++/api/Schema.hh
@@ -31,12 +31,10 @@
 
 namespace avro {
 
-
 /// The root Schema object is a base class.  Nobody constructs this class directly.
 
 class AVRO_DECL Schema {
 public:
-
     virtual ~Schema() = default;
 
     Type type() const {
diff --git a/lang/c++/api/Serializer.hh b/lang/c++/api/Serializer.hh
index 2fb815b..1a2c8e0 100644
--- a/lang/c++/api/Serializer.hh
+++ b/lang/c++/api/Serializer.hh
@@ -34,14 +34,11 @@ template<class Writer>
 class Serializer : private boost::noncopyable {
 
 public:
-
     /// Constructor only works with Writer
-    explicit Serializer() :
-        writer_() {}
+    explicit Serializer() : writer_() {}
 
     /// Constructor only works with ValidatingWriter
-    explicit Serializer(const ValidSchema &schema) :
-        writer_(schema) {}
+    explicit Serializer(const ValidSchema &schema) : writer_(schema) {}
 
     void writeNull() {
         writer_.writeValue(Null());
@@ -122,9 +119,7 @@ public:
     }
 
 private:
-
     Writer writer_;
-
 };
 
 } // namespace avro
diff --git a/lang/c++/api/Specific.hh b/lang/c++/api/Specific.hh
index c59c0d2..247d86d 100644
--- a/lang/c++/api/Specific.hh
+++ b/lang/c++/api/Specific.hh
@@ -19,18 +19,18 @@
 #ifndef avro_Codec_hh__
 #define avro_Codec_hh__
 
+#include "array"
+#include <algorithm>
+#include <map>
 #include <string>
 #include <vector>
-#include <map>
-#include <algorithm>
-#include "array"
 
 #include "boost/blank.hpp"
 
 #include "AvroTraits.hh"
 #include "Config.hh"
-#include "Encoder.hh"
 #include "Decoder.hh"
+#include "Encoder.hh"
 
 /**
  * A bunch of templates and specializations for encoding and decoding
@@ -190,7 +190,7 @@ struct codec_traits<std::string> {
  * codec_traits for Avro bytes.
  */
 template<>
-struct codec_traits<std::vector<uint8_t> > {
+struct codec_traits<std::vector<uint8_t>> {
     /**
      * Encodes a given value.
      */
@@ -210,7 +210,7 @@ struct codec_traits<std::vector<uint8_t> > {
  * codec_traits for Avro fixed.
  */
 template<size_t N>
-struct codec_traits<std::array<uint8_t, N> > {
+struct codec_traits<std::array<uint8_t, N>> {
     /**
      * Encodes a given value.
      */
@@ -232,7 +232,7 @@ struct codec_traits<std::array<uint8_t, N> > {
  * codec_traits for Avro arrays.
  */
 template<typename T>
-struct codec_traits<std::vector<T> > {
+struct codec_traits<std::vector<T>> {
     /**
      * Encodes a given value.
      */
@@ -281,7 +281,7 @@ struct codec_traits<std::conditional<avro::is_not_defined<bool_codec_traits>::va
  * codec_traits for Avro maps.
  */
 template<typename T>
-struct codec_traits<std::map<std::string, T> > {
+struct codec_traits<std::map<std::string, T>> {
     /**
      * Encodes a given value.
      */
@@ -352,9 +352,6 @@ void decode(Decoder &d, T &t) {
     codec_traits<T>::decode(d, t);
 }
 
-}   // namespace avro
+} // namespace avro
 
 #endif // avro_Codec_hh__
-
-
-
diff --git a/lang/c++/api/Stream.hh b/lang/c++/api/Stream.hh
index f910c4f..fe2c97e 100644
--- a/lang/c++/api/Stream.hh
+++ b/lang/c++/api/Stream.hh
@@ -19,9 +19,9 @@
 #ifndef avro_Stream_hh__
 #define avro_Stream_hh__
 
-#include <memory>
-#include <cstring>
 #include <cstdint>
+#include <cstring>
+#include <memory>
 
 #include "boost/utility.hpp"
 
@@ -35,7 +35,6 @@ namespace avro {
  */
 class AVRO_DECL InputStream : boost::noncopyable {
 protected:
-
     /**
      * An empty constructor.
      */
@@ -82,7 +81,6 @@ typedef std::unique_ptr<InputStream> InputStreamPtr;
  */
 class AVRO_DECL SeekableInputStream : public InputStream {
 protected:
-
     /**
      * An empty constructor.
      */
@@ -109,13 +107,12 @@ typedef std::unique_ptr<SeekableInputStream> SeekableInputStreamPtr;
  */
 class AVRO_DECL OutputStream : boost::noncopyable {
 protected:
-
     /**
      * An empty constructor.
      */
     OutputStream() = default;
-public:
 
+public:
     /**
      * Destructor.
      */
@@ -176,7 +173,7 @@ AVRO_DECL InputStreamPtr memoryInputStream(const OutputStream &source);
  * be a memory output stream. That is it must have been returned by a previous
  * call to memoryOutputStream().
  */
-AVRO_DECL std::shared_ptr<std::vector<uint8_t> > snapshot(const OutputStream &source);
+AVRO_DECL std::shared_ptr<std::vector<uint8_t>> snapshot(const OutputStream &source);
 
 /**
  * Returns a new OutputStream whose contents would be stored in a file.
@@ -475,7 +472,5 @@ inline void copy(InputStream &in, OutputStream &out) {
     w.flush();
 }
 
-}   // namespace avro
+} // namespace avro
 #endif
-
-
diff --git a/lang/c++/api/Types.hh b/lang/c++/api/Types.hh
index 389f24a..e3296ae 100644
--- a/lang/c++/api/Types.hh
+++ b/lang/c++/api/Types.hh
@@ -30,29 +30,28 @@ namespace avro {
  */
 enum Type {
 
-    AVRO_STRING,    /*!< String */
-    AVRO_BYTES,     /*!< Sequence of variable length bytes data */
-    AVRO_INT,       /*!< 32-bit integer */
-    AVRO_LONG,      /*!< 64-bit integer */
-    AVRO_FLOAT,     /*!< Floating point number */
-    AVRO_DOUBLE,    /*!< Double precision floating point number */
-    AVRO_BOOL,      /*!< Boolean value */
-    AVRO_NULL,      /*!< Null */
-
-    AVRO_RECORD,    /*!< Record, a sequence of fields */
-    AVRO_ENUM,      /*!< Enumeration */
-    AVRO_ARRAY,     /*!< Homogeneous array of some specific type */
-    AVRO_MAP,       /*!< Homogeneous map from string to some specific type */
-    AVRO_UNION,     /*!< Union of one or more types */
-    AVRO_FIXED,     /*!< Fixed number of bytes */
+    AVRO_STRING, /*!< String */
+    AVRO_BYTES,  /*!< Sequence of variable length bytes data */
+    AVRO_INT,    /*!< 32-bit integer */
+    AVRO_LONG,   /*!< 64-bit integer */
+    AVRO_FLOAT,  /*!< Floating point number */
+    AVRO_DOUBLE, /*!< Double precision floating point number */
+    AVRO_BOOL,   /*!< Boolean value */
+    AVRO_NULL,   /*!< Null */
+
+    AVRO_RECORD, /*!< Record, a sequence of fields */
+    AVRO_ENUM,   /*!< Enumeration */
+    AVRO_ARRAY,  /*!< Homogeneous array of some specific type */
+    AVRO_MAP,    /*!< Homogeneous map from string to some specific type */
+    AVRO_UNION,  /*!< Union of one or more types */
+    AVRO_FIXED,  /*!< Fixed number of bytes */
 
     AVRO_NUM_TYPES, /*!< Marker */
 
     // The following is a pseudo-type used in implementation
 
     AVRO_SYMBOLIC = AVRO_NUM_TYPES, /*!< User internally to avoid circular references. */
-    AVRO_UNKNOWN  = -1 /*!< Used internally. */
-
+    AVRO_UNKNOWN = -1               /*!< Used internally. */
 };
 
 /**
@@ -70,7 +69,7 @@ inline constexpr bool isPrimitive(Type t) noexcept {
  * and null
  */
 inline constexpr bool isCompound(Type t) noexcept {
-    return (t>= AVRO_RECORD) && (t < AVRO_NUM_TYPES);
+    return (t >= AVRO_RECORD) && (t < AVRO_NUM_TYPES);
 }
 
 /**
@@ -91,24 +90,23 @@ inline constexpr bool isAvroTypeOrPseudoType(Type t) noexcept {
 /**
  * Converts the given type into a string. Useful for generating messages.
  */
-AVRO_DECL const std::string& toString(Type type) noexcept;
+AVRO_DECL const std::string &toString(Type type) noexcept;
 
 /**
  * Writes a string form of the given type into the given ostream.
  */
-AVRO_DECL std::ostream &operator<< (std::ostream &os, avro::Type type);
+AVRO_DECL std::ostream &operator<<(std::ostream &os, avro::Type type);
 
 /// define a type to represent Avro Null in template functions
-struct AVRO_DECL Null { };
+struct AVRO_DECL Null {};
 
 /**
  * Writes schema for null \p null type to \p os.
  * \param os The ostream to write to.
  * \param null The value to be written.
  */
-std::ostream& operator<< (std::ostream &os, const Null &null);
+std::ostream &operator<<(std::ostream &os, const Null &null);
 
 } // namespace avro
 
-
 #endif
diff --git a/lang/c++/api/ValidSchema.hh b/lang/c++/api/ValidSchema.hh
index f4ea4ed..718c8f4 100644
--- a/lang/c++/api/ValidSchema.hh
+++ b/lang/c++/api/ValidSchema.hh
@@ -54,10 +54,10 @@ public:
 
     void toFlatList(std::ostream &os) const;
 
-  protected:
+protected:
     NodePtr root_;
 
-  private:
+private:
     static std::string compactSchema(const std::string &schema);
 };
 
diff --git a/lang/c++/api/Validator.hh b/lang/c++/api/Validator.hh
index afd2749..ab5d068 100644
--- a/lang/c++/api/Validator.hh
+++ b/lang/c++/api/Validator.hh
@@ -20,9 +20,9 @@
 #define avro_Validating_hh__
 
 #include <boost/noncopyable.hpp>
+#include <cstdint>
 #include <utility>
 #include <vector>
-#include <cstdint>
 
 #include "Config.hh"
 #include "Types.hh"
@@ -32,7 +32,6 @@ namespace avro {
 
 class AVRO_DECL NullValidator : private boost::noncopyable {
 public:
-
     explicit NullValidator(const ValidSchema &schema) {}
     NullValidator() = default;
 
@@ -60,7 +59,6 @@ public:
 
     void checkTypeExpected(Type) {}
     void checkFixedSizeExpected(int) {}
-
 };
 
 /// This class is used by both the ValidatingSerializer and ValidationParser
@@ -71,7 +69,6 @@ public:
 
 class AVRO_DECL Validator : private boost::noncopyable {
 public:
-
     explicit Validator(ValidSchema schema);
 
     void setCount(int64_t val);
@@ -93,8 +90,7 @@ public:
         if (!typeIsExpected(type)) {
             throw Exception(
                 boost::format("Type %1% does not match schema %2%")
-                    % type % nextType_
-            );
+                % type % nextType_);
         }
         advance();
     }
@@ -103,14 +99,12 @@ public:
         if (nextSizeExpected() != size) {
             throw Exception(
                 boost::format("Wrong size for fixed, got %1%, expected %2%")
-                    % size % nextSizeExpected()
-            );
+                % size % nextSizeExpected());
         }
         checkTypeExpected(AVRO_FIXED);
     }
 
 private:
-
     using flag_t = uint32_t;
 
     static flag_t typeToFlag(Type type) {
@@ -142,15 +136,13 @@ private:
     int64_t count_;
 
     struct CompoundType {
-        explicit CompoundType(NodePtr n) :
-            node(std::move(n)), pos(0) {}
-        NodePtr node;  ///< save the node
+        explicit CompoundType(NodePtr n) : node(std::move(n)), pos(0) {}
+        NodePtr node; ///< save the node
         size_t pos;   ///< track the leaf position to visit
     };
 
     std::vector<CompoundType> compoundStack_;
     std::vector<size_t> counters_;
-
 };
 
 } // namespace avro
diff --git a/lang/c++/api/Writer.hh b/lang/c++/api/Writer.hh
index 2cf29b2..930ea39 100644
--- a/lang/c++/api/Writer.hh
+++ b/lang/c++/api/Writer.hh
@@ -23,10 +23,10 @@
 #include <boost/noncopyable.hpp>
 
 #include "Config.hh"
-#include "buffer/Buffer.hh"
-#include "Zigzag.hh"
 #include "Types.hh"
 #include "Validator.hh"
+#include "Zigzag.hh"
+#include "buffer/Buffer.hh"
 
 namespace avro {
 
@@ -36,11 +36,9 @@ template<class ValidatorType>
 class WriterImpl : private boost::noncopyable {
 
 public:
-
     WriterImpl() = default;
 
-    explicit WriterImpl(const ValidSchema &schema) :
-        validator_(schema) {}
+    explicit WriterImpl(const ValidSchema &schema) : validator_(schema) {}
 
     void writeValue(const Null &) {
         validator_.checkTypeExpected(AVRO_NULL);
@@ -154,7 +152,6 @@ public:
     }
 
 private:
-
     void putLong(int64_t val) {
         // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
         std::array<uint8_t, 10> bytes;
@@ -175,7 +172,6 @@ private:
 
     ValidatorType validator_;
     OutputBuffer buffer_;
-
 };
 
 using Writer = WriterImpl<NullValidator>;
diff --git a/lang/c++/api/Zigzag.hh b/lang/c++/api/Zigzag.hh
index a6ecf3d..fefdc3f 100644
--- a/lang/c++/api/Zigzag.hh
+++ b/lang/c++/api/Zigzag.hh
@@ -19,9 +19,9 @@
 #ifndef avro_Encoding_hh__
 #define avro_Encoding_hh__
 
-#include <cstdint>
 #include <array>
 #include <cstddef>
+#include <cstdint>
 
 #include "Config.hh"
 /// \file
@@ -48,7 +48,6 @@ AVRO_DECL constexpr int32_t decodeZigzag32(uint32_t input) noexcept {
 AVRO_DECL size_t encodeInt32(int32_t input, std::array<uint8_t, 5> &output) noexcept;
 AVRO_DECL size_t encodeInt64(int64_t input, std::array<uint8_t, 10> &output) noexcept;
 
-
 } // namespace avro
 
 #endif
diff --git a/lang/c++/api/buffer/Buffer.hh b/lang/c++/api/buffer/Buffer.hh
index 7d7aaf8..48e6bdb 100644
--- a/lang/c++/api/buffer/Buffer.hh
+++ b/lang/c++/api/buffer/Buffer.hh
@@ -40,7 +40,6 @@ namespace avro {
 class OutputBuffer;
 class InputBuffer;
 
-
 /**
  * The OutputBuffer (write-only buffer)
  *
@@ -61,11 +60,9 @@ class InputBuffer;
  * modifying one will modify both.
  **/
 
-class AVRO_DECL OutputBuffer
-{
-
-  public:
+class AVRO_DECL OutputBuffer {
 
+public:
     typedef detail::size_type size_type;
     typedef detail::data_type data_type;
 
@@ -95,10 +92,8 @@ class AVRO_DECL OutputBuffer
      *
      **/
 
-    OutputBuffer(size_type reserveSize = 0) :
-        pimpl_(new detail::BufferImpl)
-    {
-        if(reserveSize) {
+    OutputBuffer(size_type reserveSize = 0) : pimpl_(new detail::BufferImpl) {
+        if (reserveSize) {
             reserve(reserveSize);
         }
     }
@@ -111,8 +106,7 @@ class AVRO_DECL OutputBuffer
      * the write operation.
      **/
 
-    void reserve(size_type reserveSize)
-    {
+    void reserve(size_type reserveSize) {
         pimpl_->reserveFreeSpace(reserveSize);
     }
 
@@ -149,11 +143,10 @@ class AVRO_DECL OutputBuffer
      * throw a std::length_error exception.
      **/
 
-    size_type wroteTo(size_type size)
-    {
+    size_type wroteTo(size_type size) {
         int wrote = 0;
-        if(size) {
-            if(size > freeSpace()) {
+        if (size) {
+            if (size > freeSpace()) {
                 throw std::length_error("Impossible to write more data than free space");
             }
             wrote = pimpl_->wroteTo(size);
@@ -166,7 +159,7 @@ class AVRO_DECL OutputBuffer
      **/
 
     bool empty() const {
-        return  (pimpl_->size()==0);
+        return (pimpl_->size() == 0);
     }
 
     /**
@@ -174,7 +167,7 @@ class AVRO_DECL OutputBuffer
      */
 
     size_type size() const {
-        return  pimpl_->size();
+        return pimpl_->size();
     }
 
     /**
@@ -184,7 +177,7 @@ class AVRO_DECL OutputBuffer
      **/
 
     size_type freeSpace() const {
-        return  pimpl_->freeSpace();
+        return pimpl_->freeSpace();
     }
 
     /**
@@ -193,10 +186,10 @@ class AVRO_DECL OutputBuffer
      *
      **/
 
-    template <class BufferType>
+    template<class BufferType>
     void append(const BufferType &buf) {
         // don't append an empty buffer
-        if(buf.size()) {
+        if (buf.size()) {
             pimpl_->append(*(buf.pimpl_.get()));
         }
     }
@@ -222,8 +215,7 @@ class AVRO_DECL OutputBuffer
      * Discard any data in this buffer.
      **/
 
-    void discardData()
-    {
+    void discardData() {
         pimpl_->discardData();
     }
 
@@ -232,16 +224,13 @@ class AVRO_DECL OutputBuffer
      * Throws if the size is greater than the number of bytes.
      **/
 
-    void discardData(size_t bytes)
-    {
-        if(bytes > 0) {
-            if(bytes < pimpl_->size()) {
+    void discardData(size_t bytes) {
+        if (bytes > 0) {
+            if (bytes < pimpl_->size()) {
                 pimpl_->discardData(bytes);
-            }
-            else if(bytes == pimpl_->size()) {
+            } else if (bytes == pimpl_->size()) {
                 pimpl_->discardData();
-            }
-            else {
+            } else {
                 throw std::out_of_range("trying to discard more data than exists");
             }
         }
@@ -267,8 +256,7 @@ class AVRO_DECL OutputBuffer
      * Clone this buffer, creating a copy that contains the same data.
      **/
 
-    OutputBuffer clone() const
-    {
+    OutputBuffer clone() const {
         detail::BufferImpl::SharedPtr newImpl(new detail::BufferImpl(*pimpl_));
         return OutputBuffer(newImpl);
     }
@@ -288,7 +276,7 @@ class AVRO_DECL OutputBuffer
      **/
 
     int numChunks() const {
-        return  pimpl_->numFreeChunks();
+        return pimpl_->numFreeChunks();
     }
 
     /**
@@ -296,17 +284,14 @@ class AVRO_DECL OutputBuffer
      **/
 
     int numDataChunks() const {
-        return  pimpl_->numDataChunks();
+        return pimpl_->numDataChunks();
     }
 
-  private:
-
+private:
     friend class InputBuffer;
     friend class BufferReader;
 
-    explicit OutputBuffer(const detail::BufferImpl::SharedPtr &pimpl) :
-        pimpl_(pimpl)
-    { }
+    explicit OutputBuffer(const detail::BufferImpl::SharedPtr &pimpl) : pimpl_(pimpl) {}
 
     detail::BufferImpl::SharedPtr pimpl_; ///< Must never be null.
 };
@@ -325,11 +310,9 @@ class AVRO_DECL OutputBuffer
  *
  **/
 
-class AVRO_DECL InputBuffer
-{
-
-  public:
+class AVRO_DECL InputBuffer {
 
+public:
     typedef detail::size_type size_type;
     typedef detail::data_type data_type;
 
@@ -347,9 +330,7 @@ class AVRO_DECL InputBuffer
      * deleting the underlying data if no other copies of exist.
      **/
 
-    InputBuffer() :
-        pimpl_(new detail::BufferImpl)
-    { }
+    InputBuffer() : pimpl_(new detail::BufferImpl) {}
 
     /**
      * Construct an InputBuffer that contains the contents of an OutputBuffer.
@@ -363,9 +344,7 @@ class AVRO_DECL InputBuffer
      * Implicit conversion is allowed.
      **/
 
-    InputBuffer(const OutputBuffer &src) :
-        pimpl_(new detail::BufferImpl(*src.pimpl_))
-    { }
+    InputBuffer(const OutputBuffer &src) : pimpl_(new detail::BufferImpl(*src.pimpl_)) {}
 
     /**
      * Does the buffer have any data?
@@ -408,16 +387,12 @@ class AVRO_DECL InputBuffer
         return pimpl_->numDataChunks();
     }
 
-
-  private:
-
+private:
     friend class OutputBuffer; // for append function
     friend class istreambuf;
     friend class BufferReader;
 
-    explicit InputBuffer(const detail::BufferImpl::SharedPtr &pimpl) :
-        pimpl_(pimpl)
-    { }
+    explicit InputBuffer(const detail::BufferImpl::SharedPtr &pimpl) : pimpl_(pimpl) {}
 
     /**
      * Class to indicate that a copy of a OutputBuffer to InputBuffer should be
@@ -436,9 +411,7 @@ class AVRO_DECL InputBuffer
      * Make a shallow copy of an OutputBuffer in order to read it without
      * causing conversion overhead.
      **/
-    InputBuffer(const OutputBuffer &src, const ShallowCopy &) :
-        pimpl_(src.pimpl_)
-    { }
+    InputBuffer(const OutputBuffer &src, const ShallowCopy &) : pimpl_(src.pimpl_) {}
 
     /**
      * Make a shallow copy of an InputBuffer.  The default copy constructor
@@ -447,41 +420,34 @@ class AVRO_DECL InputBuffer
      * manner.
      **/
 
-     InputBuffer(const InputBuffer &src, const ShallowCopy &) :
-        pimpl_(src.pimpl_)
-    { }
-
+    InputBuffer(const InputBuffer &src, const ShallowCopy &) : pimpl_(src.pimpl_) {}
 
     detail::BufferImpl::ConstSharedPtr pimpl_; ///< Must never be null.
 };
 
-
 /*
  * Implementations of some OutputBuffer functions are inlined here
  * because InputBuffer definition was required before.
  */
 
-inline InputBuffer OutputBuffer::extractData()
-{
+inline InputBuffer OutputBuffer::extractData() {
     detail::BufferImpl::SharedPtr newImpl(new detail::BufferImpl);
-    if(pimpl_->size()) {
+    if (pimpl_->size()) {
         pimpl_->extractData(*newImpl);
     }
     return InputBuffer(newImpl);
 }
 
-inline InputBuffer OutputBuffer::extractData(size_type bytes)
-{
-    if(bytes > pimpl_->size()) {
+inline InputBuffer OutputBuffer::extractData(size_type bytes) {
+    if (bytes > pimpl_->size()) {
         throw std::out_of_range("trying to extract more data than exists");
     }
 
     detail::BufferImpl::SharedPtr newImpl(new detail::BufferImpl);
-    if(bytes > 0) {
-        if(bytes < pimpl_->size()) {
+    if (bytes > 0) {
+        if (bytes < pimpl_->size()) {
             pimpl_->extractData(*newImpl, bytes);
-        }
-        else {
+        } else {
             pimpl_->extractData(*newImpl);
         }
     }
@@ -508,8 +474,7 @@ inline InputBuffer OutputBuffer::extractData(size_type bytes)
  **/
 
 template<class BufferType>
-inline void toIovec(BufferType &buf, std::vector<struct iovec> &iov)
-{
+inline void toIovec(BufferType &buf, std::vector<struct iovec> &iov) {
     const int chunks = buf.numChunks();
     iov.resize(chunks);
     typename BufferType::const_iterator iter = buf.begin();
@@ -521,6 +486,6 @@ inline void toIovec(BufferType &buf, std::vector<struct iovec> &iov)
 }
 #endif
 
-} // namespace
+} // namespace avro
 
 #endif
diff --git a/lang/c++/api/buffer/BufferPrint.hh b/lang/c++/api/buffer/BufferPrint.hh
index a30cdba..3262ec9 100644
--- a/lang/c++/api/buffer/BufferPrint.hh
+++ b/lang/c++/api/buffer/BufferPrint.hh
@@ -19,10 +19,10 @@
 #ifndef avro_BufferPrint_hh__
 #define avro_BufferPrint_hh__
 
+#include "BufferReader.hh"
 #include <ctype.h>
-#include <iostream>
 #include <iomanip>
-#include "BufferReader.hh"
+#include <iostream>
 
 /**
  * \file BufferPrint.hh
@@ -43,8 +43,7 @@ namespace detail {
  **/
 
 inline void
-hexPrint(std::ostream &os, BufferReader &reader)
-{
+hexPrint(std::ostream &os, BufferReader &reader) {
     std::ios_base::fmtflags savedFlags = os.flags();
 
     char sixteenBytes[16];
@@ -53,7 +52,7 @@ hexPrint(std::ostream &os, BufferReader &reader)
     os << std::setfill('0');
     os << std::hex;
 
-    while(reader.bytesRemaining()) {
+    while (reader.bytesRemaining()) {
 
         os << std::setw(8) << offset << "  ";
 
@@ -84,32 +83,27 @@ hexPrint(std::ostream &os, BufferReader &reader)
             os << "   ";
         }
         os << " |";
-        for(i = 0; i < inBuffer; ++i) {
-            os.put(isprint(sixteenBytes[i] & 0xff) ? sixteenBytes[i] : '.' );
+        for (i = 0; i < inBuffer; ++i) {
+            os.put(isprint(sixteenBytes[i] & 0xff) ? sixteenBytes[i] : '.');
         }
         os << "|\n";
-
     }
 
     // restore flags
-    os.flags( savedFlags);
+    os.flags(savedFlags);
 }
 
 } // namespace detail
 
-} // namespace
+} // namespace avro
 
-inline
-std::ostream& operator<<(std::ostream& os, const avro::OutputBuffer& buffer)
-{
+inline std::ostream &operator<<(std::ostream &os, const avro::OutputBuffer &buffer) {
     avro::BufferReader reader(buffer);
     avro::detail::hexPrint(os, reader);
     return os;
 }
 
-inline
-std::ostream& operator<<(std::ostream& os, const avro::InputBuffer& buffer)
-{
+inline std::ostream &operator<<(std::ostream &os, const avro::InputBuffer &buffer) {
     avro::BufferReader reader(buffer);
     avro::detail::hexPrint(os, reader);
     return os;
diff --git a/lang/c++/api/buffer/BufferReader.hh b/lang/c++/api/buffer/BufferReader.hh
index 678ba8a..c3acc26 100644
--- a/lang/c++/api/buffer/BufferReader.hh
+++ b/lang/c++/api/buffer/BufferReader.hh
@@ -19,8 +19,8 @@
 #ifndef avro_BufferReader_hh__
 #define avro_BufferReader_hh__
 
-#include <type_traits>
 #include "Buffer.hh"
+#include <type_traits>
 
 #ifdef min
 #undef min
@@ -40,16 +40,13 @@ namespace avro {
  * chunk boundaries.  May read from an InputBuffer or OutputBuffer.
  *
  **/
-class AVRO_DECL BufferReader : private boost::noncopyable
-{
-
-  public:
+class AVRO_DECL BufferReader : private boost::noncopyable {
 
+public:
     typedef detail::data_type data_type;
     typedef detail::size_type size_type;
 
-  private:
-
+private:
     size_type chunkRemaining() const {
         return iter_->dataSize() - chunkPos_;
     }
@@ -57,7 +54,7 @@ class AVRO_DECL BufferReader : private boost::noncopyable
     void incrementChunk(size_type howmuch) {
         bytesRemaining_ -= howmuch;
         chunkPos_ += howmuch;
-        if(chunkPos_ == iter_->dataSize()) {
+        if (chunkPos_ == iter_->dataSize()) {
             chunkPos_ = 0;
             ++iter_;
         }
@@ -73,23 +70,18 @@ class AVRO_DECL BufferReader : private boost::noncopyable
         return iter_->tellReadPos() + chunkPos_;
     }
 
-  public:
-
-    BufferReader(const InputBuffer &buf) :
-        bufferImpl_(buf.pimpl_),
-        iter_(bufferImpl_->beginRead()),
-        bytes_(bufferImpl_->size()),
-        bytesRemaining_(bytes_),
-        chunkPos_(0)
-    { }
+public:
+    BufferReader(const InputBuffer &buf) : bufferImpl_(buf.pimpl_),
+                                           iter_(bufferImpl_->beginRead()),
+                                           bytes_(bufferImpl_->size()),
+                                           bytesRemaining_(bytes_),
+                                           chunkPos_(0) {}
 
-    BufferReader(const OutputBuffer &buf) :
-        bufferImpl_(buf.pimpl_),
-        iter_(bufferImpl_->beginRead()),
-        bytes_(bufferImpl_->size()),
-        bytesRemaining_(bytes_),
-        chunkPos_(0)
-    { }
+    BufferReader(const OutputBuffer &buf) : bufferImpl_(buf.pimpl_),
+                                            iter_(bufferImpl_->beginRead()),
+                                            bytes_(bufferImpl_->size()),
+                                            bytesRemaining_(bytes_),
+                                            chunkPos_(0) {}
 
     /**
      * How many bytes are still not read from this buffer.
@@ -113,12 +105,12 @@ class AVRO_DECL BufferReader : private boost::noncopyable
 
     size_type read(data_type *data, size_type size) {
 
-        if(size > bytesRemaining_) {
+        if (size > bytesRemaining_) {
             size = bytesRemaining_;
         }
         size_type sizeToRead = size;
 
-        while(sizeToRead) {
+        while (sizeToRead) {
             const size_type toRead = std::min(sizeToRead, chunkRemaining());
             memcpy(data, addr(), toRead);
             sizeToRead -= toRead;
@@ -134,21 +126,19 @@ class AVRO_DECL BufferReader : private boost::noncopyable
      **/
 
     bool read(std::string &str, size_type size) {
-        if(size > bytesRemaining_) {
+        if (size > bytesRemaining_) {
             return false;
         }
 
-        if(size <= chunkRemaining()) {
+        if (size <= chunkRemaining()) {
             fastStringRead(str, size);
-        }
-        else {
+        } else {
             slowStringRead(str, size);
         }
 
         return true;
     }
 
-
     /**
      * Read a single value from the buffer.  The value must be a "fundamental"
      * type, e.g. int, float, etc.  (otherwise use the other writeTo tests).
@@ -156,7 +146,7 @@ class AVRO_DECL BufferReader : private boost::noncopyable
      **/
 
     template<typename T>
-    bool read(T &val)  {
+    bool read(T &val) {
         return read(val, std::is_fundamental<T>());
     }
 
@@ -166,7 +156,7 @@ class AVRO_DECL BufferReader : private boost::noncopyable
 
     bool skip(size_type bytes) {
         bool skipped = false;
-        if(bytes <= bytesRemaining_) {
+        if (bytes <= bytesRemaining_) {
             doSkip(bytes);
             skipped = true;
         }
@@ -178,25 +168,24 @@ class AVRO_DECL BufferReader : private boost::noncopyable
      **/
 
     bool seek(size_type pos) {
-        if(pos > bytes_) {
+        if (pos > bytes_) {
             return false;
         }
 
         size_type toSkip = pos;
         size_type curPos = bytesRead();
         // if the seek position is ahead, we can use skip to get there
-        if(pos >= curPos) {
+        if (pos >= curPos) {
             toSkip -= curPos;
         }
         // if the seek position is ahead of the start of the chunk we can back up to
         // start of the chunk
-        else if(pos >= (curPos - chunkPos_)) {
+        else if (pos >= (curPos - chunkPos_)) {
             curPos -= chunkPos_;
             bytesRemaining_ += chunkPos_;
             chunkPos_ = 0;
             toSkip -= curPos;
-        }
-        else {
+        } else {
             rewind();
         }
         doSkip(toSkip);
@@ -205,30 +194,29 @@ class AVRO_DECL BufferReader : private boost::noncopyable
 
     bool peek(char &val) {
         bool ret = (bytesRemaining_ > 0);
-        if(ret) {
+        if (ret) {
             val = *(addr());
         }
         return ret;
     }
 
     InputBuffer copyData(size_type bytes) {
-        if(bytes > bytesRemaining_) {
+        if (bytes > bytesRemaining_) {
             // force no copy
             bytes = 0;
         }
         detail::BufferImpl::SharedPtr newImpl(new detail::BufferImpl);
-        if(bytes) {
+        if (bytes) {
             bufferImpl_->copyData(*newImpl, iter_, chunkPos_, bytes);
             doSkip(bytes);
         }
         return InputBuffer(newImpl);
     }
 
-  private:
-
+private:
     void doSkip(size_type sizeToSkip) {
 
-        while(sizeToSkip) {
+        while (sizeToSkip) {
             const size_type toSkip = std::min(sizeToSkip, chunkRemaining());
             sizeToSkip -= toSkip;
             incrementChunk(toSkip);
@@ -236,17 +224,15 @@ class AVRO_DECL BufferReader : private boost::noncopyable
     }
 
     template<typename T>
-    bool read(T &val, const std::true_type&)
-    {
-        if(sizeof(T) > bytesRemaining_) {
+    bool read(T &val, const std::true_type &) {
+        if (sizeof(T) > bytesRemaining_) {
             return false;
         }
 
         if (sizeof(T) <= chunkRemaining()) {
-            val = *(reinterpret_cast<const T*> (addr()));
+            val = *(reinterpret_cast<const T *>(addr()));
             incrementChunk(sizeof(T));
-        }
-        else {
+        } else {
             read(reinterpret_cast<data_type *>(&val), sizeof(T));
         }
         return true;
@@ -254,8 +240,7 @@ class AVRO_DECL BufferReader : private boost::noncopyable
 
     /// An uninstantiable function, that is if boost::is_fundamental check fails
     template<typename T>
-    bool read(T &val, const std::false_type&)
-    {
+    bool read(T &val, const std::false_type &) {
         static_assert(sizeof(T) == 0, "Not a valid type to read");
         return false;
     }
@@ -268,7 +253,7 @@ class AVRO_DECL BufferReader : private boost::noncopyable
     void slowStringRead(std::string &str, size_type sizeToCopy) {
         str.clear();
         str.reserve(sizeToCopy);
-        while(sizeToCopy) {
+        while (sizeToCopy) {
             const size_type toCopy = std::min(sizeToCopy, chunkRemaining());
             str.append(addr(), toCopy);
             sizeToCopy -= toCopy;
@@ -283,7 +268,6 @@ class AVRO_DECL BufferReader : private boost::noncopyable
     size_type chunkPos_;
 };
 
-
-} // namespace
+} // namespace avro
 
 #endif
diff --git a/lang/c++/api/buffer/BufferStream.hh b/lang/c++/api/buffer/BufferStream.hh
index e6f9c5a..341822d 100644
--- a/lang/c++/api/buffer/BufferStream.hh
+++ b/lang/c++/api/buffer/BufferStream.hh
@@ -37,26 +37,20 @@ namespace avro {
 
 class AVRO_DECL ostream : public std::ostream {
 
-  public:
-
+public:
     /// Default constructor, creates a new OutputBuffer.
-    ostream() :
-        std::ostream(&obuf_)
-    { }
+    ostream() : std::ostream(&obuf_) {}
 
     /// Output to a specific buffer.
-    ostream(OutputBuffer &buf) :
-        std::ostream(&obuf_),
-        obuf_(buf)
-    { }
+    ostream(OutputBuffer &buf) : std::ostream(&obuf_),
+                                 obuf_(buf) {}
 
     /// Return the output buffer created by the write operations to this ostream.
     const OutputBuffer &getBuffer() const {
         return obuf_.getBuffer();
     }
 
-  protected:
-
+protected:
     ostreambuf obuf_;
 };
 
@@ -73,26 +67,20 @@ class AVRO_DECL ostream : public std::ostream {
 
 class AVRO_DECL istream : public std::istream {
 
-  public:
-
+public:
     /// Constructor, requires an InputBuffer to read from.
-    explicit istream(const InputBuffer &buf) :
-        std::istream(&ibuf_), ibuf_(buf)
-    { }
+    explicit istream(const InputBuffer &buf) : std::istream(&ibuf_), ibuf_(buf) {}
 
     /// Constructor, takes an OutputBuffer to read from (by making a shallow copy to an InputBuffer).
     /// Writing to the OutputBuffer while an istream is using it may lead to undefined behavior.
-    explicit istream(const OutputBuffer &buf) :
-        std::istream(&ibuf_), ibuf_(buf)
-    { }
+    explicit istream(const OutputBuffer &buf) : std::istream(&ibuf_), ibuf_(buf) {}
 
     /// Return the InputBuffer this stream is reading from.
     const InputBuffer &getBuffer() const {
         return ibuf_.getBuffer();
     }
 
-  protected:
-
+protected:
     istreambuf ibuf_;
 };
 
diff --git a/lang/c++/api/buffer/BufferStreambuf.hh b/lang/c++/api/buffer/BufferStreambuf.hh
index 5a750cd..476262e 100644
--- a/lang/c++/api/buffer/BufferStreambuf.hh
+++ b/lang/c++/api/buffer/BufferStreambuf.hh
@@ -41,42 +41,33 @@ namespace avro {
 
 class AVRO_DECL ostreambuf : public std::streambuf {
 
-  public:
-
+public:
     /// Default constructor creates a new OutputBuffer.
-    ostreambuf() :
-        std::streambuf(),
-        buffer_()
-    { }
+    ostreambuf() : std::streambuf(),
+                   buffer_() {}
 
     /// Construct using an existing OutputBuffer.
-    explicit ostreambuf(OutputBuffer &buffer) :
-        std::streambuf(),
-        buffer_( buffer )
-    { }
+    explicit ostreambuf(OutputBuffer &buffer) : std::streambuf(),
+                                                buffer_(buffer) {}
 
     /// Return the buffer.
     const OutputBuffer &getBuffer() const {
         return buffer_;
     }
 
-  protected:
-
+protected:
     /// Write a single character to the stream.
-    virtual int_type overflow(int_type c)
-    {
+    virtual int_type overflow(int_type c) {
         buffer_.writeTo(static_cast<OutputBuffer::data_type>(c));
         return c;
     }
 
     /// Write a block of characters to the stream.
-    virtual std::streamsize xsputn(const char_type *s, std::streamsize n)
-    {
+    virtual std::streamsize xsputn(const char_type *s, std::streamsize n) {
         return buffer_.writeTo(s, static_cast<size_t>(n));
     }
 
-  private:
-
+private:
     OutputBuffer buffer_;
 };
 
@@ -95,25 +86,20 @@ class AVRO_DECL ostreambuf : public std::streambuf {
 
 class AVRO_DECL istreambuf : public std::streambuf {
 
-  public:
-
+public:
     /// Default constructor requires an InputBuffer to read from.
-    explicit istreambuf(const InputBuffer &buffer) :
-        std::streambuf(),
-        buffer_( buffer ),
-        basePos_(0),
-        iter_(buffer_.begin())
-    {
+    explicit istreambuf(const InputBuffer &buffer) : std::streambuf(),
+                                                     buffer_(buffer),
+                                                     basePos_(0),
+                                                     iter_(buffer_.begin()) {
         setBuffer();
     }
 
     /// Default constructor converts an OutputBuffer to an InputBuffer
-    explicit istreambuf(const OutputBuffer &buffer) :
-        std::streambuf(),
-        buffer_( buffer, InputBuffer::ShallowCopy()),
-        basePos_(0),
-        iter_(buffer_.begin())
-    {
+    explicit istreambuf(const OutputBuffer &buffer) : std::streambuf(),
+                                                      buffer_(buffer, InputBuffer::ShallowCopy()),
+                                                      basePos_(0),
+                                                      iter_(buffer_.begin()) {
         setBuffer();
     }
 
@@ -122,12 +108,11 @@ class AVRO_DECL istreambuf : public std::streambuf {
         return buffer_;
     }
 
-  protected:
-
+protected:
     /// The current chunk of data is exhausted, read the next chunk.
     virtual int_type underflow() {
-        if(iter_ != buffer_.end()) {
-            basePos_ += (egptr()-eback());
+        if (iter_ != buffer_.end()) {
+            basePos_ += (egptr() - eback());
             ++iter_;
         }
         return setBuffer();
@@ -135,8 +120,7 @@ class AVRO_DECL istreambuf : public std::streambuf {
 
     /// Get a block of data from the stream.  Overrides default behavior
     /// to ignore eof characters that may reside in the stream.
-    virtual std::streamsize xsgetn(char_type *c, std::streamsize len)
-    {
+    virtual std::streamsize xsgetn(char_type *c, std::streamsize len) {
         std::streamsize bytesCopied = 0;
 
         while (bytesCopied < len) {
@@ -152,9 +136,9 @@ class AVRO_DECL istreambuf : public std::streambuf {
                 gbump(toCopy);
             }
 
-            if(bytesCopied < len) {
+            if (bytesCopied < len) {
                 underflow();
-                if(iter_ == buffer_.end()) {
+                if (iter_ == buffer_.end()) {
                     break;
                 }
             }
@@ -169,14 +153,13 @@ class AVRO_DECL istreambuf : public std::streambuf {
         off_type curpos = basePos_ + (gptr() - eback());
         off_type newpos = off;
 
-        if(dir == std::ios::cur) {
+        if (dir == std::ios::cur) {
             newpos += curpos;
-        }
-        else if (dir == std::ios::end) {
+        } else if (dir == std::ios::end) {
             newpos += buffer_.size();
         }
         // short circuit for tell()
-        if(newpos == curpos) {
+        if (newpos == curpos) {
             return curpos;
         }
 
@@ -184,7 +167,7 @@ class AVRO_DECL istreambuf : public std::streambuf {
 
         // if the position is after our current buffer make
         // sure it's not past the end of the buffer
-        if((newpos > endpos) && (newpos > static_cast<off_type>(buffer_.size()) )) {
+        if ((newpos > endpos) && (newpos > static_cast<off_type>(buffer_.size()))) {
             return pos_type(-1);
         }
         // if the new position is before our current iterator
@@ -193,7 +176,7 @@ class AVRO_DECL istreambuf : public std::streambuf {
             iter_ = buffer_.begin();
             basePos_ = 0;
             setBuffer();
-            endpos = (egptr() -eback());
+            endpos = (egptr() - eback());
         }
 
         // now if the new position is after the end of the buffer
@@ -220,27 +203,25 @@ class AVRO_DECL istreambuf : public std::streambuf {
         // completely read, verify this is the case, and if so, underflow to
         // fetch the next buffer
 
-        if(egptr() - gptr() == 0) {
+        if (egptr() - gptr() == 0) {
             istreambuf::underflow();
         }
         return egptr() - gptr();
     }
 
-  private:
-
+private:
     /// Setup the streambuf buffer pointers after updating
     /// the value of the iterator.  Returns the first character
     /// in the new buffer, or eof if there is no buffer.
     int_type setBuffer() {
         int_type ret = traits_type::eof();
 
-        if(iter_ != buffer_.end()) {
-            char *loc = const_cast <char *> (iter_->data()) ;
+        if (iter_ != buffer_.end()) {
+            char *loc = const_cast<char *>(iter_->data());
             setg(loc, loc, loc + iter_->size());
             ret = std::char_traits<char>::to_int_type(*gptr());
-        }
-        else {
-            setg(0,0,0);
+        } else {
+            setg(0, 0, 0);
         }
         return ret;
     }
@@ -250,6 +231,6 @@ class AVRO_DECL istreambuf : public std::streambuf {
     InputBuffer::const_iterator iter_;
 };
 
-} // namespace
+} // namespace avro
 
 #endif
diff --git a/lang/c++/api/buffer/detail/BufferDetail.hh b/lang/c++/api/buffer/detail/BufferDetail.hh
index 03e237e..22cca95 100644
--- a/lang/c++/api/buffer/detail/BufferDetail.hh
+++ b/lang/c++/api/buffer/detail/BufferDetail.hh
@@ -19,17 +19,17 @@
 #ifndef avro_BufferDetail_hh__
 #define avro_BufferDetail_hh__
 
-#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
 #include <boost/shared_array.hpp>
+#include <boost/shared_ptr.hpp>
 #include <boost/static_assert.hpp>
-#include <boost/function.hpp>
 #include <boost/utility.hpp>
 #ifdef HAVE_BOOST_ASIO
 #include <boost/asio/buffer.hpp>
 #endif
-#include <exception>
 #include <cassert>
 #include <deque>
+#include <exception>
 
 /**
  * \file BufferDetail.hh
@@ -42,10 +42,10 @@ namespace avro {
 
 namespace detail {
 
-typedef char    data_type;
-typedef size_t  size_type;
+typedef char data_type;
+typedef size_t size_type;
 #ifdef HAVE_BOOST_ASIO
-typedef boost::asio::const_buffer   ConstAsioBuffer;
+typedef boost::asio::const_buffer ConstAsioBuffer;
 typedef boost::asio::mutable_buffer MutableAsioBuffer;
 #endif
 
@@ -54,21 +54,21 @@ const size_type kMinBlockSize = 4096;
 const size_type kMaxBlockSize = 16384;
 const size_type kDefaultBlockSize = kMinBlockSize;
 
-typedef boost::function<void(void)>  free_func;
+typedef boost::function<void(void)> free_func;
 
 /**
  * Simple class to hold a functor that executes on delete
  **/
 class CallOnDestroy {
-  public:
-    CallOnDestroy(const free_func &func) : func_(func)
-    { }
+public:
+    CallOnDestroy(const free_func &func) : func_(func) {}
     ~CallOnDestroy() {
         if (func_) {
             func_();
         }
     }
-  private:
+
+private:
     free_func func_;
 };
 
@@ -89,36 +89,29 @@ class CallOnDestroy {
  *
  **/
 
-class Chunk
-{
-
-  public:
+class Chunk {
 
+public:
     typedef boost::shared_ptr<Chunk> SharedPtr;
 
     /// Default constructor, allocates a new underlying block for this chunk.
-    Chunk(size_type size) :
-        underlyingBlock_(new data_type[size]),
-        readPos_(underlyingBlock_.get()),
-        writePos_(readPos_),
-        endPos_(readPos_ + size)
-    { }
+    Chunk(size_type size) : underlyingBlock_(new data_type[size]),
+                            readPos_(underlyingBlock_.get()),
+                            writePos_(readPos_),
+                            endPos_(readPos_ + size) {}
 
     /// Foreign buffer constructor, uses the supplied data for this chunk, and
     /// only for reading.
-    Chunk(const data_type *data, size_type size, const free_func &func) :
-        callOnDestroy_(new CallOnDestroy(func)),
-        readPos_(const_cast<data_type *>(data)),
-        writePos_(readPos_ + size),
-        endPos_(writePos_)
-    { }
-
-  private:
+    Chunk(const data_type *data, size_type size, const free_func &func) : callOnDestroy_(new CallOnDestroy(func)),
+                                                                          readPos_(const_cast<data_type *>(data)),
+                                                                          writePos_(readPos_ + size),
+                                                                          endPos_(writePos_) {}
+
+private:
     // reference counted object will call a functor when it's destroyed
     boost::shared_ptr<CallOnDestroy> callOnDestroy_;
 
-  public:
-
+public:
     /// Remove readable bytes from the front of the chunk by advancing the
     /// chunk start position.
     void truncateFront(size_type howMuch) {
@@ -145,7 +138,7 @@ class Chunk
 
     /// After a write operation, increment the write position.
     void incrementCursor(size_type howMuch) {
-        writePos_  += howMuch;
+        writePos_ += howMuch;
         assert(writePos_ <= endPos_);
     }
 
@@ -164,8 +157,7 @@ class Chunk
         return (endPos_ - readPos_);
     }
 
-  private:
-
+private:
     friend bool operator==(const Chunk &lhs, const Chunk &rhs);
     friend bool operator!=(const Chunk &lhs, const Chunk &rhs);
 
@@ -191,7 +183,6 @@ inline bool operator!=(const Chunk &lhs, const Chunk &rhs) {
     return lhs.underlyingBlock_ != rhs.underlyingBlock_;
 }
 
-
 /**
  * \brief Implementation details for Buffer class
  *
@@ -201,13 +192,11 @@ inline bool operator!=(const Chunk &lhs, const Chunk &rhs) {
  *
  */
 
-class BufferImpl : boost::noncopyable
-{
+class BufferImpl : boost::noncopyable {
 
     /// Add a new chunk to the list of chunks for this buffer, growing the
     /// buffer by the default block size.
-    void allocChunkChecked(size_type size = kDefaultBlockSize)
-    {
+    void allocChunkChecked(size_type size = kDefaultBlockSize) {
         writeChunks_.push_back(Chunk(size));
         freeSpace_ += writeChunks_.back().freeSize();
     }
@@ -215,12 +204,10 @@ class BufferImpl : boost::noncopyable
     /// Add a new chunk to the list of chunks for this buffer, growing the
     /// buffer by the requested size, but within the range of a minimum and
     /// maximum.
-    void allocChunk(size_type size)
-    {
-        if(size < kMinBlockSize) {
+    void allocChunk(size_type size) {
+        if (size < kMinBlockSize) {
             size = kMinBlockSize;
-        }
-        else if (size > kMaxBlockSize) {
+        } else if (size > kMaxBlockSize) {
             size = kMaxBlockSize;
         }
         allocChunkChecked(size);
@@ -228,8 +215,7 @@ class BufferImpl : boost::noncopyable
 
     /// Update the state of the chunks after a write operation.  This function
     /// ensures the chunk states are consistent with the write.
-    void postWrite(size_type size)
-    {
+    void postWrite(size_type size) {
 
         // precondition to this function is that the writeChunk_.front()
         // contains the data that was just written, so make sure writeChunks_
@@ -257,7 +243,7 @@ class BufferImpl : boost::noncopyable
         // if readChunks_ is not the same as writeChunks_.front(), make a copy
         // of it there
 
-        if(readChunks_.empty() || (readChunks_.back() != writeChunks_.front())) {
+        if (readChunks_.empty() || (readChunks_.back() != writeChunks_.front())) {
             const Chunk &curChunk = writeChunks_.front();
             readChunks_.push_back(curChunk);
 
@@ -266,7 +252,7 @@ class BufferImpl : boost::noncopyable
             // added to the readChunk_ list).  Here, adjust the start of the
             // readChunk to begin after any data already existing in curChunk
 
-            readChunks_.back().truncateFront( curChunk.dataSize());
+            readChunks_.back().truncateFront(curChunk.dataSize());
         }
 
         assert(readChunks_.back().freeSize() == writeChunks_.front().freeSize());
@@ -282,29 +268,24 @@ class BufferImpl : boost::noncopyable
         // if there is no more free space in writeChunks_, the next write cannot use
         // it, so dispose of it now
 
-        if(writeChunks_.front().freeSize() == 0) {
+        if (writeChunks_.front().freeSize() == 0) {
             writeChunks_.pop_front();
         }
     }
 
-  public:
-
+public:
     typedef std::deque<Chunk> ChunkList;
     typedef boost::shared_ptr<BufferImpl> SharedPtr;
     typedef boost::shared_ptr<const BufferImpl> ConstSharedPtr;
 
     /// Default constructor, creates a buffer without any chunks
-    BufferImpl() :
-        freeSpace_(0),
-        size_(0)
-    { }
+    BufferImpl() : freeSpace_(0),
+                   size_(0) {}
 
     /// Copy constructor, gets a copy of all the chunks with data.
-    explicit BufferImpl(const BufferImpl &src) :
-        readChunks_(src.readChunks_),
-        freeSpace_(0),
-        size_(src.size_)
-    { }
+    explicit BufferImpl(const BufferImpl &src) : readChunks_(src.readChunks_),
+                                                 freeSpace_(0),
+                                                 size_(src.size_) {}
 
     /// Amount of data held in this buffer.
     size_type size() const {
@@ -319,7 +300,7 @@ class BufferImpl : boost::noncopyable
     /// Add enough free chunks to make the reservation size available.
     /// Actual amount may be more (rounded up to next chunk).
     void reserveFreeSpace(size_type reserveSize) {
-        while(freeSpace_ < reserveSize) {
+        while (freeSpace_ < reserveSize) {
             allocChunk(reserveSize - freeSpace_);
         }
     }
@@ -346,36 +327,32 @@ class BufferImpl : boost::noncopyable
 
     /// Write a single value to buffer, add a new chunk if necessary.
     template<typename T>
-    void writeTo(T val, const std::true_type&)
-    {
-        if(freeSpace_ && (sizeof(T) <= writeChunks_.front().freeSize())) {
+    void writeTo(T val, const std::true_type &) {
+        if (freeSpace_ && (sizeof(T) <= writeChunks_.front().freeSize())) {
             // fast path, there's enough room in the writeable chunk to just
             // straight out copy it
-            *(reinterpret_cast <T*> ( writeChunks_.front().tellWritePos()) ) = val;
+            *(reinterpret_cast<T *>(writeChunks_.front().tellWritePos())) = val;
             postWrite(sizeof(T));
-        }
-        else {
+        } else {
             // need to fixup chunks first, so use the regular memcpy
             // writeTo method
-            writeTo(reinterpret_cast<data_type*>(&val), sizeof(T));
+            writeTo(reinterpret_cast<data_type *>(&val), sizeof(T));
         }
     }
 
     /// An uninstantiable function, this is if boost::is_fundamental check fails,
     /// and will compile-time assert.
     template<typename T>
-    void writeTo(T val, const std::false_type&)
-    {
-        BOOST_STATIC_ASSERT(sizeof(T)==0);
+    void writeTo(T val, const std::false_type &) {
+        BOOST_STATIC_ASSERT(sizeof(T) == 0);
     }
 
     /// Write a block of data to the buffer, adding new chunks if necessary.
-    size_type writeTo(const data_type *data, size_type size)
-    {
+    size_type writeTo(const data_type *data, size_type size) {
         size_type bytesLeft = size;
-        while(bytesLeft) {
+        while (bytesLeft) {
 
-            if(freeSpace_ == 0) {
+            if (freeSpace_ == 0) {
                 allocChunkChecked();
             }
 
@@ -384,15 +361,14 @@ class BufferImpl : boost::noncopyable
             assert(toCopy);
             memcpy(chunk.tellWritePos(), data, toCopy);
             postWrite(toCopy);
-            data      += toCopy;
+            data += toCopy;
             bytesLeft -= toCopy;
         }
         return size;
     }
 
     /// Update internal status of chunks after data is written using iterator.
-    size_type wroteTo(size_type size)
-    {
+    size_type wroteTo(size_type size) {
         assert(size <= freeSpace_);
         size_type bytesLeft = size;
         while (bytesLeft) {
@@ -419,21 +395,19 @@ class BufferImpl : boost::noncopyable
     }
 
     /// Remove the specified amount of data from the chunks, starting at the front.
-    void discardData(size_type bytes)
-    {
+    void discardData(size_type bytes) {
         assert(bytes && bytes <= size_);
 
         size_type bytesToDiscard = bytes;
-        while( bytesToDiscard ) {
+        while (bytesToDiscard) {
 
             size_t currentSize = readChunks_.front().dataSize();
 
             // see if entire chunk is discarded
-            if(currentSize <= bytesToDiscard) {
+            if (currentSize <= bytesToDiscard) {
                 readChunks_.pop_front();
                 bytesToDiscard -= currentSize;
-            }
-            else {
+            } else {
                 readChunks_.front().truncateFront(bytesToDiscard);
                 bytesToDiscard = 0;
             }
@@ -444,22 +418,20 @@ class BufferImpl : boost::noncopyable
 
     /// Remove the specified amount of data from the chunks, moving the
     /// data to dest's chunks
-    void extractData(BufferImpl &dest, size_type bytes)
-    {
+    void extractData(BufferImpl &dest, size_type bytes) {
         assert(bytes && bytes <= size_);
 
         size_type bytesToExtract = bytes;
-        while( bytesToExtract ) {
+        while (bytesToExtract) {
 
             size_t currentSize = readChunks_.front().dataSize();
             dest.readChunks_.push_back(readChunks_.front());
 
             // see if entire chunk was extracted
-            if(currentSize <= bytesToExtract) {
+            if (currentSize <= bytesToExtract) {
                 readChunks_.pop_front();
                 bytesToExtract -= currentSize;
-            }
-            else {
+            } else {
                 readChunks_.front().truncateFront(bytesToExtract);
                 size_t excess = currentSize - bytesToExtract;
                 dest.readChunks_.back().truncateBack(excess);
@@ -472,8 +444,7 @@ class BufferImpl : boost::noncopyable
     }
 
     /// Move data from this to the destination, leaving this buffer without data
-    void extractData(BufferImpl &dest)
-    {
+    void extractData(BufferImpl &dest) {
         assert(dest.readChunks_.empty());
         dest.readChunks_.swap(readChunks_);
         dest.size_ = size_;
@@ -485,13 +456,12 @@ class BufferImpl : boost::noncopyable
     void copyData(BufferImpl &dest,
                   ChunkList::const_iterator iter,
                   size_type offset,
-                  size_type bytes) const
-    {
+                  size_type bytes) const {
         // now we are positioned to start the copying, copy as many
         // chunks as we need, the first chunk may have a non-zero offset
         // if the data to copy is not at the start of the chunk
         size_type copied = 0;
-        while(copied < bytes) {
+        while (copied < bytes) {
 
             dest.readChunks_.push_back(*iter);
 
@@ -522,34 +492,32 @@ class BufferImpl : boost::noncopyable
         return writeChunks_.size();
     }
 
-     /// Add unmanaged data to the buffer.  The buffer will not automatically
-     /// free the data, but it will call the supplied function when the data is
-     /// no longer referenced by the buffer (or copies of the buffer).
+    /// Add unmanaged data to the buffer.  The buffer will not automatically
+    /// free the data, but it will call the supplied function when the data is
+    /// no longer referenced by the buffer (or copies of the buffer).
     void appendForeignData(const data_type *data, size_type size, const free_func &func) {
         readChunks_.push_back(Chunk(data, size, func));
         size_ += size;
     }
 
-  private:
-
+private:
     /// Assignment not allowed
-    BufferImpl& operator=(const BufferImpl &src);
+    BufferImpl &operator=(const BufferImpl &src);
     /* {
         readChunks_.assign(src.readChunks_.begin(), src.readChunks_.end());
         size_ = src.size();
         return *this;
     } */
 
-    ChunkList readChunks_;     ///< chunks of this buffer containing data
-    ChunkList writeChunks_;    ///< chunks of this buffer containing free space
-
-    size_type freeSpace_;  ///< capacity of buffer before allocation required
-    size_type size_;       ///< amount of data in buffer
+    ChunkList readChunks_;  ///< chunks of this buffer containing data
+    ChunkList writeChunks_; ///< chunks of this buffer containing free space
 
+    size_type freeSpace_; ///< capacity of buffer before allocation required
+    size_type size_;      ///< amount of data in buffer
 };
 
-} // detail namespace
+} // namespace detail
 
-} // namespace
+} // namespace avro
 
 #endif
diff --git a/lang/c++/api/buffer/detail/BufferDetail.hh.rej b/lang/c++/api/buffer/detail/BufferDetail.hh.rej
index 15d261c..5f2fa85 100644
--- a/lang/c++/api/buffer/detail/BufferDetail.hh.rej
+++ b/lang/c++/api/buffer/detail/BufferDetail.hh.rej
@@ -1,16 +1,12 @@
-***************
-*** 301,306 ****
-  
-      /// Copy constructor, gets a copy of all the chunks with data.
-      explicit BufferImpl(const BufferImpl &src) :
-          readChunks_(src.readChunks_),
-          freeSpace_(0),
-          size_(src.size_)
---- 301,307 ----
-  
-      /// Copy constructor, gets a copy of all the chunks with data.
-      explicit BufferImpl(const BufferImpl &src) :
-+         boost::noncopyable(),
-          readChunks_(src.readChunks_),
-          freeSpace_(0),
-          size_(src.size_)
+******************301, 306 * ***
+
+                               /// Copy constructor, gets a copy of all the chunks with data.
+                               explicit BufferImpl(const BufferImpl &src) : readChunks_(src.readChunks_),
+freeSpace_(0),
+size_(src.size_)-- - 301, 307 ----
+
+    /// Copy constructor, gets a copy of all the chunks with data.
+    explicit BufferImpl(const BufferImpl &src) : +boost::noncopyable(),
+                                                 readChunks_(src.readChunks_),
+                                                 freeSpace_(0),
+                                                 size_(src.size_)
diff --git a/lang/c++/api/buffer/detail/BufferDetailIterator.hh b/lang/c++/api/buffer/detail/BufferDetailIterator.hh
index c05f219..2fc2794 100644
--- a/lang/c++/api/buffer/detail/BufferDetailIterator.hh
+++ b/lang/c++/api/buffer/detail/BufferDetailIterator.hh
@@ -40,17 +40,12 @@ namespace detail {
  * wraps the iterator with a cast operator to do this conversion.
  **/
 
-struct InputIteratorHelper
-{
+struct InputIteratorHelper {
     /// Construct a helper with an unnassigned iterator.
-    InputIteratorHelper() :
-        iter_()
-    {}
+    InputIteratorHelper() : iter_() {}
 
     /// Construct a helper with an iterator.
-    InputIteratorHelper(const BufferImpl::ChunkList::const_iterator &iter) :
-        iter_(iter)
-    {}
+    InputIteratorHelper(const BufferImpl::ChunkList::const_iterator &iter) : iter_(iter) {}
 
     /// The location of valid data in this chunk.
     const data_type *data() const {
@@ -83,17 +78,12 @@ struct InputIteratorHelper
  * wraps the iterator with a cast operator to do this conversion.
  */
 
-struct OutputIteratorHelper
-{
+struct OutputIteratorHelper {
     /// Construct a helper with an unnassigned iterator.
-    OutputIteratorHelper() :
-            iter_()
-    {}
+    OutputIteratorHelper() : iter_() {}
 
     /// Construct a helper with an iterator.
-    OutputIteratorHelper(const BufferImpl::ChunkList::const_iterator &iter) :
-            iter_(iter)
-    {}
+    OutputIteratorHelper(const BufferImpl::ChunkList::const_iterator &iter) : iter_(iter) {}
 
     /// The location of the first writable byte in this chunk.
     data_type *data() const {
@@ -123,11 +113,9 @@ struct OutputIteratorHelper
  **/
 
 template<typename Helper>
-class BufferIterator
-{
-
-  public:
+class BufferIterator {
 
+public:
     typedef BufferIterator<Helper> this_type;
 
     /**
@@ -144,14 +132,12 @@ class BufferIterator
     typedef std::forward_iterator_tag iterator_category; // this is a lie to appease asio
     typedef Helper value_type;
     typedef std::ptrdiff_t difference_type;
-    typedef value_type* pointer;
-    typedef value_type& reference;
+    typedef value_type *pointer;
+    typedef value_type &reference;
     //@}
 
     /// Construct an unitialized iterator.
-    BufferIterator() :
-        helper_()
-    { }
+    BufferIterator() : helper_() {}
 
     /* The default implementations are good here
     /// Copy constructor.
@@ -166,17 +152,15 @@ class BufferIterator
     */
 
     /// Construct iterator at the position in the buffer's chunk list.
-    explicit BufferIterator(BufferImpl::ChunkList::const_iterator iter) :
-        helper_(iter)
-    { }
+    explicit BufferIterator(BufferImpl::ChunkList::const_iterator iter) : helper_(iter) {}
 
     /// Dereference iterator, returns InputIteratorHelper or OutputIteratorHelper wrapper.
-    reference operator *() {
+    reference operator*() {
         return helper_;
     }
 
     /// Dereference iterator, returns const InputIteratorHelper or OutputIteratorHelper wrapper.
-    const value_type &operator *() const {
+    const value_type &operator*() const {
         return helper_;
     }
 
@@ -191,15 +175,13 @@ class BufferIterator
     }
 
     /// Increment to next chunk in list, or to end() iterator.
-    this_type& operator++()
-    {
+    this_type &operator++() {
         ++helper_.iter_;
         return *this;
     }
 
     /// Increment to next chunk in list, or to end() iterator.
-    this_type operator++(int)
-    {
+    this_type operator++(int) {
         this_type ret = *this;
         ++helper_.iter_;
         return ret;
@@ -215,16 +197,15 @@ class BufferIterator
         return (helper_.iter_ != rhs.helper_.iter_);
     }
 
-  private:
-
+private:
     Helper helper_;
 };
 
 typedef BufferIterator<InputIteratorHelper> InputBufferIterator;
 typedef BufferIterator<OutputIteratorHelper> OutputBufferIterator;
 
-} // detail namespace
+} // namespace detail
 
-} // namespace
+} // namespace avro
 
 #endif
diff --git a/lang/c++/build.sh b/lang/c++/build.sh
index afa65ed..79a251f 100755
--- a/lang/c++/build.sh
+++ b/lang/c++/build.sh
@@ -18,7 +18,7 @@
 set -e # exit on error
 
 function usage {
-  echo "Usage: $0 {lint|test|dist|clean|install|doc}"
+  echo "Usage: $0 {lint|test|dist|clean|install|doc|format}"
   exit 1
 }
 
@@ -113,6 +113,10 @@ case "$target" in
     do_doc
     ;;
 
+  format)
+    clang-format -i --style file `find api -type f` `find impl -type f` `find test -type f`
+    ;;
+
   clean)
     (cd build && make clean)
     rm -rf doc test.avro test?.df test??.df test_skip.df test_lastSync.df test_readRecordUsingLastSync.df
diff --git a/lang/c++/impl/BinaryDecoder.cc b/lang/c++/impl/BinaryDecoder.cc
index 11371f4..2e293ef 100644
--- a/lang/c++/impl/BinaryDecoder.cc
+++ b/lang/c++/impl/BinaryDecoder.cc
@@ -16,10 +16,10 @@
  * limitations under the License.
  */
 
-#include <memory>
 #include "Decoder.hh"
-#include "Zigzag.hh"
 #include "Exception.hh"
+#include "Zigzag.hh"
+#include <memory>
 
 namespace avro {
 
@@ -120,7 +120,8 @@ void BinaryDecoder::decodeString(std::string &value) {
     value.resize(len);
     if (len > 0) {
         in_.readBytes(const_cast<uint8_t *>(
-                          reinterpret_cast<const uint8_t *>(value.c_str())), len);
+                          reinterpret_cast<const uint8_t *>(value.c_str())),
+                      len);
     }
 }
 
@@ -218,5 +219,4 @@ int64_t BinaryDecoder::doDecodeLong() {
     return decodeZigzag64(encoded);
 }
 
-}   // namespace avro
-
+} // namespace avro
diff --git a/lang/c++/impl/BinaryEncoder.cc b/lang/c++/impl/BinaryEncoder.cc
index 72bdbd9..cc396b0 100644
--- a/lang/c++/impl/BinaryEncoder.cc
+++ b/lang/c++/impl/BinaryEncoder.cc
@@ -144,4 +144,4 @@ void BinaryEncoder::doEncodeLong(int64_t l) {
     auto size = encodeInt64(l, bytes);
     out_.writeBytes(bytes.data(), size);
 }
-}   // namespace avro
+} // namespace avro
diff --git a/lang/c++/impl/Compiler.cc b/lang/c++/impl/Compiler.cc
index f7ab8ff..5427636 100644
--- a/lang/c++/impl/Compiler.cc
+++ b/lang/c++/impl/Compiler.cc
@@ -20,28 +20,27 @@
 #include <utility>
 
 #include "Compiler.hh"
-#include "Types.hh"
 #include "Schema.hh"
-#include "ValidSchema.hh"
 #include "Stream.hh"
+#include "Types.hh"
+#include "ValidSchema.hh"
 
 #include "json/JsonDom.hh"
 
-using std::string;
+using std::make_pair;
 using std::map;
-using std::vector;
 using std::pair;
-using std::make_pair;
+using std::string;
+using std::vector;
 
 namespace avro {
-using json::Entity;
-using json::Object;
 using json::Array;
+using json::Entity;
 using json::EntityType;
+using json::Object;
 
 using SymbolTable = map<Name, NodePtr>;
 
-
 // #define DEBUG_VERBOSE
 
 static NodePtr makePrimitive(const string &t) {
@@ -110,8 +109,7 @@ json::Object::const_iterator findField(const Entity &e,
 template<typename T>
 void ensureType(const Entity &e, const string &name) {
     if (e.type() != json::type_traits<T>::type()) {
-        throw Exception(boost::format("Json field \"%1%\" is not a %2%: %3%") %
-            name % json::type_traits<T>::name() % e.toString());
+        throw Exception(boost::format("Json field \"%1%\" is not a %2%: %3%") % name % json::type_traits<T>::name() % e.toString());
     }
 }
 
@@ -148,16 +146,14 @@ struct Field {
     const string name;
     const NodePtr schema;
     const GenericDatum defaultValue;
-    Field(string n, NodePtr v, GenericDatum dv) :
-        name(std::move(n)), schema(std::move(v)), defaultValue(std::move(dv)) {}
+    Field(string n, NodePtr v, GenericDatum dv) : name(std::move(n)), schema(std::move(v)), defaultValue(std::move(dv)) {}
 };
 
 static void assertType(const Entity &e, EntityType et) {
     if (e.type() != et) {
         throw Exception(boost::format("Unexpected type for default value: "
-                                      "Expected %1%, but found %2% in line %3%") %
-            json::typeToString(et) % json::typeToString(e.type()) %
-            e.line());
+                                      "Expected %1%, but found %2% in line %3%")
+                        % json::typeToString(et) % json::typeToString(e.type()) % e.line());
     }
 }
 
@@ -179,13 +175,17 @@ static GenericDatum makeGenericDatum(NodePtr n,
         t = n->type();
     }
     switch (t) {
-        case AVRO_STRING:assertType(e, json::etString);
+        case AVRO_STRING:
+            assertType(e, json::etString);
             return GenericDatum(e.stringValue());
-        case AVRO_BYTES:assertType(e, json::etString);
+        case AVRO_BYTES:
+            assertType(e, json::etString);
             return GenericDatum(toBin(e.bytesValue()));
-        case AVRO_INT:assertType(e, json::etLong);
+        case AVRO_INT:
+            assertType(e, json::etLong);
             return GenericDatum(static_cast<int32_t>(e.longValue()));
-        case AVRO_LONG:assertType(e, json::etLong);
+        case AVRO_LONG:
+            assertType(e, json::etLong);
             return GenericDatum(e.longValue());
         case AVRO_FLOAT:
             if (dt == json::etLong) {
@@ -199,9 +199,11 @@ static GenericDatum makeGenericDatum(NodePtr n,
             }
             assertType(e, json::etDouble);
             return GenericDatum(e.doubleValue());
-        case AVRO_BOOL:assertType(e, json::etBool);
+        case AVRO_BOOL:
+            assertType(e, json::etBool);
             return GenericDatum(e.boolValue());
-        case AVRO_NULL:assertType(e, json::etNull);
+        case AVRO_NULL:
+            assertType(e, json::etNull);
             return GenericDatum();
         case AVRO_RECORD: {
             assertType(e, json::etObject);
@@ -211,14 +213,16 @@ static GenericDatum makeGenericDatum(NodePtr n,
                 auto it = v.find(n->nameAt(i));
                 if (it == v.end()) {
                     throw Exception(boost::format(
-                        "No value found in default for %1%") % n->nameAt(i));
+                                        "No value found in default for %1%")
+                                    % n->nameAt(i));
                 }
                 result.setFieldAt(i,
                                   makeGenericDatum(n->leafAt(i), it->second, st));
             }
             return GenericDatum(n, result);
         }
-        case AVRO_ENUM:assertType(e, json::etString);
+        case AVRO_ENUM:
+            assertType(e, json::etString);
             return GenericDatum(n, GenericEnum(n, e.stringValue()));
         case AVRO_ARRAY: {
             assertType(e, json::etArray);
@@ -245,9 +249,10 @@ static GenericDatum makeGenericDatum(NodePtr n,
             result.datum() = makeGenericDatum(n->leafAt(0), e, st);
             return GenericDatum(n, result);
         }
-        case AVRO_FIXED:assertType(e, json::etString);
+        case AVRO_FIXED:
+            assertType(e, json::etString);
             return GenericDatum(n, GenericFixed(n, toBin(e.bytesValue())));
-        default:throw Exception(boost::format("Unknown type: %1%") % t);
+        default: throw Exception(boost::format("Unknown type: %1%") % t);
     }
 }
 
@@ -260,8 +265,7 @@ static Field makeField(const Entity &e, SymbolTable &st, const string &ns) {
     if (containsField(m, "doc")) {
         node->setDoc(getDocField(e, m));
     }
-    GenericDatum d = (it2 == m.end()) ? GenericDatum() :
-                     makeGenericDatum(node, it2->second, st);
+    GenericDatum d = (it2 == m.end()) ? GenericDatum() : makeGenericDatum(node, it2->second, st);
     return Field(n, node, d);
 }
 
@@ -337,8 +341,7 @@ static NodePtr makeEnumNode(const Entity &e,
     concepts::MultiAttribute<string> symbols;
     for (const auto &it : v) {
         if (it.type() != json::etString) {
-            throw Exception(boost::format("Enum symbol not a string: %1%") %
-                it.toString());
+            throw Exception(boost::format("Enum symbol not a string: %1%") % it.toString());
         }
         symbols.add(it.stringValue());
     }
@@ -353,8 +356,7 @@ static NodePtr makeFixedNode(const Entity &e,
                              const Name &name, const Object &m) {
     int v = static_cast<int>(getLongField(e, m, "size"));
     if (v <= 0) {
-        throw Exception(boost::format("Size for fixed is not positive: %1%") %
-            e.toString());
+        throw Exception(boost::format("Size for fixed is not positive: %1%") % e.toString());
     }
     NodePtr node =
         NodePtr(new NodeFixed(asSingleAttribute(name), asSingleAttribute(v)));
@@ -397,9 +399,8 @@ static Name getName(const Entity &e, const Object &m, const string &ns) {
         if (it != m.end()) {
             if (it->second.type() != json::type_traits<string>::type()) {
                 throw Exception(boost::format(
-                    "Json field \"%1%\" is not a %2%: %3%") %
-                    "namespace" % json::type_traits<string>::name() %
-                    it->second.toString());
+                                    "Json field \"%1%\" is not a %2%: %3%")
+                                % "namespace" % json::type_traits<string>::name() % it->second.toString());
             }
             Name result = Name(name, it->second.stringValue());
             return result;
@@ -412,8 +413,7 @@ static NodePtr makeNode(const Entity &e, const Object &m,
                         SymbolTable &st, const string &ns) {
     const string &type = getStringField(e, m, "type");
     NodePtr result;
-    if (type == "record" || type == "error" ||
-        type == "enum" || type == "fixed") {
+    if (type == "record" || type == "error" || type == "enum" || type == "fixed") {
         Name nm = getName(e, m, ns);
         if (type == "record" || type == "error") {
             result = NodePtr(new NodeRecord());
@@ -423,17 +423,15 @@ static NodePtr makeNode(const Entity &e, const Object &m,
                 string doc = getDocField(e, m);
 
                 NodePtr r = makeRecordNode(e, nm, &doc, m, st, nm.ns());
-                (std::dynamic_pointer_cast<NodeRecord>(r))->swap(
-                    *std::dynamic_pointer_cast<NodeRecord>(result));
-            } else {  // No doc
+                (std::dynamic_pointer_cast<NodeRecord>(r))->swap(*std::dynamic_pointer_cast<NodeRecord>(result));
+            } else { // No doc
                 NodePtr r =
                     makeRecordNode(e, nm, nullptr, m, st, nm.ns());
                 (std::dynamic_pointer_cast<NodeRecord>(r))
                     ->swap(*std::dynamic_pointer_cast<NodeRecord>(result));
             }
         } else {
-            result = (type == "enum") ? makeEnumNode(e, nm, m) :
-                     makeFixedNode(e, nm, m);
+            result = (type == "enum") ? makeEnumNode(e, nm, m) : makeFixedNode(e, nm, m);
             st[nm] = result;
         }
     } else if (type == "array") {
@@ -455,7 +453,7 @@ static NodePtr makeNode(const Entity &e, const Object &m,
     }
 
     throw Exception(boost::format("Unknown type definition: %1%")
-                        % e.toString());
+                    % e.toString());
 }
 
 static NodePtr makeNode(const Entity &e, const Array &m,
@@ -469,17 +467,16 @@ static NodePtr makeNode(const Entity &e, const Array &m,
 
 static NodePtr makeNode(const json::Entity &e, SymbolTable &st, const string &ns) {
     switch (e.type()) {
-        case json::etString:return makeNode(e.stringValue(), st, ns);
-        case json::etObject:return makeNode(e, e.objectValue(), st, ns);
-        case json::etArray:return makeNode(e, e.arrayValue(), st, ns);
-        default:throw Exception(boost::format("Invalid Avro type: %1%") % e.toString());
+        case json::etString: return makeNode(e.stringValue(), st, ns);
+        case json::etObject: return makeNode(e, e.objectValue(), st, ns);
+        case json::etArray: return makeNode(e, e.arrayValue(), st, ns);
+        default: throw Exception(boost::format("Invalid Avro type: %1%") % e.toString());
     }
 }
 json::Object::const_iterator findField(const Entity &e, const Object &m, const string &fieldName) {
     auto it = m.find(fieldName);
     if (it == m.end()) {
-        throw Exception(boost::format("Missing Json field \"%1%\": %2%") %
-            fieldName % e.toString());
+        throw Exception(boost::format("Missing Json field \"%1%\": %2%") % fieldName % e.toString());
     } else {
         return it;
     }
@@ -537,7 +534,6 @@ AVRO_DECL bool compileJsonSchema(std::istream &is, ValidSchema &schema, string &
         error = e.what();
         return false;
     }
-
 }
 
 } // namespace avro
diff --git a/lang/c++/impl/DataFile.cc b/lang/c++/impl/DataFile.cc
index 2ff6734..8f67a01 100644
--- a/lang/c++/impl/DataFile.cc
+++ b/lang/c++/impl/DataFile.cc
@@ -22,23 +22,23 @@
 
 #include <sstream>
 
-#include <boost/random/mersenne_twister.hpp>
+#include <boost/crc.hpp> // for boost::crc_32_type
 #include <boost/iostreams/device/file.hpp>
 #include <boost/iostreams/filter/gzip.hpp>
 #include <boost/iostreams/filter/zlib.hpp>
-#include <boost/crc.hpp>  // for boost::crc_32_type
+#include <boost/random/mersenne_twister.hpp>
 
 #ifdef SNAPPY_CODEC_AVAILABLE
 #include <snappy.h>
 #endif
 
 namespace avro {
-using std::unique_ptr;
-using std::ostringstream;
-using std::istringstream;
-using std::vector;
 using std::copy;
+using std::istringstream;
+using std::ostringstream;
 using std::string;
+using std::unique_ptr;
+using std::vector;
 
 using std::array;
 
@@ -56,63 +56,59 @@ const size_t minSyncInterval = 32;
 const size_t maxSyncInterval = 1u << 30;
 
 boost::iostreams::zlib_params get_zlib_params() {
-  boost::iostreams::zlib_params ret;
-  ret.method = boost::iostreams::zlib::deflated;
-  ret.noheader = true;
-  return ret;
-}
-}
-
-DataFileWriterBase::DataFileWriterBase(const char* filename, const ValidSchema& schema, size_t syncInterval,
-                                       Codec codec) :
-    filename_(filename),
-    schema_(schema),
-    encoderPtr_(binaryEncoder()),
-    syncInterval_(syncInterval),
-    codec_(codec),
-    stream_(fileOutputStream(filename)),
-    buffer_(memoryOutputStream()),
-    sync_(makeSync()),
-    objectCount_(0),
-    lastSync_(0)
-{
+    boost::iostreams::zlib_params ret;
+    ret.method = boost::iostreams::zlib::deflated;
+    ret.noheader = true;
+    return ret;
+}
+} // namespace
+
+DataFileWriterBase::DataFileWriterBase(const char *filename, const ValidSchema &schema, size_t syncInterval,
+                                       Codec codec) : filename_(filename),
+                                                      schema_(schema),
+                                                      encoderPtr_(binaryEncoder()),
+                                                      syncInterval_(syncInterval),
+                                                      codec_(codec),
+                                                      stream_(fileOutputStream(filename)),
+                                                      buffer_(memoryOutputStream()),
+                                                      sync_(makeSync()),
+                                                      objectCount_(0),
+                                                      lastSync_(0) {
     init(schema, syncInterval, codec);
 }
 
 DataFileWriterBase::DataFileWriterBase(std::unique_ptr<OutputStream> outputStream,
-    const ValidSchema& schema, size_t syncInterval, Codec codec) :
-    filename_(),
-    schema_(schema),
-    encoderPtr_(binaryEncoder()),
-    syncInterval_(syncInterval),
-    codec_(codec),
-    stream_(std::move(outputStream)),
-    buffer_(memoryOutputStream()),
-    sync_(makeSync()),
-    objectCount_(0),
-    lastSync_(0)
-{
+                                       const ValidSchema &schema, size_t syncInterval, Codec codec) : filename_(),
+                                                                                                      schema_(schema),
+                                                                                                      encoderPtr_(binaryEncoder()),
+                                                                                                      syncInterval_(syncInterval),
+                                                                                                      codec_(codec),
+                                                                                                      stream_(std::move(outputStream)),
+                                                                                                      buffer_(memoryOutputStream()),
+                                                                                                      sync_(makeSync()),
+                                                                                                      objectCount_(0),
+                                                                                                      lastSync_(0) {
     init(schema, syncInterval, codec);
 }
 
 void DataFileWriterBase::init(const ValidSchema &schema, size_t syncInterval, const Codec &codec) {
     if (syncInterval < minSyncInterval || syncInterval > maxSyncInterval) {
         throw Exception(boost::format("Invalid sync interval: %1%. "
-            "Should be between %2% and %3%") % syncInterval %
-                        minSyncInterval % maxSyncInterval);
+                                      "Should be between %2% and %3%")
+                        % syncInterval % minSyncInterval % maxSyncInterval);
     }
     setMetadata(AVRO_CODEC_KEY, AVRO_NULL_CODEC);
 
     if (codec_ == NULL_CODEC) {
-      setMetadata(AVRO_CODEC_KEY, AVRO_NULL_CODEC);
+        setMetadata(AVRO_CODEC_KEY, AVRO_NULL_CODEC);
     } else if (codec_ == DEFLATE_CODEC) {
-      setMetadata(AVRO_CODEC_KEY, AVRO_DEFLATE_CODEC);
+        setMetadata(AVRO_CODEC_KEY, AVRO_DEFLATE_CODEC);
 #ifdef SNAPPY_CODEC_AVAILABLE
     } else if (codec_ == SNAPPY_CODEC) {
-      setMetadata(AVRO_CODEC_KEY, AVRO_SNAPPY_CODEC);
+        setMetadata(AVRO_CODEC_KEY, AVRO_SNAPPY_CODEC);
 #endif
     } else {
-      throw Exception(boost::format("Unknown codec: %1%") % codec);
+        throw Exception(boost::format("Unknown codec: %1%") % codec);
     }
     setMetadata(AVRO_SCHEMA_KEY, schema.toJson(false));
 
@@ -122,22 +118,18 @@ void DataFileWriterBase::init(const ValidSchema &schema, size_t syncInterval, co
     lastSync_ = stream_->byteCount();
 }
 
-
-DataFileWriterBase::~DataFileWriterBase()
-{
+DataFileWriterBase::~DataFileWriterBase() {
     if (stream_) {
         close();
     }
 }
 
-void DataFileWriterBase::close()
-{
+void DataFileWriterBase::close() {
     flush();
     stream_.reset();
 }
 
-void DataFileWriterBase::sync()
-{
+void DataFileWriterBase::sync() {
     encoderPtr_->flush();
 
     encoderPtr_->init(*stream_);
@@ -154,16 +146,16 @@ void DataFileWriterBase::sync()
             boost::iostreams::filtering_ostream os;
             os.push(boost::iostreams::zlib_compressor(get_zlib_params()));
             os.push(boost::iostreams::back_inserter(buf));
-            const uint8_t* data;
+            const uint8_t *data;
             size_t len;
 
             std::unique_ptr<InputStream> input = memoryInputStream(*buffer_);
             while (input->next(&data, &len)) {
-                boost::iostreams::write(os, reinterpret_cast<const char*>(data), len);
+                boost::iostreams::write(os, reinterpret_cast<const char *>(data), len);
             }
         } // make sure all is flushed
         std::unique_ptr<InputStream> in = memoryInputStream(
-           reinterpret_cast<const uint8_t*>(buf.data()), buf.size());
+            reinterpret_cast<const uint8_t *>(buf.data()), buf.size());
         int64_t byteCount = buf.size();
         avro::encode(*encoderPtr_, byteCount);
         encoderPtr_->flush();
@@ -176,25 +168,25 @@ void DataFileWriterBase::sync()
         {
             boost::iostreams::filtering_ostream os;
             os.push(boost::iostreams::back_inserter(temp));
-            const uint8_t* data;
+            const uint8_t *data;
             size_t len;
 
             std::unique_ptr<InputStream> input = memoryInputStream(*buffer_);
             while (input->next(&data, &len)) {
-                boost::iostreams::write(os, reinterpret_cast<const char*>(data),
-                        len);
+                boost::iostreams::write(os, reinterpret_cast<const char *>(data),
+                                        len);
             }
         } // make sure all is flushed
 
-        crc.process_bytes(reinterpret_cast<const char*>(temp.data()),
-                temp.size());
+        crc.process_bytes(reinterpret_cast<const char *>(temp.data()),
+                          temp.size());
         // For Snappy, add the CRC32 checksum
         int32_t checksum = crc();
 
         // Now compress
         size_t compressed_size = snappy::Compress(
-                reinterpret_cast<const char*>(temp.data()), temp.size(),
-                &compressed);
+            reinterpret_cast<const char *>(temp.data()), temp.size(),
+            &compressed);
         temp.clear();
         {
             boost::iostreams::filtering_ostream os;
@@ -206,7 +198,7 @@ void DataFileWriterBase::sync()
         temp.push_back((checksum >> 8) & 0xFF);
         temp.push_back(checksum & 0xFF);
         std::unique_ptr<InputStream> in = memoryInputStream(
-                reinterpret_cast<const uint8_t*>(temp.data()), temp.size());
+            reinterpret_cast<const uint8_t *>(temp.data()), temp.size());
         int64_t byteCount = temp.size();
         avro::encode(*encoderPtr_, byteCount);
         encoderPtr_->flush();
@@ -225,38 +217,33 @@ void DataFileWriterBase::sync()
     objectCount_ = 0;
 }
 
-void DataFileWriterBase::syncIfNeeded()
-{
+void DataFileWriterBase::syncIfNeeded() {
     encoderPtr_->flush();
     if (buffer_->byteCount() >= syncInterval_) {
         sync();
     }
 }
 
-uint64_t DataFileWriterBase::getCurrentBlockStart() const
-{
+uint64_t DataFileWriterBase::getCurrentBlockStart() const {
     return lastSync_;
 }
 
-void DataFileWriterBase::flush()
-{
+void DataFileWriterBase::flush() {
     sync();
 }
 
 boost::mt19937 random(static_cast<uint32_t>(time(nullptr)));
 
-DataFileSync DataFileWriterBase::makeSync()
-{
+DataFileSync DataFileWriterBase::makeSync() {
     DataFileSync sync;
     std::generate(sync.begin(), sync.end(), random);
     return sync;
 }
 
 typedef array<uint8_t, 4> Magic;
-static Magic magic = { { 'O', 'b', 'j', '\x01' } };
+static Magic magic = {{'O', 'b', 'j', '\x01'}};
 
-void DataFileWriterBase::writeHeader()
-{
+void DataFileWriterBase::writeHeader() {
     encoderPtr_->init(*stream_);
     avro::encode(*encoderPtr_, magic);
     avro::encode(*encoderPtr_, metadata_);
@@ -264,69 +251,56 @@ void DataFileWriterBase::writeHeader()
     encoderPtr_->flush();
 }
 
-void DataFileWriterBase::setMetadata(const string& key, const string& value)
-{
+void DataFileWriterBase::setMetadata(const string &key, const string &value) {
     vector<uint8_t> v(value.size());
     copy(value.begin(), value.end(), v.begin());
     metadata_[key] = v;
 }
 
-DataFileReaderBase::DataFileReaderBase(const char* filename) :
-    filename_(filename), codec_(NULL_CODEC), stream_(fileSeekableInputStream(filename)),
-    decoder_(binaryDecoder()), objectCount_(0), eof_(false), blockStart_(-1),
-    blockEnd_(-1)
-{
+DataFileReaderBase::DataFileReaderBase(const char *filename) : filename_(filename), codec_(NULL_CODEC), stream_(fileSeekableInputStream(filename)),
+                                                               decoder_(binaryDecoder()), objectCount_(0), eof_(false), blockStart_(-1),
+                                                               blockEnd_(-1) {
     readHeader();
 }
 
-DataFileReaderBase::DataFileReaderBase(std::unique_ptr<InputStream> inputStream) :
-    codec_(NULL_CODEC), stream_(std::move(inputStream)),
-    decoder_(binaryDecoder()), objectCount_(0), eof_(false)
-{
+DataFileReaderBase::DataFileReaderBase(std::unique_ptr<InputStream> inputStream) : codec_(NULL_CODEC), stream_(std::move(inputStream)),
+                                                                                   decoder_(binaryDecoder()), objectCount_(0), eof_(false) {
     readHeader();
 }
 
-void DataFileReaderBase::init()
-{
+void DataFileReaderBase::init() {
     readerSchema_ = dataSchema_;
-    dataDecoder_  = binaryDecoder();
+    dataDecoder_ = binaryDecoder();
     readDataBlock();
 }
 
-void DataFileReaderBase::init(const ValidSchema& readerSchema)
-{
+void DataFileReaderBase::init(const ValidSchema &readerSchema) {
     readerSchema_ = readerSchema;
-    dataDecoder_  = (readerSchema_.toJson(true) != dataSchema_.toJson(true)) ?
-        resolvingDecoder(dataSchema_, readerSchema_, binaryDecoder()) :
-        binaryDecoder();
+    dataDecoder_ = (readerSchema_.toJson(true) != dataSchema_.toJson(true)) ? resolvingDecoder(dataSchema_, readerSchema_, binaryDecoder()) : binaryDecoder();
     readDataBlock();
 }
 
-static void drain(InputStream& in)
-{
+static void drain(InputStream &in) {
     const uint8_t *p = nullptr;
     size_t n = 0;
-    while (in.next(&p, &n));
+    while (in.next(&p, &n))
+        ;
 }
 
-char hex(unsigned int x)
-{
-    return static_cast<char>(x + (x < 10 ? '0' :  ('a' - 10)));
+char hex(unsigned int x) {
+    return static_cast<char>(x + (x < 10 ? '0' : ('a' - 10)));
 }
 
-std::ostream& operator << (std::ostream& os, const DataFileSync& s)
-{
+std::ostream &operator<<(std::ostream &os, const DataFileSync &s) {
     for (uint8_t i : s) {
-        os << hex(i / 16)  << hex(i % 16) << ' ';
+        os << hex(i / 16) << hex(i % 16) << ' ';
     }
     os << std::endl;
     return os;
 }
 
-
-bool DataFileReaderBase::hasMore()
-{
-    for (; ;) {
+bool DataFileReaderBase::hasMore() {
+    for (;;) {
         if (eof_) {
             return false;
         } else if (objectCount_ != 0) {
@@ -346,10 +320,10 @@ bool DataFileReaderBase::hasMore()
 }
 
 class BoundedInputStream : public InputStream {
-    InputStream& in_;
+    InputStream &in_;
     size_t limit_;
 
-    bool next(const uint8_t** data, size_t* len) override {
+    bool next(const uint8_t **data, size_t *len) override {
         if (limit_ != 0 && in_.next(data, len)) {
             if (*len > limit_) {
                 in_.backup(*len - limit_);
@@ -379,22 +353,19 @@ class BoundedInputStream : public InputStream {
     }
 
 public:
-    BoundedInputStream(InputStream& in, size_t limit) :
-        in_(in), limit_(limit) { }
+    BoundedInputStream(InputStream &in, size_t limit) : in_(in), limit_(limit) {}
 };
 
-unique_ptr<InputStream> boundedInputStream(InputStream& in, size_t limit)
-{
+unique_ptr<InputStream> boundedInputStream(InputStream &in, size_t limit) {
     return unique_ptr<InputStream>(new BoundedInputStream(in, limit));
 }
 
-void DataFileReaderBase::readDataBlock()
-{
+void DataFileReaderBase::readDataBlock() {
     decoder_->init(*stream_);
     blockStart_ = stream_->byteCount();
-    const uint8_t* p = nullptr;
+    const uint8_t *p = nullptr;
     size_t n = 0;
-    if (! stream_->next(&p, &n)) {
+    if (!stream_->next(&p, &n)) {
         eof_ = true;
         return;
     }
@@ -415,7 +386,7 @@ void DataFileReaderBase::readDataBlock()
         uint32_t checksum = 0;
         compressed_.clear();
         uncompressed.clear();
-        const uint8_t* data;
+        const uint8_t *data;
         size_t len;
         while (st->next(&data, &len)) {
             compressed_.insert(compressed_.end(), data, data + len);
@@ -427,20 +398,22 @@ void DataFileReaderBase::readDataBlock()
         int b4 = compressed_[len - 1] & 0xFF;
 
         checksum = (b1 << 24) + (b2 << 16) + (b3 << 8) + (b4);
-        if (!snappy::Uncompress(reinterpret_cast<const char*>(compressed_.data()),
-                len - 4, &uncompressed)) {
+        if (!snappy::Uncompress(reinterpret_cast<const char *>(compressed_.data()),
+                                len - 4, &uncompressed)) {
             throw Exception(
-                    "Snappy Compression reported an error when decompressing");
+                "Snappy Compression reported an error when decompressing");
         }
         crc.process_bytes(uncompressed.c_str(), uncompressed.size());
         uint32_t c = crc();
         if (checksum != c) {
-            throw Exception(boost::format("Checksum did not match for Snappy compression: Expected: %1%, computed: %2%") % checksum % c);
+            throw Exception(
+                boost::format("Checksum did not match for Snappy compression: Expected: %1%, computed: %2%") % checksum
+                % c);
         }
         os_.reset(new boost::iostreams::filtering_istream());
         os_->push(
-                boost::iostreams::basic_array_source<char>(uncompressed.c_str(),
-                        uncompressed.size()));
+            boost::iostreams::basic_array_source<char>(uncompressed.c_str(),
+                                                       uncompressed.size()));
         std::unique_ptr<InputStream> in = istreamInputStream(*os_);
 
         dataDecoder_->init(*in);
@@ -448,7 +421,7 @@ void DataFileReaderBase::readDataBlock()
 #endif
     } else {
         compressed_.clear();
-        const uint8_t* data;
+        const uint8_t *data;
         size_t len;
         while (st->next(&data, &len)) {
             compressed_.insert(compressed_.end(), data, data + len);
@@ -456,7 +429,7 @@ void DataFileReaderBase::readDataBlock()
         os_.reset(new boost::iostreams::filtering_istream());
         os_->push(boost::iostreams::zlib_decompressor(get_zlib_params()));
         os_->push(boost::iostreams::basic_array_source<char>(
-                                                             compressed_.data(), compressed_.size()));
+            compressed_.data(), compressed_.size()));
 
         std::unique_ptr<InputStream> in = nonSeekableIstreamInputStream(*os_);
         dataDecoder_->init(*in);
@@ -464,34 +437,30 @@ void DataFileReaderBase::readDataBlock()
     }
 }
 
-void DataFileReaderBase::close()
-{
+void DataFileReaderBase::close() {
 }
 
-static string toString(const vector<uint8_t>& v)
-{
+static string toString(const vector<uint8_t> &v) {
     string result;
     result.resize(v.size());
     copy(v.begin(), v.end(), result.begin());
     return result;
 }
 
-static ValidSchema makeSchema(const vector<uint8_t>& v)
-{
+static ValidSchema makeSchema(const vector<uint8_t> &v) {
     istringstream iss(toString(v));
     ValidSchema vs;
     compileJsonSchema(iss, vs);
     return ValidSchema(vs);
 }
 
-void DataFileReaderBase::readHeader()
-{
+void DataFileReaderBase::readHeader() {
     decoder_->init(*stream_);
     Magic m;
     avro::decode(*decoder_, m);
     if (magic != m) {
         throw Exception("Invalid data file. Magic does not match: "
-            + filename_);
+                        + filename_);
     }
     avro::decode(*decoder_, metadata_);
     Metadata::const_iterator it = metadata_.find(AVRO_SCHEMA_KEY);
@@ -500,7 +469,7 @@ void DataFileReaderBase::readHeader()
     }
 
     dataSchema_ = makeSchema(it->second);
-    if (! readerSchema_.root()) {
+    if (!readerSchema_.root()) {
         readerSchema_ = dataSchema();
     }
 
@@ -509,7 +478,7 @@ void DataFileReaderBase::readHeader()
         codec_ = DEFLATE_CODEC;
 #ifdef SNAPPY_CODEC_AVAILABLE
     } else if (it != metadata_.end()
-            && toString(it->second) == AVRO_SNAPPY_CODEC) {
+               && toString(it->second) == AVRO_SNAPPY_CODEC) {
         codec_ = SNAPPY_CODEC;
 #endif
     } else {
@@ -524,8 +493,7 @@ void DataFileReaderBase::readHeader()
     blockStart_ = stream_->byteCount();
 }
 
-void DataFileReaderBase::doSeek(int64_t position)
-{
+void DataFileReaderBase::doSeek(int64_t position) {
     if (auto *ss = dynamic_cast<SeekableInputStream *>(stream_.get())) {
         if (!eof_) {
             dataDecoder_->init(*dataStream_);
@@ -539,14 +507,12 @@ void DataFileReaderBase::doSeek(int64_t position)
     }
 }
 
-void DataFileReaderBase::seek(int64_t position)
-{
+void DataFileReaderBase::seek(int64_t position) {
     doSeek(position);
     readDataBlock();
 }
 
-void DataFileReaderBase::sync(int64_t position)
-{
+void DataFileReaderBase::sync(int64_t position) {
     doSeek(position);
     DataFileSync sync_buffer;
     const uint8_t *p = nullptr;
@@ -587,11 +553,11 @@ void DataFileReaderBase::sync(int64_t position)
 }
 
 bool DataFileReaderBase::pastSync(int64_t position) {
-  return !hasMore() || blockStart_ >= position + SyncSize;
+    return !hasMore() || blockStart_ >= position + SyncSize;
 }
 
 int64_t DataFileReaderBase::previousSync() const {
-  return blockStart_;
+    return blockStart_;
 }
 
-}   // namespace avro
+} // namespace avro
diff --git a/lang/c++/impl/FileStream.cc b/lang/c++/impl/FileStream.cc
index 67e850c..9fda4ec 100644
--- a/lang/c++/impl/FileStream.cc
+++ b/lang/c++/impl/FileStream.cc
@@ -16,11 +16,11 @@
  * limitations under the License.
  */
 
-#include <fstream>
 #include "Stream.hh"
+#include <fstream>
 #ifndef _WIN32
-#include "unistd.h"
 #include "fcntl.h"
+#include "unistd.h"
 #include <cerrno>
 
 #ifndef O_BINARY
@@ -34,9 +34,9 @@
 #endif
 #endif
 
-using std::unique_ptr;
 using std::istream;
 using std::ostream;
+using std::unique_ptr;
 
 namespace avro {
 namespace {
@@ -44,14 +44,12 @@ struct BufferCopyIn {
     virtual ~BufferCopyIn() = default;
     virtual void seek(size_t len) = 0;
     virtual bool read(uint8_t *b, size_t toRead, size_t &actual) = 0;
-
 };
 
 struct FileBufferCopyIn : public BufferCopyIn {
 #ifdef _WIN32
     HANDLE h_;
-    FileBufferCopyIn(const char* filename) :
-        h_(::CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
+    FileBufferCopyIn(const char *filename) : h_(::CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
         if (h_ == INVALID_HANDLE_VALUE) {
             throw Exception(boost::format("Cannot open file: %1%") % ::GetLastError());
         }
@@ -67,9 +65,9 @@ struct FileBufferCopyIn : public BufferCopyIn {
         }
     }
 
-    bool read(uint8_t* b, size_t toRead, size_t& actual) {
+    bool read(uint8_t *b, size_t toRead, size_t &actual) {
         DWORD dw = 0;
-        if (! ::ReadFile(h_, b, toRead, &dw, NULL)) {
+        if (!::ReadFile(h_, b, toRead, &dw, NULL)) {
             throw Exception(boost::format("Cannot read file: %1%") % ::GetLastError());
         }
         actual = static_cast<size_t>(dw);
@@ -78,11 +76,9 @@ struct FileBufferCopyIn : public BufferCopyIn {
 #else
     const int fd_;
 
-    explicit FileBufferCopyIn(const char *filename) :
-        fd_(open(filename, O_RDONLY | O_BINARY)) {
+    explicit FileBufferCopyIn(const char *filename) : fd_(open(filename, O_RDONLY | O_BINARY)) {
         if (fd_ < 0) {
-            throw Exception(boost::format("Cannot open file: %1%") %
-                ::strerror(errno));
+            throw Exception(boost::format("Cannot open file: %1%") % ::strerror(errno));
         }
     }
 
@@ -93,8 +89,7 @@ struct FileBufferCopyIn : public BufferCopyIn {
     void seek(size_t len) override {
         off_t r = ::lseek(fd_, len, SEEK_CUR);
         if (r == static_cast<off_t>(-1)) {
-            throw Exception(boost::format("Cannot skip file: %1%") %
-                strerror(errno));
+            throw Exception(boost::format("Cannot skip file: %1%") % strerror(errno));
         }
     }
 
@@ -107,7 +102,6 @@ struct FileBufferCopyIn : public BufferCopyIn {
         return false;
     }
 #endif
-
 };
 
 struct IStreamBufferCopyIn : public BufferCopyIn {
@@ -130,7 +124,6 @@ struct IStreamBufferCopyIn : public BufferCopyIn {
         actual = static_cast<size_t>(is_.gcount());
         return (!is_.eof() || actual != 0);
     }
-
 };
 
 struct NonSeekableIStreamBufferCopyIn : public IStreamBufferCopyIn {
@@ -154,7 +147,7 @@ struct NonSeekableIStreamBufferCopyIn : public IStreamBufferCopyIn {
     }
 };
 
-}
+} // namespace
 
 class BufferCopyInInputStream : public SeekableInputStream {
     const size_t bufferSize_;
@@ -218,13 +211,12 @@ class BufferCopyInInputStream : public SeekableInputStream {
     }
 
 public:
-    BufferCopyInInputStream(unique_ptr<BufferCopyIn> in, size_t bufferSize) :
-        bufferSize_(bufferSize),
-        buffer_(new uint8_t[bufferSize]),
-        in_(std::move(in)),
-        byteCount_(0),
-        next_(buffer_),
-        available_(0) {}
+    BufferCopyInInputStream(unique_ptr<BufferCopyIn> in, size_t bufferSize) : bufferSize_(bufferSize),
+                                                                              buffer_(new uint8_t[bufferSize]),
+                                                                              in_(std::move(in)),
+                                                                              byteCount_(0),
+                                                                              next_(buffer_),
+                                                                              available_(0) {}
 
     ~BufferCopyInInputStream() override {
         delete[] buffer_;
@@ -240,8 +232,7 @@ struct BufferCopyOut {
 struct FileBufferCopyOut : public BufferCopyOut {
 #ifdef _WIN32
     HANDLE h_;
-    FileBufferCopyOut(const char* filename) :
-        h_(::CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
+    FileBufferCopyOut(const char *filename) : h_(::CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) {
         if (h_ == INVALID_HANDLE_VALUE) {
             throw Exception(boost::format("Cannot open file: %1%") % ::GetLastError());
         }
@@ -251,10 +242,10 @@ struct FileBufferCopyOut : public BufferCopyOut {
         ::CloseHandle(h_);
     }
 
-    void write(const uint8_t* b, size_t len) {
+    void write(const uint8_t *b, size_t len) {
         while (len > 0) {
             DWORD dw = 0;
-            if (! ::WriteFile(h_, b, len, &dw, NULL)) {
+            if (!::WriteFile(h_, b, len, &dw, NULL)) {
                 throw Exception(boost::format("Cannot read file: %1%") % ::GetLastError());
             }
             b += dw;
@@ -264,12 +255,10 @@ struct FileBufferCopyOut : public BufferCopyOut {
 #else
     const int fd_;
 
-    explicit FileBufferCopyOut(const char *filename) :
-        fd_(::open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644)) {
+    explicit FileBufferCopyOut(const char *filename) : fd_(::open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644)) {
 
         if (fd_ < 0) {
-            throw Exception(boost::format("Cannot open file: %1%") %
-                ::strerror(errno));
+            throw Exception(boost::format("Cannot open file: %1%") % ::strerror(errno));
         }
     }
 
@@ -279,12 +268,10 @@ struct FileBufferCopyOut : public BufferCopyOut {
 
     void write(const uint8_t *b, size_t len) override {
         if (::write(fd_, b, len) < 0) {
-            throw Exception(boost::format("Cannot write file: %1%") %
-                ::strerror(errno));
+            throw Exception(boost::format("Cannot write file: %1%") % ::strerror(errno));
         }
     }
 #endif
-
 };
 
 struct OStreamBufferCopyOut : public BufferCopyOut {
@@ -296,10 +283,9 @@ struct OStreamBufferCopyOut : public BufferCopyOut {
     void write(const uint8_t *b, size_t len) override {
         os_.write(reinterpret_cast<const char *>(b), len);
     }
-
 };
 
-}
+} // namespace
 
 class BufferCopyOutputStream : public OutputStream {
     size_t bufferSize_;
@@ -339,12 +325,11 @@ class BufferCopyOutputStream : public OutputStream {
     }
 
 public:
-    BufferCopyOutputStream(unique_ptr<BufferCopyOut> out, size_t bufferSize) :
-        bufferSize_(bufferSize),
-        buffer_(new uint8_t[bufferSize]),
-        out_(std::move(out)),
-        next_(buffer_),
-        available_(bufferSize_), byteCount_(0) {}
+    BufferCopyOutputStream(unique_ptr<BufferCopyOut> out, size_t bufferSize) : bufferSize_(bufferSize),
+                                                                               buffer_(new uint8_t[bufferSize]),
+                                                                               out_(std::move(out)),
+                                                                               next_(buffer_),
+                                                                               available_(bufferSize_), byteCount_(0) {}
 
     ~BufferCopyOutputStream() override {
         delete[] buffer_;
@@ -387,4 +372,4 @@ unique_ptr<OutputStream> ostreamOutputStream(ostream &os,
     return unique_ptr<OutputStream>(new BufferCopyOutputStream(std::move(out), bufferSize));
 }
 
-}   // namespace avro
+} // namespace avro
diff --git a/lang/c++/impl/Generic.cc b/lang/c++/impl/Generic.cc
index 49f867b..6e0436a 100644
--- a/lang/c++/impl/Generic.cc
+++ b/lang/c++/impl/Generic.cc
@@ -21,29 +21,26 @@
 
 namespace avro {
 
+using std::ostringstream;
 using std::string;
 using std::vector;
-using std::ostringstream;
 
 typedef vector<uint8_t> bytes;
 
 void GenericContainer::assertType(const NodePtr &schema, Type type) {
     if (schema->type() != type) {
-        throw Exception(boost::format("Schema type %1 expected %2") %
-            toString(schema->type()) % toString(type));
+        throw Exception(boost::format("Schema type %1 expected %2") % toString(schema->type()) % toString(type));
     }
 }
 
-GenericReader::GenericReader(ValidSchema s, const DecoderPtr &decoder) :
-    schema_(std::move(s)), isResolving_(dynamic_cast<ResolvingDecoder *>(&(*decoder)) != nullptr),
-    decoder_(decoder) {
+GenericReader::GenericReader(ValidSchema s, const DecoderPtr &decoder) : schema_(std::move(s)), isResolving_(dynamic_cast<ResolvingDecoder *>(&(*decoder)) != nullptr),
+                                                                         decoder_(decoder) {
 }
 
 GenericReader::GenericReader(const ValidSchema &writerSchema,
-                             const ValidSchema &readerSchema, const DecoderPtr &decoder) :
-    schema_(readerSchema),
-    isResolving_(true),
-    decoder_(resolvingDecoder(writerSchema, readerSchema, decoder)) {
+                             const ValidSchema &readerSchema, const DecoderPtr &decoder) : schema_(readerSchema),
+                                                                                           isResolving_(true),
+                                                                                           decoder_(resolvingDecoder(writerSchema, readerSchema, decoder)) {
 }
 
 void GenericReader::read(GenericDatum &datum) const {
@@ -56,27 +53,34 @@ void GenericReader::read(GenericDatum &datum, Decoder &d, bool isResolving) {
         datum.selectBranch(d.decodeUnionIndex());
     }
     switch (datum.type()) {
-        case AVRO_NULL:d.decodeNull();
+        case AVRO_NULL:
+            d.decodeNull();
             break;
-        case AVRO_BOOL:datum.value<bool>() = d.decodeBool();
+        case AVRO_BOOL:
+            datum.value<bool>() = d.decodeBool();
             break;
-        case AVRO_INT:datum.value<int32_t>() = d.decodeInt();
+        case AVRO_INT:
+            datum.value<int32_t>() = d.decodeInt();
             break;
-        case AVRO_LONG:datum.value<int64_t>() = d.decodeLong();
+        case AVRO_LONG:
+            datum.value<int64_t>() = d.decodeLong();
             break;
-        case AVRO_FLOAT:datum.value<float>() = d.decodeFloat();
+        case AVRO_FLOAT:
+            datum.value<float>() = d.decodeFloat();
             break;
-        case AVRO_DOUBLE:datum.value<double>() = d.decodeDouble();
+        case AVRO_DOUBLE:
+            datum.value<double>() = d.decodeDouble();
             break;
-        case AVRO_STRING:d.decodeString(datum.value<string>());
+        case AVRO_STRING:
+            d.decodeString(datum.value<string>());
             break;
-        case AVRO_BYTES:d.decodeBytes(datum.value<bytes>());
+        case AVRO_BYTES:
+            d.decodeBytes(datum.value<bytes>());
             break;
         case AVRO_FIXED: {
             auto &f = datum.value<GenericFixed>();
             d.decodeFixed(f.schema()->fixedSize(), f.value());
-        }
-            break;
+        } break;
         case AVRO_RECORD: {
             auto &r = datum.value<GenericRecord>();
             size_t c = r.schema()->leaves();
@@ -91,9 +95,9 @@ void GenericReader::read(GenericDatum &datum, Decoder &d, bool isResolving) {
                     read(r.fieldAt(i), d, isResolving);
                 }
             }
-        }
-            break;
-        case AVRO_ENUM:datum.value<GenericEnum>().set(d.decodeEnum());
+        } break;
+        case AVRO_ENUM:
+            datum.value<GenericEnum>().set(d.decodeEnum());
             break;
         case AVRO_ARRAY: {
             auto &v = datum.value<GenericArray>();
@@ -108,8 +112,7 @@ void GenericReader::read(GenericDatum &datum, Decoder &d, bool isResolving) {
                     read(r[start], d, isResolving);
                 }
             }
-        }
-            break;
+        } break;
         case AVRO_MAP: {
             auto &v = datum.value<GenericMap>();
             GenericMap::Value &r = v.value();
@@ -124,11 +127,9 @@ void GenericReader::read(GenericDatum &datum, Decoder &d, bool isResolving) {
                     read(r[start].second, d, isResolving);
                 }
             }
-        }
-            break;
+        } break;
         default:
-            throw Exception(boost::format("Unknown schema type %1%") %
-                toString(datum.type()));
+            throw Exception(boost::format("Unknown schema type %1%") % toString(datum.type()));
     }
 }
 
@@ -141,8 +142,7 @@ void GenericReader::read(Decoder &d, GenericDatum &g) {
     read(g, d, dynamic_cast<ResolvingDecoder *>(&d) != nullptr);
 }
 
-GenericWriter::GenericWriter(ValidSchema s, EncoderPtr encoder) :
-    schema_(std::move(s)), encoder_(std::move(encoder)) {
+GenericWriter::GenericWriter(ValidSchema s, EncoderPtr encoder) : schema_(std::move(s)), encoder_(std::move(encoder)) {
 }
 
 void GenericWriter::write(const GenericDatum &datum) const {
@@ -154,23 +154,32 @@ void GenericWriter::write(const GenericDatum &datum, Encoder &e) {
         e.encodeUnionIndex(datum.unionBranch());
     }
     switch (datum.type()) {
-        case AVRO_NULL:e.encodeNull();
+        case AVRO_NULL:
+            e.encodeNull();
             break;
-        case AVRO_BOOL:e.encodeBool(datum.value<bool>());
+        case AVRO_BOOL:
+            e.encodeBool(datum.value<bool>());
             break;
-        case AVRO_INT:e.encodeInt(datum.value<int32_t>());
+        case AVRO_INT:
+            e.encodeInt(datum.value<int32_t>());
             break;
-        case AVRO_LONG:e.encodeLong(datum.value<int64_t>());
+        case AVRO_LONG:
+            e.encodeLong(datum.value<int64_t>());
             break;
-        case AVRO_FLOAT:e.encodeFloat(datum.value<float>());
+        case AVRO_FLOAT:
+            e.encodeFloat(datum.value<float>());
             break;
-        case AVRO_DOUBLE:e.encodeDouble(datum.value<double>());
+        case AVRO_DOUBLE:
+            e.encodeDouble(datum.value<double>());
             break;
-        case AVRO_STRING:e.encodeString(datum.value<string>());
+        case AVRO_STRING:
+            e.encodeString(datum.value<string>());
             break;
-        case AVRO_BYTES:e.encodeBytes(datum.value<bytes>());
+        case AVRO_BYTES:
+            e.encodeBytes(datum.value<bytes>());
             break;
-        case AVRO_FIXED:e.encodeFixed(datum.value<GenericFixed>().value());
+        case AVRO_FIXED:
+            e.encodeFixed(datum.value<GenericFixed>().value());
             break;
         case AVRO_RECORD: {
             const auto &r = datum.value<GenericRecord>();
@@ -178,9 +187,9 @@ void GenericWriter::write(const GenericDatum &datum, Encoder &e) {
             for (size_t i = 0; i < c; ++i) {
                 write(r.fieldAt(i), e);
             }
-        }
-            break;
-        case AVRO_ENUM:e.encodeEnum(datum.value<GenericEnum>().value());
+        } break;
+        case AVRO_ENUM:
+            e.encodeEnum(datum.value<GenericEnum>().value());
             break;
         case AVRO_ARRAY: {
             const GenericArray::Value &r = datum.value<GenericArray>().value();
@@ -193,8 +202,7 @@ void GenericWriter::write(const GenericDatum &datum, Encoder &e) {
                 }
             }
             e.arrayEnd();
-        }
-            break;
+        } break;
         case AVRO_MAP: {
             const GenericMap::Value &r = datum.value<GenericMap>().value();
             e.mapStart();
@@ -207,11 +215,9 @@ void GenericWriter::write(const GenericDatum &datum, Encoder &e) {
                 }
             }
             e.mapEnd();
-        }
-            break;
+        } break;
         default:
-            throw Exception(boost::format("Unknown schema type %1%") %
-                toString(datum.type()));
+            throw Exception(boost::format("Unknown schema type %1%") % toString(datum.type()));
     }
 }
 
@@ -219,4 +225,4 @@ void GenericWriter::write(Encoder &e, const GenericDatum &g) {
     write(g, e);
 }
 
-}   // namespace avro
+} // namespace avro
diff --git a/lang/c++/impl/GenericDatum.cc b/lang/c++/impl/GenericDatum.cc
index abd2e2a..7b2bf93 100644
--- a/lang/c++/impl/GenericDatum.cc
+++ b/lang/c++/impl/GenericDatum.cc
@@ -24,15 +24,13 @@ using std::vector;
 
 namespace avro {
 
-GenericDatum::GenericDatum(const ValidSchema &schema) :
-    type_(schema.root()->type()),
-    logicalType_(schema.root()->logicalType()) {
+GenericDatum::GenericDatum(const ValidSchema &schema) : type_(schema.root()->type()),
+                                                        logicalType_(schema.root()->logicalType()) {
     init(schema.root());
 }
 
-GenericDatum::GenericDatum(const NodePtr &schema) :
-    type_(schema->type()),
-    logicalType_(schema->logicalType()) {
+GenericDatum::GenericDatum(const NodePtr &schema) : type_(schema->type()),
+                                                    logicalType_(schema->logicalType()) {
     init(schema);
 }
 
@@ -44,47 +42,57 @@ void GenericDatum::init(const NodePtr &schema) {
         logicalType_ = sc->logicalType();
     }
     switch (type_) {
-        case AVRO_NULL:break;
-        case AVRO_BOOL:value_ = bool();
+        case AVRO_NULL: break;
+        case AVRO_BOOL:
+            value_ = bool();
             break;
-        case AVRO_INT:value_ = int32_t();
+        case AVRO_INT:
+            value_ = int32_t();
             break;
-        case AVRO_LONG:value_ = int64_t();
+        case AVRO_LONG:
+            value_ = int64_t();
             break;
-        case AVRO_FLOAT:value_ = float();
+        case AVRO_FLOAT:
+            value_ = float();
             break;
-        case AVRO_DOUBLE:value_ = double();
+        case AVRO_DOUBLE:
+            value_ = double();
             break;
-        case AVRO_STRING:value_ = string();
+        case AVRO_STRING:
+            value_ = string();
             break;
-        case AVRO_BYTES:value_ = vector<uint8_t>();
+        case AVRO_BYTES:
+            value_ = vector<uint8_t>();
             break;
-        case AVRO_FIXED:value_ = GenericFixed(sc);
+        case AVRO_FIXED:
+            value_ = GenericFixed(sc);
             break;
-        case AVRO_RECORD:value_ = GenericRecord(sc);
+        case AVRO_RECORD:
+            value_ = GenericRecord(sc);
             break;
-        case AVRO_ENUM:value_ = GenericEnum(sc);
+        case AVRO_ENUM:
+            value_ = GenericEnum(sc);
             break;
-        case AVRO_ARRAY:value_ = GenericArray(sc);
+        case AVRO_ARRAY:
+            value_ = GenericArray(sc);
             break;
-        case AVRO_MAP:value_ = GenericMap(sc);
+        case AVRO_MAP:
+            value_ = GenericMap(sc);
             break;
-        case AVRO_UNION:value_ = GenericUnion(sc);
+        case AVRO_UNION:
+            value_ = GenericUnion(sc);
             break;
         default:
-            throw Exception(boost::format("Unknown schema type %1%") %
-                toString(type_));
+            throw Exception(boost::format("Unknown schema type %1%") % toString(type_));
     }
 }
 
-GenericRecord::GenericRecord(const NodePtr &schema) :
-    GenericContainer(AVRO_RECORD, schema) {
+GenericRecord::GenericRecord(const NodePtr &schema) : GenericContainer(AVRO_RECORD, schema) {
     fields_.resize(schema->leaves());
     for (size_t i = 0; i < schema->leaves(); ++i) {
         fields_[i] = GenericDatum(schema->leafAt(i));
     }
 }
 
-GenericFixed::GenericFixed(const NodePtr &schema, const vector<uint8_t> &v) :
-    GenericContainer(AVRO_FIXED, schema), value_(v) {}
-}   // namespace avro
+GenericFixed::GenericFixed(const NodePtr &schema, const vector<uint8_t> &v) : GenericContainer(AVRO_FIXED, schema), value_(v) {}
+} // namespace avro
diff --git a/lang/c++/impl/LogicalType.cc b/lang/c++/impl/LogicalType.cc
index 909596b..1aa24bf 100644
--- a/lang/c++/impl/LogicalType.cc
+++ b/lang/c++/impl/LogicalType.cc
@@ -16,8 +16,8 @@
  * limitations under the License.
  */
 
-#include "Exception.hh"
 #include "LogicalType.hh"
+#include "Exception.hh"
 
 namespace avro {
 
@@ -50,26 +50,34 @@ void LogicalType::setScale(int scale) {
 
 void LogicalType::printJson(std::ostream &os) const {
     switch (type_) {
-        case LogicalType::NONE:break;
-        case LogicalType::DECIMAL:os << R"("logicalType": "decimal")";
+        case LogicalType::NONE: break;
+        case LogicalType::DECIMAL:
+            os << R"("logicalType": "decimal")";
             os << ", \"precision\": " << precision_;
             os << ", \"scale\": " << scale_;
             break;
-        case DATE:os << R"("logicalType": "date")";
+        case DATE:
+            os << R"("logicalType": "date")";
             break;
-        case TIME_MILLIS:os << R"("logicalType": "time-millis")";
+        case TIME_MILLIS:
+            os << R"("logicalType": "time-millis")";
             break;
-        case TIME_MICROS:os << R"("logicalType": "time-micros")";
+        case TIME_MICROS:
+            os << R"("logicalType": "time-micros")";
             break;
-        case TIMESTAMP_MILLIS:os << R"("logicalType": "timestamp-millis")";
+        case TIMESTAMP_MILLIS:
+            os << R"("logicalType": "timestamp-millis")";
             break;
-        case TIMESTAMP_MICROS:os << R"("logicalType": "timestamp-micros")";
+        case TIMESTAMP_MICROS:
+            os << R"("logicalType": "timestamp-micros")";
             break;
-        case DURATION:os << R"("logicalType": "duration")";
+        case DURATION:
+            os << R"("logicalType": "duration")";
             break;
-        case UUID:os << R"("logicalType": "uuid")";
+        case UUID:
+            os << R"("logicalType": "uuid")";
             break;
     }
 }
 
-}  // namespace avro
+} // namespace avro
diff --git a/lang/c++/impl/Node.cc b/lang/c++/impl/Node.cc
index da122cd..46310d0 100644
--- a/lang/c++/impl/Node.cc
+++ b/lang/c++/impl/Node.cc
@@ -59,8 +59,7 @@ static bool invalidChar2(char c) {
 }
 
 void Name::check() const {
-    if (!ns_.empty() && (ns_[0] == '.' || ns_[ns_.size() - 1] == '.'
-        || std::find_if(ns_.begin(), ns_.end(), invalidChar1) != ns_.end())) {
+    if (!ns_.empty() && (ns_[0] == '.' || ns_[ns_.size() - 1] == '.' || std::find_if(ns_.begin(), ns_.end(), invalidChar1) != ns_.end())) {
         throw Exception("Invalid namespace: " + ns_);
     }
     if (simpleName_.empty()
@@ -78,7 +77,7 @@ void Node::setLogicalType(LogicalType logicalType) {
 
     // Check that the logical type is applicable to the node type.
     switch (logicalType.type()) {
-        case LogicalType::NONE:break;
+        case LogicalType::NONE: break;
         case LogicalType::DECIMAL: {
             if (type_ != AVRO_BYTES && type_ != AVRO_FIXED) {
                 throw Exception("DECIMAL logical type can annotate "
@@ -93,8 +92,8 @@ void Node::setLogicalType(LogicalType logicalType) {
                         boost::format(
                             "DECIMAL precision %1% is too large for the "
                             "FIXED type of size %2%, precision cannot be "
-                            "larger than %3%") % logicalType.precision() %
-                            fixedSize() % maxPrecision);
+                            "larger than %3%")
+                        % logicalType.precision() % fixedSize() % maxPrecision);
                 }
             }
             if (logicalType.scale() > logicalType.precision()) {
diff --git a/lang/c++/impl/NodeImpl.cc b/lang/c++/impl/NodeImpl.cc
index 001eb1e..810e164 100644
--- a/lang/c++/impl/NodeImpl.cc
+++ b/lang/c++/impl/NodeImpl.cc
@@ -16,10 +16,9 @@
  * limitations under the License.
  */
 
-
+#include "NodeImpl.hh"
 #include <sstream>
 #include <utility>
-#include "NodeImpl.hh"
 
 using std::string;
 namespace avro {
@@ -34,21 +33,27 @@ string escape(const string &unescaped) {
         switch (c) {
             case '\\':
             case '"':
-            case '/':s += '\\';
+            case '/':
+                s += '\\';
                 s += c;
                 break;
-            case '\b':s += '\\';
+            case '\b':
+                s += '\\';
                 s += 'b';
                 break;
-            case '\f':s += '\f';
+            case '\f':
+                s += '\f';
                 break;
-            case '\n':s += '\\';
+            case '\n':
+                s += '\\';
                 s += 'n';
                 break;
-            case '\r':s += '\\';
+            case '\r':
+                s += '\\';
                 s += 'r';
                 break;
-            case '\t':s += '\\';
+            case '\t':
+                s += '\\';
                 s += 't';
                 break;
             default:
@@ -65,8 +70,7 @@ string escape(const string &unescaped) {
 
 // Wrap an indentation in a struct for ostream operator<<
 struct indent {
-    explicit indent(size_t depth) :
-        d(depth) {}
+    explicit indent(size_t depth) : d(depth) {}
     int d;
 };
 
@@ -113,7 +117,7 @@ NodePrimitive::resolve(const Node &reader) const {
                 return RESOLVE_PROMOTABLE_TO_DOUBLE;
             }
 
-        default:break;
+        default: break;
     }
 
     return furtherResolution(reader);
@@ -184,10 +188,9 @@ SchemaResolution
 NodeFixed::resolve(const Node &reader) const {
     if (reader.type() == AVRO_FIXED) {
         return (
-                   (reader.fixedSize() == fixedSize()) &&
-                       (reader.name() == name())
-               ) ?
-               RESOLVE_MATCH : RESOLVE_NO_MATCH;
+                   (reader.fixedSize() == fixedSize()) && (reader.name() == name()))
+            ? RESOLVE_MATCH
+            : RESOLVE_NO_MATCH;
     }
     return furtherResolution(reader);
 }
@@ -198,32 +201,34 @@ NodeSymbolic::resolve(const Node &reader) const {
     return node->resolve(reader);
 }
 
-void
-NodePrimitive::printJson(std::ostream &os, size_t depth) const {
+void NodePrimitive::printJson(std::ostream &os, size_t depth) const {
     bool hasLogicalType = logicalType().type() != LogicalType::NONE;
 
     if (hasLogicalType) {
-        os << "{\n" << indent(depth) << "\"type\": ";
+        os << "{\n"
+           << indent(depth) << "\"type\": ";
     }
 
     os << '\"' << type() << '\"';
 
     if (hasLogicalType) {
-        os << ",\n" << indent(depth);
+        os << ",\n"
+           << indent(depth);
         logicalType().printJson(os);
         os << "\n}";
     }
     if (!getDoc().empty()) {
-        os << ",\n" << indent(depth) << R"("doc": ")"
+        os << ",\n"
+           << indent(depth) << R"("doc": ")"
            << escape(getDoc()) << "\"";
     }
 }
 
-void
-NodeSymbolic::printJson(std::ostream &os, size_t depth) const {
+void NodeSymbolic::printJson(std::ostream &os, size_t depth) const {
     os << '\"' << nameAttribute_.get() << '\"';
     if (!getDoc().empty()) {
-        os << ",\n" << indent(depth) << R"("doc": ")"
+        os << ",\n"
+           << indent(depth) << R"("doc": ")"
            << escape(getDoc()) << "\"";
     }
 }
@@ -235,8 +240,7 @@ static void printName(std::ostream &os, const Name &n, size_t depth) {
     os << indent(depth) << R"("name": ")" << n.simpleName() << "\",\n";
 }
 
-void
-NodeRecord::printJson(std::ostream &os, size_t depth) const {
+void NodeRecord::printJson(std::ostream &os, size_t depth) const {
     os << "{\n";
     os << indent(++depth) << "\"type\": \"record\",\n";
     printName(os, nameAttribute_.get(), depth);
@@ -254,17 +258,18 @@ NodeRecord::printJson(std::ostream &os, size_t depth) const {
         if (i > 0) {
             os << ',';
         }
-        os << '\n' << indent(depth) << "{\n";
+        os << '\n'
+           << indent(depth) << "{\n";
         os << indent(++depth) << R"("name": ")" << leafNameAttributes_.get(i) << "\",\n";
         os << indent(depth) << "\"type\": ";
         leafAttributes_.get(i)->printJson(os, depth);
 
         if (!defaultValues.empty()) {
-            if (!defaultValues[i].isUnion() &&
-                defaultValues[i].type() == AVRO_NULL) {
+            if (!defaultValues[i].isUnion() && defaultValues[i].type() == AVRO_NULL) {
                 // No "default" field.
             } else {
-                os << ",\n" << indent(depth) << "\"default\": ";
+                os << ",\n"
+                   << indent(depth) << "\"default\": ";
                 leafAttributes_.get(i)->printDefaultToJson(defaultValues[i], os,
                                                            depth);
             }
@@ -272,7 +277,8 @@ NodeRecord::printJson(std::ostream &os, size_t depth) const {
         os << '\n';
         os << indent(--depth) << '}';
     }
-    os << '\n' << indent(--depth) << "]\n";
+    os << '\n'
+       << indent(--depth) << "]\n";
     os << indent(--depth) << '}';
 }
 
@@ -281,23 +287,30 @@ void NodePrimitive::printDefaultToJson(const GenericDatum &g, std::ostream &os,
     assert(isPrimitive(g.type()));
 
     switch (g.type()) {
-        case AVRO_NULL:os << "null";
+        case AVRO_NULL:
+            os << "null";
             break;
-        case AVRO_BOOL:os << (g.value<bool>() ? "true" : "false");
+        case AVRO_BOOL:
+            os << (g.value<bool>() ? "true" : "false");
             break;
-        case AVRO_INT:os << g.value<int32_t>();
+        case AVRO_INT:
+            os << g.value<int32_t>();
             break;
-        case AVRO_LONG:os << g.value<int64_t>();
+        case AVRO_LONG:
+            os << g.value<int64_t>();
             break;
-        case AVRO_FLOAT:os << g.value<float>();
+        case AVRO_FLOAT:
+            os << g.value<float>();
             break;
-        case AVRO_DOUBLE:os << g.value<double>();
+        case AVRO_DOUBLE:
+            os << g.value<double>();
             break;
-        case AVRO_STRING:os << "\"" << escape(g.value<string>()) << "\"";
+        case AVRO_STRING:
+            os << "\"" << escape(g.value<string>()) << "\"";
             break;
         case AVRO_BYTES: {
             // Convert to a string:
-            const auto &vg = g.value<std::vector<uint8_t> >();
+            const auto &vg = g.value<std::vector<uint8_t>>();
             string s;
             s.resize(vg.size() * kByteStringSize);
             for (unsigned int i = 0; i < vg.size(); i++) {
@@ -305,9 +318,8 @@ void NodePrimitive::printDefaultToJson(const GenericDatum &g, std::ostream &os,
                 s.replace(i * kByteStringSize, kByteStringSize, hex_string);
             }
             os << "\"" << s << "\"";
-        }
-            break;
-        default:break;
+        } break;
+        default: break;
     }
 }
 
@@ -356,7 +368,8 @@ void NodeArray::printDefaultToJson(const GenericDatum &g, std::ostream &os,
             leafAt(0)->printDefaultToJson(g.value<GenericArray>().value()[i], os,
                                           depth);
         }
-        os << "\n" << indent(--depth) << "]";
+        os << "\n"
+           << indent(--depth) << "]";
     }
 }
 
@@ -377,7 +390,7 @@ void NodeRecord::printDefaultToJson(const GenericDatum &g, std::ostream &os,
         for (size_t i = 0; i < g.value<GenericRecord>().fieldCount(); i++) {
             if (i == 0) {
                 ++depth;
-            } else {  // i > 0
+            } else { // i > 0
                 os << ",\n";
             }
 
@@ -392,20 +405,20 @@ void NodeRecord::printDefaultToJson(const GenericDatum &g, std::ostream &os,
             leafAt(i)->printDefaultToJson(g.value<GenericRecord>().fieldAt(i), os,
                                           depth);
         }
-        os << "\n" << indent(--depth) << "}";
+        os << "\n"
+           << indent(--depth) << "}";
     }
 }
 NodeRecord::NodeRecord(const HasName &name,
                        const MultiLeaves &fields,
                        const LeafNames &fieldsNames,
-                       std::vector<GenericDatum> dv) :
-    NodeImplRecord(AVRO_RECORD, name, fields, fieldsNames, NoSize()),
-    defaultValues(std::move(dv)) {
+                       std::vector<GenericDatum> dv) : NodeImplRecord(AVRO_RECORD, name, fields, fieldsNames, NoSize()),
+                                                       defaultValues(std::move(dv)) {
     for (size_t i = 0; i < leafNameAttributes_.size(); ++i) {
         if (!nameIndex_.add(leafNameAttributes_.get(i), i)) {
             throw Exception(boost::format(
-                "Cannot add duplicate field: %1%") %
-                leafNameAttributes_.get(i));
+                                "Cannot add duplicate field: %1%")
+                            % leafNameAttributes_.get(i));
         }
     }
 }
@@ -430,12 +443,12 @@ void NodeMap::printDefaultToJson(const GenericDatum &g, std::ostream &os,
             leafAt(i)->printDefaultToJson(g.value<GenericMap>().value()[i].second, os,
                                           depth);
         }
-        os << "\n" << indent(--depth) << "}";
+        os << "\n"
+           << indent(--depth) << "}";
     }
 }
 
-void
-NodeEnum::printJson(std::ostream &os, size_t depth) const {
+void NodeEnum::printJson(std::ostream &os, size_t depth) const {
     os << "{\n";
     os << indent(++depth) << "\"type\": \"enum\",\n";
     if (!getDoc().empty()) {
@@ -458,8 +471,7 @@ NodeEnum::printJson(std::ostream &os, size_t depth) const {
     os << indent(--depth) << '}';
 }
 
-void
-NodeArray::printJson(std::ostream &os, size_t depth) const {
+void NodeArray::printJson(std::ostream &os, size_t depth) const {
     os << "{\n";
     os << indent(depth + 1) << "\"type\": \"array\",\n";
     if (!getDoc().empty()) {
@@ -472,8 +484,7 @@ NodeArray::printJson(std::ostream &os, size_t depth) const {
     os << indent(depth) << '}';
 }
 
-void
-NodeMap::printJson(std::ostream &os, size_t depth) const {
+void NodeMap::printJson(std::ostream &os, size_t depth) const {
     os << "{\n";
     os << indent(depth + 1) << "\"type\": \"map\",\n";
     if (!getDoc().empty()) {
@@ -486,14 +497,12 @@ NodeMap::printJson(std::ostream &os, size_t depth) const {
     os << indent(depth) << '}';
 }
 
-NodeMap::NodeMap() :
-    NodeImplMap(AVRO_MAP) {
+NodeMap::NodeMap() : NodeImplMap(AVRO_MAP) {
     NodePtr key(new NodePrimitive(AVRO_STRING));
     doAddLeaf(key);
 }
 
-void
-NodeUnion::printJson(std::ostream &os, size_t depth) const {
+void NodeUnion::printJson(std::ostream &os, size_t depth) const {
     os << "[\n";
     int fields = leafAttributes_.size();
     ++depth;
@@ -508,8 +517,7 @@ NodeUnion::printJson(std::ostream &os, size_t depth) const {
     os << indent(--depth) << ']';
 }
 
-void
-NodeFixed::printJson(std::ostream &os, size_t depth) const {
+void NodeFixed::printJson(std::ostream &os, size_t depth) const {
     os << "{\n";
     os << indent(++depth) << "\"type\": \"fixed\",\n";
     if (!getDoc().empty()) {
@@ -520,11 +528,13 @@ NodeFixed::printJson(std::ostream &os, size_t depth) const {
     os << indent(depth) << "\"size\": " << sizeAttribute_.get();
 
     if (logicalType().type() != LogicalType::NONE) {
-        os << ",\n" << indent(depth);
+        os << ",\n"
+           << indent(depth);
         logicalType().printJson(os);
     }
 
-    os << "\n" << indent(--depth) << '}';
+    os << "\n"
+       << indent(--depth) << '}';
 }
 
 } // namespace avro
diff --git a/lang/c++/impl/Resolver.cc b/lang/c++/impl/Resolver.cc
index 06481cb..bf05dff 100644
--- a/lang/c++/impl/Resolver.cc
+++ b/lang/c++/impl/Resolver.cc
@@ -17,20 +17,20 @@
  * limitations under the License.
  */
 
-#include <memory>
 #include "Resolver.hh"
+#include "AvroTraits.hh"
 #include "Layout.hh"
 #include "NodeImpl.hh"
-#include "ValidSchema.hh"
 #include "Reader.hh"
-#include "AvroTraits.hh"
+#include "ValidSchema.hh"
+#include <memory>
 
 namespace avro {
 using std::unique_ptr;
 
 class ResolverFactory;
 typedef std::shared_ptr<Resolver> ResolverPtr;
-typedef std::vector<std::unique_ptr<Resolver> > ResolverPtrVector;
+typedef std::vector<std::unique_ptr<Resolver>> ResolverPtrVector;
 
 // #define DEBUG_VERBOSE
 
@@ -49,9 +49,7 @@ NoOp noop;
 template<typename T>
 class PrimitiveSkipper : public Resolver {
 public:
-
-    PrimitiveSkipper() :
-        Resolver() {}
+    PrimitiveSkipper() : Resolver() {}
 
     void parse(Reader &reader, uint8_t *address) const override {
         T val;
@@ -63,40 +61,34 @@ public:
 template<typename T>
 class PrimitiveParser : public Resolver {
 public:
-
-    explicit PrimitiveParser(const PrimitiveLayout &offset) :
-        Resolver(),
-        offset_(offset.offset()) {}
+    explicit PrimitiveParser(const PrimitiveLayout &offset) : Resolver(),
+                                                              offset_(offset.offset()) {}
 
     void parse(Reader &reader, uint8_t *address) const override {
-        T *location = reinterpret_cast<T *> (address + offset_);
+        T *location = reinterpret_cast<T *>(address + offset_);
         reader.readValue(*location);
         DEBUG_OUT("Reading " << *location);
     }
 
 private:
-
     size_t offset_;
 };
 
 template<typename WT, typename RT>
 class PrimitivePromoter : public Resolver {
 public:
-
-    explicit PrimitivePromoter(const PrimitiveLayout &offset) :
-        Resolver(),
-        offset_(offset.offset()) {}
+    explicit PrimitivePromoter(const PrimitiveLayout &offset) : Resolver(),
+                                                                offset_(offset.offset()) {}
 
     void parse(Reader &reader, uint8_t *address) const override {
         parseIt<WT>(reader, address);
     }
 
 private:
-
     void parseIt(Reader &reader, uint8_t *address, const std::true_type &) const {
         WT val;
         reader.readValue(val);
-        RT *location = reinterpret_cast<RT *> (address + offset_);
+        RT *location = reinterpret_cast<RT *>(address + offset_);
         *location = static_cast<RT>(val);
         DEBUG_OUT("Promoting " << val);
     }
@@ -112,11 +104,9 @@ private:
 };
 
 template<>
-class PrimitiveSkipper<std::vector<uint8_t> > : public Resolver {
+class PrimitiveSkipper<std::vector<uint8_t>> : public Resolver {
 public:
-
-    PrimitiveSkipper() :
-        Resolver() {}
+    PrimitiveSkipper() : Resolver() {}
 
     void parse(Reader &reader, uint8_t *address) const override {
         std::vector<uint8_t> val;
@@ -126,27 +116,23 @@ public:
 };
 
 template<>
-class PrimitiveParser<std::vector<uint8_t> > : public Resolver {
+class PrimitiveParser<std::vector<uint8_t>> : public Resolver {
 public:
-
-    explicit PrimitiveParser(const PrimitiveLayout &offset) :
-        Resolver(),
-        offset_(offset.offset()) {}
+    explicit PrimitiveParser(const PrimitiveLayout &offset) : Resolver(),
+                                                              offset_(offset.offset()) {}
 
     void parse(Reader &reader, uint8_t *address) const override {
-        auto *location = reinterpret_cast<std::vector<uint8_t> *> (address + offset_);
+        auto *location = reinterpret_cast<std::vector<uint8_t> *>(address + offset_);
         reader.readBytes(*location);
         DEBUG_OUT("Reading bytes");
     }
 
 private:
-
     size_t offset_;
 };
 
 class RecordSkipper : public Resolver {
 public:
-
     RecordSkipper(ResolverFactory &factory, const NodePtr &writer);
 
     void parse(Reader &reader, uint8_t *address) const override {
@@ -160,14 +146,11 @@ public:
     }
 
 protected:
-
     ResolverPtrVector resolvers_;
-
 };
 
 class RecordParser : public Resolver {
 public:
-
     void parse(Reader &reader, uint8_t *address) const override {
         DEBUG_OUT("Reading record");
 
@@ -181,14 +164,11 @@ public:
     RecordParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets);
 
 protected:
-
     ResolverPtrVector resolvers_;
-
 };
 
 class MapSkipper : public Resolver {
 public:
-
     MapSkipper(ResolverFactory &factory, const NodePtr &writer);
 
     void parse(Reader &reader, uint8_t *address) const override {
@@ -206,13 +186,11 @@ public:
     }
 
 protected:
-
     ResolverPtr resolver_;
 };
 
 class MapParser : public Resolver {
 public:
-
     typedef uint8_t *(*GenericMapSetter)(uint8_t *map, const std::string &key);
 
     MapParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets);
@@ -223,7 +201,7 @@ public:
         uint8_t *mapAddress = address + offset_;
 
         std::string key;
-        auto *setter = reinterpret_cast<GenericMapSetter *> (address + setFuncOffset_);
+        auto *setter = reinterpret_cast<GenericMapSetter *>(address + setFuncOffset_);
 
         int64_t size;
         do {
@@ -239,7 +217,6 @@ public:
     }
 
 protected:
-
     ResolverPtr resolver_;
     size_t offset_;
     size_t setFuncOffset_;
@@ -247,7 +224,6 @@ protected:
 
 class ArraySkipper : public Resolver {
 public:
-
     ArraySkipper(ResolverFactory &factory, const NodePtr &writer);
 
     void parse(Reader &reader, uint8_t *address) const override {
@@ -263,7 +239,6 @@ public:
     }
 
 protected:
-
     ResolverPtr resolver_;
 };
 
@@ -271,7 +246,6 @@ typedef uint8_t *(*GenericArraySetter)(uint8_t *array);
 
 class ArrayParser : public Resolver {
 public:
-
     ArrayParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets);
 
     void parse(Reader &reader, uint8_t *address) const override {
@@ -279,7 +253,7 @@ public:
 
         uint8_t *arrayAddress = address + offset_;
 
-        auto *setter = reinterpret_cast<GenericArraySetter *> (address + setFuncOffset_);
+        auto *setter = reinterpret_cast<GenericArraySetter *>(address + setFuncOffset_);
 
         int64_t size;
         do {
@@ -293,9 +267,7 @@ public:
     }
 
 protected:
-
-    ArrayParser() :
-        Resolver(), offset_(0), setFuncOffset_(0) {}
+    ArrayParser() : Resolver(), offset_(0), setFuncOffset_(0) {}
 
     ResolverPtr resolver_;
     size_t offset_;
@@ -304,9 +276,7 @@ protected:
 
 class EnumSkipper : public Resolver {
 public:
-
-    EnumSkipper(ResolverFactory &factory, const NodePtr &writer) :
-        Resolver() {}
+    EnumSkipper(ResolverFactory &factory, const NodePtr &writer) : Resolver() {}
 
     void parse(Reader &reader, uint8_t *address) const override {
         int64_t val = reader.readEnum();
@@ -316,15 +286,13 @@ public:
 
 class EnumParser : public Resolver {
 public:
-
     enum EnumRepresentation {
         VAL
     };
 
-    EnumParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets) :
-        Resolver(),
-        offset_(offsets.at(0).offset()),
-        readerSize_(reader->names()) {
+    EnumParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets) : Resolver(),
+                                                                                                                        offset_(offsets.at(0).offset()),
+                                                                                                                        readerSize_(reader->names()) {
         const size_t writerSize = writer->names();
 
         mapping_.reserve(writerSize);
@@ -342,23 +310,20 @@ public:
         assert(static_cast<size_t>(val) < mapping_.size());
 
         if (mapping_[val] < readerSize_) {
-            auto *location = reinterpret_cast<EnumRepresentation *> (address + offset_);
+            auto *location = reinterpret_cast<EnumRepresentation *>(address + offset_);
             *location = static_cast<EnumRepresentation>(mapping_[val]);
             DEBUG_OUT("Setting enum" << *location);
         }
     }
 
 protected:
-
     size_t offset_;
     size_t readerSize_;
     std::vector<size_t> mapping_;
-
 };
 
 class UnionSkipper : public Resolver {
 public:
-
     UnionSkipper(ResolverFactory &factory, const NodePtr &writer);
 
     void parse(Reader &reader, uint8_t *address) const override {
@@ -368,13 +333,11 @@ public:
     }
 
 protected:
-
     ResolverPtrVector resolvers_;
 };
 
 class UnionParser : public Resolver {
 public:
-
     typedef uint8_t *(*GenericUnionSetter)(uint8_t *, int64_t);
 
     UnionParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets);
@@ -385,15 +348,14 @@ public:
         auto *readerChoice = reinterpret_cast<int64_t *>(address + choiceOffset_);
 
         *readerChoice = choiceMapping_[writerChoice];
-        auto *setter = reinterpret_cast<GenericUnionSetter *> (address + setFuncOffset_);
-        auto *value = reinterpret_cast<uint8_t *> (address + offset_);
+        auto *setter = reinterpret_cast<GenericUnionSetter *>(address + setFuncOffset_);
+        auto *value = reinterpret_cast<uint8_t *>(address + offset_);
         uint8_t *location = (*setter)(value, *readerChoice);
 
         resolvers_[writerChoice]->parse(reader, location);
     }
 
 protected:
-
     ResolverPtrVector resolvers_;
     std::vector<int64_t> choiceMapping_;
     size_t offset_;
@@ -403,7 +365,6 @@ protected:
 
 class UnionToNonUnionParser : public Resolver {
 public:
-
     typedef uint8_t *(*GenericUnionSetter)(uint8_t *, int64_t);
 
     UnionToNonUnionParser(ResolverFactory &factory,
@@ -418,13 +379,11 @@ public:
     }
 
 protected:
-
     ResolverPtrVector resolvers_;
 };
 
 class NonUnionToUnionParser : public Resolver {
 public:
-
     typedef uint8_t *(*GenericUnionSetter)(uint8_t *, int64_t);
 
     NonUnionToUnionParser(ResolverFactory &factory,
@@ -437,15 +396,14 @@ public:
 
         auto *choice = reinterpret_cast<int64_t *>(address + choiceOffset_);
         *choice = choice_;
-        auto *setter = reinterpret_cast<GenericUnionSetter *> (address + setFuncOffset_);
-        auto *value = reinterpret_cast<uint8_t *> (address + offset_);
+        auto *setter = reinterpret_cast<GenericUnionSetter *>(address + setFuncOffset_);
+        auto *value = reinterpret_cast<uint8_t *>(address + offset_);
         uint8_t *location = (*setter)(value, choice_);
 
         resolver_->parse(reader, location);
     }
 
 protected:
-
     ResolverPtr resolver_;
     size_t choice_;
     size_t offset_;
@@ -455,9 +413,7 @@ protected:
 
 class FixedSkipper : public Resolver {
 public:
-
-    FixedSkipper(ResolverFactory &factory, const NodePtr &writer) :
-        Resolver() {
+    FixedSkipper(ResolverFactory &factory, const NodePtr &writer) : Resolver() {
         size_ = writer->fixedSize();
     }
 
@@ -468,31 +424,25 @@ public:
     }
 
 protected:
-
     int size_;
-
 };
 
 class FixedParser : public Resolver {
 public:
-
-    FixedParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets) :
-        Resolver() {
+    FixedParser(ResolverFactory &factory, const NodePtr &writer, const NodePtr &reader, const CompoundLayout &offsets) : Resolver() {
         size_ = writer->fixedSize();
         offset_ = offsets.at(0).offset();
     }
 
     void parse(Reader &reader, uint8_t *address) const override {
         DEBUG_OUT("Reading fixed");
-        auto *location = reinterpret_cast<uint8_t *> (address + offset_);
+        auto *location = reinterpret_cast<uint8_t *>(address + offset_);
         reader.readFixed(location, size_);
     }
 
 protected:
-
     int size_;
     size_t offset_;
-
 };
 
 class ResolverFactory : private boost::noncopyable {
@@ -562,22 +512,18 @@ class ResolverFactory : private boost::noncopyable {
     }
 
 public:
-
     unique_ptr<Resolver>
     construct(const NodePtr &writer, const NodePtr &reader, const Layout &offset) {
 
-        typedef unique_ptr<Resolver>
-        (ResolverFactory::*BuilderFunc)(const NodePtr &writer, const NodePtr &reader, const Layout &offset);
+        typedef unique_ptr<Resolver> (ResolverFactory::*BuilderFunc)(const NodePtr &writer, const NodePtr &reader, const Layout &offset);
 
-        NodePtr currentWriter = (writer->type() == AVRO_SYMBOLIC) ?
-                                resolveSymbol(writer) : writer;
+        NodePtr currentWriter = (writer->type() == AVRO_SYMBOLIC) ? resolveSymbol(writer) : writer;
 
-        NodePtr currentReader = (reader->type() == AVRO_SYMBOLIC) ?
-                                resolveSymbol(reader) : reader;
+        NodePtr currentReader = (reader->type() == AVRO_SYMBOLIC) ? resolveSymbol(reader) : reader;
 
         static const BuilderFunc funcs[] = {
             &ResolverFactory::constructPrimitive<std::string>,
-            &ResolverFactory::constructPrimitive<std::vector<uint8_t> >,
+            &ResolverFactory::constructPrimitive<std::vector<uint8_t>>,
             &ResolverFactory::constructPrimitive<int32_t>,
             &ResolverFactory::constructPrimitive<int64_t>,
             &ResolverFactory::constructPrimitive<float>,
@@ -589,8 +535,7 @@ public:
             &ResolverFactory::constructCompound<ArrayParser, ArraySkipper>,
             &ResolverFactory::constructCompound<MapParser, MapSkipper>,
             &ResolverFactory::constructCompound<UnionParser, UnionSkipper>,
-            &ResolverFactory::constructCompound<FixedParser, FixedSkipper>
-        };
+            &ResolverFactory::constructCompound<FixedParser, FixedSkipper>};
 
         static_assert((sizeof(funcs) / sizeof(BuilderFunc)) == (AVRO_NUM_TYPES),
                       "Invalid number of builder functions");
@@ -606,12 +551,11 @@ public:
 
         typedef unique_ptr<Resolver> (ResolverFactory::*BuilderFunc)(const NodePtr &writer);
 
-        NodePtr currentWriter = (writer->type() == AVRO_SYMBOLIC) ?
-                                writer->leafAt(0) : writer;
+        NodePtr currentWriter = (writer->type() == AVRO_SYMBOLIC) ? writer->leafAt(0) : writer;
 
         static const BuilderFunc funcs[] = {
             &ResolverFactory::constructPrimitiveSkipper<std::string>,
-            &ResolverFactory::constructPrimitiveSkipper<std::vector<uint8_t> >,
+            &ResolverFactory::constructPrimitiveSkipper<std::vector<uint8_t>>,
             &ResolverFactory::constructPrimitiveSkipper<int32_t>,
             &ResolverFactory::constructPrimitiveSkipper<int64_t>,
             &ResolverFactory::constructPrimitiveSkipper<float>,
@@ -623,8 +567,7 @@ public:
             &ResolverFactory::constructCompoundSkipper<ArraySkipper>,
             &ResolverFactory::constructCompoundSkipper<MapSkipper>,
             &ResolverFactory::constructCompoundSkipper<UnionSkipper>,
-            &ResolverFactory::constructCompoundSkipper<FixedSkipper>
-        };
+            &ResolverFactory::constructCompoundSkipper<FixedSkipper>};
 
         static_assert((sizeof(funcs) / sizeof(BuilderFunc)) == (AVRO_NUM_TYPES),
                       "Invalid number of builder functions");
@@ -636,8 +579,7 @@ public:
     }
 };
 
-RecordSkipper::RecordSkipper(ResolverFactory &factory, const NodePtr &writer) :
-    Resolver() {
+RecordSkipper::RecordSkipper(ResolverFactory &factory, const NodePtr &writer) : Resolver() {
     size_t leaves = writer->leaves();
     resolvers_.reserve(leaves);
     for (size_t i = 0; i < leaves; ++i) {
@@ -649,8 +591,7 @@ RecordSkipper::RecordSkipper(ResolverFactory &factory, const NodePtr &writer) :
 RecordParser::RecordParser(ResolverFactory &factory,
                            const NodePtr &writer,
                            const NodePtr &reader,
-                           const CompoundLayout &offsets) :
-    Resolver() {
+                           const CompoundLayout &offsets) : Resolver() {
     size_t leaves = writer->leaves();
     resolvers_.reserve(leaves);
     for (size_t i = 0; i < leaves; ++i) {
@@ -671,34 +612,29 @@ RecordParser::RecordParser(ResolverFactory &factory,
     }
 }
 
-MapSkipper::MapSkipper(ResolverFactory &factory, const NodePtr &writer) :
-    Resolver(),
-    resolver_(factory.skipper(writer->leafAt(1))) {}
+MapSkipper::MapSkipper(ResolverFactory &factory, const NodePtr &writer) : Resolver(),
+                                                                          resolver_(factory.skipper(writer->leafAt(1))) {}
 
 MapParser::MapParser(ResolverFactory &factory,
                      const NodePtr &writer,
                      const NodePtr &reader,
-                     const CompoundLayout &offsets) :
-    Resolver(),
-    resolver_(factory.construct(writer->leafAt(1), reader->leafAt(1), offsets.at(1))),
-    offset_(offsets.offset()),
-    setFuncOffset_(offsets.at(0).offset()) {}
+                     const CompoundLayout &offsets) : Resolver(),
+                                                      resolver_(factory.construct(writer->leafAt(1), reader->leafAt(1), offsets.at(1))),
+                                                      offset_(offsets.offset()),
+                                                      setFuncOffset_(offsets.at(0).offset()) {}
 
-ArraySkipper::ArraySkipper(ResolverFactory &factory, const NodePtr &writer) :
-    Resolver(),
-    resolver_(factory.skipper(writer->leafAt(0))) {}
+ArraySkipper::ArraySkipper(ResolverFactory &factory, const NodePtr &writer) : Resolver(),
+                                                                              resolver_(factory.skipper(writer->leafAt(0))) {}
 
 ArrayParser::ArrayParser(ResolverFactory &factory,
                          const NodePtr &writer,
                          const NodePtr &reader,
-                         const CompoundLayout &offsets) :
-    Resolver(),
-    resolver_(factory.construct(writer->leafAt(0), reader->leafAt(0), offsets.at(1))),
-    offset_(offsets.offset()),
-    setFuncOffset_(offsets.at(0).offset()) {}
-
-UnionSkipper::UnionSkipper(ResolverFactory &factory, const NodePtr &writer) :
-    Resolver() {
+                         const CompoundLayout &offsets) : Resolver(),
+                                                          resolver_(factory.construct(writer->leafAt(0), reader->leafAt(0), offsets.at(1))),
+                                                          offset_(offsets.offset()),
+                                                          setFuncOffset_(offsets.at(0).offset()) {}
+
+UnionSkipper::UnionSkipper(ResolverFactory &factory, const NodePtr &writer) : Resolver() {
     size_t leaves = writer->leaves();
     resolvers_.reserve(leaves);
     for (size_t i = 0; i < leaves; ++i) {
@@ -737,16 +673,15 @@ checkUnionMatch(const NodePtr &writer, const NodePtr &reader, size_t &index) {
     return bestMatch;
 }
 
-}
+} // namespace
 
 UnionParser::UnionParser(ResolverFactory &factory,
                          const NodePtr &writer,
                          const NodePtr &reader,
-                         const CompoundLayout &offsets) :
-    Resolver(),
-    offset_(offsets.offset()),
-    choiceOffset_(offsets.at(0).offset()),
-    setFuncOffset_(offsets.at(1).offset()) {
+                         const CompoundLayout &offsets) : Resolver(),
+                                                          offset_(offsets.offset()),
+                                                          choiceOffset_(offsets.at(0).offset()),
+                                                          setFuncOffset_(offsets.at(1).offset()) {
 
     size_t leaves = writer->leaves();
     resolvers_.reserve(leaves);
@@ -774,12 +709,11 @@ UnionParser::UnionParser(ResolverFactory &factory,
 NonUnionToUnionParser::NonUnionToUnionParser(ResolverFactory &factory,
                                              const NodePtr &writer,
                                              const NodePtr &reader,
-                                             const CompoundLayout &offsets) :
-    Resolver(),
-    offset_(offsets.offset()),
-    choice_(0),
-    choiceOffset_(offsets.at(0).offset()),
-    setFuncOffset_(offsets.at(1).offset()) {
+                                             const CompoundLayout &offsets) : Resolver(),
+                                                                              offset_(offsets.offset()),
+                                                                              choice_(0),
+                                                                              choiceOffset_(offsets.at(0).offset()),
+                                                                              setFuncOffset_(offsets.at(1).offset()) {
 #ifndef NDEBUG
     SchemaResolution bestMatch =
 #endif
@@ -791,8 +725,7 @@ NonUnionToUnionParser::NonUnionToUnionParser(ResolverFactory &factory,
 UnionToNonUnionParser::UnionToNonUnionParser(ResolverFactory &factory,
                                              const NodePtr &writer,
                                              const NodePtr &reader,
-                                             const Layout &offsets) :
-    Resolver() {
+                                             const Layout &offsets) : Resolver() {
     size_t leaves = writer->leaves();
     resolvers_.reserve(leaves);
     for (size_t i = 0; i < leaves; ++i) {
diff --git a/lang/c++/impl/ResolverSchema.cc b/lang/c++/impl/ResolverSchema.cc
index eb26659..7ddea33 100644
--- a/lang/c++/impl/ResolverSchema.cc
+++ b/lang/c++/impl/ResolverSchema.cc
@@ -26,11 +26,9 @@ namespace avro {
 ResolverSchema::ResolverSchema(
     const ValidSchema &writerSchema,
     const ValidSchema &readerSchema,
-    const Layout &readerLayout) :
-    resolver_(constructResolver(writerSchema, readerSchema, readerLayout)) {}
+    const Layout &readerLayout) : resolver_(constructResolver(writerSchema, readerSchema, readerLayout)) {}
 
-void
-ResolverSchema::parse(Reader &reader, uint8_t *address) {
+void ResolverSchema::parse(Reader &reader, uint8_t *address) {
     resolver_->parse(reader, address);
 }
 
diff --git a/lang/c++/impl/Schema.cc b/lang/c++/impl/Schema.cc
index 20f5f84..4224529 100644
--- a/lang/c++/impl/Schema.cc
+++ b/lang/c++/impl/Schema.cc
@@ -16,20 +16,17 @@
  * limitations under the License.
  */
 
-
 #include <utility>
 
 #include "Schema.hh"
 
 namespace avro {
 
-RecordSchema::RecordSchema(const std::string &name) :
-    Schema(new NodeRecord) {
+RecordSchema::RecordSchema(const std::string &name) : Schema(new NodeRecord) {
     node_->setName(Name(name));
 }
 
-void
-RecordSchema::addField(const std::string &name, const Schema &fieldSchema) {
+void RecordSchema::addField(const std::string &name, const Schema &fieldSchema) {
     // add the name first. it will throw if the name is a duplicate, preventing
     // the leaf from being added
     node_->addName(name);
@@ -44,41 +41,33 @@ void RecordSchema::setDoc(const std::string &doc) {
     node_->setDoc(doc);
 }
 
-EnumSchema::EnumSchema(const std::string &name) :
-    Schema(new NodeEnum) {
+EnumSchema::EnumSchema(const std::string &name) : Schema(new NodeEnum) {
     node_->setName(Name(name));
 }
 
-void
-EnumSchema::addSymbol(const std::string &symbol) {
+void EnumSchema::addSymbol(const std::string &symbol) {
     node_->addName(symbol);
 }
 
-ArraySchema::ArraySchema(const Schema &itemsSchema) :
-    Schema(new NodeArray) {
+ArraySchema::ArraySchema(const Schema &itemsSchema) : Schema(new NodeArray) {
     node_->addLeaf(itemsSchema.root());
 }
 
-ArraySchema::ArraySchema(const ArraySchema &itemsSchema) :
-    Schema(new NodeArray) {
+ArraySchema::ArraySchema(const ArraySchema &itemsSchema) : Schema(new NodeArray) {
     node_->addLeaf(itemsSchema.root());
 }
 
-MapSchema::MapSchema(const Schema &valuesSchema) :
-    Schema(new NodeMap) {
+MapSchema::MapSchema(const Schema &valuesSchema) : Schema(new NodeMap) {
     node_->addLeaf(valuesSchema.root());
 }
 
-MapSchema::MapSchema(const MapSchema &valuesSchema) :
-    Schema(new NodeMap) {
+MapSchema::MapSchema(const MapSchema &valuesSchema) : Schema(new NodeMap) {
     node_->addLeaf(valuesSchema.root());
 }
 
-UnionSchema::UnionSchema() :
-    Schema(new NodeUnion) {}
+UnionSchema::UnionSchema() : Schema(new NodeUnion) {}
 
-void
-UnionSchema::addType(const Schema &typeSchema) {
+void UnionSchema::addType(const Schema &typeSchema) {
     if (typeSchema.type() == AVRO_UNION) {
         throw Exception("Cannot add unions to unions");
     }
@@ -98,14 +87,12 @@ UnionSchema::addType(const Schema &typeSchema) {
     node_->addLeaf(typeSchema.root());
 }
 
-FixedSchema::FixedSchema(int size, const std::string &name) :
-    Schema(new NodeFixed) {
+FixedSchema::FixedSchema(int size, const std::string &name) : Schema(new NodeFixed) {
     node_->setFixedSize(size);
     node_->setName(Name(name));
 }
 
-SymbolicSchema::SymbolicSchema(const Name &name, const NodePtr &link) :
-    Schema(new NodeSymbolic(HasName(name), link)) {
+SymbolicSchema::SymbolicSchema(const Name &name, const NodePtr &link) : Schema(new NodeSymbolic(HasName(name), link)) {
 }
 
 } // namespace avro
diff --git a/lang/c++/impl/Stream.cc b/lang/c++/impl/Stream.cc
index 166915f..a7f22cb 100644
--- a/lang/c++/impl/Stream.cc
+++ b/lang/c++/impl/Stream.cc
@@ -24,7 +24,7 @@ namespace avro {
 using std::vector;
 
 class MemoryInputStream : public InputStream {
-    const std::vector<uint8_t*>& data_;
+    const std::vector<uint8_t *> &data_;
     const size_t chunkSize_;
     const size_t size_;
     const size_t available_;
@@ -45,12 +45,11 @@ class MemoryInputStream : public InputStream {
     }
 
 public:
-    MemoryInputStream(const std::vector<uint8_t*>& b,
-        size_t chunkSize, size_t available) :
-            data_(b), chunkSize_(chunkSize), size_(b.size()),
-            available_(available), cur_(0), curLen_(0) { }
+    MemoryInputStream(const std::vector<uint8_t *> &b,
+                      size_t chunkSize, size_t available) : data_(b), chunkSize_(chunkSize), size_(b.size()),
+                                                            available_(available), cur_(0), curLen_(0) {}
 
-    bool next(const uint8_t** data, size_t* len) override {
+    bool next(const uint8_t **data, size_t *len) override {
         if (size_t n = maxLen()) {
             *data = data_[cur_] + curLen_;
             *len = n - curLen_;
@@ -84,14 +83,15 @@ public:
 };
 
 class MemoryInputStream2 : public InputStream {
-    const uint8_t* const data_;
+    const uint8_t *const data_;
     const size_t size_;
     size_t curLen_;
+
 public:
     MemoryInputStream2(const uint8_t *data, size_t len)
-        : data_(data), size_(len), curLen_(0) { }
+        : data_(data), size_(len), curLen_(0) {}
 
-    bool next(const uint8_t** data, size_t* len) override {
+    bool next(const uint8_t **data, size_t *len) override {
         if (curLen_ == size_) {
             return false;
         }
@@ -120,20 +120,20 @@ public:
 class MemoryOutputStream : public OutputStream {
 public:
     const size_t chunkSize_;
-    std::vector<uint8_t*> data_;
+    std::vector<uint8_t *> data_;
     size_t available_;
     size_t byteCount_;
 
     explicit MemoryOutputStream(size_t chunkSize) : chunkSize_(chunkSize),
-        available_(0), byteCount_(0) { }
+                                                    available_(0), byteCount_(0) {}
     ~MemoryOutputStream() override {
-        for (std::vector<uint8_t*>::const_iterator it = data_.begin();
-            it != data_.end(); ++it) {
-            delete[] *it;
+        for (std::vector<uint8_t *>::const_iterator it = data_.begin();
+             it != data_.end(); ++it) {
+            delete[] * it;
         }
     }
 
-    bool next(uint8_t** data, size_t* len) override {
+    bool next(uint8_t **data, size_t *len) override {
         if (available_ == 0) {
             data_.push_back(new uint8_t[chunkSize_]);
             available_ = chunkSize_;
@@ -154,39 +154,31 @@ public:
         return byteCount_;
     }
 
-    void flush() override { }
+    void flush() override {}
 };
 
-std::unique_ptr<OutputStream> memoryOutputStream(size_t chunkSize)
-{
+std::unique_ptr<OutputStream> memoryOutputStream(size_t chunkSize) {
     return std::unique_ptr<OutputStream>(new MemoryOutputStream(chunkSize));
 }
 
-std::unique_ptr<InputStream> memoryInputStream(const uint8_t* data, size_t len)
-{
+std::unique_ptr<InputStream> memoryInputStream(const uint8_t *data, size_t len) {
     return std::unique_ptr<InputStream>(new MemoryInputStream2(data, len));
 }
 
-std::unique_ptr<InputStream> memoryInputStream(const OutputStream& source)
-{
-    const auto& mos =
-        dynamic_cast<const MemoryOutputStream&>(source);
-    return (mos.data_.empty()) ?
-        std::unique_ptr<InputStream>(new MemoryInputStream2(nullptr, 0)) :
-        std::unique_ptr<InputStream>(new MemoryInputStream(mos.data_,
-            mos.chunkSize_,
-            (mos.chunkSize_ - mos.available_)));
+std::unique_ptr<InputStream> memoryInputStream(const OutputStream &source) {
+    const auto &mos =
+        dynamic_cast<const MemoryOutputStream &>(source);
+    return (mos.data_.empty()) ? std::unique_ptr<InputStream>(new MemoryInputStream2(nullptr, 0)) : std::unique_ptr<InputStream>(new MemoryInputStream(mos.data_, mos.chunkSize_, (mos.chunkSize_ - mos.available_)));
 }
 
-std::shared_ptr<std::vector<uint8_t> > snapshot(const OutputStream& source)
-{
-    const auto& mos =
-        dynamic_cast<const MemoryOutputStream&>(source);
-    std::shared_ptr<std::vector<uint8_t> > result(new std::vector<uint8_t>());
+std::shared_ptr<std::vector<uint8_t>> snapshot(const OutputStream &source) {
+    const auto &mos =
+        dynamic_cast<const MemoryOutputStream &>(source);
+    std::shared_ptr<std::vector<uint8_t>> result(new std::vector<uint8_t>());
     size_t c = mos.byteCount_;
     result->reserve(mos.byteCount_);
     for (auto it = mos.data_.begin();
-        it != mos.data_.end(); ++it) {
+         it != mos.data_.end(); ++it) {
         size_t n = std::min(c, mos.chunkSize_);
         std::copy(*it, *it + n, std::back_inserter(*result));
         c -= n;
@@ -194,5 +186,4 @@ std::shared_ptr<std::vector<uint8_t> > snapshot(const OutputStream& source)
     return result;
 }
 
-}   // namespace avro
-
+} // namespace avro
diff --git a/lang/c++/impl/Types.cc b/lang/c++/impl/Types.cc
index 806220a..754e584 100644
--- a/lang/c++/impl/Types.cc
+++ b/lang/c++/impl/Types.cc
@@ -16,9 +16,9 @@
  * limitations under the License.
  */
 
+#include "Types.hh"
 #include <iostream>
 #include <string>
-#include "Types.hh"
 
 namespace avro {
 namespace strings {
@@ -37,15 +37,13 @@ const std::string typeToString[] = {
     "map",
     "union",
     "fixed",
-    "symbolic"
-};
+    "symbolic"};
 
 static_assert((sizeof(typeToString) / sizeof(std::string)) == (AVRO_NUM_TYPES + 1),
               "Incorrect Avro typeToString");
 
 } // namespace strings
 
-
 // this static assert exists because a 32 bit integer is used as a bit-flag for each type,
 // and it would be a problem for this flag if we ever supported more than 32 types
 static_assert(AVRO_NUM_TYPES < 32, "Too many Avro types");
@@ -60,18 +58,17 @@ const std::string &toString(Type type) noexcept {
 }
 
 std::ostream &operator<<(std::ostream &os, Type type) {
-  if (isAvroTypeOrPseudoType(type)) {
-    os << strings::typeToString[type];
-  } else {
-    os << static_cast<int>(type);
-  }
-  return os;
+    if (isAvroTypeOrPseudoType(type)) {
+        os << strings::typeToString[type];
+    } else {
+        os << static_cast<int>(type);
+    }
+    return os;
 }
 
 std::ostream &operator<<(std::ostream &os, const Null &) {
-  os << "(null value)";
-  return os;
+    os << "(null value)";
+    return os;
 }
 
 } // namespace avro
-
diff --git a/lang/c++/impl/ValidSchema.cc b/lang/c++/impl/ValidSchema.cc
index b0ebb15..63a3bbe 100644
--- a/lang/c++/impl/ValidSchema.cc
+++ b/lang/c++/impl/ValidSchema.cc
@@ -21,16 +21,16 @@
 #include <sstream>
 #include <utility>
 
-#include "ValidSchema.hh"
-#include "Schema.hh"
 #include "Node.hh"
+#include "Schema.hh"
+#include "ValidSchema.hh"
 
-using std::string;
-using std::ostringstream;
-using std::make_pair;
 using boost::format;
+using std::make_pair;
+using std::ostringstream;
 using std::shared_ptr;
 using std::static_pointer_cast;
+using std::string;
 
 namespace avro {
 using SymbolMap = std::map<Name, NodePtr>;
@@ -38,7 +38,7 @@ using SymbolMap = std::map<Name, NodePtr>;
 static bool validate(const NodePtr &node, SymbolMap &symbolMap) {
     if (!node->isValid()) {
         throw Exception(format("Schema is invalid, due to bad node of type %1%")
-                            % node->type());
+                        % node->type());
     }
 
     if (node->hasName()) {
@@ -51,8 +51,7 @@ static bool validate(const NodePtr &node, SymbolMap &symbolMap) {
 
         if (node->type() == AVRO_SYMBOLIC) {
             if (!found) {
-                throw Exception(format("Symbolic name \"%1%\" is unknown") %
-                    node->name());
+                throw Exception(format("Symbolic name \"%1%\" is unknown") % node->name());
             }
 
             shared_ptr<NodeSymbolic> symNode =
@@ -106,14 +105,12 @@ ValidSchema::ValidSchema() : root_(NullSchema().root()) {
     validate(root_);
 }
 
-void
-ValidSchema::setSchema(const Schema &schema) {
+void ValidSchema::setSchema(const Schema &schema) {
     root_ = schema.root();
     validate(root_);
 }
 
-void
-ValidSchema::toJson(std::ostream &os) const {
+void ValidSchema::toJson(std::ostream &os) const {
     root_->printJson(os, 0);
     os << '\n';
 }
@@ -128,8 +125,7 @@ ValidSchema::toJson(bool prettyPrint) const {
     return oss.str();
 }
 
-void
-ValidSchema::toFlatList(std::ostream &os) const {
+void ValidSchema::toFlatList(std::ostream &os) const {
     root_->printBasicInfo(os);
 }
 
@@ -183,4 +179,3 @@ string ValidSchema::compactSchema(const string &schema) {
 }
 
 } // namespace avro
-
diff --git a/lang/c++/impl/Validator.cc b/lang/c++/impl/Validator.cc
index 3901044..0e5fd8b 100644
--- a/lang/c++/impl/Validator.cc
+++ b/lang/c++/impl/Validator.cc
@@ -18,32 +18,29 @@
 
 #include <utility>
 
-#include "Validator.hh"
-#include "ValidSchema.hh"
 #include "NodeImpl.hh"
+#include "ValidSchema.hh"
+#include "Validator.hh"
 
 namespace avro {
 
-Validator::Validator(ValidSchema schema) :
-    schema_(std::move(schema)),
-    nextType_(AVRO_NULL),
-    expectedTypesFlag_(0),
-    compoundStarted_(false),
-    waitingForCount_(false),
-    count_(0) {
+Validator::Validator(ValidSchema schema) : schema_(std::move(schema)),
+                                           nextType_(AVRO_NULL),
+                                           expectedTypesFlag_(0),
+                                           compoundStarted_(false),
+                                           waitingForCount_(false),
+                                           count_(0) {
     setupOperation(schema_.root());
 }
 
-void
-Validator::setWaitingForCount() {
+void Validator::setWaitingForCount() {
     waitingForCount_ = true;
     count_ = 0;
     expectedTypesFlag_ = typeToFlag(AVRO_INT) | typeToFlag(AVRO_LONG);
     nextType_ = AVRO_LONG;
 }
 
-void
-Validator::enumAdvance() {
+void Validator::enumAdvance() {
     if (compoundStarted_) {
         setWaitingForCount();
         compoundStarted_ = false;
@@ -53,8 +50,7 @@ Validator::enumAdvance() {
     }
 }
 
-bool
-Validator::countingSetup() {
+bool Validator::countingSetup() {
     auto proceed = true;
     if (compoundStarted_) {
         setWaitingForCount();
@@ -73,8 +69,7 @@ Validator::countingSetup() {
     return proceed;
 }
 
-void
-Validator::countingAdvance() {
+void Validator::countingAdvance() {
     if (countingSetup()) {
         auto index = (compoundStack_.back().pos)++;
         const NodePtr &node = compoundStack_.back().node;
@@ -97,8 +92,7 @@ Validator::countingAdvance() {
     }
 }
 
-void
-Validator::unionAdvance() {
+void Validator::unionAdvance() {
     if (compoundStarted_) {
         setWaitingForCount();
         compoundStarted_ = false;
@@ -111,46 +105,41 @@ Validator::unionAdvance() {
             setupOperation(node->leafAt(static_cast<int>(count_)));
         } else {
             throw Exception(
-                boost::format("Union selection out of range, got %1%," \
-                    " expecting 0-%2%")
-                    % count_ % (node->leaves() - 1)
-            );
+                boost::format("Union selection out of range, got %1%,"
+                              " expecting 0-%2%")
+                % count_ % (node->leaves() - 1));
         }
     }
 }
 
-void
-Validator::fixedAdvance() {
+void Validator::fixedAdvance() {
     compoundStarted_ = false;
     compoundStack_.pop_back();
 }
 
-int
-Validator::nextSizeExpected() const {
+int Validator::nextSizeExpected() const {
     return compoundStack_.back().node->fixedSize();
 }
 
-void
-Validator::doAdvance() {
+void Validator::doAdvance() {
     using AdvanceFunc = void (Validator::*)();
 
     // only the compound types need advance functions here
     static const AdvanceFunc funcs[] = {
-        nullptr, // string
-        nullptr, // bytes
-        nullptr, // int
-        nullptr, // long
-        nullptr, // float
-        nullptr, // double
-        nullptr, // bool
-        nullptr, // null
+        nullptr,                     // string
+        nullptr,                     // bytes
+        nullptr,                     // int
+        nullptr,                     // long
+        nullptr,                     // float
+        nullptr,                     // double
+        nullptr,                     // bool
+        nullptr,                     // null
         &Validator::countingAdvance, // Record is treated like counting with count == 1
         &Validator::enumAdvance,
         &Validator::countingAdvance,
         &Validator::countingAdvance,
         &Validator::unionAdvance,
-        &Validator::fixedAdvance
-    };
+        &Validator::fixedAdvance};
     static_assert((sizeof(funcs) / sizeof(AdvanceFunc)) == (AVRO_NUM_TYPES),
                   "Invalid number of advance functions");
 
@@ -180,8 +169,7 @@ void Validator::advance() {
     }
 }
 
-void
-Validator::setCount(int64_t count) {
+void Validator::setCount(int64_t count) {
     if (!waitingForCount_) {
         throw Exception("Not expecting count");
     } else if (count_ < 0) {
@@ -192,8 +180,7 @@ Validator::setCount(int64_t count) {
     doAdvance();
 }
 
-void
-Validator::setupFlag(Type type) {
+void Validator::setupFlag(Type type) {
     // use flags instead of strictly types, so that we can be more lax about the type
     // (for example, a long should be able to accept an int type, but not vice versa)
     static const flag_t flags[] = {
@@ -210,16 +197,14 @@ Validator::setupFlag(Type type) {
         typeToFlag(AVRO_ARRAY),
         typeToFlag(AVRO_MAP),
         typeToFlag(AVRO_UNION),
-        typeToFlag(AVRO_FIXED)
-    };
+        typeToFlag(AVRO_FIXED)};
     static_assert((sizeof(flags) / sizeof(flag_t)) == (AVRO_NUM_TYPES),
                   "Invalid number of avro type flags");
 
     expectedTypesFlag_ = flags[type];
 }
 
-void
-Validator::setupOperation(const NodePtr &node) {
+void Validator::setupOperation(const NodePtr &node) {
     nextType_ = node->type();
 
     if (nextType_ == AVRO_SYMBOLIC) {
@@ -239,14 +224,12 @@ Validator::setupOperation(const NodePtr &node) {
     }
 }
 
-bool
-Validator::getCurrentRecordName(std::string &name) const {
+bool Validator::getCurrentRecordName(std::string &name) const {
     auto found = false;
     name.clear();
 
     // if the top of the stack is a record I want this record name
-    auto idx = static_cast<int>(compoundStack_.size() -
-        ((!compoundStack_.empty() && (isPrimitive(nextType_) || nextType_ == AVRO_RECORD)) ? 1 : 2));
+    auto idx = static_cast<int>(compoundStack_.size() - ((!compoundStack_.empty() && (isPrimitive(nextType_) || nextType_ == AVRO_RECORD)) ? 1 : 2));
 
     if (idx >= 0 && compoundStack_[idx].node->type() == AVRO_RECORD) {
         name = compoundStack_[idx].node->name().simpleName();
@@ -255,8 +238,7 @@ Validator::getCurrentRecordName(std::string &name) const {
     return found;
 }
 
-bool
-Validator::getNextFieldName(std::string &name) const {
+bool Validator::getNextFieldName(std::string &name) const {
     auto found = false;
     name.clear();
     auto idx = static_cast<int>(compoundStack_.size() - (isCompound(nextType_) ? 2 : 1));
diff --git a/lang/c++/impl/Zigzag.cc b/lang/c++/impl/Zigzag.cc
index 3638806..538a89c 100644
--- a/lang/c++/impl/Zigzag.cc
+++ b/lang/c++/impl/Zigzag.cc
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-
 #include "Zigzag.hh"
 
 namespace avro {
diff --git a/lang/c++/impl/avrogencpp.cc b/lang/c++/impl/avrogencpp.cc
index c926db4..6157041 100644
--- a/lang/c++/impl/avrogencpp.cc
+++ b/lang/c++/impl/avrogencpp.cc
@@ -20,8 +20,8 @@
 #ifndef _WIN32
 #include <ctime>
 #endif
-#include <iostream>
 #include <fstream>
+#include <iostream>
 #include <map>
 #include <set>
 
@@ -35,28 +35,28 @@
 #include <boost/algorithm/string_regex.hpp>
 
 #include "Compiler.hh"
-#include "ValidSchema.hh"
 #include "NodeImpl.hh"
+#include "ValidSchema.hh"
 
-using std::ostream;
+using avro::NodePtr;
+using avro::resolveSymbol;
 using std::ifstream;
-using std::ofstream;
 using std::map;
+using std::ofstream;
+using std::ostream;
 using std::set;
 using std::string;
 using std::vector;
-using avro::NodePtr;
-using avro::resolveSymbol;
 
 using boost::lexical_cast;
 
-using avro::ValidSchema;
 using avro::compileJsonSchema;
+using avro::ValidSchema;
 
 #if __cplusplus >= 201703L
-#define ANY_NS  "std"
+#define ANY_NS "std"
 #else
-#define ANY_NS  "boost"
+#define ANY_NS "boost"
 #endif
 
 struct PendingSetterGetter {
@@ -65,21 +65,19 @@ struct PendingSetterGetter {
     string name;
     size_t idx;
 
-    PendingSetterGetter(string  sn, string  t, string  n, size_t i) :
-        structName(std::move(sn)), type(std::move(t)), name(std::move(n)), idx(i) { }
+    PendingSetterGetter(string sn, string t, string n, size_t i) : structName(std::move(sn)), type(std::move(t)), name(std::move(n)), idx(i) {}
 };
 
 struct PendingConstructor {
     string structName;
     string memberName;
     bool initMember;
-    PendingConstructor(string  sn, string  n, bool im) :
-        structName(std::move(sn)), memberName(std::move(n)), initMember(im) { }
+    PendingConstructor(string sn, string n, bool im) : structName(std::move(sn)), memberName(std::move(n)), initMember(im) {}
 };
 
 class CodeGen {
     size_t unionNumber_;
-    std::ostream& os_;
+    std::ostream &os_;
     bool inNamespace_;
     const std::string ns_;
     const std::string schemaFile_;
@@ -96,36 +94,35 @@ class CodeGen {
     set<NodePtr> doing;
 
     std::string guard();
-    std::string fullname(const string& name) const;
-    std::string generateEnumType(const NodePtr& n);
-    std::string cppTypeOf(const NodePtr& n);
-    std::string generateRecordType(const NodePtr& n);
+    std::string fullname(const string &name) const;
+    std::string generateEnumType(const NodePtr &n);
+    std::string cppTypeOf(const NodePtr &n);
+    std::string generateRecordType(const NodePtr &n);
     std::string unionName();
-    std::string generateUnionType(const NodePtr& n);
-    std::string generateType(const NodePtr& n);
-    std::string generateDeclaration(const NodePtr& n);
-    std::string doGenerateType(const NodePtr& n);
-    void generateEnumTraits(const NodePtr& n);
-    void generateTraits(const NodePtr& n);
-    void generateRecordTraits(const NodePtr& n);
-    void generateUnionTraits(const NodePtr& n);
+    std::string generateUnionType(const NodePtr &n);
+    std::string generateType(const NodePtr &n);
+    std::string generateDeclaration(const NodePtr &n);
+    std::string doGenerateType(const NodePtr &n);
+    void generateEnumTraits(const NodePtr &n);
+    void generateTraits(const NodePtr &n);
+    void generateRecordTraits(const NodePtr &n);
+    void generateUnionTraits(const NodePtr &n);
     void emitCopyright();
+
 public:
-    CodeGen(std::ostream& os, std::string  ns,
-        std::string  schemaFile, std::string  headerFile,
-        std::string  guardString,
-        std::string  includePrefix, bool noUnion) :
-        unionNumber_(0), os_(os), inNamespace_(false), ns_(std::move(ns)),
-        schemaFile_(std::move(schemaFile)), headerFile_(std::move(headerFile)),
-        includePrefix_(std::move(includePrefix)), noUnion_(noUnion),
-        guardString_(std::move(guardString)),
-        random_(static_cast<uint32_t>(::time(nullptr))) { }
-    void generate(const ValidSchema& schema);
+    CodeGen(std::ostream &os, std::string ns,
+            std::string schemaFile, std::string headerFile,
+            std::string guardString,
+            std::string includePrefix, bool noUnion) : unionNumber_(0), os_(os), inNamespace_(false), ns_(std::move(ns)),
+                                                       schemaFile_(std::move(schemaFile)), headerFile_(std::move(headerFile)),
+                                                       includePrefix_(std::move(includePrefix)), noUnion_(noUnion),
+                                                       guardString_(std::move(guardString)),
+                                                       random_(static_cast<uint32_t>(::time(nullptr))) {}
+    void generate(const ValidSchema &schema);
 };
 
-static string decorate(const std::string &name)
-{
-    static const char * cppReservedWords[] = {
+static string decorate(const std::string &name) {
+    static const char *cppReservedWords[] = {
         "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break",
         "case", "catch", "char", "char8_t", "char16_t", "char32_t", "class", "compl", "concept",
         "const", "consteval", "constexpr", "const_cast", "continue", "co_await", "co_return",
@@ -136,27 +133,23 @@ static string decorate(const std::string &name)
         "register", "reinterpret_cast", "requires", "return", "short", "signed", "sizeof", "static",
         "static_assert", "static_cast", "struct", "switch", "synchronized", "template", "this",
         "thread_local", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned",
-        "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
-    };
+        "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"};
 
-    for (auto & cppReservedWord : cppReservedWords)
+    for (auto &cppReservedWord : cppReservedWords)
         if (strcmp(name.c_str(), cppReservedWord) == 0)
             return name + '_';
     return name;
 }
 
-static string decorate(const avro::Name& name)
-{
+static string decorate(const avro::Name &name) {
     return decorate(name.simpleName());
 }
 
-string CodeGen::fullname(const string& name) const
-{
+string CodeGen::fullname(const string &name) const {
     return ns_.empty() ? name : (ns_ + "::" + name);
 }
 
-string CodeGen::generateEnumType(const NodePtr& n)
-{
+string CodeGen::generateEnumType(const NodePtr &n) {
     string s = decorate(n->name());
     os_ << "enum class " << s << ": unsigned {\n";
     size_t c = n->names();
@@ -167,83 +160,78 @@ string CodeGen::generateEnumType(const NodePtr& n)
     return s;
 }
 
-string CodeGen::cppTypeOf(const NodePtr& n)
-{
+string CodeGen::cppTypeOf(const NodePtr &n) {
     switch (n->type()) {
-    case avro::AVRO_STRING:
-        return "std::string";
-    case avro::AVRO_BYTES:
-        return "std::vector<uint8_t>";
-    case avro::AVRO_INT:
-        return "int32_t";
-    case avro::AVRO_LONG:
-        return "int64_t";
-    case avro::AVRO_FLOAT:
-        return "float";
-    case avro::AVRO_DOUBLE:
-        return "double";
-    case avro::AVRO_BOOL:
-        return "bool";
-    case avro::AVRO_RECORD:
-    case avro::AVRO_ENUM:
-        {
+        case avro::AVRO_STRING:
+            return "std::string";
+        case avro::AVRO_BYTES:
+            return "std::vector<uint8_t>";
+        case avro::AVRO_INT:
+            return "int32_t";
+        case avro::AVRO_LONG:
+            return "int64_t";
+        case avro::AVRO_FLOAT:
+            return "float";
+        case avro::AVRO_DOUBLE:
+            return "double";
+        case avro::AVRO_BOOL:
+            return "bool";
+        case avro::AVRO_RECORD:
+        case avro::AVRO_ENUM: {
             string nm = decorate(n->name());
             return inNamespace_ ? nm : fullname(nm);
         }
-    case avro::AVRO_ARRAY:
-        return "std::vector<" + cppTypeOf(n->leafAt(0)) + " >";
-    case avro::AVRO_MAP:
-        return "std::map<std::string, " + cppTypeOf(n->leafAt(1)) + " >";
-    case avro::AVRO_FIXED:
-        return "std::array<uint8_t, " +
-            lexical_cast<string>(n->fixedSize()) + ">";
-    case avro::AVRO_SYMBOLIC:
-        return cppTypeOf(resolveSymbol(n));
-    case avro::AVRO_UNION:
-        return fullname(done[n]);
-    case avro::AVRO_NULL:
-        return "avro::null";
-    default:
-        return "$Undefined$";
+        case avro::AVRO_ARRAY:
+            return "std::vector<" + cppTypeOf(n->leafAt(0)) + " >";
+        case avro::AVRO_MAP:
+            return "std::map<std::string, " + cppTypeOf(n->leafAt(1)) + " >";
+        case avro::AVRO_FIXED:
+            return "std::array<uint8_t, " + lexical_cast<string>(n->fixedSize()) + ">";
+        case avro::AVRO_SYMBOLIC:
+            return cppTypeOf(resolveSymbol(n));
+        case avro::AVRO_UNION:
+            return fullname(done[n]);
+        case avro::AVRO_NULL:
+            return "avro::null";
+        default:
+            return "$Undefined$";
     }
 }
 
-static string cppNameOf(const NodePtr& n)
-{
+static string cppNameOf(const NodePtr &n) {
     switch (n->type()) {
-    case avro::AVRO_NULL:
-        return "null";
-    case avro::AVRO_STRING:
-        return "string";
-    case avro::AVRO_BYTES:
-        return "bytes";
-    case avro::AVRO_INT:
-        return "int";
-    case avro::AVRO_LONG:
-        return "long";
-    case avro::AVRO_FLOAT:
-        return "float";
-    case avro::AVRO_DOUBLE:
-        return "double";
-    case avro::AVRO_BOOL:
-        return "bool";
-    case avro::AVRO_RECORD:
-    case avro::AVRO_ENUM:
-    case avro::AVRO_FIXED:
-        return decorate(n->name());
-    case avro::AVRO_ARRAY:
-        return "array";
-    case avro::AVRO_MAP:
-        return "map";
-    case avro::AVRO_SYMBOLIC:
-        return cppNameOf(resolveSymbol(n));
-    default:
-        return "$Undefined$";
+        case avro::AVRO_NULL:
+            return "null";
+        case avro::AVRO_STRING:
+            return "string";
+        case avro::AVRO_BYTES:
+            return "bytes";
+        case avro::AVRO_INT:
+            return "int";
+        case avro::AVRO_LONG:
+            return "long";
+        case avro::AVRO_FLOAT:
+            return "float";
+        case avro::AVRO_DOUBLE:
+            return "double";
+        case avro::AVRO_BOOL:
+            return "bool";
+        case avro::AVRO_RECORD:
+        case avro::AVRO_ENUM:
+        case avro::AVRO_FIXED:
+            return decorate(n->name());
+        case avro::AVRO_ARRAY:
+            return "array";
+        case avro::AVRO_MAP:
+            return "map";
+        case avro::AVRO_SYMBOLIC:
+            return cppNameOf(resolveSymbol(n));
+        default:
+            return "$Undefined$";
     }
 }
 
-string CodeGen::generateRecordType(const NodePtr& n)
-{
+string CodeGen::generateRecordType(const NodePtr &n) {
     size_t c = n->leaves();
     string decoratedName = decorate(n->name());
     vector<string> types;
@@ -257,7 +245,7 @@ string CodeGen::generateRecordType(const NodePtr& n)
     }
 
     os_ << "struct " << decoratedName << " {\n";
-    if (! noUnion_) {
+    if (!noUnion_) {
         for (size_t i = 0; i < c; ++i) {
             if (n->leafAt(i)->type() == avro::AVRO_UNION) {
                 os_ << "    typedef " << types[i]
@@ -269,7 +257,7 @@ string CodeGen::generateRecordType(const NodePtr& n)
         // the nameAt(i) does not take c++ reserved words into account
         // so we need to call decorate on it
         std::string decoratedNameAt = decorate(n->nameAt(i));
-        if (! noUnion_ && n->leafAt(i)->type() == avro::AVRO_UNION) {
+        if (!noUnion_ && n->leafAt(i)->type() == avro::AVRO_UNION) {
             os_ << "    " << decoratedNameAt << "_t";
         } else {
             os_ << "    " << types[i];
@@ -287,7 +275,7 @@ string CodeGen::generateRecordType(const NodePtr& n)
         // so we need to call decorate on it
         std::string decoratedNameAt = decorate(n->nameAt(i));
         os_ << "        " << decoratedNameAt << "(";
-        if (! noUnion_ && n->leafAt(i)->type() == avro::AVRO_UNION) {
+        if (!noUnion_ && n->leafAt(i)->type() == avro::AVRO_UNION) {
             // the nameAt(i) does not take c++ reserved words into account
             // so we need to call decorate on it
             os_ << decoratedNameAt << "_t";
@@ -305,21 +293,19 @@ string CodeGen::generateRecordType(const NodePtr& n)
     return decoratedName;
 }
 
-void makeCanonical(string& s, bool foldCase)
-{
-    for (char & c : s) {
+void makeCanonical(string &s, bool foldCase) {
+    for (char &c : s) {
         if (isalpha(c)) {
             if (foldCase) {
                 c = static_cast<char>(toupper(c));
             }
-        } else if (! isdigit(c)) {
+        } else if (!isdigit(c)) {
             c = '_';
         }
     }
 }
 
-string CodeGen::unionName()
-{
+string CodeGen::unionName() {
     string s = schemaFile_;
     string::size_type n = s.find_last_of("/\\");
     if (n != string::npos) {
@@ -330,34 +316,33 @@ string CodeGen::unionName()
     return s + "_Union__" + boost::lexical_cast<string>(unionNumber_++) + "__";
 }
 
-static void generateGetterAndSetter(ostream& os,
-    const string& structName, const string& type, const string& name,
-    size_t idx)
-{
+static void generateGetterAndSetter(ostream &os,
+                                    const string &structName, const string &type, const string &name,
+                                    size_t idx) {
     string sn = " " + structName + "::";
 
     os << "inline\n";
 
     os << type << sn << "get_" << name << "() const {\n"
-        << "    if (idx_ != " << idx << ") {\n"
-        << "        throw avro::Exception(\"Invalid type for "
-            << "union\");\n"
-        << "    }\n"
-        << "    return " << ANY_NS << "::any_cast<" << type << " >(value_);\n"
-        << "}\n\n";
+       << "    if (idx_ != " << idx << ") {\n"
+       << "        throw avro::Exception(\"Invalid type for "
+       << "union\");\n"
+       << "    }\n"
+       << "    return " << ANY_NS << "::any_cast<" << type << " >(value_);\n"
+       << "}\n\n";
 
     os << "inline\n"
-        << "void" << sn << "set_" << name
-        << "(const " << type << "& v) {\n"
-        << "    idx_ = " << idx << ";\n"
-        << "    value_ = v;\n"
-        << "}\n\n";
+       << "void" << sn << "set_" << name
+       << "(const " << type << "& v) {\n"
+       << "    idx_ = " << idx << ";\n"
+       << "    value_ = v;\n"
+       << "}\n\n";
 }
 
-static void generateConstructor(ostream& os,
-    const string& structName, bool initMember,
-    const string& type) {
-    os << "inline " << structName  << "::" << structName << "() : idx_(0)";
+static void generateConstructor(ostream &os,
+                                const string &structName, bool initMember,
+                                const string &type) {
+    os << "inline " << structName << "::" << structName << "() : idx_(0)";
     if (initMember) {
         os << ", value_(" << type << "())";
     }
@@ -370,8 +355,7 @@ static void generateConstructor(ostream& os,
  * such names must be declared and the inline functions deferred until all
  * types are fully defined.
  */
-string CodeGen::generateUnionType(const NodePtr& n)
-{
+string CodeGen::generateUnionType(const NodePtr &n) {
     size_t c = n->leaves();
     vector<string> types;
     vector<string> names;
@@ -379,14 +363,14 @@ string CodeGen::generateUnionType(const NodePtr& n)
     auto it = doing.find(n);
     if (it != doing.end()) {
         for (size_t i = 0; i < c; ++i) {
-            const NodePtr& nn = n->leafAt(i);
+            const NodePtr &nn = n->leafAt(i);
             types.push_back(generateDeclaration(nn));
             names.push_back(cppNameOf(nn));
         }
     } else {
         doing.insert(n);
         for (size_t i = 0; i < c; ++i) {
-            const NodePtr& nn = n->leafAt(i);
+            const NodePtr &nn = n->leafAt(i);
             types.push_back(generateType(nn));
             names.push_back(cppNameOf(nn));
         }
@@ -406,7 +390,7 @@ string CodeGen::generateUnionType(const NodePtr& n)
         << "    size_t idx() const { return idx_; }\n";
 
     for (size_t i = 0; i < c; ++i) {
-        const NodePtr& nn = n->leafAt(i);
+        const NodePtr &nn = n->leafAt(i);
         if (nn->type() == avro::AVRO_NULL) {
             os_ << "    bool is_null() const {\n"
                 << "        return (idx_ == " << i << ");\n"
@@ -416,17 +400,18 @@ string CodeGen::generateUnionType(const NodePtr& n)
                 << "        value_ = " << ANY_NS << "::any();\n"
                 << "    }\n";
         } else {
-            const string& type = types[i];
-            const string& name = names[i];
+            const string &type = types[i];
+            const string &name = names[i];
             os_ << "    " << type << " get_" << name << "() const;\n"
-                   "    void set_" << name << "(const " << type << "& v);\n";
+                                                        "    void set_"
+                << name << "(const " << type << "& v);\n";
             pendingGettersAndSetters.emplace_back(result, type, name, i);
         }
     }
 
     os_ << "    " << result << "();\n";
     pendingConstructors.emplace_back(result, types[0],
-        n->leafAt(0)->type() != avro::AVRO_NULL);
+                                     n->leafAt(0)->type() != avro::AVRO_NULL);
     os_ << "};\n\n";
 
     return result;
@@ -435,9 +420,8 @@ string CodeGen::generateUnionType(const NodePtr& n)
 /**
  * Returns the type for the given schema node and emits code to os.
  */
-string CodeGen::generateType(const NodePtr& n)
-{
-    NodePtr nn = (n->type() == avro::AVRO_SYMBOLIC) ?  resolveSymbol(n) : n;
+string CodeGen::generateType(const NodePtr &n) {
+    NodePtr nn = (n->type() == avro::AVRO_SYMBOLIC) ? resolveSymbol(n) : n;
 
     map<NodePtr, string>::const_iterator it = done.find(nn);
     if (it != done.end()) {
@@ -448,92 +432,86 @@ string CodeGen::generateType(const NodePtr& n)
     return result;
 }
 
-string CodeGen::doGenerateType(const NodePtr& n)
-{
+string CodeGen::doGenerateType(const NodePtr &n) {
     switch (n->type()) {
-    case avro::AVRO_STRING:
-    case avro::AVRO_BYTES:
-    case avro::AVRO_INT:
-    case avro::AVRO_LONG:
-    case avro::AVRO_FLOAT:
-    case avro::AVRO_DOUBLE:
-    case avro::AVRO_BOOL:
-    case avro::AVRO_NULL:
-    case avro::AVRO_FIXED:
-        return cppTypeOf(n);
-    case avro::AVRO_ARRAY:
-    {
-        const NodePtr& ln = n->leafAt(0);
-        string dn;
-        if (doing.find(n) == doing.end()) {
-            doing.insert(n);
-            dn = generateType(ln);
-            doing.erase(n);
-        } else {
-            dn = generateDeclaration(ln);
+        case avro::AVRO_STRING:
+        case avro::AVRO_BYTES:
+        case avro::AVRO_INT:
+        case avro::AVRO_LONG:
+        case avro::AVRO_FLOAT:
+        case avro::AVRO_DOUBLE:
+        case avro::AVRO_BOOL:
+        case avro::AVRO_NULL:
+        case avro::AVRO_FIXED:
+            return cppTypeOf(n);
+        case avro::AVRO_ARRAY: {
+            const NodePtr &ln = n->leafAt(0);
+            string dn;
+            if (doing.find(n) == doing.end()) {
+                doing.insert(n);
+                dn = generateType(ln);
+                doing.erase(n);
+            } else {
+                dn = generateDeclaration(ln);
+            }
+            return "std::vector<" + dn + " >";
         }
-        return "std::vector<" + dn + " >";
-    }
-    case avro::AVRO_MAP:
-    {
-        const NodePtr& ln = n->leafAt(1);
-        string dn;
-        if (doing.find(n) == doing.end()) {
-            doing.insert(n);
-            dn = generateType(ln);
-            doing.erase(n);
-        } else {
-            dn = generateDeclaration(ln);
+        case avro::AVRO_MAP: {
+            const NodePtr &ln = n->leafAt(1);
+            string dn;
+            if (doing.find(n) == doing.end()) {
+                doing.insert(n);
+                dn = generateType(ln);
+                doing.erase(n);
+            } else {
+                dn = generateDeclaration(ln);
+            }
+            return "std::map<std::string, " + dn + " >";
         }
-        return "std::map<std::string, " + dn + " >";
-    }
-    case avro::AVRO_RECORD:
-        return generateRecordType(n);
-    case avro::AVRO_ENUM:
-        return generateEnumType(n);
-    case avro::AVRO_UNION:
-        return generateUnionType(n);
-    default:
-        break;
+        case avro::AVRO_RECORD:
+            return generateRecordType(n);
+        case avro::AVRO_ENUM:
+            return generateEnumType(n);
+        case avro::AVRO_UNION:
+            return generateUnionType(n);
+        default:
+            break;
     }
     return "$Undefined$";
 }
 
-string CodeGen::generateDeclaration(const NodePtr& n)
-{
-    NodePtr nn = (n->type() == avro::AVRO_SYMBOLIC) ?  resolveSymbol(n) : n;
+string CodeGen::generateDeclaration(const NodePtr &n) {
+    NodePtr nn = (n->type() == avro::AVRO_SYMBOLIC) ? resolveSymbol(n) : n;
     switch (nn->type()) {
-    case avro::AVRO_STRING:
-    case avro::AVRO_BYTES:
-    case avro::AVRO_INT:
-    case avro::AVRO_LONG:
-    case avro::AVRO_FLOAT:
-    case avro::AVRO_DOUBLE:
-    case avro::AVRO_BOOL:
-    case avro::AVRO_NULL:
-    case avro::AVRO_FIXED:
-        return cppTypeOf(nn);
-    case avro::AVRO_ARRAY:
-        return "std::vector<" + generateDeclaration(nn->leafAt(0)) + " >";
-    case avro::AVRO_MAP:
-        return "std::map<std::string, " +
-            generateDeclaration(nn->leafAt(1)) + " >";
-    case avro::AVRO_RECORD:
-        os_ << "struct " << cppTypeOf(nn) << ";\n";
-        return cppTypeOf(nn);
-    case avro::AVRO_ENUM:
-        return generateEnumType(nn);
-    case avro::AVRO_UNION:
-        // FIXME: When can this happen?
-        return generateUnionType(nn);
-    default:
-        break;
+        case avro::AVRO_STRING:
+        case avro::AVRO_BYTES:
+        case avro::AVRO_INT:
+        case avro::AVRO_LONG:
+        case avro::AVRO_FLOAT:
+        case avro::AVRO_DOUBLE:
+        case avro::AVRO_BOOL:
+        case avro::AVRO_NULL:
+        case avro::AVRO_FIXED:
+            return cppTypeOf(nn);
+        case avro::AVRO_ARRAY:
+            return "std::vector<" + generateDeclaration(nn->leafAt(0)) + " >";
+        case avro::AVRO_MAP:
+            return "std::map<std::string, " + generateDeclaration(nn->leafAt(1)) + " >";
+        case avro::AVRO_RECORD:
+            os_ << "struct " << cppTypeOf(nn) << ";\n";
+            return cppTypeOf(nn);
+        case avro::AVRO_ENUM:
+            return generateEnumType(nn);
+        case avro::AVRO_UNION:
+            // FIXME: When can this happen?
+            return generateUnionType(nn);
+        default:
+            break;
     }
     return "$Undefined$";
 }
 
-void CodeGen::generateEnumTraits(const NodePtr& n)
-{
+void CodeGen::generateEnumTraits(const NodePtr &n) {
     string dname = decorate(n->name());
     string fn = fullname(dname);
 
@@ -546,7 +524,8 @@ void CodeGen::generateEnumTraits(const NodePtr& n)
         << "        if (v > " << fn << "::" << last << ")\n"
         << "        {\n"
         << "            std::ostringstream error;\n"
-        << R"(            error << "enum value " << static_cast<unsigned>(v) << " is out of bound for )" << fn << " and cannot be encoded\";\n"
+        << R"(            error << "enum value " << static_cast<unsigned>(v) << " is out of bound for )" << fn
+        << " and cannot be encoded\";\n"
         << "            throw avro::Exception(error.str());\n"
         << "        }\n"
         << "        e.encodeEnum(static_cast<size_t>(v));\n"
@@ -556,7 +535,8 @@ void CodeGen::generateEnumTraits(const NodePtr& n)
         << "        if (index > static_cast<size_t>(" << fn << "::" << last << "))\n"
         << "        {\n"
         << "            std::ostringstream error;\n"
-        << R"(            error << "enum value " << index << " is out of bound for )" << fn << " and cannot be decoded\";\n"
+        << R"(            error << "enum value " << index << " is out of bound for )" << fn
+        << " and cannot be decoded\";\n"
         << "            throw avro::Exception(error.str());\n"
         << "        }\n"
         << "        v = static_cast<" << fn << ">(index);\n"
@@ -564,8 +544,7 @@ void CodeGen::generateEnumTraits(const NodePtr& n)
         << "};\n\n";
 }
 
-void CodeGen::generateRecordTraits(const NodePtr& n)
-{
+void CodeGen::generateRecordTraits(const NodePtr &n) {
     size_t c = n->leaves();
     for (size_t i = 0; i < c; ++i) {
         generateTraits(n->leafAt(i));
@@ -616,12 +595,11 @@ void CodeGen::generateRecordTraits(const NodePtr& n)
         << "};\n\n";
 }
 
-void CodeGen::generateUnionTraits(const NodePtr& n)
-{
+void CodeGen::generateUnionTraits(const NodePtr &n) {
     size_t c = n->leaves();
 
     for (size_t i = 0; i < c; ++i) {
-        const NodePtr& nn = n->leafAt(i);
+        const NodePtr &nn = n->leafAt(i);
         generateTraits(nn);
     }
 
@@ -634,7 +612,7 @@ void CodeGen::generateUnionTraits(const NodePtr& n)
         << "        switch (v.idx()) {\n";
 
     for (size_t i = 0; i < c; ++i) {
-        const NodePtr& nn = n->leafAt(i);
+        const NodePtr &nn = n->leafAt(i);
         os_ << "        case " << i << ":\n";
         if (nn->type() == avro::AVRO_NULL) {
             os_ << "            e.encodeNull();\n";
@@ -650,11 +628,11 @@ void CodeGen::generateUnionTraits(const NodePtr& n)
         << "    static void decode(Decoder& d, " << fn << "& v) {\n"
         << "        size_t n = d.decodeUnionIndex();\n"
         << "        if (n >= " << c << ") { throw avro::Exception(\""
-            "Union index too big\"); }\n"
+                                       "Union index too big\"); }\n"
         << "        switch (n) {\n";
 
     for (size_t i = 0; i < c; ++i) {
-        const NodePtr& nn = n->leafAt(i);
+        const NodePtr &nn = n->leafAt(i);
         os_ << "        case " << i << ":\n";
         if (nn->type() == avro::AVRO_NULL) {
             os_ << "            d.decodeNull();\n"
@@ -673,72 +651,67 @@ void CodeGen::generateUnionTraits(const NodePtr& n)
         << "};\n\n";
 }
 
-void CodeGen::generateTraits(const NodePtr& n)
-{
+void CodeGen::generateTraits(const NodePtr &n) {
     switch (n->type()) {
-    case avro::AVRO_STRING:
-    case avro::AVRO_BYTES:
-    case avro::AVRO_INT:
-    case avro::AVRO_LONG:
-    case avro::AVRO_FLOAT:
-    case avro::AVRO_DOUBLE:
-    case avro::AVRO_BOOL:
-    case avro::AVRO_NULL:
-        break;
-    case avro::AVRO_RECORD:
-        generateRecordTraits(n);
-        break;
-    case avro::AVRO_ENUM:
-        generateEnumTraits(n);
-        break;
-    case avro::AVRO_ARRAY:
-    case avro::AVRO_MAP:
-        generateTraits(n->leafAt(n->type() == avro::AVRO_ARRAY ? 0 : 1));
-        break;
-    case avro::AVRO_UNION:
-        generateUnionTraits(n);
-        break;
-    case avro::AVRO_FIXED:
-    default:
-        break;
+        case avro::AVRO_STRING:
+        case avro::AVRO_BYTES:
+        case avro::AVRO_INT:
+        case avro::AVRO_LONG:
+        case avro::AVRO_FLOAT:
+        case avro::AVRO_DOUBLE:
+        case avro::AVRO_BOOL:
+        case avro::AVRO_NULL:
+            break;
+        case avro::AVRO_RECORD:
+            generateRecordTraits(n);
+            break;
+        case avro::AVRO_ENUM:
+            generateEnumTraits(n);
+            break;
+        case avro::AVRO_ARRAY:
+        case avro::AVRO_MAP:
+            generateTraits(n->leafAt(n->type() == avro::AVRO_ARRAY ? 0 : 1));
+            break;
+        case avro::AVRO_UNION:
+            generateUnionTraits(n);
+            break;
+        case avro::AVRO_FIXED:
+        default:
+            break;
     }
 }
 
-void CodeGen::emitCopyright()
-{
-    os_ <<
-        "/**\n"
-        " * Licensed to the Apache Software Foundation (ASF) under one\n"
-        " * or more contributor license agreements.  See the NOTICE file\n"
-        " * distributed with this work for additional information\n"
-        " * regarding copyright ownership.  The ASF licenses this file\n"
-        " * to you under the Apache License, Version 2.0 (the\n"
-        " * \"License\"); you may not use this file except in compliance\n"
-        " * with the License.  You may obtain a copy of the License at\n"
-        " *\n"
-        " *     https://www.apache.org/licenses/LICENSE-2.0\n"
-        " *\n"
-        " * Unless required by applicable law or agreed to in writing, "
-            "software\n"
-        " * distributed under the License is distributed on an "
-            "\"AS IS\" BASIS,\n"
-        " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express "
-            "or implied.\n"
-        " * See the License for the specific language governing "
-            "permissions and\n"
-        " * limitations under the License.\n"
-        " */\n\n\n";
+void CodeGen::emitCopyright() {
+    os_ << "/**\n"
+           " * Licensed to the Apache Software Foundation (ASF) under one\n"
+           " * or more contributor license agreements.  See the NOTICE file\n"
+           " * distributed with this work for additional information\n"
+           " * regarding copyright ownership.  The ASF licenses this file\n"
+           " * to you under the Apache License, Version 2.0 (the\n"
+           " * \"License\"); you may not use this file except in compliance\n"
+           " * with the License.  You may obtain a copy of the License at\n"
+           " *\n"
+           " *     https://www.apache.org/licenses/LICENSE-2.0\n"
+           " *\n"
+           " * Unless required by applicable law or agreed to in writing, "
+           "software\n"
+           " * distributed under the License is distributed on an "
+           "\"AS IS\" BASIS,\n"
+           " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express "
+           "or implied.\n"
+           " * See the License for the specific language governing "
+           "permissions and\n"
+           " * limitations under the License.\n"
+           " */\n\n\n";
 }
 
-string CodeGen::guard()
-{
+string CodeGen::guard() {
     string h = headerFile_;
     makeCanonical(h, true);
     return h + "_" + lexical_cast<string>(random_()) + "__H_";
 }
 
-void CodeGen::generate(const ValidSchema& schema)
-{
+void CodeGen::generate(const ValidSchema &schema) {
     emitCopyright();
 
     string h = guardString_.empty() ? guard() : guardString_;
@@ -758,38 +731,38 @@ void CodeGen::generate(const ValidSchema& schema)
         << "\n";
 
     vector<string> nsVector;
-    if (! ns_.empty()) {
+    if (!ns_.empty()) {
         boost::algorithm::split_regex(nsVector, ns_, boost::regex("::"));
         for (vector<string>::const_iterator it =
-            nsVector.begin();
-            it != nsVector.end(); ++it) {
+                 nsVector.begin();
+             it != nsVector.end(); ++it) {
             os_ << "namespace " << *it << " {\n";
         }
         inNamespace_ = true;
     }
 
-    const NodePtr& root = schema.root();
+    const NodePtr &root = schema.root();
     generateType(root);
 
     for (vector<PendingSetterGetter>::const_iterator it =
-        pendingGettersAndSetters.begin();
-        it != pendingGettersAndSetters.end(); ++it) {
+             pendingGettersAndSetters.begin();
+         it != pendingGettersAndSetters.end(); ++it) {
         generateGetterAndSetter(os_, it->structName, it->type, it->name,
-            it->idx);
+                                it->idx);
     }
 
     for (vector<PendingConstructor>::const_iterator it =
-        pendingConstructors.begin();
-        it != pendingConstructors.end(); ++it) {
+             pendingConstructors.begin();
+         it != pendingConstructors.end(); ++it) {
         generateConstructor(os_, it->structName,
-            it->initMember, it->memberName);
+                            it->initMember, it->memberName);
     }
 
-    if (! ns_.empty()) {
+    if (!ns_.empty()) {
         inNamespace_ = false;
         for (vector<string>::const_iterator it =
-            nsVector.begin();
-            it != nsVector.end(); ++it) {
+                 nsVector.begin();
+             it != nsVector.end(); ++it) {
             os_ << "}\n";
         }
     }
@@ -804,13 +777,11 @@ void CodeGen::generate(const ValidSchema& schema)
 
     os_ << "#endif\n";
     os_.flush();
-
 }
 
 namespace po = boost::program_options;
 
-static string readGuard(const string& filename)
-{
+static string readGuard(const string &filename) {
     std::ifstream ifs(filename.c_str());
     string buf;
     string candidate;
@@ -831,8 +802,7 @@ static string readGuard(const string& filename)
     return candidate;
 }
 
-int main(int argc, char** argv)
-{
+int main(int argc, char **argv) {
     const string NS("namespace");
     const string OUT("output");
     const string IN("input");
@@ -840,20 +810,13 @@ int main(int argc, char** argv)
     const string NO_UNION_TYPEDEF("no-union-typedef");
 
     po::options_description desc("Allowed options");
-    desc.add_options()
-        ("help,h", "produce help message")
-        ("include-prefix,p", po::value<string>()->default_value("avro"),
-            "prefix for include headers, - for none, default: avro")
-        ("no-union-typedef,U", "do not generate typedefs for unions in records")
-        ("namespace,n", po::value<string>(), "set namespace for generated code")
-        ("input,i", po::value<string>(), "input file")
-        ("output,o", po::value<string>(), "output file to generate");
+    desc.add_options()("help,h", "produce help message")("include-prefix,p", po::value<string>()->default_value("avro"),
+                                                         "prefix for include headers, - for none, default: avro")("no-union-typedef,U", "do not generate typedefs for unions in records")("namespace,n", po::value<string>(), "set namespace for generated code")("input,i", po::value<string>(), "input file")("output,o", po::value<string>(), "output file to generate");
 
     po::variables_map vm;
     po::store(po::parse_command_line(argc, argv, desc), vm);
     po::notify(vm);
 
-
     if (vm.count("help") || vm.count(IN) == 0 || vm.count(OUT) == 0) {
         std::cout << desc << std::endl;
         return 1;
@@ -873,26 +836,24 @@ int main(int argc, char** argv)
     try {
         ValidSchema schema;
 
-        if (! inf.empty()) {
+        if (!inf.empty()) {
             ifstream in(inf.c_str());
             compileJsonSchema(in, schema);
         } else {
             compileJsonSchema(std::cin, schema);
         }
 
-        if (! outf.empty()) {
+        if (!outf.empty()) {
             string g = readGuard(outf);
             ofstream out(outf.c_str());
             CodeGen(out, ns, inf, outf, g, incPrefix, noUnion).generate(schema);
         } else {
-            CodeGen(std::cout, ns, inf, outf, "", incPrefix, noUnion).
-                generate(schema);
+            CodeGen(std::cout, ns, inf, outf, "", incPrefix, noUnion).generate(schema);
         }
         return 0;
     } catch (std::exception &e) {
         std::cerr << "Failed to parse or compile schema: "
-            << e.what() << std::endl;
+                  << e.what() << std::endl;
         return 1;
     }
-
 }
diff --git a/lang/c++/impl/json/JsonDom.cc b/lang/c++/impl/json/JsonDom.cc
index ac4d8c9..fdf46e9 100644
--- a/lang/c++/impl/json/JsonDom.cc
+++ b/lang/c++/impl/json/JsonDom.cc
@@ -22,48 +22,45 @@
 
 #include <string.h>
 
-#include "Stream.hh"
 #include "JsonIO.hh"
+#include "Stream.hh"
 
-using std::string;
 using boost::format;
+using std::string;
 
 namespace avro {
 namespace json {
-const char* typeToString(EntityType t)
-{
+const char *typeToString(EntityType t) {
     switch (t) {
-    case etNull: return "null";
-    case etBool: return "bool";
-    case etLong: return "long";
-    case etDouble: return "double";
-    case etString: return "string";
-    case etArray: return "array";
-    case etObject: return "object";
-    default: return "unknown";
+        case etNull: return "null";
+        case etBool: return "bool";
+        case etLong: return "long";
+        case etDouble: return "double";
+        case etString: return "string";
+        case etArray: return "array";
+        case etObject: return "object";
+        default: return "unknown";
     }
 }
 
-Entity readEntity(JsonParser& p)
-{
+Entity readEntity(JsonParser &p) {
     switch (p.peek()) {
-    case JsonParser::tkNull:
-        p.advance();
-        return Entity(p.line());
-    case JsonParser::tkBool:
-        p.advance();
-        return Entity(p.boolValue(), p.line());
-    case JsonParser::tkLong:
-        p.advance();
-        return Entity(p.longValue(), p.line());
-    case JsonParser::tkDouble:
-        p.advance();
-        return Entity(p.doubleValue(), p.line());
-    case JsonParser::tkString:
-        p.advance();
-        return Entity(std::make_shared<String>(p.rawString()), p.line());
-    case JsonParser::tkArrayStart:
-        {
+        case JsonParser::tkNull:
+            p.advance();
+            return Entity(p.line());
+        case JsonParser::tkBool:
+            p.advance();
+            return Entity(p.boolValue(), p.line());
+        case JsonParser::tkLong:
+            p.advance();
+            return Entity(p.longValue(), p.line());
+        case JsonParser::tkDouble:
+            p.advance();
+            return Entity(p.doubleValue(), p.line());
+        case JsonParser::tkString:
+            p.advance();
+            return Entity(std::make_shared<String>(p.rawString()), p.line());
+        case JsonParser::tkArrayStart: {
             size_t l = p.line();
             p.advance();
             std::shared_ptr<Array> v = std::make_shared<Array>();
@@ -73,8 +70,7 @@ Entity readEntity(JsonParser& p)
             p.advance();
             return Entity(v, l);
         }
-    case JsonParser::tkObjectStart:
-        {
+        case JsonParser::tkObjectStart: {
             size_t l = p.line();
             p.advance();
             std::shared_ptr<Object> v = std::make_shared<Object>();
@@ -87,94 +83,82 @@ Entity readEntity(JsonParser& p)
             p.advance();
             return Entity(v, l);
         }
-    default:
-        throw std::domain_error(JsonParser::toString(p.peek()));
+        default:
+            throw std::domain_error(JsonParser::toString(p.peek()));
     }
-
 }
 
-Entity loadEntity(const char* text)
-{
-    return loadEntity(reinterpret_cast<const uint8_t*>(text), ::strlen(text));
+Entity loadEntity(const char *text) {
+    return loadEntity(reinterpret_cast<const uint8_t *>(text), ::strlen(text));
 }
 
-Entity loadEntity(InputStream& in)
-{
+Entity loadEntity(InputStream &in) {
     JsonParser p;
     p.init(in);
     return readEntity(p);
 }
 
-Entity loadEntity(const uint8_t* text, size_t len)
-{
+Entity loadEntity(const uint8_t *text, size_t len) {
     std::unique_ptr<InputStream> in = memoryInputStream(text, len);
     return loadEntity(*in);
 }
 
-void writeEntity(JsonGenerator<JsonNullFormatter>& g, const Entity& n)
-{
+void writeEntity(JsonGenerator<JsonNullFormatter> &g, const Entity &n) {
     switch (n.type()) {
-    case etNull:
-        g.encodeNull();
-        break;
-    case etBool:
-        g.encodeBool(n.boolValue());
-        break;
-    case etLong:
-        g.encodeNumber(n.longValue());
-        break;
-    case etDouble:
-        g.encodeNumber(n.doubleValue());
-        break;
-    case etString:
-        g.encodeString(n.stringValue());
-        break;
-    case etArray:
-        {
+        case etNull:
+            g.encodeNull();
+            break;
+        case etBool:
+            g.encodeBool(n.boolValue());
+            break;
+        case etLong:
+            g.encodeNumber(n.longValue());
+            break;
+        case etDouble:
+            g.encodeNumber(n.doubleValue());
+            break;
+        case etString:
+            g.encodeString(n.stringValue());
+            break;
+        case etArray: {
             g.arrayStart();
-            const Array& v = n.arrayValue();
+            const Array &v = n.arrayValue();
             for (Array::const_iterator it = v.begin();
-                it != v.end(); ++it) {
+                 it != v.end(); ++it) {
                 writeEntity(g, *it);
             }
             g.arrayEnd();
-        }
-        break;
-    case etObject:
-        {
+        } break;
+        case etObject: {
             g.objectStart();
-            const Object& v = n.objectValue();
+            const Object &v = n.objectValue();
             for (Object::const_iterator it = v.begin(); it != v.end(); ++it) {
                 g.encodeString(it->first);
                 writeEntity(g, it->second);
             }
             g.objectEnd();
-        }
-        break;
+        } break;
     }
 }
 
-void Entity::ensureType(EntityType type) const
-{
+void Entity::ensureType(EntityType type) const {
     if (type_ != type) {
-        format msg = format("Invalid type. Expected \"%1%\" actual %2%") %
-            typeToString(type) % typeToString(type_);
+        format msg = format("Invalid type. Expected \"%1%\" actual %2%") % typeToString(type) % typeToString(type_);
         throw Exception(msg);
     }
 }
 
 String Entity::stringValue() const {
     ensureType(etString);
-    return JsonParser::toStringValue(**boost::any_cast<std::shared_ptr<String> >(&value_));
+    return JsonParser::toStringValue(**boost::any_cast<std::shared_ptr<String>>(&value_));
 }
 
 String Entity::bytesValue() const {
     ensureType(etString);
-    return JsonParser::toBytesValue(**boost::any_cast<std::shared_ptr<String> >(&value_));
+    return JsonParser::toBytesValue(**boost::any_cast<std::shared_ptr<String>>(&value_));
 }
 
-std::string Entity::toString() const
-{
+std::string Entity::toString() const {
     std::unique_ptr<OutputStream> out = memoryOutputStream();
     JsonGenerator<JsonNullFormatter> g;
     g.init(*out);
@@ -198,6 +182,5 @@ std::string Entity::toString() const
     return result;
 }
 
-}
-}
-
+} // namespace json
+} // namespace avro
diff --git a/lang/c++/impl/json/JsonDom.hh b/lang/c++/impl/json/JsonDom.hh
index e1f549d..cc17a86 100644
--- a/lang/c++/impl/json/JsonDom.hh
+++ b/lang/c++/impl/json/JsonDom.hh
@@ -20,14 +20,14 @@
 #define avro_json_JsonDom_hh__
 
 #include <iostream>
-#include <stdint.h>
 #include <map>
+#include <memory>
+#include <stdint.h>
 #include <string>
 #include <vector>
-#include <memory>
 
-#include "boost/any.hpp"
 #include "Config.hh"
+#include "boost/any.hpp"
 
 namespace avro {
 
@@ -59,7 +59,7 @@ enum EntityType {
     etObject
 };
 
-const char* typeToString(EntityType t);
+const char *typeToString(EntityType t);
 
 class AVRO_DECL Entity {
     EntityType type_;
@@ -67,14 +67,15 @@ class AVRO_DECL Entity {
     size_t line_; // can't be const else noncopyable...
 
     void ensureType(EntityType) const;
+
 public:
-    Entity(size_t line = 0) : type_(etNull), line_(line) { }
-    Entity(Bool v, size_t line = 0) : type_(etBool), value_(v), line_(line) { }
-    Entity(Long v, size_t line = 0) : type_(etLong), value_(v), line_(line) { }
-    Entity(Double v, size_t line = 0) : type_(etDouble), value_(v), line_(line) { }
-    Entity(const std::shared_ptr<String>& v, size_t line = 0) : type_(etString), value_(v), line_(line) { }
-    Entity(const std::shared_ptr<Array>& v, size_t line = 0) : type_(etArray), value_(v), line_(line) { }
-    Entity(const std::shared_ptr<Object>& v, size_t line = 0) : type_(etObject), value_(v), line_(line) { }
+    Entity(size_t line = 0) : type_(etNull), line_(line) {}
+    Entity(Bool v, size_t line = 0) : type_(etBool), value_(v), line_(line) {}
+    Entity(Long v, size_t line = 0) : type_(etLong), value_(v), line_(line) {}
+    Entity(Double v, size_t line = 0) : type_(etDouble), value_(v), line_(line) {}
+    Entity(const std::shared_ptr<String> &v, size_t line = 0) : type_(etString), value_(v), line_(line) {}
+    Entity(const std::shared_ptr<Array> &v, size_t line = 0) : type_(etArray), value_(v), line_(line) {}
+    Entity(const std::shared_ptr<Object> &v, size_t line = 0) : type_(etObject), value_(v), line_(line) {}
 
     EntityType type() const { return type_; }
 
@@ -99,64 +100,68 @@ public:
 
     String bytesValue() const;
 
-    const Array& arrayValue() const {
+    const Array &arrayValue() const {
         ensureType(etArray);
-        return **boost::any_cast<std::shared_ptr<Array> >(&value_);
+        return **boost::any_cast<std::shared_ptr<Array>>(&value_);
     }
 
-    const Object& objectValue() const {
+    const Object &objectValue() const {
         ensureType(etObject);
-        return **boost::any_cast<std::shared_ptr<Object> >(&value_);
+        return **boost::any_cast<std::shared_ptr<Object>>(&value_);
     }
 
     std::string toString() const;
 };
 
-template <typename T>
+template<typename T>
 struct type_traits {
 };
 
-template <> struct type_traits<bool> {
+template<>
+struct type_traits<bool> {
     static EntityType type() { return etBool; }
-    static const char* name() { return "bool"; }
+    static const char *name() { return "bool"; }
 };
 
-template <> struct type_traits<int64_t> {
+template<>
+struct type_traits<int64_t> {
     static EntityType type() { return etLong; }
-    static const char* name() { return "long"; }
+    static const char *name() { return "long"; }
 };
 
-template <> struct type_traits<double> {
+template<>
+struct type_traits<double> {
     static EntityType type() { return etDouble; }
-    static const char* name() { return "double"; }
+    static const char *name() { return "double"; }
 };
 
-template <> struct type_traits<std::string> {
+template<>
+struct type_traits<std::string> {
     static EntityType type() { return etString; }
-    static const char* name() { return "string"; }
+    static const char *name() { return "string"; }
 };
 
-template <> struct type_traits<std::vector<Entity> > {
+template<>
+struct type_traits<std::vector<Entity>> {
     static EntityType type() { return etArray; }
-    static const char* name() { return "array"; }
+    static const char *name() { return "array"; }
 };
 
-template <> struct type_traits<std::map<std::string, Entity> > {
+template<>
+struct type_traits<std::map<std::string, Entity>> {
     static EntityType type() { return etObject; }
-    static const char* name() { return "object"; }
+    static const char *name() { return "object"; }
 };
 
-AVRO_DECL Entity readEntity(JsonParser& p);
+AVRO_DECL Entity readEntity(JsonParser &p);
 
-AVRO_DECL Entity loadEntity(InputStream& in);
-AVRO_DECL Entity loadEntity(const char* text);
-AVRO_DECL Entity loadEntity(const uint8_t* text, size_t len);
+AVRO_DECL Entity loadEntity(InputStream &in);
+AVRO_DECL Entity loadEntity(const char *text);
+AVRO_DECL Entity loadEntity(const uint8_t *text, size_t len);
 
-void writeEntity(JsonGenerator<JsonNullFormatter>& g, const Entity& n);
+void writeEntity(JsonGenerator<JsonNullFormatter> &g, const Entity &n);
 
-}
-}
+} // namespace json
+} // namespace avro
 
 #endif
-
-
diff --git a/lang/c++/impl/json/JsonIO.cc b/lang/c++/impl/json/JsonIO.cc
index c11a722..ba930e6 100644
--- a/lang/c++/impl/json/JsonIO.cc
+++ b/lang/c++/impl/json/JsonIO.cc
@@ -24,21 +24,20 @@ namespace json {
 using std::ostringstream;
 using std::string;
 
-const char* const
-JsonParser::tokenNames[] = {
-    "Null",
-    "Bool",
-    "Integer",
-    "Double",
-    "String",
-    "Array start",
-    "Array end",
-    "Object start",
-    "Object end",
+const char *const
+    JsonParser::tokenNames[] = {
+        "Null",
+        "Bool",
+        "Integer",
+        "Double",
+        "String",
+        "Array start",
+        "Array end",
+        "Object start",
+        "Object end",
 };
 
-char JsonParser::next()
-{
+char JsonParser::next() {
     char ch = hasNext ? nextChar : ' ';
     while (isspace(ch)) {
         if (ch == '\n') {
@@ -50,18 +49,13 @@ char JsonParser::next()
     return ch;
 }
 
-void JsonParser::expectToken(Token tk)
-{
+void JsonParser::expectToken(Token tk) {
     if (advance() != tk) {
         if (tk == tkDouble) {
-            if(cur() == tkString
+            if (cur() == tkString
                 && (sv == "Infinity" || sv == "-Infinity" || sv == "NaN")) {
                 curToken = tkDouble;
-                dv = sv == "Infinity" ?
-                    std::numeric_limits<double>::infinity() :
-                    sv == "-Infinity" ?
-                        -std::numeric_limits<double>::infinity() :
-                    std::numeric_limits<double>::quiet_NaN();
+                dv = sv == "Infinity" ? std::numeric_limits<double>::infinity() : sv == "-Infinity" ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::quiet_NaN();
                 return;
             } else if (cur() == tkLong) {
                 dv = double(lv);
@@ -76,8 +70,7 @@ void JsonParser::expectToken(Token tk)
     }
 }
 
-JsonParser::Token JsonParser::doAdvance()
-{
+JsonParser::Token JsonParser::doAdvance() {
     char ch = next();
     if (ch == ']') {
         if (curState == stArray0 || curState == stArrayN) {
@@ -121,137 +114,136 @@ JsonParser::Token JsonParser::doAdvance()
     }
 
     switch (ch) {
-    case '[':
-        stateStack.push(curState);
-        curState = stArray0;
-        return tkArrayStart;
-    case '{':
-        stateStack.push(curState);
-        curState = stObject0;
-        return tkObjectStart;
-    case '"':
-        return tryString();
-    case 't':
-        bv = true;
-        return tryLiteral("rue", 3, tkBool);
-    case 'f':
-        bv = false;
-        return tryLiteral("alse", 4, tkBool);
-    case 'n':
-        return tryLiteral("ull", 3, tkNull);
-    default:
-        if (isdigit(ch) || ch == '-') {
-            return tryNumber(ch);
-        } else {
-            throw unexpected(ch);
-        }
+        case '[':
+            stateStack.push(curState);
+            curState = stArray0;
+            return tkArrayStart;
+        case '{':
+            stateStack.push(curState);
+            curState = stObject0;
+            return tkObjectStart;
+        case '"':
+            return tryString();
+        case 't':
+            bv = true;
+            return tryLiteral("rue", 3, tkBool);
+        case 'f':
+            bv = false;
+            return tryLiteral("alse", 4, tkBool);
+        case 'n':
+            return tryLiteral("ull", 3, tkNull);
+        default:
+            if (isdigit(ch) || ch == '-') {
+                return tryNumber(ch);
+            } else {
+                throw unexpected(ch);
+            }
     }
 }
 
-JsonParser::Token JsonParser::tryNumber(char ch)
-{
+JsonParser::Token JsonParser::tryNumber(char ch) {
     sv.clear();
     sv.push_back(ch);
 
     hasNext = false;
     int state = (ch == '-') ? 0 : (ch == '0') ? 1 : 2;
-    for (; ;) {
+    for (;;) {
         switch (state) {
-        case 0:
-            if (in_.hasMore()) {
-                ch = in_.read();
-                if (isdigit(ch)) {
-                    state = (ch == '0') ? 1 : 2;
-                    sv.push_back(ch);
-                    continue;
+            case 0:
+                if (in_.hasMore()) {
+                    ch = in_.read();
+                    if (isdigit(ch)) {
+                        state = (ch == '0') ? 1 : 2;
+                        sv.push_back(ch);
+                        continue;
+                    }
+                    hasNext = true;
                 }
-                hasNext = true;
-            }
-            break;
-        case 1:
-            if (in_.hasMore()) {
-                ch = in_.read();
-                if (ch == '.') {
-                    state = 3;
-                    sv.push_back(ch);
-                    continue;
-                } else if (ch == 'e' || ch == 'E') {
-                    sv.push_back(ch);
-                    state = 5;
-                    continue;
+                break;
+            case 1:
+                if (in_.hasMore()) {
+                    ch = in_.read();
+                    if (ch == '.') {
+                        state = 3;
+                        sv.push_back(ch);
+                        continue;
+                    } else if (ch == 'e' || ch == 'E') {
+                        sv.push_back(ch);
+                        state = 5;
+                        continue;
+                    }
+                    hasNext = true;
                 }
-                hasNext = true;
-            }
-            break;
-        case 2:
-            if (in_.hasMore()) {
-                ch = in_.read();
-                if (isdigit(ch)) {
-                    sv.push_back(ch);
-                    continue;
-                } else if (ch == '.') {
-                    state = 3;
-                    sv.push_back(ch);
-                    continue;
-                } else if (ch == 'e' || ch == 'E') {
-                    sv.push_back(ch);
-                    state = 5;
-                    continue;
+                break;
+            case 2:
+                if (in_.hasMore()) {
+                    ch = in_.read();
+                    if (isdigit(ch)) {
+                        sv.push_back(ch);
+                        continue;
+                    } else if (ch == '.') {
+                        state = 3;
+                        sv.push_back(ch);
+                        continue;
+                    } else if (ch == 'e' || ch == 'E') {
+                        sv.push_back(ch);
+                        state = 5;
+                        continue;
+                    }
+                    hasNext = true;
                 }
-                hasNext = true;
-            }
-            break;
-        case 3:
-        case 6:
-            if (in_.hasMore()) {
-                ch = in_.read();
-                if (isdigit(ch)) {
-                    sv.push_back(ch);
-                    state++;
-                    continue;
+                break;
+            case 3:
+            case 6:
+                if (in_.hasMore()) {
+                    ch = in_.read();
+                    if (isdigit(ch)) {
+                        sv.push_back(ch);
+                        state++;
+                        continue;
+                    }
+                    hasNext = true;
                 }
-                hasNext = true;
-            }
-            break;
-        case 4:
-            if (in_.hasMore()) {
-                ch = in_.read();
-                if (isdigit(ch)) {
-                    sv.push_back(ch);
-                    continue;
-                } else if (ch == 'e' || ch == 'E') {
-                    sv.push_back(ch);
-                    state = 5;
-                    continue;
+                break;
+            case 4:
+                if (in_.hasMore()) {
+                    ch = in_.read();
+                    if (isdigit(ch)) {
+                        sv.push_back(ch);
+                        continue;
+                    } else if (ch == 'e' || ch == 'E') {
+                        sv.push_back(ch);
+                        state = 5;
+                        continue;
+                    }
+                    hasNext = true;
                 }
-                hasNext = true;
-            }
-            break;
-        case 5:
-            if (in_.hasMore()) {
-                ch = in_.read();
-                if (ch == '+' || ch == '-') {
-                    sv.push_back(ch);
-                    state = 6;
-                    continue;
-                } else if (isdigit(ch)) {
-                    sv.push_back(ch);
-                    state = 7;
-                    continue;
+                break;
+            case 5:
+                if (in_.hasMore()) {
+                    ch = in_.read();
+                    if (ch == '+' || ch == '-') {
+                        sv.push_back(ch);
+                        state = 6;
+                        continue;
+                    } else if (isdigit(ch)) {
+                        sv.push_back(ch);
+                        state = 7;
+                        continue;
+                    }
+                    hasNext = true;
                 }
-                hasNext = true;
-            }
-            break;
-        case 7:
-            if (in_.hasMore()) {
-                ch = in_.read();
-                if (isdigit(ch)) {
-                    sv.push_back(ch);
-                    continue;
+                break;
+            case 7:
+                if (in_.hasMore()) {
+                    ch = in_.read();
+                    if (isdigit(ch)) {
+                        sv.push_back(ch);
+                        continue;
+                    }
+                    hasNext = true;
                 }
-                hasNext = true;
-            }
-            break;
+                break;
         }
         if (state == 1 || state == 2 || state == 4 || state == 7) {
             if (hasNext) {
@@ -275,50 +267,45 @@ JsonParser::Token JsonParser::tryNumber(char ch)
     }
 }
 
-JsonParser::Token JsonParser::tryString()
-{
+JsonParser::Token JsonParser::tryString() {
     sv.clear();
-    for ( ; ;) {
+    for (;;) {
         char ch = in_.read();
         if (ch == '"') {
             return tkString;
         } else if (ch == '\\') {
             ch = in_.read();
             switch (ch) {
-            case '"':
-            case '\\':
-            case '/':
-            case 'b':
-            case 'f':
-            case 'n':
-            case 'r':
-            case 't':
-                sv.push_back('\\');
-                sv.push_back(ch);
-                break;
-            case 'u':
-            case 'U':
-                {
+                case '"':
+                case '\\':
+                case '/':
+                case 'b':
+                case 'f':
+                case 'n':
+                case 'r':
+                case 't':
+                    sv.push_back('\\');
+                    sv.push_back(ch);
+                    break;
+                case 'u':
+                case 'U': {
                     uint32_t n = 0;
                     char e[4];
-                    in_.readBytes(reinterpret_cast<uint8_t*>(e), 4);
+                    in_.readBytes(reinterpret_cast<uint8_t *>(e), 4);
                     sv.push_back('\\');
                     sv.push_back(ch);
                     for (int i = 0; i < 4; i++) {
                         n *= 16;
                         char c = e[i];
-                        if (isdigit(c) ||
-                            (c >= 'a' && c <= 'f') ||
-                            (c >= 'A' && c <= 'F')) {
+                        if (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) {
                             sv.push_back(c);
                         } else {
                             throw unexpected(c);
                         }
                     }
-                }
-                break;
-            default:
-                throw unexpected(ch);
+                } break;
+                default:
+                    throw unexpected(ch);
             }
         } else {
             sv.push_back(ch);
@@ -326,38 +313,35 @@ JsonParser::Token JsonParser::tryString()
     }
 }
 
-
-string JsonParser::decodeString(const string& s, bool binary)
-{
+string JsonParser::decodeString(const string &s, bool binary) {
     string result;
     for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
         char ch = *it;
         if (ch == '\\') {
             ch = *++it;
             switch (ch) {
-            case '"':
-            case '\\':
-            case '/':
-                result.push_back(ch);
-                continue;
-            case 'b':
-                result.push_back('\b');
-                continue;
-            case 'f':
-                result.push_back('\f');
-                continue;
-            case 'n':
-                result.push_back('\n');
-                continue;
-            case 'r':
-                result.push_back('\r');
-                continue;
-            case 't':
-                result.push_back('\t');
-                continue;
-            case 'u':
-            case 'U':
-                {
+                case '"':
+                case '\\':
+                case '/':
+                    result.push_back(ch);
+                    continue;
+                case 'b':
+                    result.push_back('\b');
+                    continue;
+                case 'f':
+                    result.push_back('\f');
+                    continue;
+                case 'n':
+                    result.push_back('\n');
+                    continue;
+                case 'r':
+                    result.push_back('\r');
+                    continue;
+                case 't':
+                    result.push_back('\t');
+                    continue;
+                case 'u':
+                case 'U': {
                     uint32_t n = 0;
                     char e[4];
                     for (int i = 0; i < 4; i++) {
@@ -375,8 +359,8 @@ string JsonParser::decodeString(const string& s, bool binary)
                     if (binary) {
                         if (n > 0xff) {
                             throw Exception(boost::format(
-                                "Invalid byte for binary: %1%%2%") % ch %
-                                    string(e, 4));
+                                                "Invalid byte for binary: %1%%2%")
+                                            % ch % string(e, 4));
                         } else {
                             result.push_back(n);
                             continue;
@@ -389,20 +373,20 @@ string JsonParser::decodeString(const string& s, bool binary)
                         result.push_back((n & 0x3f) | 0x80);
                     } else if (n < 0x10000) {
                         result.push_back((n >> 12) | 0xe0);
-                        result.push_back(((n >> 6)& 0x3f) | 0x80);
+                        result.push_back(((n >> 6) & 0x3f) | 0x80);
                         result.push_back((n & 0x3f) | 0x80);
                     } else if (n < 110000) {
                         result.push_back((n >> 18) | 0xf0);
-                        result.push_back(((n >> 12)& 0x3f) | 0x80);
-                        result.push_back(((n >> 6)& 0x3f) | 0x80);
+                        result.push_back(((n >> 12) & 0x3f) | 0x80);
+                        result.push_back(((n >> 6) & 0x3f) | 0x80);
                         result.push_back((n & 0x3f) | 0x80);
                     } else {
                         throw Exception(boost::format(
-                            "Invalid unicode value: %1%i%2%") % ch %
-                                string(e, 4));
+                                            "Invalid unicode value: %1%i%2%")
+                                        % ch % string(e, 4));
                     }
                 }
-                continue;
+                    continue;
             }
         } else {
             result.push_back(ch);
@@ -411,17 +395,15 @@ string JsonParser::decodeString(const string& s, bool binary)
     return result;
 }
 
-Exception JsonParser::unexpected(unsigned char c)
-{
+Exception JsonParser::unexpected(unsigned char c) {
     std::ostringstream oss;
     oss << "Unexpected character in json " << toHex(c / 16) << toHex(c % 16);
     return Exception(oss.str());
 }
 
-JsonParser::Token JsonParser::tryLiteral(const char exp[], size_t n, Token tk)
-{
+JsonParser::Token JsonParser::tryLiteral(const char exp[], size_t n, Token tk) {
     char c[100];
-    in_.readBytes(reinterpret_cast<uint8_t*>(c), n);
+    in_.readBytes(reinterpret_cast<uint8_t *>(c), n);
     for (size_t i = 0; i < n; ++i) {
         if (c[i] != exp[i]) {
             throw unexpected(c[i]);
@@ -437,6 +419,5 @@ JsonParser::Token JsonParser::tryLiteral(const char exp[], size_t n, Token tk)
     return tk;
 }
 
-}
-}
-
+} // namespace json
+} // namespace avro
diff --git a/lang/c++/impl/json/JsonIO.hh b/lang/c++/impl/json/JsonIO.hh
index cb42e37..466e5b7 100644
--- a/lang/c++/impl/json/JsonIO.hh
+++ b/lang/c++/impl/json/JsonIO.hh
@@ -19,13 +19,13 @@
 #ifndef avro_json_JsonIO_hh__
 #define avro_json_JsonIO_hh__
 
+#include <boost/lexical_cast.hpp>
+#include <boost/math/special_functions/fpclassify.hpp>
+#include <boost/utility.hpp>
 #include <locale>
+#include <sstream>
 #include <stack>
 #include <string>
-#include <sstream>
-#include <boost/math/special_functions/fpclassify.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/utility.hpp>
 
 #include "Config.hh"
 #include "Stream.hh"
@@ -37,7 +37,6 @@ inline char toHex(unsigned int n) {
     return (n < 10) ? (n + '0') : (n + 'a' - 10);
 }
 
-
 class AVRO_DECL JsonParser : boost::noncopyable {
 public:
     enum Token {
@@ -56,12 +55,12 @@ public:
 
 private:
     enum State {
-        stValue,    // Expect a data type
-        stArray0,   // Expect a data type or ']'
-        stArrayN,   // Expect a ',' or ']'
-        stObject0,  // Expect a string or a '}'
-        stObjectN,  // Expect a ',' or '}'
-        stKey       // Expect a ':'
+        stValue,   // Expect a data type
+        stArray0,  // Expect a data type or ']'
+        stArrayN,  // Expect a ',' or ']'
+        stObject0, // Expect a string or a '}'
+        stObjectN, // Expect a ',' or '}'
+        stKey      // Expect a ':'
     };
     std::stack<State> stateStack;
     State curState;
@@ -84,12 +83,12 @@ private:
     Exception unexpected(unsigned char ch);
     char next();
 
-    static std::string decodeString(const std::string& s, bool binary);
+    static std::string decodeString(const std::string &s, bool binary);
 
 public:
-    JsonParser() : curState(stValue), hasNext(false), peeked(false), line_(1) { }
+    JsonParser() : curState(stValue), hasNext(false), peeked(false), line_(1) {}
 
-    void init(InputStream& is) {
+    void init(InputStream &is) {
         // Clear by swapping with an empty stack
         std::stack<State>().swap(stateStack);
         curState = stValue;
@@ -100,7 +99,7 @@ public:
     }
 
     Token advance() {
-        if (! peeked) {
+        if (!peeked) {
             curToken = doAdvance();
         } else {
             peeked = false;
@@ -109,7 +108,7 @@ public:
     }
 
     Token peek() {
-        if (! peeked) {
+        if (!peeked) {
             curToken = doAdvance();
             peeked = true;
         }
@@ -134,7 +133,7 @@ public:
         return lv;
     }
 
-    const std::string& rawString() const {
+    const std::string &rawString() const {
         return sv;
     }
 
@@ -157,7 +156,7 @@ public:
     /**
      * Return UTF-8 encoded string value.
      */
-    static std::string toStringValue(const std::string& sv) {
+    static std::string toStringValue(const std::string &sv) {
         return decodeString(sv, false);
     }
 
@@ -165,20 +164,20 @@ public:
      * Return byte-encoded string value. It is an error if the input
      * JSON string contained unicode characters more than "\u00ff'.
      */
-    static std::string toBytesValue(const std::string& sv) {
+    static std::string toBytesValue(const std::string &sv) {
         return decodeString(sv, true);
     }
 
-    static const char* const tokenNames[];
+    static const char *const tokenNames[];
 
-    static const char* toString(Token tk) {
+    static const char *toString(Token tk) {
         return tokenNames[tk];
     }
 };
 
 class AVRO_DECL JsonNullFormatter {
 public:
-    JsonNullFormatter(StreamWriter&) { }
+    JsonNullFormatter(StreamWriter &) {}
 
     void handleObjectStart() {}
     void handleObjectEnd() {}
@@ -187,7 +186,7 @@ public:
 };
 
 class AVRO_DECL JsonPrettyFormatter {
-    StreamWriter& out_;
+    StreamWriter &out_;
     size_t level_;
     std::vector<uint8_t> indent_;
 
@@ -200,8 +199,9 @@ class AVRO_DECL JsonPrettyFormatter {
         }
         out_.writeBytes(indent_.data(), charsToIndent);
     }
+
 public:
-    JsonPrettyFormatter(StreamWriter& out) : out_(out), level_(0), indent_(10, ' ') { }
+    JsonPrettyFormatter(StreamWriter &out) : out_(out), level_(0), indent_(10, ' ') {}
 
     void handleObjectStart() {
         out_.write('\n');
@@ -225,7 +225,7 @@ public:
     }
 };
 
-template <class F>
+template<class F>
 class AVRO_DECL JsonGenerator {
     StreamWriter out_;
     F formatter_;
@@ -241,13 +241,13 @@ class AVRO_DECL JsonGenerator {
     std::stack<State> stateStack;
     State top;
 
-    void write(const char *b, const char* p) {
+    void write(const char *b, const char *p) {
         if (b != p) {
-            out_.writeBytes(reinterpret_cast<const uint8_t*>(b), p - b);
+            out_.writeBytes(reinterpret_cast<const uint8_t *>(b), p - b);
         }
     }
 
-    void escape(char c, const char* b, const char *p) {
+    void escape(char c, const char *b, const char *p) {
         write(b, p);
         out_.write('\\');
         out_.write(c);
@@ -268,10 +268,10 @@ class AVRO_DECL JsonGenerator {
         writeHex((c >> 8) & 0xff);
         writeHex(c & 0xff);
     }
-    void doEncodeString(const char* b, size_t len, bool binary) {
-        const char* e = b + len;
+    void doEncodeString(const char *b, size_t len, bool binary) {
+        const char *e = b + len;
         out_.write('"');
-        for (const char* p = b; p != e; p++) {
+        for (const char *p = b; p != e; p++) {
             if ((*p & 0x80) != 0) {
                 write(b, p);
                 if (binary) {
@@ -307,34 +307,34 @@ class AVRO_DECL JsonGenerator {
                 }
             } else {
                 switch (*p) {
-                case '\\':
-                case '"':
-                case '/':
-                    escape(*p, b, p);
-                    break;
-                case '\b':
-                    escape('b', b, p);
-                    break;
-                case '\f':
-                    escape('f', b, p);
-                    break;
-                case '\n':
-                    escape('n', b, p);
-                    break;
-                case '\r':
-                    escape('r', b, p);
-                    break;
-                case '\t':
-                    escape('t', b, p);
-                    break;
-                default:
-                    if (std::iscntrl(*p, std::locale::classic())) {
-                        write(b, p);
-                        escapeCtl(*p);
+                    case '\\':
+                    case '"':
+                    case '/':
+                        escape(*p, b, p);
                         break;
-                    } else {
-                        continue;
-                    }
+                    case '\b':
+                        escape('b', b, p);
+                        break;
+                    case '\f':
+                        escape('f', b, p);
+                        break;
+                    case '\n':
+                        escape('n', b, p);
+                        break;
+                    case '\r':
+                        escape('r', b, p);
+                        break;
+                    case '\t':
+                        escape('t', b, p);
+                        break;
+                    default:
+                        if (std::iscntrl(*p, std::locale::classic())) {
+                            write(b, p);
+                            escapeCtl(*p);
+                            break;
+                        } else {
+                            continue;
+                        }
                 }
             }
             b = p + 1;
@@ -359,9 +359,9 @@ class AVRO_DECL JsonGenerator {
     }
 
 public:
-    JsonGenerator() : formatter_(out_), top(stStart) { }
+    JsonGenerator() : formatter_(out_), top(stStart) {}
 
-    void init(OutputStream& os) {
+    void init(OutputStream &os) {
         out_.reset(os);
     }
 
@@ -375,27 +375,27 @@ public:
 
     void encodeNull() {
         sep();
-        out_.writeBytes(reinterpret_cast<const uint8_t*>("null"), 4);
+        out_.writeBytes(reinterpret_cast<const uint8_t *>("null"), 4);
         sep2();
     }
 
     void encodeBool(bool b) {
         sep();
         if (b) {
-            out_.writeBytes(reinterpret_cast<const uint8_t*>("true"), 4);
+            out_.writeBytes(reinterpret_cast<const uint8_t *>("true"), 4);
         } else {
-            out_.writeBytes(reinterpret_cast<const uint8_t*>("false"), 5);
+            out_.writeBytes(reinterpret_cast<const uint8_t *>("false"), 5);
         }
         sep2();
     }
 
-    template <typename T>
+    template<typename T>
     void encodeNumber(T t) {
         sep();
         std::ostringstream oss;
         oss << boost::lexical_cast<std::string>(t);
         const std::string s = oss.str();
-        out_.writeBytes(reinterpret_cast<const uint8_t*>(s.data()), s.size());
+        out_.writeBytes(reinterpret_cast<const uint8_t *>(s.data()), s.size());
         sep2();
     }
 
@@ -412,12 +412,11 @@ public:
             oss << "-Infinity";
         }
         const std::string s = oss.str();
-        out_.writeBytes(reinterpret_cast<const uint8_t*>(s.data()), s.size());
+        out_.writeBytes(reinterpret_cast<const uint8_t *>(s.data()), s.size());
         sep2();
     }
 
-
-    void encodeString(const std::string& s) {
+    void encodeString(const std::string &s) {
         if (top == stMap0) {
             top = stKey;
         } else if (top == stMapN) {
@@ -436,7 +435,7 @@ public:
         }
     }
 
-    void encodeBinary(const uint8_t* bytes, size_t len) {
+    void encodeBinary(const uint8_t *bytes, size_t len) {
         sep();
         doEncodeString(reinterpret_cast<const char *>(bytes), len, true);
         sep2();
@@ -473,10 +472,9 @@ public:
         out_.write('}');
         sep2();
     }
-
 };
 
-}
-}
+} // namespace json
+} // namespace avro
 
 #endif
diff --git a/lang/c++/impl/parsing/JsonCodec.cc b/lang/c++/impl/parsing/JsonCodec.cc
index c21b6ce..9416ff6 100644
--- a/lang/c++/impl/parsing/JsonCodec.cc
+++ b/lang/c++/impl/parsing/JsonCodec.cc
@@ -18,19 +18,19 @@
 
 #define __STDC_LIMIT_MACROS
 
-#include <string>
-#include <map>
 #include <algorithm>
+#include <boost/math/special_functions/fpclassify.hpp>
 #include <cctype>
+#include <map>
 #include <memory>
-#include <boost/math/special_functions/fpclassify.hpp>
+#include <string>
 
-#include "ValidatingCodec.hh"
-#include "Symbol.hh"
-#include "ValidSchema.hh"
 #include "Decoder.hh"
 #include "Encoder.hh"
 #include "NodeImpl.hh"
+#include "Symbol.hh"
+#include "ValidSchema.hh"
+#include "ValidatingCodec.hh"
 
 #include "../json/JsonIO.hh"
 
@@ -40,24 +40,23 @@ namespace parsing {
 
 using std::make_shared;
 
+using std::istringstream;
 using std::map;
-using std::vector;
-using std::string;
-using std::reverse;
 using std::ostringstream;
-using std::istringstream;
+using std::reverse;
+using std::string;
+using std::vector;
 
-using avro::json::JsonParser;
 using avro::json::JsonGenerator;
 using avro::json::JsonNullFormatter;
+using avro::json::JsonParser;
 
 class JsonGrammarGenerator : public ValidatingGrammarGenerator {
-    ProductionPtr doGenerate(const NodePtr& n,
-        std::map<NodePtr, ProductionPtr> &m);
+    ProductionPtr doGenerate(const NodePtr &n,
+                             std::map<NodePtr, ProductionPtr> &m);
 };
 
-static std::string nameOf(const NodePtr& n)
-{
+static std::string nameOf(const NodePtr &n) {
     if (n->hasName()) {
         return std::string(n->name());
     }
@@ -66,24 +65,23 @@ static std::string nameOf(const NodePtr& n)
     return oss.str();
 }
 
-ProductionPtr JsonGrammarGenerator::doGenerate(const NodePtr& n,
-    std::map<NodePtr, ProductionPtr> &m) {
+ProductionPtr JsonGrammarGenerator::doGenerate(const NodePtr &n,
+                                               std::map<NodePtr, ProductionPtr> &m) {
     switch (n->type()) {
-    case AVRO_NULL:
-    case AVRO_BOOL:
-    case AVRO_INT:
-    case AVRO_LONG:
-    case AVRO_FLOAT:
-    case AVRO_DOUBLE:
-    case AVRO_STRING:
-    case AVRO_BYTES:
-    case AVRO_FIXED:
-    case AVRO_ARRAY:
-    case AVRO_MAP:
-    case AVRO_SYMBOLIC:
-        return ValidatingGrammarGenerator::doGenerate(n, m);
-    case AVRO_RECORD:
-        {
+        case AVRO_NULL:
+        case AVRO_BOOL:
+        case AVRO_INT:
+        case AVRO_LONG:
+        case AVRO_FLOAT:
+        case AVRO_DOUBLE:
+        case AVRO_STRING:
+        case AVRO_BYTES:
+        case AVRO_FIXED:
+        case AVRO_ARRAY:
+        case AVRO_MAP:
+        case AVRO_SYMBOLIC:
+            return ValidatingGrammarGenerator::doGenerate(n, m);
+        case AVRO_RECORD: {
             ProductionPtr result = make_shared<Production>();
 
             m.erase(n);
@@ -92,7 +90,7 @@ ProductionPtr JsonGrammarGenerator::doGenerate(const NodePtr& n,
             result->reserve(2 + 2 * c);
             result->push_back(Symbol::recordStartSymbol());
             for (size_t i = 0; i < c; ++i) {
-                const NodePtr& leaf = n->leafAt(i);
+                const NodePtr &leaf = n->leafAt(i);
                 ProductionPtr v = doGenerate(leaf, m);
                 result->push_back(Symbol::fieldSymbol(n->nameAt(i)));
                 copy(v->rbegin(), v->rend(), back_inserter(*result));
@@ -103,8 +101,7 @@ ProductionPtr JsonGrammarGenerator::doGenerate(const NodePtr& n,
             m[n] = result;
             return make_shared<Production>(1, Symbol::indirect(result));
         }
-    case AVRO_ENUM:
-        {
+        case AVRO_ENUM: {
             vector<string> nn;
             size_t c = n->names();
             nn.reserve(c);
@@ -117,8 +114,7 @@ ProductionPtr JsonGrammarGenerator::doGenerate(const NodePtr& n,
             m[n] = result;
             return result;
         }
-    case AVRO_UNION:
-        {
+        case AVRO_UNION: {
             size_t c = n->leaves();
 
             vector<ProductionPtr> vv;
@@ -128,7 +124,7 @@ ProductionPtr JsonGrammarGenerator::doGenerate(const NodePtr& n,
             names.reserve(c);
 
             for (size_t i = 0; i < c; ++i) {
-                const NodePtr& nn = n->leafAt(i);
+                const NodePtr &nn = n->leafAt(i);
                 ProductionPtr v = doGenerate(nn, m);
                 if (nn->type() != AVRO_NULL) {
                     ProductionPtr v2 = make_shared<Production>();
@@ -145,59 +141,59 @@ ProductionPtr JsonGrammarGenerator::doGenerate(const NodePtr& n,
             result->push_back(Symbol::unionSymbol());
             return result;
         }
-    default:
-        throw Exception("Unknown node type");
+        default:
+            throw Exception("Unknown node type");
     }
 }
 
-static void expectToken(JsonParser& in, JsonParser::Token tk)
-{
+static void expectToken(JsonParser &in, JsonParser::Token tk) {
     in.expectToken(tk);
 }
 
 class JsonDecoderHandler {
-    JsonParser& in_;
+    JsonParser &in_;
+
 public:
-    JsonDecoderHandler(JsonParser& p) : in_(p) { }
-    size_t handle(const Symbol& s) {
+    JsonDecoderHandler(JsonParser &p) : in_(p) {}
+    size_t handle(const Symbol &s) {
         switch (s.kind()) {
-        case Symbol::sRecordStart:
-            expectToken(in_, JsonParser::tkObjectStart);
-            break;
-        case Symbol::sRecordEnd:
-            expectToken(in_, JsonParser::tkObjectEnd);
-            break;
-        case Symbol::sField:
-            expectToken(in_, JsonParser::tkString);
-            if (s.extra<string>() != in_.stringValue()) {
-                throw Exception("Incorrect field");
-            }
-            break;
-        default:
-            break;
+            case Symbol::sRecordStart:
+                expectToken(in_, JsonParser::tkObjectStart);
+                break;
+            case Symbol::sRecordEnd:
+                expectToken(in_, JsonParser::tkObjectEnd);
+                break;
+            case Symbol::sField:
+                expectToken(in_, JsonParser::tkString);
+                if (s.extra<string>() != in_.stringValue()) {
+                    throw Exception("Incorrect field");
+                }
+                break;
+            default:
+                break;
         }
         return 0;
     }
 };
 
-template <typename P>
+template<typename P>
 class JsonDecoder : public Decoder {
     JsonParser in_;
     JsonDecoderHandler handler_;
     P parser_;
 
-    void init(InputStream& is);
+    void init(InputStream &is);
     void decodeNull();
     bool decodeBool();
     int32_t decodeInt();
     int64_t decodeLong();
     float decodeFloat();
     double decodeDouble();
-    void decodeString(string& value);
+    void decodeString(string &value);
     void skipString();
-    void decodeBytes(vector<uint8_t>& value);
+    void decodeBytes(vector<uint8_t> &value);
     void skipBytes();
-    void decodeFixed(size_t n, vector<uint8_t>& value);
+    void decodeFixed(size_t n, vector<uint8_t> &value);
     void skipFixed(size_t n);
     size_t decodeEnum();
     size_t arrayStart();
@@ -211,121 +207,105 @@ class JsonDecoder : public Decoder {
     void expect(JsonParser::Token tk);
     void skipComposite();
     void drain();
-public:
-
-    JsonDecoder(const ValidSchema& s) :
-        handler_(in_),
-        parser_(JsonGrammarGenerator().generate(s), NULL, handler_) { }
 
+public:
+    JsonDecoder(const ValidSchema &s) : handler_(in_),
+                                        parser_(JsonGrammarGenerator().generate(s), NULL, handler_) {}
 };
 
-template <typename P>
-void JsonDecoder<P>::init(InputStream& is)
-{
+template<typename P>
+void JsonDecoder<P>::init(InputStream &is) {
     in_.init(is);
     parser_.reset();
 }
 
-template <typename P>
-void JsonDecoder<P>::expect(JsonParser::Token tk)
-{
+template<typename P>
+void JsonDecoder<P>::expect(JsonParser::Token tk) {
     expectToken(in_, tk);
 }
 
-template <typename P>
-void JsonDecoder<P>::decodeNull()
-{
+template<typename P>
+void JsonDecoder<P>::decodeNull() {
     parser_.advance(Symbol::sNull);
     expect(JsonParser::tkNull);
 }
 
-template <typename P>
-bool JsonDecoder<P>::decodeBool()
-{
+template<typename P>
+bool JsonDecoder<P>::decodeBool() {
     parser_.advance(Symbol::sBool);
     expect(JsonParser::tkBool);
     bool result = in_.boolValue();
     return result;
 }
 
-template <typename P>
-int32_t JsonDecoder<P>::decodeInt()
-{
+template<typename P>
+int32_t JsonDecoder<P>::decodeInt() {
     parser_.advance(Symbol::sInt);
     expect(JsonParser::tkLong);
     int64_t result = in_.longValue();
     if (result < INT32_MIN || result > INT32_MAX) {
         throw Exception(boost::format("Value out of range for Avro int: %1%")
-            % result);
+                        % result);
     }
     return static_cast<int32_t>(result);
 }
 
-template <typename P>
-int64_t JsonDecoder<P>::decodeLong()
-{
+template<typename P>
+int64_t JsonDecoder<P>::decodeLong() {
     parser_.advance(Symbol::sLong);
     expect(JsonParser::tkLong);
     int64_t result = in_.longValue();
     return result;
 }
 
-template <typename P>
-float JsonDecoder<P>::decodeFloat()
-{
+template<typename P>
+float JsonDecoder<P>::decodeFloat() {
     parser_.advance(Symbol::sFloat);
     expect(JsonParser::tkDouble);
     double result = in_.doubleValue();
     return static_cast<float>(result);
 }
 
-template <typename P>
-double JsonDecoder<P>::decodeDouble()
-{
+template<typename P>
+double JsonDecoder<P>::decodeDouble() {
     parser_.advance(Symbol::sDouble);
     expect(JsonParser::tkDouble);
     double result = in_.doubleValue();
     return result;
 }
 
-template <typename P>
-void JsonDecoder<P>::decodeString(string& value)
-{
+template<typename P>
+void JsonDecoder<P>::decodeString(string &value) {
     parser_.advance(Symbol::sString);
     expect(JsonParser::tkString);
     value = in_.stringValue();
 }
 
-template <typename P>
-void JsonDecoder<P>::skipString()
-{
+template<typename P>
+void JsonDecoder<P>::skipString() {
     parser_.advance(Symbol::sString);
     expect(JsonParser::tkString);
 }
 
-static vector<uint8_t> toBytes(const string& s)
-{
+static vector<uint8_t> toBytes(const string &s) {
     return vector<uint8_t>(s.begin(), s.end());
 }
 
-template <typename P>
-void JsonDecoder<P>::decodeBytes(vector<uint8_t>& value )
-{
+template<typename P>
+void JsonDecoder<P>::decodeBytes(vector<uint8_t> &value) {
     parser_.advance(Symbol::sBytes);
     expect(JsonParser::tkString);
     value = toBytes(in_.bytesValue());
 }
 
-template <typename P>
-void JsonDecoder<P>::skipBytes()
-{
+template<typename P>
+void JsonDecoder<P>::skipBytes() {
     parser_.advance(Symbol::sBytes);
     expect(JsonParser::tkString);
 }
 
-template <typename P>
-void JsonDecoder<P>::decodeFixed(size_t n, vector<uint8_t>& value)
-{
+template<typename P>
+void JsonDecoder<P>::decodeFixed(size_t n, vector<uint8_t> &value) {
     parser_.advance(Symbol::sFixed);
     parser_.assertSize(n);
     expect(JsonParser::tkString);
@@ -335,9 +315,8 @@ void JsonDecoder<P>::decodeFixed(size_t n, vector<uint8_t>& value)
     }
 }
 
-template <typename P>
-void JsonDecoder<P>::skipFixed(size_t n)
-{
+template<typename P>
+void JsonDecoder<P>::skipFixed(size_t n) {
     parser_.advance(Symbol::sFixed);
     parser_.assertSize(n);
     expect(JsonParser::tkString);
@@ -347,27 +326,24 @@ void JsonDecoder<P>::skipFixed(size_t n)
     }
 }
 
-template <typename P>
-size_t JsonDecoder<P>::decodeEnum()
-{
+template<typename P>
+size_t JsonDecoder<P>::decodeEnum() {
     parser_.advance(Symbol::sEnum);
     expect(JsonParser::tkString);
     size_t result = parser_.indexForName(in_.stringValue());
     return result;
 }
 
-template <typename P>
-size_t JsonDecoder<P>::arrayStart()
-{
+template<typename P>
+size_t JsonDecoder<P>::arrayStart() {
     parser_.advance(Symbol::sArrayStart);
     parser_.pushRepeatCount(0);
     expect(JsonParser::tkArrayStart);
     return arrayNext();
 }
 
-template <typename P>
-size_t JsonDecoder<P>::arrayNext()
-{
+template<typename P>
+size_t JsonDecoder<P>::arrayNext() {
     parser_.processImplicitActions();
     if (in_.peek() == JsonParser::tkArrayEnd) {
         in_.advance();
@@ -380,38 +356,35 @@ size_t JsonDecoder<P>::arrayNext()
 }
 
 template<typename P>
-void JsonDecoder<P>::skipComposite()
-{
+void JsonDecoder<P>::skipComposite() {
     size_t level = 0;
-    for (; ;) {
+    for (;;) {
         switch (in_.advance()) {
-        case JsonParser::tkArrayStart:
-        case JsonParser::tkObjectStart:
-            ++level;
-            continue;
-        case JsonParser::tkArrayEnd:
-        case JsonParser::tkObjectEnd:
-            if (level == 0) {
-                return;
-            }
-            --level;
-            continue;
-        default:
-            continue;
+            case JsonParser::tkArrayStart:
+            case JsonParser::tkObjectStart:
+                ++level;
+                continue;
+            case JsonParser::tkArrayEnd:
+            case JsonParser::tkObjectEnd:
+                if (level == 0) {
+                    return;
+                }
+                --level;
+                continue;
+            default:
+                continue;
         }
     }
 }
 
 template<typename P>
-void JsonDecoder<P>::drain()
-{
+void JsonDecoder<P>::drain() {
     parser_.processImplicitActions();
     in_.drain();
 }
 
-template <typename P>
-size_t JsonDecoder<P>::skipArray()
-{
+template<typename P>
+size_t JsonDecoder<P>::skipArray() {
     parser_.advance(Symbol::sArrayStart);
     parser_.pop();
     parser_.advance(Symbol::sArrayEnd);
@@ -420,18 +393,16 @@ size_t JsonDecoder<P>::skipArray()
     return 0;
 }
 
-template <typename P>
-size_t JsonDecoder<P>::mapStart()
-{
+template<typename P>
+size_t JsonDecoder<P>::mapStart() {
     parser_.advance(Symbol::sMapStart);
     parser_.pushRepeatCount(0);
     expect(JsonParser::tkObjectStart);
     return mapNext();
 }
 
-template <typename P>
-size_t JsonDecoder<P>::mapNext()
-{
+template<typename P>
+size_t JsonDecoder<P>::mapNext() {
     parser_.processImplicitActions();
     if (in_.peek() == JsonParser::tkObjectEnd) {
         in_.advance();
@@ -443,9 +414,8 @@ size_t JsonDecoder<P>::mapNext()
     return 1;
 }
 
-template <typename P>
-size_t JsonDecoder<P>::skipMap()
-{
+template<typename P>
+size_t JsonDecoder<P>::skipMap() {
     parser_.advance(Symbol::sMapStart);
     parser_.pop();
     parser_.advance(Symbol::sMapEnd);
@@ -454,9 +424,8 @@ size_t JsonDecoder<P>::skipMap()
     return 0;
 }
 
-template <typename P>
-size_t JsonDecoder<P>::decodeUnionIndex()
-{
+template<typename P>
+size_t JsonDecoder<P>::decodeUnionIndex() {
     parser_.advance(Symbol::sUnion);
 
     size_t result;
@@ -473,34 +442,35 @@ size_t JsonDecoder<P>::decodeUnionIndex()
 
 template<typename F = JsonNullFormatter>
 class JsonHandler {
-    JsonGenerator<F>& generator_;
+    JsonGenerator<F> &generator_;
+
 public:
-    JsonHandler(JsonGenerator<F>& g) : generator_(g) { }
-    size_t handle(const Symbol& s) {
+    JsonHandler(JsonGenerator<F> &g) : generator_(g) {}
+    size_t handle(const Symbol &s) {
         switch (s.kind()) {
-        case Symbol::sRecordStart:
-            generator_.objectStart();
-            break;
-        case Symbol::sRecordEnd:
-            generator_.objectEnd();
-            break;
-        case Symbol::sField:
-            generator_.encodeString(s.extra<string>());
-            break;
-        default:
-            break;
+            case Symbol::sRecordStart:
+                generator_.objectStart();
+                break;
+            case Symbol::sRecordEnd:
+                generator_.objectEnd();
+                break;
+            case Symbol::sField:
+                generator_.encodeString(s.extra<string>());
+                break;
+            default:
+                break;
         }
         return 0;
     }
 };
 
-template <typename P, typename F = JsonNullFormatter>
+template<typename P, typename F = JsonNullFormatter>
 class JsonEncoder : public Encoder {
     JsonGenerator<F> out_;
     JsonHandler<F> handler_;
     P parser_;
 
-    void init(OutputStream& os);
+    void init(OutputStream &os);
     void flush();
     int64_t byteCount() const;
     void encodeNull();
@@ -509,7 +479,7 @@ class JsonEncoder : public Encoder {
     void encodeLong(int64_t l);
     void encodeFloat(float f);
     void encodeDouble(double d);
-    void encodeString(const std::string& s);
+    void encodeString(const std::string &s);
     void encodeBytes(const uint8_t *bytes, size_t len);
     void encodeFixed(const uint8_t *bytes, size_t len);
     void encodeEnum(size_t e);
@@ -520,62 +490,54 @@ class JsonEncoder : public Encoder {
     void setItemCount(size_t count);
     void startItem();
     void encodeUnionIndex(size_t e);
+
 public:
-    JsonEncoder(const ValidSchema& schema) :
-        handler_(out_),
-        parser_(JsonGrammarGenerator().generate(schema), NULL, handler_) { }
+    JsonEncoder(const ValidSchema &schema) : handler_(out_),
+                                             parser_(JsonGrammarGenerator().generate(schema), NULL, handler_) {}
 };
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::init(OutputStream& os)
-{
+void JsonEncoder<P, F>::init(OutputStream &os) {
     out_.init(os);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::flush()
-{
+void JsonEncoder<P, F>::flush() {
     parser_.processImplicitActions();
     out_.flush();
 }
 
 template<typename P, typename F>
-int64_t JsonEncoder<P, F>::byteCount() const
-{
+int64_t JsonEncoder<P, F>::byteCount() const {
     return out_.byteCount();
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeNull()
-{
+void JsonEncoder<P, F>::encodeNull() {
     parser_.advance(Symbol::sNull);
     out_.encodeNull();
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeBool(bool b)
-{
+void JsonEncoder<P, F>::encodeBool(bool b) {
     parser_.advance(Symbol::sBool);
     out_.encodeBool(b);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeInt(int32_t i)
-{
+void JsonEncoder<P, F>::encodeInt(int32_t i) {
     parser_.advance(Symbol::sInt);
     out_.encodeNumber(i);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeLong(int64_t l)
-{
+void JsonEncoder<P, F>::encodeLong(int64_t l) {
     parser_.advance(Symbol::sLong);
     out_.encodeNumber(l);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeFloat(float f)
-{
+void JsonEncoder<P, F>::encodeFloat(float f) {
     parser_.advance(Symbol::sFloat);
     if (f == std::numeric_limits<float>::infinity()) {
         out_.encodeString("Infinity");
@@ -589,8 +551,7 @@ void JsonEncoder<P, F>::encodeFloat(float f)
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeDouble(double d)
-{
+void JsonEncoder<P, F>::encodeDouble(double d) {
     parser_.advance(Symbol::sDouble);
     if (d == std::numeric_limits<double>::infinity()) {
         out_.encodeString("Infinity");
@@ -604,76 +565,66 @@ void JsonEncoder<P, F>::encodeDouble(double d)
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeString(const std::string& s)
-{
+void JsonEncoder<P, F>::encodeString(const std::string &s) {
     parser_.advance(Symbol::sString);
     out_.encodeString(s);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeBytes(const uint8_t *bytes, size_t len)
-{
+void JsonEncoder<P, F>::encodeBytes(const uint8_t *bytes, size_t len) {
     parser_.advance(Symbol::sBytes);
     out_.encodeBinary(bytes, len);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeFixed(const uint8_t *bytes, size_t len)
-{
+void JsonEncoder<P, F>::encodeFixed(const uint8_t *bytes, size_t len) {
     parser_.advance(Symbol::sFixed);
     parser_.assertSize(len);
     out_.encodeBinary(bytes, len);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeEnum(size_t e)
-{
+void JsonEncoder<P, F>::encodeEnum(size_t e) {
     parser_.advance(Symbol::sEnum);
-    const string& s = parser_.nameForIndex(e);
+    const string &s = parser_.nameForIndex(e);
     out_.encodeString(s);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::arrayStart()
-{
+void JsonEncoder<P, F>::arrayStart() {
     parser_.advance(Symbol::sArrayStart);
     parser_.pushRepeatCount(0);
     out_.arrayStart();
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::arrayEnd()
-{
+void JsonEncoder<P, F>::arrayEnd() {
     parser_.popRepeater();
     parser_.advance(Symbol::sArrayEnd);
     out_.arrayEnd();
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::mapStart()
-{
+void JsonEncoder<P, F>::mapStart() {
     parser_.advance(Symbol::sMapStart);
     parser_.pushRepeatCount(0);
     out_.objectStart();
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::mapEnd()
-{
+void JsonEncoder<P, F>::mapEnd() {
     parser_.popRepeater();
     parser_.advance(Symbol::sMapEnd);
     out_.objectEnd();
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::setItemCount(size_t count)
-{
+void JsonEncoder<P, F>::setItemCount(size_t count) {
     parser_.nextRepeatCount(count);
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::startItem()
-{
+void JsonEncoder<P, F>::startItem() {
     parser_.processImplicitActions();
     if (parser_.top() != Symbol::sRepeater) {
         throw Exception("startItem at not an item boundary");
@@ -681,8 +632,7 @@ void JsonEncoder<P, F>::startItem()
 }
 
 template<typename P, typename F>
-void JsonEncoder<P, F>::encodeUnionIndex(size_t e)
-{
+void JsonEncoder<P, F>::encodeUnionIndex(size_t e) {
     parser_.advance(Symbol::sUnion);
 
     const std::string name = parser_.nameForIndex(e);
@@ -694,25 +644,21 @@ void JsonEncoder<P, F>::encodeUnionIndex(size_t e)
     parser_.selectBranch(e);
 }
 
-}   // namespace parsing
+} // namespace parsing
 
-DecoderPtr jsonDecoder(const ValidSchema& s)
-{
+DecoderPtr jsonDecoder(const ValidSchema &s) {
     return std::make_shared<parsing::JsonDecoder<
-        parsing::SimpleParser<parsing::JsonDecoderHandler> > >(s);
+        parsing::SimpleParser<parsing::JsonDecoderHandler>>>(s);
 }
 
-EncoderPtr jsonEncoder(const ValidSchema& schema)
-{
+EncoderPtr jsonEncoder(const ValidSchema &schema) {
     return std::make_shared<parsing::JsonEncoder<
-        parsing::SimpleParser<parsing::JsonHandler<avro::json::JsonNullFormatter> >, avro::json::JsonNullFormatter> >(schema);
+        parsing::SimpleParser<parsing::JsonHandler<avro::json::JsonNullFormatter>>, avro::json::JsonNullFormatter>>(schema);
 }
 
-EncoderPtr jsonPrettyEncoder(const ValidSchema& schema)
-{
+EncoderPtr jsonPrettyEncoder(const ValidSchema &schema) {
     return std::make_shared<parsing::JsonEncoder<
-        parsing::SimpleParser<parsing::JsonHandler<avro::json::JsonPrettyFormatter> >, avro::json::JsonPrettyFormatter> >(schema);
+        parsing::SimpleParser<parsing::JsonHandler<avro::json::JsonPrettyFormatter>>, avro::json::JsonPrettyFormatter>>(schema);
 }
 
-}   // namespace avro
-
+} // namespace avro
diff --git a/lang/c++/impl/parsing/ResolvingDecoder.cc b/lang/c++/impl/parsing/ResolvingDecoder.cc
index f6dbaca..5c8b680 100644
--- a/lang/c++/impl/parsing/ResolvingDecoder.cc
+++ b/lang/c++/impl/parsing/ResolvingDecoder.cc
@@ -18,22 +18,22 @@
 
 #define __STDC_LIMIT_MACROS
 
-#include <string>
-#include <stack>
-#include <map>
 #include <algorithm>
-#include <memory>
 #include <ctype.h>
+#include <map>
+#include <memory>
+#include <stack>
+#include <string>
 
-#include "ValidatingCodec.hh"
-#include "Symbol.hh"
-#include "Types.hh"
-#include "ValidSchema.hh"
 #include "Decoder.hh"
 #include "Encoder.hh"
-#include "NodeImpl.hh"
 #include "Generic.hh"
+#include "NodeImpl.hh"
 #include "Stream.hh"
+#include "Symbol.hh"
+#include "Types.hh"
+#include "ValidSchema.hh"
+#include "ValidatingCodec.hh"
 
 namespace avro {
 
@@ -41,37 +41,37 @@ using std::make_shared;
 
 namespace parsing {
 
+using std::make_shared;
 using std::shared_ptr;
 using std::static_pointer_cast;
-using std::make_shared;
 
-using std::unique_ptr;
+using std::find_if;
+using std::istringstream;
+using std::make_pair;
 using std::map;
+using std::ostringstream;
 using std::pair;
-using std::vector;
-using std::string;
 using std::reverse;
-using std::ostringstream;
-using std::istringstream;
 using std::stack;
-using std::find_if;
-using std::make_pair;
+using std::string;
+using std::unique_ptr;
+using std::vector;
 
 typedef pair<NodePtr, NodePtr> NodePair;
 
 class ResolvingGrammarGenerator : public ValidatingGrammarGenerator {
-    ProductionPtr doGenerate2(const NodePtr& writer,
-        const NodePtr& reader, map<NodePair, ProductionPtr> &m,
-        map<NodePtr, ProductionPtr> &m2);
-    ProductionPtr resolveRecords(const NodePtr& writer,
-        const NodePtr& reader, map<NodePair, ProductionPtr> &m,
-        map<NodePtr, ProductionPtr> &m2);
-    ProductionPtr resolveUnion(const NodePtr& writer,
-        const NodePtr& reader, map<NodePair, ProductionPtr> &m,
-        map<NodePtr, ProductionPtr> &m2);
-
-    static vector<pair<string, size_t> > fields(const NodePtr& n) {
-        vector<pair<string, size_t> > result;
+    ProductionPtr doGenerate2(const NodePtr &writer,
+                              const NodePtr &reader, map<NodePair, ProductionPtr> &m,
+                              map<NodePtr, ProductionPtr> &m2);
+    ProductionPtr resolveRecords(const NodePtr &writer,
+                                 const NodePtr &reader, map<NodePair, ProductionPtr> &m,
+                                 map<NodePtr, ProductionPtr> &m2);
+    ProductionPtr resolveUnion(const NodePtr &writer,
+                               const NodePtr &reader, map<NodePair, ProductionPtr> &m,
+                               map<NodePtr, ProductionPtr> &m2);
+
+    static vector<pair<string, size_t>> fields(const NodePtr &n) {
+        vector<pair<string, size_t>> result;
         size_t c = n->names();
         for (size_t i = 0; i < c; ++i) {
             result.push_back(make_pair(n->nameAt(i), i));
@@ -79,22 +79,22 @@ class ResolvingGrammarGenerator : public ValidatingGrammarGenerator {
         return result;
     }
 
-    static int bestBranch(const NodePtr& writer, const NodePtr& reader);
+    static int bestBranch(const NodePtr &writer, const NodePtr &reader);
 
-    ProductionPtr getWriterProduction(const NodePtr& n,
-        map<NodePtr, ProductionPtr>& m2);
+    ProductionPtr getWriterProduction(const NodePtr &n,
+                                      map<NodePtr, ProductionPtr> &m2);
 
 public:
     Symbol generate(
-        const ValidSchema& writer, const ValidSchema& reader);
+        const ValidSchema &writer, const ValidSchema &reader);
 };
 
 Symbol ResolvingGrammarGenerator::generate(
-    const ValidSchema& writer, const ValidSchema& reader) {
+    const ValidSchema &writer, const ValidSchema &reader) {
     map<NodePtr, ProductionPtr> m2;
 
-    const NodePtr& rr = reader.root();
-    const NodePtr& rw = writer.root();
+    const NodePtr &rr = reader.root();
+    const NodePtr &rw = writer.root();
     ProductionPtr backup = ValidatingGrammarGenerator::doGenerate(rw, m2);
     fixup(backup, m2);
 
@@ -104,9 +104,8 @@ Symbol ResolvingGrammarGenerator::generate(
     return Symbol::rootSymbol(main, backup);
 }
 
-int ResolvingGrammarGenerator::bestBranch(const NodePtr& writer,
-    const NodePtr& reader)
-{
+int ResolvingGrammarGenerator::bestBranch(const NodePtr &writer,
+                                          const NodePtr &reader) {
     Type t = writer->type();
 
     const size_t c = reader->leaves();
@@ -127,30 +126,29 @@ int ResolvingGrammarGenerator::bestBranch(const NodePtr& writer,
     }
 
     for (size_t j = 0; j < c; ++j) {
-        const NodePtr& r = reader->leafAt(j);
+        const NodePtr &r = reader->leafAt(j);
         Type rt = r->type();
         switch (t) {
-        case AVRO_INT:
-            if (rt == AVRO_LONG || rt == AVRO_DOUBLE || rt == AVRO_FLOAT) {
-                return j;
-            }
-            break;
-        case AVRO_LONG:
-        case AVRO_FLOAT:
-            if (rt == AVRO_DOUBLE) {
-                return j;
-            }
-            break;
-        default:
-            break;
+            case AVRO_INT:
+                if (rt == AVRO_LONG || rt == AVRO_DOUBLE || rt == AVRO_FLOAT) {
+                    return j;
+                }
+                break;
+            case AVRO_LONG:
+            case AVRO_FLOAT:
+                if (rt == AVRO_DOUBLE) {
+                    return j;
+                }
+                break;
+            default:
+                break;
         }
     }
     return -1;
 }
 
-static shared_ptr<vector<uint8_t> > getAvroBinary(
-    const GenericDatum& defaultValue)
-{
+static shared_ptr<vector<uint8_t>> getAvroBinary(
+    const GenericDatum &defaultValue) {
     EncoderPtr e = binaryEncoder();
     unique_ptr<OutputStream> os = memoryOutputStream();
     e->init(*os);
@@ -160,20 +158,17 @@ static shared_ptr<vector<uint8_t> > getAvroBinary(
 }
 
 template<typename T1, typename T2>
-struct equalsFirst
-{
-    const T1& v_;
-    equalsFirst(const T1& v) : v_(v) { }
-    bool operator()(const pair<T1, T2>& p) {
+struct equalsFirst {
+    const T1 &v_;
+    equalsFirst(const T1 &v) : v_(v) {}
+    bool operator()(const pair<T1, T2> &p) {
         return p.first == v_;
     }
 };
 
 ProductionPtr ResolvingGrammarGenerator::getWriterProduction(
-    const NodePtr& n, map<NodePtr, ProductionPtr>& m2)
-{
-    const NodePtr& nn = (n->type() == AVRO_SYMBOLIC) ?
-        static_cast<const NodeSymbolic& >(*n).getNode() : n;
+    const NodePtr &n, map<NodePtr, ProductionPtr> &m2) {
+    const NodePtr &nn = (n->type() == AVRO_SYMBOLIC) ? static_cast<const NodeSymbolic &>(*n).getNode() : n;
     map<NodePtr, ProductionPtr>::const_iterator it2 = m2.find(nn);
     if (it2 != m2.end()) {
         return it2->second;
@@ -185,14 +180,13 @@ ProductionPtr ResolvingGrammarGenerator::getWriterProduction(
 }
 
 ProductionPtr ResolvingGrammarGenerator::resolveRecords(
-    const NodePtr& writer, const NodePtr& reader,
-    map<NodePair, ProductionPtr>& m,
-    map<NodePtr, ProductionPtr>& m2)
-{
+    const NodePtr &writer, const NodePtr &reader,
+    map<NodePair, ProductionPtr> &m,
+    map<NodePtr, ProductionPtr> &m2) {
     ProductionPtr result = make_shared<Production>();
 
-    vector<pair<string, size_t> > wf = fields(writer);
-    vector<pair<string, size_t> > rf = fields(reader);
+    vector<pair<string, size_t>> wf = fields(writer);
+    vector<pair<string, size_t>> rf = fields(reader);
     vector<size_t> fieldOrder;
     fieldOrder.reserve(reader->names());
 
@@ -202,14 +196,14 @@ ProductionPtr ResolvingGrammarGenerator::resolveRecords(
      * If no matching field is found for reader, arrange to skip the writer
      * field.
      */
-    for (vector<pair<string, size_t> >::const_iterator it = wf.begin();
-        it != wf.end(); ++it) {
-        vector<pair<string, size_t> >::iterator it2 =
+    for (vector<pair<string, size_t>>::const_iterator it = wf.begin();
+         it != wf.end(); ++it) {
+        vector<pair<string, size_t>>::iterator it2 =
             find_if(rf.begin(), rf.end(),
-                equalsFirst<string, size_t>(it->first));
+                    equalsFirst<string, size_t>(it->first));
         if (it2 != rf.end()) {
             ProductionPtr p = doGenerate2(writer->leafAt(it->second),
-                reader->leafAt(it2->second), m, m2);
+                                          reader->leafAt(it2->second), m, m2);
             copy(p->rbegin(), p->rend(), back_inserter(*result));
             fieldOrder.push_back(it2->second);
             rf.erase(it2);
@@ -229,8 +223,8 @@ ProductionPtr ResolvingGrammarGenerator::resolveRecords(
      * Examine the reader fields left out, (i.e. those didn't have corresponding
      * writer field).
      */
-    for (vector<pair<string, size_t> >::const_iterator it = rf.begin();
-        it != rf.end(); ++it) {
+    for (vector<pair<string, size_t>>::const_iterator it = rf.begin();
+         it != rf.end(); ++it) {
 
         NodePtr s = reader->leafAt(it->second);
         fieldOrder.push_back(it->second);
@@ -238,13 +232,12 @@ ProductionPtr ResolvingGrammarGenerator::resolveRecords(
         if (s->type() == AVRO_SYMBOLIC) {
             s = resolveSymbol(s);
         }
-        shared_ptr<vector<uint8_t> > defaultBinary =
+        shared_ptr<vector<uint8_t>> defaultBinary =
             getAvroBinary(reader->defaultValueAt(it->second));
         result->push_back(Symbol::defaultStartAction(defaultBinary));
-        map<NodePair, shared_ptr<Production> >::const_iterator it2 =
+        map<NodePair, shared_ptr<Production>>::const_iterator it2 =
             m.find(NodePair(s, s));
-        ProductionPtr p = (it2 == m.end()) ?
-            doGenerate2(s, s, m, m2) : it2->second;
+        ProductionPtr p = (it2 == m.end()) ? doGenerate2(s, s, m, m2) : it2->second;
         copy(p->rbegin(), p->rend(), back_inserter(*result));
         result->push_back(Symbol::defaultEndAction());
     }
@@ -253,14 +246,12 @@ ProductionPtr ResolvingGrammarGenerator::resolveRecords(
     result->push_back(Symbol::recordAction());
 
     return result;
-
 }
 
 ProductionPtr ResolvingGrammarGenerator::resolveUnion(
-    const NodePtr& writer, const NodePtr& reader,
-    map<NodePair, ProductionPtr>& m,
-    map<NodePtr, ProductionPtr>& m2)
-{
+    const NodePtr &writer, const NodePtr &reader,
+    map<NodePair, ProductionPtr> &m,
+    map<NodePtr, ProductionPtr> &m2) {
     vector<ProductionPtr> v;
     size_t c = writer->leaves();
     v.reserve(c);
@@ -275,10 +266,9 @@ ProductionPtr ResolvingGrammarGenerator::resolveUnion(
 }
 
 ProductionPtr ResolvingGrammarGenerator::doGenerate2(
-    const NodePtr& w, const NodePtr& r,
+    const NodePtr &w, const NodePtr &r,
     map<NodePair, ProductionPtr> &m,
-    map<NodePtr, ProductionPtr> &m2)
-{
+    map<NodePtr, ProductionPtr> &m2) {
     const NodePtr writer = w->type() == AVRO_SYMBOLIC ? resolveSymbol(w) : w;
     const NodePtr reader = r->type() == AVRO_SYMBOLIC ? resolveSymbol(r) : r;
     Type writerType = writer->type();
@@ -286,59 +276,55 @@ ProductionPtr ResolvingGrammarGenerator::doGenerate2(
 
     if (writerType == readerType) {
         switch (writerType) {
-        case AVRO_NULL:
-            return make_shared<Production>(1, Symbol::nullSymbol());
-        case AVRO_BOOL:
-            return make_shared<Production>(1, Symbol::boolSymbol());
-        case AVRO_INT:
-            return make_shared<Production>(1, Symbol::intSymbol());
-        case AVRO_LONG:
-            return make_shared<Production>(1, Symbol::longSymbol());
-        case AVRO_FLOAT:
-            return make_shared<Production>(1, Symbol::floatSymbol());
-        case AVRO_DOUBLE:
-            return make_shared<Production>(1, Symbol::doubleSymbol());
-        case AVRO_STRING:
-            return make_shared<Production>(1, Symbol::stringSymbol());
-        case AVRO_BYTES:
-            return make_shared<Production>(1, Symbol::bytesSymbol());
-        case AVRO_FIXED:
-            if (writer->name() == reader->name() &&
-                writer->fixedSize() == reader->fixedSize()) {
-                ProductionPtr result = make_shared<Production>();
-                result->push_back(Symbol::sizeCheckSymbol(reader->fixedSize()));
-                result->push_back(Symbol::fixedSymbol());
-                m[make_pair(writer, reader)] = result;
-                return result;
-            }
-            break;
-        case AVRO_RECORD:
-            if (writer->name() == reader->name()) {
-                const pair<NodePtr, NodePtr> key(writer, reader);
-                map<NodePair, ProductionPtr>::const_iterator kp = m.find(key);
-                if (kp != m.end()) {
-                    return (kp->second) ? kp->second :
-                        make_shared<Production>(1, Symbol::placeholder(key));
+            case AVRO_NULL:
+                return make_shared<Production>(1, Symbol::nullSymbol());
+            case AVRO_BOOL:
+                return make_shared<Production>(1, Symbol::boolSymbol());
+            case AVRO_INT:
+                return make_shared<Production>(1, Symbol::intSymbol());
+            case AVRO_LONG:
+                return make_shared<Production>(1, Symbol::longSymbol());
+            case AVRO_FLOAT:
+                return make_shared<Production>(1, Symbol::floatSymbol());
+            case AVRO_DOUBLE:
+                return make_shared<Production>(1, Symbol::doubleSymbol());
+            case AVRO_STRING:
+                return make_shared<Production>(1, Symbol::stringSymbol());
+            case AVRO_BYTES:
+                return make_shared<Production>(1, Symbol::bytesSymbol());
+            case AVRO_FIXED:
+                if (writer->name() == reader->name() && writer->fixedSize() == reader->fixedSize()) {
+                    ProductionPtr result = make_shared<Production>();
+                    result->push_back(Symbol::sizeCheckSymbol(reader->fixedSize()));
+                    result->push_back(Symbol::fixedSymbol());
+                    m[make_pair(writer, reader)] = result;
+                    return result;
                 }
-                m[key] = ProductionPtr();
-                ProductionPtr result = resolveRecords(writer, reader, m, m2);
-                m[key] = result;
-		return make_shared<Production>(1, Symbol::indirect(result));
-            }
-            break;
-
-        case AVRO_ENUM:
-            if (writer->name() == reader->name()) {
-                ProductionPtr result = make_shared<Production>();
-                result->push_back(Symbol::enumAdjustSymbol(writer, reader));
-                result->push_back(Symbol::enumSymbol());
-                m[make_pair(writer, reader)] = result;
-                return result;
-            }
-            break;
+                break;
+            case AVRO_RECORD:
+                if (writer->name() == reader->name()) {
+                    const pair<NodePtr, NodePtr> key(writer, reader);
+                    map<NodePair, ProductionPtr>::const_iterator kp = m.find(key);
+                    if (kp != m.end()) {
+                        return (kp->second) ? kp->second : make_shared<Production>(1, Symbol::placeholder(key));
+                    }
+                    m[key] = ProductionPtr();
+                    ProductionPtr result = resolveRecords(writer, reader, m, m2);
+                    m[key] = result;
+                    return make_shared<Production>(1, Symbol::indirect(result));
+                }
+                break;
 
-        case AVRO_ARRAY:
-            {
+            case AVRO_ENUM:
+                if (writer->name() == reader->name()) {
+                    ProductionPtr result = make_shared<Production>();
+                    result->push_back(Symbol::enumAdjustSymbol(writer, reader));
+                    result->push_back(Symbol::enumSymbol());
+                    m[make_pair(writer, reader)] = result;
+                    return result;
+                }
+                break;
+            case AVRO_ARRAY: {
                 ProductionPtr p = getWriterProduction(writer->leafAt(0), m2);
                 ProductionPtr p2 = doGenerate2(writer->leafAt(0), reader->leafAt(0), m, m2);
                 ProductionPtr result = make_shared<Production>();
@@ -347,10 +333,9 @@ ProductionPtr ResolvingGrammarGenerator::doGenerate2(
                 result->push_back(Symbol::arrayStartSymbol());
                 return result;
             }
-        case AVRO_MAP:
-            {
+            case AVRO_MAP: {
                 ProductionPtr pp =
-                    doGenerate2(writer->leafAt(1),reader->leafAt(1), m, m2);
+                    doGenerate2(writer->leafAt(1), reader->leafAt(1), m, m2);
                 ProductionPtr v(new Production(*pp));
                 v->push_back(Symbol::stringSymbol());
 
@@ -365,10 +350,9 @@ ProductionPtr ResolvingGrammarGenerator::doGenerate2(
                 result->push_back(Symbol::mapStartSymbol());
                 return result;
             }
-        case AVRO_UNION:
-            return resolveUnion(writer, reader, m, m2);
-        case AVRO_SYMBOLIC:
-            {
+            case AVRO_UNION:
+                return resolveUnion(writer, reader, m, m2);
+            case AVRO_SYMBOLIC: {
                 shared_ptr<NodeSymbolic> w =
                     static_pointer_cast<NodeSymbolic>(writer);
                 shared_ptr<NodeSymbolic> r =
@@ -382,38 +366,34 @@ ProductionPtr ResolvingGrammarGenerator::doGenerate2(
                     return make_shared<Production>(1, Symbol::placeholder(p));
                 }
             }
-        default:
-            throw Exception("Unknown node type");
+            default:
+                throw Exception("Unknown node type");
         }
... 9277 lines suppressed ...