Skip to content

Instantly share code, notes, and snippets.

@jpark9013
Last active March 6, 2022 18:56
Show Gist options
  • Save jpark9013/24d4989eae44d248e9e177b5e255b4c9 to your computer and use it in GitHub Desktop.
Save jpark9013/24d4989eae44d248e9e177b5e255b4c9 to your computer and use it in GitHub Desktop.
sample output from cpp-data-classes program
class DataTable {
std::int64_t rows;
std::vector<std::string> names;
std::vector<std::pair<double, double>> locations;
std::string table_name;
public:
DataTable() {
}
DataTable(const std::int64_t &_rows, const std::vector<std::string> &_names, const std::vector<std::pair<double, double>> &_locations, const std::string &_table_name) : rows(_rows), names(_names), locations(_locations), table_name(_table_name) {
}
friend bool operator == (const DataTable &a, const DataTable &b) {
return a.rows == b.rows && a.names == b.names && a.locations == b.locations && a.table_name == b.table_name;
}
friend bool operator != (const DataTable &a, const DataTable &b) {
return !(a == b);
}
friend bool operator < (const DataTable &a, const DataTable &b) {
return a.rows < b.rows && a.names < b.names && a.locations < b.locations && a.table_name < b.table_name;
}
friend bool operator <= (const DataTable &a, const DataTable &b) {
return !(a > b);
}
friend bool operator > (const DataTable &a, const DataTable &b) {
return a.rows > b.rows && a.names > b.names && a.locations > b.locations && a.table_name > b.table_name;
}
friend bool operator >= (const DataTable &a, const DataTable &b) {
return !(a < b);
}
std::int64_t get_rows() {
return rows;
}
void set_rows(const std::int64_t &x) {
rows = x;
}
std::vector<std::string> get_names() {
return names;
}
void set_names(const std::vector<std::string> &x) {
names = x;
}
std::vector<std::pair<double, double>> get_locations() {
return locations;
}
void set_locations(const std::vector<std::pair<double, double>> &x) {
locations = x;
}
std::string get_table_name() {
return table_name;
}
void set_table_name(const std::string &x) {
table_name = x;
}
};
std::string to_string(const DataTable &x) {
return to_string(rows) + " " + to_string(names) + " " + to_string(locations) + " " + to_string(table_name);
}
template<typename U>
U& operator << (U& out, const DataTable &x) {
return out << ' ' << rows << ' ' << names << ' ' << locations << ' ' << table_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment