From b63f29486dcb9b7ebd79ebb3c8c13ff41a39d9a9 Mon Sep 17 00:00:00 2001 From: manga_osyo Date: Tue, 1 May 2012 19:03:57 +0900 Subject: [PATCH] add Sprout.Weed example --- libs/weed/example/remove_space.cpp | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 libs/weed/example/remove_space.cpp diff --git a/libs/weed/example/remove_space.cpp b/libs/weed/example/remove_space.cpp new file mode 100644 index 00000000..23600f52 --- /dev/null +++ b/libs/weed/example/remove_space.cpp @@ -0,0 +1,36 @@ +// +// Sprout C++ Library +// +// Copyright (c) 2012 +// bolero-MURAKAMI : http://d.hatena.ne.jp/boleros/ +// osyo-manga : http://d.hatena.ne.jp/osyo-manga/ +// +// Readme: +// https://github.com/osyo-manga/cpp-half/blob/master/README +// +// License: +// Boost Software License - Version 1.0 +// +// +#include + + +int +main(){ + namespace w = sprout::weed; + + static constexpr auto max_string_size = 32; + static constexpr auto space = *w::omit[ w::space ]; + static constexpr auto remove_space = *w::lim(space >> w::char_); + + static constexpr auto source = sprout::to_string(" homu : mami= 10 "); + static constexpr auto result = w::parse( + sprout::begin(source), sprout::end(source), + remove_space + ); + + static_assert(result.success(), "fail remove_space parse"); + static_assert(result.attr() == "homu:mami=10", ""); + + return 0; +}