summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2022-02-04 15:55:35 +0100
committerThomas Schmucker <ts@its1.de>2022-02-04 15:55:35 +0100
commitf954c1b8350118107d7f2e7ddab42e5ca7f6a052 (patch)
treea523c23501d82daac4fdffdf9601a15ee0f0e935
parentc206224a92def1a7c11770a1cecb851afcebd095 (diff)
parent54082bd65ec6abe1515c2a96d6879ed11dcc57f9 (diff)
downloadscissor-f954c1b8350118107d7f2e7ddab42e5ca7f6a052.tar.gz
scissor-f954c1b8350118107d7f2e7ddab42e5ca7f6a052.tar.bz2
scissor-f954c1b8350118107d7f2e7ddab42e5ca7f6a052.zip
Merge branch 'container-type'
-rw-r--r--src/srcut.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/srcut.cpp b/src/srcut.cpp
index 44131a0..119bfc3 100644
--- a/src/srcut.cpp
+++ b/src/srcut.cpp
@@ -8,8 +8,10 @@
8 8
9using namespace std; 9using namespace std;
10 10
11typedef map<string, vector<string>> container_type;
12
11istream& 13istream&
12operator>>(istream& in, map<string, vector<string>>& container) 14operator>>(istream& in, container_type& container)
13{ 15{
14 static constexpr auto begin_marker = "--8<--"; 16 static constexpr auto begin_marker = "--8<--";
15 static constexpr auto end_marker = "-->8--"; 17 static constexpr auto end_marker = "-->8--";
@@ -84,7 +86,7 @@ operator>>(istream& in, map<string, vector<string>>& container)
84} 86}
85 87
86ostream& 88ostream&
87print(ostream& os, const string& key, const map<string, vector<string>>& container) 89print(ostream& os, const string& key, const container_type& container)
88{ 90{
89 const auto it = container.find(key); 91 const auto it = container.find(key);
90 if ( it != container.end() ) { 92 if ( it != container.end() ) {
@@ -107,6 +109,7 @@ main(int argc, char* argv[])
107 int show_tags = 0; 109 int show_tags = 0;
108 int ch; 110 int ch;
109 111
112 opterr = 0;
110 while ( (ch = getopt(argc, argv, "t")) != -1 ) { 113 while ( (ch = getopt(argc, argv, "t")) != -1 ) {
111 switch ( ch ) { 114 switch ( ch ) {
112 case 't': 115 case 't':
@@ -120,7 +123,7 @@ main(int argc, char* argv[])
120 argc -= optind; 123 argc -= optind;
121 argv += optind; 124 argv += optind;
122 125
123 map<string, vector<string>> container; 126 container_type container;
124 127
125 cin >> container; 128 cin >> container;
126 129