Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/libbash:master commit in: test/
Date: Sun, 03 Apr 2011 10:16:20
Message-Id: cc316ba6127e6dd527205e352ddf9e97d00be21b.betelgeuse@gentoo
1 commit: cc316ba6127e6dd527205e352ddf9e97d00be21b
2 Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
3 AuthorDate: Sat Apr 2 21:00:19 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 2 21:00:19 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=cc316ba6
7
8 Variable printer output using Karma
9
10 ---
11 test/variable_printer.cpp | 17 ++++++++---------
12 1 files changed, 8 insertions(+), 9 deletions(-)
13
14 diff --git a/test/variable_printer.cpp b/test/variable_printer.cpp
15 index b519d3f..cb839f2 100644
16 --- a/test/variable_printer.cpp
17 +++ b/test/variable_printer.cpp
18 @@ -26,28 +26,27 @@
19 #include <iostream>
20 #include <map>
21
22 -#include <boost/range/algorithm/for_each.hpp>
23 #include <gtest/gtest.h>
24 +#include <boost/spirit/include/karma.hpp>
25 +#include <boost/fusion/include/std_pair.hpp>
26
27 #include "libbash.h"
28
29 -using namespace std;
30 -
31 int main(int argc, char** argv)
32 {
33 if(argc != 2)
34 {
35 - cerr<<"Please provide your script as an argument"<<endl;
36 + std::cerr<<"Please provide your script as an argument"<<std::endl;
37 exit(EXIT_FAILURE);
38 }
39
40 - unordered_map<string, string> variables;
41 + std::unordered_map<std::string, std::string> variables;
42 libbash::interpret(argv[1], variables);
43
44 - std::map<string, string> sorted(variables.begin(), variables.end());
45 - boost::for_each(sorted, [&](const std::pair<string,string>& pair){
46 - cout << pair.first << '=' << pair.second << endl;
47 - });
48 + std::map<std::string, std::string> sorted(variables.begin(), variables.end());
49 +
50 + using namespace boost::spirit::karma;
51 + std::cout << format((string << '=' << string) % eol, sorted) << std::endl;
52
53 return 0;
54 }