src/core/examples/command-line-example.cc
changeset 10867 75c3c163aed0
parent 10866 e4b913c6fe41
child 11093 5ae2ca8407fc
equal deleted inserted replaced
10866:e4b913c6fe41 10867:75c3c163aed0
    58   const TypeId tid = TypeId::LookupByName (attrClass);
    58   const TypeId tid = TypeId::LookupByName (attrClass);
    59   std::string attrDef;
    59   std::string attrDef;
    60   {
    60   {
    61     struct TypeId::AttributeInformation info;
    61     struct TypeId::AttributeInformation info;
    62     tid.LookupAttributeByName (attrName, &info);
    62     tid.LookupAttributeByName (attrName, &info);
    63     attrDef = info.initialValue->SerializeToString (info.checker);
    63     attrDef = info.originalInitialValue->SerializeToString (info.checker);
    64   }
    64   }
    65   
    65   
    66   
    66   
    67   CommandLine cmd;
    67   CommandLine cmd;
    68   cmd.Usage ("CommandLine example program.\n"
    68   cmd.Usage ("CommandLine example program.\n"
    88             << std::endl;
    88             << std::endl;
    89   
    89   
    90   std::cout << std::setw (10)              << "strArg:"
    90   std::cout << std::setw (10)              << "strArg:"
    91             << "\""            << strDef   << "\""
    91             << "\""            << strDef   << "\""
    92             << std::endl;
    92             << std::endl;
    93 
    93   std::cout << std::setw (10)              << "anti:"
    94   // Look up new default value for attribute
    94             << "\""            << attrDef  << "\""
    95   {
    95             << std::endl;
    96     struct TypeId::AttributeInformation info;
       
    97     tid.LookupAttributeByName (attrName, &info);
       
    98   
       
    99     std::cout << std::setw (10)            << "anti:"
       
   100               << "\""
       
   101               << info.originalInitialValue->SerializeToString (info.checker)
       
   102               << "\""
       
   103               << std::endl;
       
   104   }
       
   105   std::cout << std::setw (10)              << "cbArg:"
    96   std::cout << std::setw (10)              << "cbArg:"
   106             << "\""            << cbDef    << "\""
    97             << "\""            << cbDef    << "\""
   107             << std::endl;
    98             << std::endl;
   108   std::cout << std::endl;
    99   std::cout << std::endl;
   109 
   100 
   110 
   101 
   111   // Show final values
   102   // Show final values
       
   103   std::cout << "Final values:" << std::endl;
   112   std::cout << std::left << std::setw (10) << "intArg:"
   104   std::cout << std::left << std::setw (10) << "intArg:"
   113             <<                    intArg
   105             <<                    intArg
   114             << std::endl;
   106             << std::endl;
   115   std::cout << std::setw (10)              << "boolArg:"
   107   std::cout << std::setw (10)              << "boolArg:"
   116             << std::boolalpha  << boolArg
   108             << std::boolalpha  << boolArg