BioDynaMo  v1.03.58-27764645
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 <iostream>
17 namespace bdm {
18 
19 std::vector<std::string> Split(const std::string& s,
20  const std::string& delimiter) {
21  std::vector<std::string> result;
22  uint64_t pos = 0;
23  uint64_t last = 0;
24 
25  while ((pos = s.find(delimiter, last)) != std::string::npos) {
26  result.push_back(s.substr(last, pos - last));
27  last = pos + delimiter.length();
28  }
29  result.push_back(s.substr(last));
30  return result;
31 }
32 
33 } // 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:19