Vince's CSV Parser
col_names.hpp
1 #pragma once
2 #include <memory>
3 #include <unordered_map>
4 #include <string>
5 #include <vector>
6 
7 #include "common.hpp"
8 
9 namespace csv {
10  namespace internals {
11  struct ColNames;
12  using ColNamesPtr = std::shared_ptr<ColNames>;
13 
21  struct ColNames {
22  public:
23  ColNames() = default;
24  ColNames(const std::vector<std::string>& names) {
25  set_col_names(names);
26  }
27 
28  std::vector<std::string> get_col_names() const;
29  void set_col_names(const std::vector<std::string>&);
30  int index_of(csv::string_view) const;
31 
32  bool empty() const noexcept { return this->col_names.empty(); }
33  size_t size() const noexcept;
34 
35  private:
36  std::vector<std::string> col_names;
37  std::unordered_map<std::string, size_t> col_pos;
38  };
39  }
40 }
A standalone header file containing shared code.
The all encompassing namespace.
nonstd::string_view string_view
The string_view class used by this library.
Definition: common.hpp:75
A data structure for handling column name information.
Definition: col_names.hpp:21