Some more work.
authorCarl N Baldwin <cnb@plane.(none)>
Sun, 16 Oct 2005 03:54:27 +0000 (21:54 -0600)
committerCarl N Baldwin <cnb@plane.(none)>
Sun, 16 Oct 2005 03:54:27 +0000 (21:54 -0600)
Makefile.am
filedata.cpp [new file with mode: 0644]
filedata.hpp [new file with mode: 0644]
main.cc

index d4632fe952009a86c6bf16a22b27c1ed5d8af281..a9d90e36c6623642f565fd746064605bf65a6a9f 100644 (file)
@@ -4,7 +4,9 @@ bin_SCRIPTS = find-cmd.sh
 
 EXTRA_DIST = $(bin_SCRIPTS)
 
-lsbackups_SOURCES = main.cc
+lsbackups_SOURCES = main.cc \
+                    filedata.hpp \
+                    filedata.cpp
 
 AM_CPPFLAGS = $(SQLITE3_CFLAGS)
 LDADD       = $(SQLITE3_LIBS)
diff --git a/filedata.cpp b/filedata.cpp
new file mode 100644 (file)
index 0000000..c3a8840
--- /dev/null
@@ -0,0 +1,20 @@
+#include <string>
+
+#include "filedata.hpp"
+
+using namespace std;
+
+FileData::FileData( char               _type,
+                    string             _permissions,
+                    string             _user,
+                    string             _group,
+                    unsigned int       _size,
+                    unsigned long long _modified_date,
+                    string             _name )
+: type( _type ),
+  permissions( _permissions ),
+  user( _user ),
+  group( _group ),
+  size( _size ),
+  modified_date( _modified_date ),
+  name( _name ) {}
diff --git a/filedata.hpp b/filedata.hpp
new file mode 100644 (file)
index 0000000..0393ecd
--- /dev/null
@@ -0,0 +1,26 @@
+#include <string>
+
+class FileData {
+  public:
+    // Construct a FileData object with default values
+    FileData( char,
+              std::string,
+              std::string,
+              std::string,
+              unsigned int,
+              unsigned long long,
+              std::string
+              );
+
+  private:
+    FileData();
+    FileData( const FileData & );
+
+    char               type;
+    std::string        permissions;
+    std::string        user;
+    std::string        group;
+    unsigned int       size;
+    unsigned long long modified_date;
+    std::string        name;
+};
diff --git a/main.cc b/main.cc
index bd744b67b6ac59a488f7783e18d99c471f4d5b37..b809f589e5d6381e8e8af3251772f27f1ede5e79 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -1,8 +1,30 @@
 #include <iostream>
+#include <iterator>
+#include <string>
+#include <vector>
 #include <algorithm>
 
 using namespace std;
 
+vector<string> split( const string &line, char c, int limit = -1 ) {
+  string::size_type start = 0, end = 0;
+
+  vector<string> out;
+  while( 0 != limit-- && end != line.size() ) {
+    if( 0 == limit ) {
+      end = line.size();
+    } else {
+      end = line.find( c, start );
+      if( end == string::npos ) {
+        end = line.size();
+      }
+    }
+    out.push_back( line.substr( start, end-start ) );
+    start = end + 1;
+  }
+  return out;
+}
+
 int main() {
   string file_string;
   do {
@@ -11,7 +33,10 @@ int main() {
       file_string.push_back( c );
     }
     if( 0 != file_string.size() ) {
-      cout << file_string << endl;
+      // Example entry
+      // type perms user group size datemodified name (7 total)
+      // f 0600 cnb cnb 424 20051015205340 ./.git/index
+      vector<string> values = split( file_string, ' ', 7 );
     }
   } while( ! cin.eof() );
 }