]> git.tdb.fi Git - libs/core.git/commitdiff
Put examples in their own directory
authorMikko Rasa <tdb@tdb.fi>
Sat, 30 Jul 2011 08:40:15 +0000 (11:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 30 Jul 2011 08:40:15 +0000 (11:40 +0300)
Build
examples/grep.cpp [new file with mode: 0644]
examples/transcode.cpp [new file with mode: 0644]
grep.cpp [deleted file]
transcode.cpp [deleted file]

diff --git a/Build b/Build
index b82fdec9d915cb2f3347c600e9d2cf0c1e1bd8bf..318f3414df20eae3cecb296bce4be288fb5e2b19 100644 (file)
--- a/Build
+++ b/Build
@@ -77,7 +77,7 @@ package "mspcore"
 
        program "grep"
        {
-               source "grep.cpp";
+               source "examples/grep.cpp";
                build_info
                {
                        library "mspcore";
@@ -86,7 +86,7 @@ package "mspcore"
 
        program "transcode"
        {
-               source "transcode.cpp";
+               source "examples/transcode.cpp";
                build_info
                {
                        library "mspcore";
diff --git a/examples/grep.cpp b/examples/grep.cpp
new file mode 100644 (file)
index 0000000..c87ee72
--- /dev/null
@@ -0,0 +1,35 @@
+#include <iostream>
+#include <string>
+#include <msp/core/getopt.h>
+#include <msp/strings/regex.h>
+
+using namespace std;
+using namespace Msp;
+
+int main(int argc, char **argv)
+{
+       bool debug = false;
+       GetOpt getopt;
+       getopt.add_option('d', "debug", debug, GetOpt::NO_ARG);
+       getopt(argc, argv);
+
+       const vector<string> &args = getopt.get_args();
+
+       if(args.empty())
+       {
+               cerr<<"Usage: "<<argv[0]<<" <regex>\n";
+               return 1;
+       }
+
+       Regex regex(args[0]);
+       if(debug)
+               cout<<regex.disassemble();
+       string line;
+       while(getline(cin, line))
+       {
+               if(RegMatch match = regex.match(line))
+                       cout<<line<<'\n';
+       }
+
+       return 0;
+}
diff --git a/examples/transcode.cpp b/examples/transcode.cpp
new file mode 100644 (file)
index 0000000..3f4121d
--- /dev/null
@@ -0,0 +1,43 @@
+#include <iostream>
+#include <string>
+#include <msp/stringcodec/codec.h>
+
+using namespace std;
+using namespace Msp;
+
+int main(int argc, char **argv)
+{
+       if(argc<3)
+       {
+               cerr<<"Usage: "<<argv[0]<<" <from-enc> <to-enc>\n";
+               return 1;
+       }
+
+       StringCodec::Codec *from = StringCodec::create_codec(argv[1]);
+       StringCodec::Codec *to = StringCodec::create_codec(argv[2]);
+
+       StringCodec::Decoder *from_dec = from->create_decoder();
+       StringCodec::Encoder *to_enc = to->create_encoder();
+
+       string line;
+       while(getline(cin, line))
+       {
+               line += '\n';
+               StringCodec::ustring ustr;
+               from_dec->decode(line, ustr);
+               string result;
+               to_enc->encode(ustr, result);
+               cout<<result;
+       }
+
+       string result;
+       to_enc->sync(result);
+       cout<<result;
+
+       delete from_dec;
+       delete to_enc;
+       delete from;
+       delete to;
+
+       return 0;
+}
diff --git a/grep.cpp b/grep.cpp
deleted file mode 100644 (file)
index c87ee72..0000000
--- a/grep.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <iostream>
-#include <string>
-#include <msp/core/getopt.h>
-#include <msp/strings/regex.h>
-
-using namespace std;
-using namespace Msp;
-
-int main(int argc, char **argv)
-{
-       bool debug = false;
-       GetOpt getopt;
-       getopt.add_option('d', "debug", debug, GetOpt::NO_ARG);
-       getopt(argc, argv);
-
-       const vector<string> &args = getopt.get_args();
-
-       if(args.empty())
-       {
-               cerr<<"Usage: "<<argv[0]<<" <regex>\n";
-               return 1;
-       }
-
-       Regex regex(args[0]);
-       if(debug)
-               cout<<regex.disassemble();
-       string line;
-       while(getline(cin, line))
-       {
-               if(RegMatch match = regex.match(line))
-                       cout<<line<<'\n';
-       }
-
-       return 0;
-}
diff --git a/transcode.cpp b/transcode.cpp
deleted file mode 100644 (file)
index 3f4121d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <iostream>
-#include <string>
-#include <msp/stringcodec/codec.h>
-
-using namespace std;
-using namespace Msp;
-
-int main(int argc, char **argv)
-{
-       if(argc<3)
-       {
-               cerr<<"Usage: "<<argv[0]<<" <from-enc> <to-enc>\n";
-               return 1;
-       }
-
-       StringCodec::Codec *from = StringCodec::create_codec(argv[1]);
-       StringCodec::Codec *to = StringCodec::create_codec(argv[2]);
-
-       StringCodec::Decoder *from_dec = from->create_decoder();
-       StringCodec::Encoder *to_enc = to->create_encoder();
-
-       string line;
-       while(getline(cin, line))
-       {
-               line += '\n';
-               StringCodec::ustring ustr;
-               from_dec->decode(line, ustr);
-               string result;
-               to_enc->encode(ustr, result);
-               cout<<result;
-       }
-
-       string result;
-       to_enc->sync(result);
-       cout<<result;
-
-       delete from_dec;
-       delete to_enc;
-       delete from;
-       delete to;
-
-       return 0;
-}