From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- boost/libs/program_options/src/split.cpp | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 boost/libs/program_options/src/split.cpp (limited to 'boost/libs/program_options/src/split.cpp') diff --git a/boost/libs/program_options/src/split.cpp b/boost/libs/program_options/src/split.cpp new file mode 100644 index 00000000..96da068b --- /dev/null +++ b/boost/libs/program_options/src/split.cpp @@ -0,0 +1,62 @@ +// Copyright Sascha Ochsenknecht 2009. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_PROGRAM_OPTIONS_SOURCE + +#include +#include + +#include +#include + +namespace boost { namespace program_options { namespace detail { + + template< class charT > + std::vector > + split_unix( + const std::basic_string& cmdline, + const std::basic_string& seperator, + const std::basic_string& quote, + const std::basic_string& escape) + { + typedef boost::tokenizer< boost::escaped_list_separator, + typename std::basic_string::const_iterator, + std::basic_string > tokenizerT; + + tokenizerT tok(cmdline.begin(), cmdline.end(), + boost::escaped_list_separator< charT >(escape, seperator, quote)); + + std::vector< std::basic_string > result; + for (typename tokenizerT::iterator cur_token(tok.begin()), end_token(tok.end()); cur_token != end_token; ++cur_token) { + if (!cur_token->empty()) + result.push_back(*cur_token); + } + return result; + } + +}}} // namespace + +namespace boost { namespace program_options { + + // Take a command line string and splits in into tokens, according + // to the given collection of seperators chars. + BOOST_PROGRAM_OPTIONS_DECL std::vector + split_unix(const std::string& cmdline, const std::string& seperator, + const std::string& quote, const std::string& escape) + { + return detail::split_unix< char >(cmdline, seperator, quote, escape); + } + +#ifndef BOOST_NO_STD_WSTRING + BOOST_PROGRAM_OPTIONS_DECL std::vector + split_unix(const std::wstring& cmdline, const std::wstring& seperator, + const std::wstring& quote, const std::wstring& escape) + { + return detail::split_unix< wchar_t >(cmdline, seperator, quote, escape); + } +#endif + +}} // namespace + -- cgit v1.2.3