diff options
| author | Thomas Schmucker <ts@its1.de> | 2020-10-04 10:19:52 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2020-10-04 10:19:52 +0200 |
| commit | e9c5ab91e36e36e4d97b7310b89638f33b1e268a (patch) | |
| tree | 5491fbbde6547650c650b7d86ae3b57423bae3b9 /src/srcut.cpp | |
| parent | 94f7f1f40dd1ed326af7eb0baebf93f800a52c81 (diff) | |
| download | scissor-e9c5ab91e36e36e4d97b7310b89638f33b1e268a.tar.gz scissor-e9c5ab91e36e36e4d97b7310b89638f33b1e268a.tar.bz2 scissor-e9c5ab91e36e36e4d97b7310b89638f33b1e268a.zip | |
benutze die Argumente der Kommandozeile als Schlüssel...
Diffstat (limited to 'src/srcut.cpp')
| -rw-r--r-- | src/srcut.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/srcut.cpp b/src/srcut.cpp index 6df435b..0e5654a 100644 --- a/src/srcut.cpp +++ b/src/srcut.cpp | |||
| @@ -83,26 +83,31 @@ operator>>(istream& in, map<string, vector<string>>& container) | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | ostream& | 85 | ostream& |
| 86 | operator<<(ostream& os, const map<string, vector<string>>& container) | 86 | print(ostream& os, const string& key, const map<string, vector<string>>& container) |
| 87 | { | 87 | { |
| 88 | for ( const auto& chunk: container ) { | 88 | const auto it = container.find(key); |
| 89 | os << "CHUNK: " << chunk.first << '\n'; | 89 | if ( it != container.end() ) { |
| 90 | auto line = begin(chunk.second); | 90 | auto line = begin(it->second); |
| 91 | while ( line != end(chunk.second) ) { | 91 | while ( line != end(it->second) ) { |
| 92 | os << *line << '\n'; | 92 | os << *line << '\n'; |
| 93 | 93 | ||
| 94 | ++line; | 94 | ++line; |
| 95 | } | 95 | } |
| 96 | os << "-------\n\n"; | 96 | } |
| 97 | else { | ||
| 98 | os << "ERROR: " << key << " not found!" << endl; | ||
| 97 | } | 99 | } |
| 98 | return os; | 100 | return os; |
| 99 | } | 101 | } |
| 100 | 102 | ||
| 101 | int | 103 | int |
| 102 | main(void) | 104 | main(int argc, char* argv[]) |
| 103 | { | 105 | { |
| 104 | map<string, vector<string>> container; | 106 | map<string, vector<string>> container; |
| 105 | 107 | ||
| 106 | cin >> container; | 108 | cin >> container; |
| 107 | cout << container; | 109 | |
| 110 | for ( int i = 1; i < argc; ++i ) { | ||
| 111 | print(cout, argv[i], container); | ||
| 112 | } | ||
| 108 | } | 113 | } |
