Skip to content

Commit

Permalink
add << and >> operator for SM command line parsing.
Browse files Browse the repository at this point in the history
cxxopts use >> to parse opts.

Signed-off-by: Xiaoxi Chen <[email protected]>
  • Loading branch information
xiaoxichen committed Apr 19, 2024
1 parent 8436d39 commit 4c40fac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomeObjectConan(ConanFile):
name = "homeobject"
version = "1.1.1"
version = "2.0.1"
homepage = "https://github.com/eBay/HomeObject"
description = "Blob Store built on HomeReplication"
topics = ("ebay")
Expand Down
28 changes: 28 additions & 0 deletions src/include/homeobject/homeobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,34 @@ ENUM(DevType, uint8_t, AUTO_DETECT = 1, HDD, NVME, UNSUPPORTED);
struct device_info_t {
explicit device_info_t(std::string name, DevType dtype = DevType::AUTO_DETECT) : path{std::filesystem::canonical(name)}, type{dtype} {}
bool operator ==(device_info_t const& rhs) const { return path == rhs.path && type == rhs.type; }
friend istream &operator>>( istream &input, device_info_t &di ) {
string t_input;
input >> di.path >> t_input;
if (t_input == "HDD") {
di.type = DevType::HDD;
} else if (t_input == "NVME") {
di.type = t_input::NVME;
} else {
di.type = DevType::AUTO_DETECT;
}
return input;
}
ostream& operator<<(ostream& os, const device_info_t& di)
{
os << "Device: {Path: " << di.path << ", Type: ";
switch (di.type) {
case DevType::HDD:
os << "HDD";
break;
case DevType::NVME:
os << "NVME";
break;
default:
os << "AUTO_DETECT";
break;
}
return os;
}
std::filesystem::path path;
DevType type;
};
Expand Down

0 comments on commit 4c40fac

Please sign in to comment.