osquery-1/osquery/core/text.cpp
2014-12-03 15:14:02 -08:00

22 lines
594 B
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#include <osquery/core.h>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/trim.hpp>
namespace osquery {
std::vector<std::string> split(const std::string& s, const std::string& delim) {
std::vector<std::string> elems;
boost::split(elems, s, boost::is_any_of(delim));
auto start = std::remove_if(
elems.begin(), elems.end(), [](const std::string& s) { return s == ""; });
elems.erase(start, elems.end());
for (auto& each : elems) {
boost::algorithm::trim(each);
}
return elems;
}
}