BioDynaMo  v1.05.120-25dc9790
string.cc
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #include "core/util/string.h"
16 #include <cstdint>
17 #include <iostream>
18 
19 namespace bdm {
20 
21 std::vector<std::string> Split(const std::string& s,
22  const std::string& delimiter) {
23  std::vector<std::string> result;
24  uint64_t pos = 0;
25  uint64_t last = 0;
26 
27  while ((pos = s.find(delimiter, last)) != std::string::npos) {
28  result.push_back(s.substr(last, pos - last));
29  last = pos + delimiter.length();
30  }
31  result.push_back(s.substr(last));
32  return result;
33 }
34 
35 } // namespace bdm
bdm
Definition: agent.cc:39
string.h
bdm::Split
std::vector< std::string > Split(const std::string &s, const std::string &delimiter)
Definition: string.cc:21