b809f589e5d6381e8e8af3251772f27f1ede5e79
[backups/.git] / main.cc
1 #include <iostream>
2 #include <iterator>
3 #include <string>
4 #include <vector>
5 #include <algorithm>
6
7 using namespace std;
8
9 vector<string> split( const string &line, char c, int limit = -1 ) {
10   string::size_type start = 0, end = 0;
11
12   vector<string> out;
13   while( 0 != limit-- && end != line.size() ) {
14     if( 0 == limit ) {
15       end = line.size();
16     } else {
17       end = line.find( c, start );
18       if( end == string::npos ) {
19         end = line.size();
20       }
21     }
22     out.push_back( line.substr( start, end-start ) );
23     start = end + 1;
24   }
25   return out;
26 }
27
28 int main() {
29   string file_string;
30   do {
31     file_string.clear();
32     for( int c = cin.get(); 0 != c && ! cin.eof(); c = cin.get() ) {
33       file_string.push_back( c );
34     }
35     if( 0 != file_string.size() ) {
36       // Example entry
37       // type perms user group size datemodified name (7 total)
38       // f 0600 cnb cnb 424 20051015205340 ./.git/index
39       vector<string> values = split( file_string, ' ', 7 );
40     }
41   } while( ! cin.eof() );
42 }