Skip to content

Commit

Permalink
Add a virtual class for BuildInfo entries.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 446445268
  • Loading branch information
buildbreaker2021 authored and copybara-github committed May 4, 2022
1 parent ff9cfe0 commit d32302f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tools/cpp/build_info_entry_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,53 @@
#ifndef BAZEL_TOOLS_CPP_BUILD_INFO_ENTRY_SET_H_
#define BAZEL_TOOLS_CPP_BUILD_INFO_ENTRY_SET_H_

#include <string>
#include <unordered_map>

namespace bazel {
namespace tools {
namespace cpp {

class BuildInfoEntrySet {
public:
BuildInfoEntrySet(
std::unordered_map<std::string, std::string>& info_file_map,
std::unordered_map<std::string, std::string>& version_file_map)
: info_file_map_(info_file_map), version_file_map_(version_file_map) {}
enum KeyType {
STRING = 0,
INTEGER = 1,
};
struct KeyDescription {
KeyDescription(KeyType key_type, const std::string& default_value,
const std::string& redacted_value)
: key_type(key_type),
default_value(default_value),
redacted_value(redacted_value) {}
const KeyType key_type;
const std::string default_value;
const std::string redacted_value;
bool operator==(const KeyDescription& kd) const {
return (key_type == kd.key_type && default_value == kd.default_value &&
redacted_value == kd.redacted_value);
}
};

virtual std::unordered_map<std::string, std::string>
GetVolatileFileEntries() = 0;
virtual std::unordered_map<std::string, std::string>
GetNonVolatileFileEntries() = 0;
virtual std::unordered_map<std::string, std::string>
GetRedactedFileEntries() = 0;
virtual ~BuildInfoEntrySet() = 0;

private:
std::unordered_map<std::string, std::string> info_file_map_;
std::unordered_map<std::string, std::string> version_file_map_;
};

} // namespace cpp
} // namespace tools
} // namespace bazel

#endif // BAZEL_TOOLS_CPP_BUILD_INFO_ENTRY_SET_H_

0 comments on commit d32302f

Please sign in to comment.