tables::column::substr

1)

column<std::string_view>
column<std::string_view>::substr(const std::size_t pos = 0, const std::size_t count = std::string::npos) const;

2)

column<std::string_view>
substr(const column<std::size_t>& pos, const column<std::size_t>& count) const;

  1. Returns column with substring starts at position pos, of length count.

  2. Returns column with substring using positions and lenghts indicated in columns pos and count.

Complexity

Linear

Example

Code

#include <cpptables/table.hh>

using namespace tables;
using namespace std;

void column_substr()
{
  using sv_column = column<std::string_view>;
  using sz_column = column<std::size_t>;

  const sv_column xs({ 
    "abc def ghi",
    "foo bar xyz",
    "hello world"
  });


  cout << xs.substr(0,3) << "\n";
  cout << xs.substr( 
    sz_column({0, 4, 6}),
    sz_column({3, 3, 5})
  ) << "\n";
}

Output

abc foo hel
abc bar world