⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmdl_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
  }  // check whether the flag is specified or not  //  String flag_param(L"swap");  Boolean swap;  cmdl.addFlagParam(swap, flag_param);  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //--------------------------------------------------------------------------  //  // 5. class-specific public methods  //     add option parameter methods  //  //--------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: add option parameter methods...\n");    Console::increaseIndention();  }  // add the sample frequency  //  Float sf;  cmdl.addOptionParam(sf, sf_param, sf_def);       // add the number of bytes  //  Long nbytes;  cmdl.addOptionParam(nbytes, nbytes_param, nbytes_def);    // add the number of channels(long)  //  Long num_chan;  cmdl.addOptionParam(num_chan, num_chan_param, num_chan_def);     // add the volume(long)  //  Long v;  cmdl.addOptionParam(v, v_param, v_def);  // add the number of parameters(long)  //  Long num;  cmdl.addOptionParam(num, num_param, num_def);   // add the byte(byte)  //  Byte bytes;  cmdl.addOptionParam(bytes, bytes_param, bytes_def);    // add the play mode(string)  //  String mode;  cmdl.addOptionParam(mode, mode_param, mode_def);  // add the filename(string)  //  String filename;  cmdl.addOptionParam(filename, filename_param, filename_def);  // add the debug level(Integral::DEBUG)  //  DebugLevel debuglevel;  cmdl.addOptionParam(debuglevel);  // add the double value  //  Double freq;  cmdl.addOptionParam(freq, freq_param, freq_def);  // add the short value  //  Short val_short;  cmdl.addOptionParam(val_short, val_short_param, val_short_def);  // add the ushort value  //  Ushort val_ushort;  cmdl.addOptionParam(val_ushort, val_ushort_param, val_ushort_def);  // add the llong value  //  Llong val_llng;  cmdl.addOptionParam(val_llng, val_llng_param, val_llng_def);  // add the ulong value  //  Ulong val_ulng;  cmdl.addOptionParam(val_ulng, val_ulng_param, val_ulng_def);  // add the ullong value  //  Ullong val_ullng;  cmdl.addOptionParam(val_ullng, val_ullng_param, val_ullng_def);  // test parse methods  //  // parse the commandline  //  cmdl.parse(16, (const char**)arg0);    // check the arguments  //  if (!swap) {    return Error::handle(name(), L"addFlagParam", Error::TEST,			 __FILE__, __LINE__);  }    if (!sf.almostEqual(7000.0)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }    if (!nbytes.eq(4)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!num_chan.eq(3)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!v.eq(2)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!num.eq(1)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!mode.eq(L"stereo")) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!filename.eq(L"sample")) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!debuglevel.eq(Integral::DEF_DEBUG)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }    if (!freq.almostEqual(8000.0)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!val_short.eq(4)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }    if (!val_ushort.eq(2)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }    if (!val_llng.eq(10)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }    if (!val_ulng.eq(100)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }    if (!val_ullng.eq(256)) {    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }    // test basic parse method  //  String arg_string(L"foo.exe -debug ALL file1.raw file2.raw");  CommandLine cmdl2;  DebugLevel dbg_2;  cmdl2.addOptionParam(dbg_2);    cmdl2.parse(arg_string);  if (!dbg_2.eq(Integral::ALL)) {    return Error::handle(name(), L"parse", Error::TEST, __FILE__, __LINE__);  }  // create another command line  //  String arg_string1(L"foo.exe file2.raw -dbl 3500.0 -byte 2 -type mix -dbl 3600.0 -b 3 -ty stereo");  CommandLine cmdl3;    String dbl_param(L"dbl");  String byte_param(L"byte");  String type_param(L"type");    SingleLinkedList<Double> dbl_res;  SingleLinkedList<Byte> byte_res;  SingleLinkedList<String> type_res;  Double dbl_temp;  dbl_temp = 3500.0;  dbl_res.insert(&dbl_temp);  dbl_temp = 3600.0;  dbl_res.insert(&dbl_temp);  Byte byte_temp;  byte_temp = 2;  byte_res.insert(&byte_temp);  byte_temp = 3;  byte_res.insert(&byte_temp);  String type_temp;  type_temp.assign(L"mix");  type_res.insert(&type_temp);  type_temp.assign(L"stereo");  type_res.insert(&type_temp);  // add the single-linked list of double value  //  SingleLinkedList<Double> dbl1;  cmdl3.addOptionParam(dbl1, dbl_param);  // add the single-linked list of byte value  //  SingleLinkedList<Byte> byte1;  cmdl3.addOptionParam(byte1, byte_param);  // add the single-linked list of string value  //  SingleLinkedList<String> type1;  cmdl3.addOptionParam(type1, type_param);  // test parse methods  //  // parse the commandline  //  cmdl3.parse(arg_string1);    // check the arguments  //  if (!dbl1.eq(dbl_res)) {    dbl_res.debug(L"expected result:");    dbl1.debug(L"wrong result:");    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!byte1.eq(byte_res)) {    byte_res.debug(L"expected result:");    byte1.debug(L"wrong result:");    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  if (!type1.eq(type_res)) {    type_res.debug(L"expected result:");    type1.debug(L"wrong result:");    return Error::handle(name(), L"addOptionParam", Error::TEST,			 __FILE__, __LINE__);  }  // test getActualCmdl method  //  String dump_expected(L"foo.exe file2.raw -dbl 3500.0 -byte 2 -type mix -dbl 3600.0 -byte 3 -type stereo");  String dump_actual;  cmdl3.getActualCmdl(dump_actual);  if (dump_expected.ne(dump_actual)) {    dump_expected.debug(L"expected result:");    dump_actual.debug(L"wrong result:");    return Error::handle(name(), L"getActualCmdl", Error::TEST, __FILE__,			 __LINE__);  }  if (level_a > Integral::BRIEF) {    // test parse method echoing the -echo_cmdl option    //    String arg_string2(arg_string1);    arg_string2.concat(L" -echo_cmdl");    String running_msg(L"Command: ");    running_msg.concat(dump_expected);        CommandLine cmdl4;    cmdl4.addOptionParam(dbl1, dbl_param);    cmdl4.addOptionParam(byte1, byte_param);    cmdl4.addOptionParam(type1, type_param);    // call parse method and print the expanded commmand line to Console    //    cmdl4.parse(arg_string2);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //------------------------------------------------------------------------  //  // 6. class-specific public methods  //     get methods  //  //-------------------------------------------------------------------------    // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: get methods...\n");    Console::increaseIndention();  }  // get number of unused arguments  //  long num_arg = cmdl.numArguments();  if (num_arg != 2) {    cmdl.debug(L"cmdl");    Console::put(num_arg);    return Error::handle(cmdl.name(), L"numArguments", ERR,			 __FILE__, __LINE__);  }    // get used arguments  //  String arg;  if ((!cmdl.getArgument(arg, 0)) || (arg.ne(L"file1.raw"))) {    return Error::handle(cmdl.name(), L"getArgument", ERR, __FILE__, __LINE__);	         }    if ((!cmdl.getArgument(arg, 1)) || (arg.ne(L"file2.raw"))) {    return Error::handle(cmdl.name(), L"getArgument", ERR,  __FILE__, __LINE__);  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //---------------------------------------------------------------------------  //  // 7. print completion message  //  //---------------------------------------------------------------------------  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    if (level_a > Integral::NONE) {    SysString output(L"diagnostics passed for class ");    output.concat(name());    output.concat(L"\n");    Console::put(output);  }    // exit gracefully  //  return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -