hwse commented on code in PR #3088:
URL: https://github.com/apache/avro/pull/3088#discussion_r1724929886
##########
lang/c++/impl/avrogencpp.cc:
##########
@@ -915,3 +924,34 @@ int main(int argc, char **argv) {
return 1;
}
}
+
+UnionCodeTracker::UnionCodeTracker(const std::string &schemaFile) :
schemaFile_(schemaFile) {
+}
+
+std::optional<std::string> UnionCodeTracker::getExistingUnionName(const
std::vector<std::string> &unionBranches) const {
+ if (const auto it = unionBranchNameMapping_.find(unionBranches); it !=
unionBranchNameMapping_.end()) {
+ return it->second;
+ }
+ return std::nullopt;
+}
+
+std::string UnionCodeTracker::generateNewUnionName(const
std::vector<std::string> &unionBranches) {
+ string s = schemaFile_;
+ string::size_type n = s.find_last_of("/\\");
+ if (n != string::npos) {
+ s = s.substr(n);
+ }
+ makeCanonical(s, false);
+
+ std::string result = s + "_Union__" +
boost::lexical_cast<string>(unionNumber_++) + "__";
+ unionBranchNameMapping_.emplace(unionBranches, result);
+ return result;
+}
+
+bool UnionCodeTracker::unionTraitsAlreadyGenerated(const std::string
&unionClassName) const {
+ return generatedUnionTraits_.find(unionClassName) !=
generatedUnionTraits_.end();
+}
+
+void UnionCodeTracker::setTraitsGenerated(const std::string &unionName) {
Review Comment:
Good Point, i renamed it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]