testCoder.cxx

00001 #include "config.h"
00002 #include "CommandCoderBase.h"
00003 #include "Options.h"
00004 #include <iostream>
00005 #include <iomanip>
00006 
00007 int
00008 main(int argc, char** argv) 
00009 {
00010   Option<bool>        hOpt('h', "help",    "Show this help", false,false);
00011   Option<bool>        VOpt('V', "version", "Show version number", false,false);
00012   Option<unsigned>    tOpt('t', "tag",     "Tag to use\t", 0);
00013   Option<std::string> TOpt('T', "target",  "Feeserver target","FMD-FEE_0_0_0");
00014   CommandLine cl("");
00015   cl.Add(hOpt);
00016   cl.Add(VOpt);
00017   cl.Add(tOpt);
00018   cl.Add(TOpt);
00019 
00020   if (!cl.Process(argc, argv)) return 1;
00021   if (hOpt.IsSet()) {
00022     cl.Help();
00023     return 0;
00024   }
00025   if (VOpt.IsSet()) {
00026     std::cout << "rcuconf version " << VERSION << std::endl;
00027     return 0;
00028   }
00029  
00030   CommandCoderBase* coco = CommandCoderBase::createInstance();
00031   
00032 
00033   int nwords = coco->createDataBlock(const_cast<char*>(TOpt->c_str()), tOpt);
00034   if (nwords < 0) {
00035     typedef std::vector<std::string> errors_t;
00036     errors_t errs = coco->getError();
00037     std::cerr << "Errors: " << std::endl;
00038     for (errors_t::iterator i = errs.begin(); i != errs.end(); ++i) 
00039       std::cerr << "\t" << *i << std::endl;
00040     return 0;
00041   }
00042   
00043   long int* block = coco->getDataBlock();
00044   std::cout << "Block: " << std::endl;
00045   for (int i = 0; i < nwords; i++) 
00046     std::cout << "\t"   << i 
00047               << "\t0x" << std::hex << std::setfill('0') 
00048               << std::setw(sizeof(long)) << block[i] 
00049               << std::setfill(' ') << std::dec << std::endl;
00050     
00051   return 0;
00052 }
00053 
00054       
Top of page Last update Fri Apr 27 01:54:16 2007
Copyright © 2004 Christian Holm Created by DoxyGen 1.3.5