This is an automated email from the ASF dual-hosted git repository.
rskraba 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 90d0a49 Fix whitespace in CodeGen::generateEnumTraits to be
consistent with the rest of the generated code. (#1034)
90d0a49 is described below
commit 90d0a49d02416cac41962ac40d3662967febfcdb
Author: Allen Reese <[email protected]>
AuthorDate: Wed Jan 20 00:42:39 2021 -0800
Fix whitespace in CodeGen::generateEnumTraits to be consistent with the
rest of the generated code. (#1034)
avrogencpp has tabs in CodeGen::generateEnumTraits, which is inconsistent
with the rest of the generated code. (#1034)
This commit replaces all of the tabs in the CodeGen::generateEnumTraits
function with 4 spaces to match the formatting of the rest of the file as well
as the rest of the generated code
Co-authored-by: Allen Reese <[email protected]>
---
lang/c++/impl/avrogencpp.cc | 50 ++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/lang/c++/impl/avrogencpp.cc b/lang/c++/impl/avrogencpp.cc
index bdbca28..9154f60 100644
--- a/lang/c++/impl/avrogencpp.cc
+++ b/lang/c++/impl/avrogencpp.cc
@@ -524,31 +524,31 @@ string CodeGen::generateDeclaration(const NodePtr& n)
void CodeGen::generateEnumTraits(const NodePtr& n)
{
- string dname = decorate(n->name());
- string fn = fullname(dname);
- string last = n->nameAt(n->names() - 1);
-
- os_ << "template<> struct codec_traits<" << fn << "> {\n"
- << " static void encode(Encoder& e, " << fn << " v) {\n"
- << " if (v > " << fn << "::" << last << ")\n"
- << " {\n"
- << " std::ostringstream error;\n"
- << " 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"
- << " }\n"
- << " static void decode(Decoder& d, " << fn << "& v) {\n"
- << " size_t index = d.decodeEnum();\n"
- << " if (index > static_cast<size_t>(" << fn << "::"
<< last << "))\n"
- << " {\n"
- << " std::ostringstream error;\n"
- << " 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"
- << " }\n"
- << "};\n\n";
+ string dname = decorate(n->name());
+ string fn = fullname(dname);
+ string last = n->nameAt(n->names() - 1);
+
+ os_ << "template<> struct codec_traits<" << fn << "> {\n"
+ << " static void encode(Encoder& e, " << fn << " v) {\n"
+ << " if (v > " << fn << "::" << last << ")\n"
+ << " {\n"
+ << " std::ostringstream error;\n"
+ << " 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"
+ << " }\n"
+ << " static void decode(Decoder& d, " << fn << "& v) {\n"
+ << " size_t index = d.decodeEnum();\n"
+ << " if (index > static_cast<size_t>(" << fn << "::" << last <<
"))\n"
+ << " {\n"
+ << " std::ostringstream error;\n"
+ << " 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"
+ << " }\n"
+ << "};\n\n";
}
void CodeGen::generateRecordTraits(const NodePtr& n)