From: Mikko Rasa Date: Sat, 30 Jul 2011 08:40:15 +0000 (+0300) Subject: Put examples in their own directory X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=628d762fbfd512aedde6f313f66594291dad4eb1;p=libs%2Fcore.git Put examples in their own directory --- diff --git a/Build b/Build index b82fdec..318f341 100644 --- 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 index 0000000..c87ee72 --- /dev/null +++ b/examples/grep.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +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 &args = getopt.get_args(); + + if(args.empty()) + { + cerr<<"Usage: "<\n"; + return 1; + } + + Regex regex(args[0]); + if(debug) + cout< +#include +#include + +using namespace std; +using namespace Msp; + +int main(int argc, char **argv) +{ + if(argc<3) + { + cerr<<"Usage: "< \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<sync(result); + cout< -#include -#include -#include - -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 &args = getopt.get_args(); - - if(args.empty()) - { - cerr<<"Usage: "<\n"; - return 1; - } - - Regex regex(args[0]); - if(debug) - cout< -#include -#include - -using namespace std; -using namespace Msp; - -int main(int argc, char **argv) -{ - if(argc<3) - { - cerr<<"Usage: "< \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<sync(result); - cout<