00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <openrj/stl/database.hpp>
00029
00030
00031 #include <stlsoft/iterators/ostream_iterator.hpp>
00032
00033
00034 #include <iostream>
00035
00036
00037
00038
00039
00040 using std::cerr;
00041 using std::endl;
00042 using std::cout;
00043
00044
00045
00046
00047
00048
00049 static const char contents[] =
00050
00051 "%% Sample Open-RJ database - Cats and Dogs\n"
00052 "%% Created: 28th September 2004\n"
00053 "%% Updated: 29th September 2004\n"
00054 "Name: Barney\n"
00055 "Species: Dog\n"
00056 "Breed: Bijon \\\n"
00057 " Frieze\n"
00058 "%%\n"
00059 "Name: Elsa\n"
00060 "Species: Dog\n"
00061 "Breed: Mixed\n"
00062 "%%\n"
00063 "Name: Fluffy Kitten\n"
00064 "Species: Cat\n"
00065 "%%\n"
00066 "Name: Moet\n"
00067 "Species: Dog\n"
00068 "Breed: Boxer\n"
00069 "%%\n"
00070 "Name: Rebel\n"
00071 "Species: Dog\n"
00072 "Breed: German \\\n"
00073 " Shepherd\n"
00074 "%%\n"
00075 "Name: Sparky\n"
00076 "Species: Cat\n"
00077 "%%\n";
00078
00079
00080
00081 int main()
00082 {
00083 try
00084 {
00085 unsigned flags = 0;
00086 openrj::stl::memory_database db(&contents[0], sizeof(contents), flags);
00087
00088 cout << endl << "Enumerate all fields in the database:" << endl;
00089
00090 std::copy(db.fields_begin(), db.fields_end(), stlsoft::ostream_iterator<openrj::stl::field>(std::cout, " ", "\n"));
00091 }
00092 catch(std::exception &x)
00093 {
00094 cerr << "Failed to open database: " << x.what() << endl;
00095 }
00096
00097 return EXIT_SUCCESS;
00098 }
00099
00100
00101
00102