Ignore:
Timestamp:
13 Jul 2013, 10:26:41 (11 years ago)
Author:
tech
Message:

MergeMerged tags/HTM-DEV-1.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.3-dev2/source/Lib/TAppCommon/program_options_lite.h

    r446 r534  
    3636#include <list>
    3737#include <map>
     38#include  "../TLibCommon/TypeDef.h"
    3839
    3940#if H_MV
     
    8586    struct OptionBase
    8687    {
     88#if H_MV     
     89      OptionBase(const std::string& name, const std::string& desc, bool duplicate = false)
     90        : opt_string(name), opt_desc(desc), opt_duplicate(duplicate)
     91#else
    8792      OptionBase(const std::string& name, const std::string& desc)
    8893      : opt_string(name), opt_desc(desc)
     94#endif
    8995      {};
    9096     
     
    98104      std::string opt_string;
    99105      std::string opt_desc;
     106#if H_MV
     107      bool        opt_duplicate;
     108#endif
    100109    };
    101110   
     
    104113    struct Option : public OptionBase
    105114    {
     115#if H_MV
     116      Option(const std::string& name, T& storage, T default_val, const std::string& desc, bool duplicate = false)
     117        : OptionBase(name, desc, duplicate), opt_storage(storage), opt_default_val(default_val)
     118#else
    106119      Option(const std::string& name, T& storage, T default_val, const std::string& desc)
    107120      : OptionBase(name, desc), opt_storage(storage), opt_default_val(default_val)
     121#endif
    108122      {}
    109123     
     
    362376      {
    363377        std::string cNameBuffer;
    364         std::string cDescriptionBuffer;
     378        std::string cDescBuffer;
    365379
    366380        cNameBuffer       .resize( name.size() + 10 );
    367         cDescriptionBuffer.resize( desc.size() + 10 );
     381        cDescBuffer.resize( desc.size() + 10 );
    368382
    369383        storage.resize(uiMaxNum);
    370384        for ( unsigned int uiK = 0; uiK < uiMaxNum; uiK++ )
    371385        {
     386          Bool duplicate = (uiK != 0);
    372387          // isn't there are sprintf function for string??
    373388          sprintf((char*) cNameBuffer.c_str()       ,name.c_str(),uiK,uiK);
    374           sprintf((char*) cDescriptionBuffer.c_str(),desc.c_str(),uiK,uiK);
    375 
    376           parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescriptionBuffer ));
     389
     390          if ( !duplicate )
     391          {         
     392            sprintf((char*) cDescBuffer.c_str(),desc.c_str(),uiK,uiK);
     393          }
     394
     395          cNameBuffer.resize( std::strlen(cNameBuffer.c_str()) ); 
     396          cDescBuffer.resize( std::strlen(cDescBuffer.c_str()) );
     397         
     398
     399          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescBuffer, duplicate ));
    377400        }
    378401
Note: See TracChangeset for help on using the changeset viewer.