Add type name String as std::string

This commit is contained in:
jfmcarreira committed 2016-04-30 03:31:41 +01:00
1 parent 42d18a3a09
commit 3dd3e458b9
25 files changed
+128 -129

No files matched your search

+6 -4
View File
@@ -49,6 +49,8 @@ typedef float Float;
typedef unsigned char UInt8;
typedef unsigned int UInt16;
typedef std::string String;
// ====================================================================================================================
// 64-bit integer type
// ====================================================================================================================
@@ -118,16 +120,16 @@ enum RGBcomponent
};
inline std::string lowercase( const std::string& in )
inline String lowercase( const String& in )
{
std::string out;
String out;
transform( in.begin(), in.end(), std::back_inserter( out ), tolower );
return out;
}
inline std::string uppercase( const std::string& in )
inline String uppercase( const String& in )
{
std::string out;
String out;
transform( in.begin(), in.end(), std::back_inserter( out ), toupper );
return out;
}
+8 -8
View File
@@ -37,18 +37,18 @@
#endif
std::vector<std::string> PlaYUVerFrame::supportedColorSpacesListNames()
std::vector<String> PlaYUVerFrame::supportedColorSpacesListNames()
{
std::vector<std::string> colorSpaceList;
std::vector<String> colorSpaceList;
colorSpaceList.push_back( "YUV" );
colorSpaceList.push_back( "RGB" );
colorSpaceList.push_back( "GRAY" );
return colorSpaceList;
}
std::vector<std::string> PlaYUVerFrame::supportedPixelFormatListNames()
std::vector<String> PlaYUVerFrame::supportedPixelFormatListNames()
{
std::vector<std::string> formatsList;
std::vector<String> formatsList;
Int numberFormats = PLAYUVER_NUMBER_FORMATS;
for( Int i = 0; i < numberFormats; i++ )
{
@@ -57,9 +57,9 @@ std::vector<std::string> PlaYUVerFrame::supportedPixelFormatListNames()
return formatsList;
}
std::vector<std::string> PlaYUVerFrame::supportedPixelFormatListNames( Int colorSpace )
std::vector<String> PlaYUVerFrame::supportedPixelFormatListNames( Int colorSpace )
{
std::vector<std::string> formatsList;
std::vector<String> formatsList;
Int numberFormats = PLAYUVER_NUMBER_FORMATS;
for( Int i = 0; i < numberFormats; i++ )
{
@@ -69,7 +69,7 @@ std::vector<std::string> PlaYUVerFrame::supportedPixelFormatListNames( Int color
return formatsList;
}
Int PlaYUVerFrame::findPixelFormat( std::string name )
Int PlaYUVerFrame::findPixelFormat( String name )
{
for( Int i = 0; i < PLAYUVER_NUMBER_FORMATS; i++ )
{
@@ -257,7 +257,7 @@ Bool PlaYUVerFrame::haveSameFmt( PlaYUVerFrame* other, UInt match ) const
return bRet;
}
std::string PlaYUVerFrame::getPelFmtName()
String PlaYUVerFrame::getPelFmtName()
{
return m_pcPelFormat->name;
}
+8 -8
View File
@@ -87,16 +87,16 @@ public:
* of PlaYUVerFrame
* @return vector of strings with pixel formats names
*/
static std::vector<std::string> supportedColorSpacesListNames();
static std::vector<String> supportedColorSpacesListNames();
/**
* Function that handles the supported pixel formats
* of PlaYUVerFrame
* @return vector of strings with pixel formats names
*/
static std::vector<std::string> supportedPixelFormatListNames();
static std::vector<std::string> supportedPixelFormatListNames( Int colorSpace );
static Int findPixelFormat( std::string name );
static std::vector<String> supportedPixelFormatListNames();
static std::vector<String> supportedPixelFormatListNames( Int colorSpace );
static Int findPixelFormat( String name );
/**
* Get number of bytes per frame of a specific
@@ -221,7 +221,7 @@ public:
Bool haveSameFmt( PlaYUVerFrame* other, UInt match = MATCH_ALL ) const;
std::string getPelFmtName();
String getPelFmtName();
/**
* Histogram
@@ -271,9 +271,9 @@ public:
NUMBER_METRICS,
};
static std::vector<std::string> supportedQualityMetricsList()
static std::vector<String> supportedQualityMetricsList()
{
std::vector<std::string> metrics;
std::vector<String> metrics;
metrics.push_back( "PSNR" );
metrics.push_back( "MSE" );
metrics.push_back( "SSIM" );
@@ -293,7 +293,7 @@ private:
//! Struct with the pixel format description.
PlaYUVerPixFmtDescriptor* m_pcPelFormat;
std::string m_cPelFmtName;
String m_cPelFmtName;
UInt m_uiWidth; //!< Width of the frame
UInt m_uiHeight; //!< Height of the frame
+5 -5
View File
@@ -49,7 +49,7 @@
using namespace std;
Options::Options( const std::string& name )
Options::Options( const String& name )
{
m_cOptionGroupName = name;
m_bAllowUnkonw = true;
@@ -63,12 +63,12 @@ Options::~Options()
}
}
OptionBase* Options::operator[]( const std::string& optName )
OptionBase* Options::operator[]( const String& optName )
{
return getOption( optName );
}
OptionBase* Options::getOption( const std::string& optName )
OptionBase* Options::getOption( const String& optName )
{
Options::OptionMap::iterator opt_it;
opt_it = opt_short_map.find( optName );
@@ -92,7 +92,7 @@ OptionBase* Options::getOption( const std::string& optName )
return NULL;
}
Bool Options::hasOpt( const std::string& optName )
Bool Options::hasOpt( const String& optName )
{
return getOption( optName )->count() > 0 ? true : false;
}
@@ -347,7 +347,7 @@ list<const char*> Options::scanArgv( unsigned argc, const char* argv[] )
return non_option_arguments;
}
Void Options::scanArgs( std::vector<std::string> args_array)
Void Options::scanArgs( std::vector<String> args_array)
{
for( unsigned i = 0; i < args_array.size(); i++ )
{
+36 -36
View File
@@ -52,7 +52,7 @@ struct Options;
struct ParseFailure: public std::exception
{
ParseFailure( std::string arg0, std::string val0 ) throw() :
ParseFailure( String arg0, String val0 ) throw() :
arg( arg0 ),
val( val0 )
{
@@ -62,8 +62,8 @@ struct ParseFailure: public std::exception
{
}
std::string arg;
std::string val;
String arg;
String val;
const char* what() const throw()
{
@@ -76,7 +76,7 @@ struct ParseFailure: public std::exception
* information should be stored in a derived class. */
struct OptionBase
{
OptionBase( const std::string& name, const std::string& desc ) :
OptionBase( const String& name, const String& desc ) :
arg_count( 0 ),
opt_string( name ),
opt_desc( desc )
@@ -88,7 +88,7 @@ struct OptionBase
}
/* parse argument arg, to obtain a value for the option */
virtual void parse( const std::string& arg ) = 0;
virtual void parse( const String& arg ) = 0;
/* set the argument to the default value */
//virtual void setDefault() = 0;
int count()
@@ -101,15 +101,15 @@ struct OptionBase
}
int arg_count;
std::string opt_string;
std::string opt_desc;
String opt_string;
String opt_desc;
Bool is_binary;
};
/** Type specific option storage */
struct FlagOpt: public OptionBase
{
FlagOpt( const std::string& name, Bool default_val, const std::string& desc ) :
FlagOpt( const String& name, Bool default_val, const String& desc ) :
OptionBase( name, desc ),
opt_storage( false ),
opt_default_val( default_val )
@@ -117,7 +117,7 @@ struct FlagOpt: public OptionBase
is_binary = true;
}
void parse( const std::string& arg )
void parse( const String& arg )
{
opt_storage = true;
arg_count++;
@@ -135,14 +135,14 @@ struct FlagOpt: public OptionBase
template<typename T>
struct StandardOpt: public OptionBase
{
StandardOpt( const std::string& name, T& storage, const std::string& desc ) :
StandardOpt( const String& name, T& storage, const String& desc ) :
OptionBase( name, desc ),
opt_storage( storage )
{
is_binary = false;
}
void parse( const std::string& arg );
void parse( const String& arg );
// void setDefault()
// {
@@ -154,7 +154,7 @@ struct StandardOpt: public OptionBase
/* Generic parsing */
template<typename T>
inline void StandardOpt<T>::parse( const std::string& arg )
inline void StandardOpt<T>::parse( const String& arg )
{
std::istringstream arg_ss( arg, std::istringstream::in );
arg_ss.exceptions( std::ios::failbit );
@@ -170,7 +170,7 @@ inline void StandardOpt<T>::parse( const std::string& arg )
}
template<>
inline void StandardOpt< std::vector<UInt> >::parse( const std::string& arg )
inline void StandardOpt< std::vector<UInt> >::parse( const String& arg )
{
UInt aux_opt_storage;
std::istringstream arg_ss( arg, std::istringstream::in );
@@ -188,7 +188,7 @@ inline void StandardOpt< std::vector<UInt> >::parse( const std::string& arg )
}
template<>
inline void StandardOpt< std::vector<Int> >::parse( const std::string& arg )
inline void StandardOpt< std::vector<Int> >::parse( const String& arg )
{
Int aux_opt_storage;
std::istringstream arg_ss( arg, std::istringstream::in );
@@ -207,7 +207,7 @@ inline void StandardOpt< std::vector<Int> >::parse( const std::string& arg )
/* string parsing is specialized */
template<>
inline void StandardOpt<std::string>::parse( const std::string& arg )
inline void StandardOpt<String>::parse( const String& arg )
{
opt_storage = arg;
arg_count++;
@@ -215,7 +215,7 @@ inline void StandardOpt<std::string>::parse( const std::string& arg )
/* string vector parsing is specialized */
template<>
inline void StandardOpt<std::vector<std::string> >::parse( const std::string& arg )
inline void StandardOpt<std::vector<String> >::parse( const String& arg )
{
opt_storage.push_back( arg );
arg_count++;
@@ -224,9 +224,9 @@ inline void StandardOpt<std::vector<std::string> >::parse( const std::string& ar
/** Option class for argument handling using a user provided function */
struct OptionFunc: public OptionBase
{
typedef Void (Func)( Options&, const std::string& );
typedef Void (Func)( Options&, const String& );
OptionFunc( const std::string& name, Options& parent_, Func *func_, const std::string& desc ) :
OptionFunc( const String& name, Options& parent_, Func *func_, const String& desc ) :
OptionBase( name, desc ),
parent( parent_ ),
func( func_ )
@@ -234,7 +234,7 @@ struct OptionFunc: public OptionBase
is_binary = false;
}
void parse( const std::string& arg )
void parse( const String& arg )
{
func( parent, arg );
arg_count++;
@@ -247,7 +247,7 @@ struct OptionFunc: public OptionBase
private:
Options& parent;
void (*func)( Options&, const std::string& );
void (*func)( Options&, const String& );
};
class OptionSpecific;
@@ -267,49 +267,49 @@ public:
if( opt )
delete opt;
}
std::list<std::string> opt_long;
std::list<std::string> opt_short;
std::list<String> opt_long;
std::list<String> opt_short;
OptionBase* opt;
};
typedef std::list<Option*> OptionsList;
Options( const std::string& name = "" );
Options( const String& name = "" );
~Options();
std::list<const char*> scanArgv( unsigned argc, const char* argv[] );
Void scanArgs( std::vector<std::string> args_array);
Void scanArgs( std::vector<String> args_array);
Void doHelp( std::ostream& out, unsigned columns = 80 );
OptionSpecific addOptions();
Void setDefaults();
OptionBase* operator[]( const std::string& optName );
OptionBase* getOption( const std::string& optName );
OptionBase* operator[]( const String& optName );
OptionBase* getOption( const String& optName );
OptionsList& getOptionList()
{
return opt_list;
}
Bool hasOpt( const std::string& optName );
Bool hasOpt( const String& optName );
void addOption( OptionBase *opt );
private:
typedef std::map<std::string, OptionsList> OptionMap;
typedef std::map<String, OptionsList> OptionMap;
OptionMap opt_long_map;
OptionMap opt_short_map;
OptionsList opt_list;
std::string m_cOptionGroupName;
String m_cOptionGroupName;
Bool m_bAllowUnkonw;
Bool storePair( Bool allow_long, Bool allow_short, const std::string& name, const std::string& value );
Bool storePair( const std::string& name, const std::string& value );
Bool storePair( Bool allow_long, Bool allow_short, const String& name, const String& value );
Bool storePair( const String& name, const String& value );
UInt parseLONG( unsigned argc, const char* argv[] );
UInt parseLONG( std::string arg );
UInt parseLONG( String arg );
unsigned parseSHORT( unsigned argc, const char* argv[] );
};
@@ -330,7 +330,7 @@ public:
*/
template<typename T>
OptionSpecific&
operator()( const std::string& name, T& storage, const std::string& desc )
operator()( const String& name, T& storage, const String& desc )
{
parent.addOption( new StandardOpt<T>( name, storage, desc ) );
return *this;
@@ -343,7 +343,7 @@ public:
* with desc as an optional help description
*/
OptionSpecific&
operator()( const std::string& name, const std::string& desc )
operator()( const String& name, const String& desc )
{
parent.addOption( new FlagOpt( name, false, desc ) );
return *this;
@@ -356,7 +356,7 @@ public:
* with desc as an optional help description
*/
OptionSpecific&
operator()( const std::string& name, Bool default_val, const std::string& desc )
operator()( const String& name, Bool default_val, const String& desc )
{
parent.addOption( new FlagOpt( name, default_val, desc ) );
return *this;
@@ -370,7 +370,7 @@ public:
* handle evaluating the option's value.
*/
OptionSpecific&
operator()( const std::string& name, OptionFunc::Func *func, const std::string& desc )
operator()( const String& name, OptionFunc::Func *func, const String& desc )
{
parent.addOption( new OptionFunc( name, parent, func, desc ) );
return *this;
+10 -10
View File
@@ -99,9 +99,9 @@ std::vector<PlaYUVerStdResolution> PlaYUVerStream::stdResolutionSizes()
}
CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( std::string strFilename, bool bRead )
CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, bool bRead )
{
std::string currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
String currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
currExt = lowercase( currExt );
std::vector<PlaYUVerSupportedFormat> supportedFmts;
@@ -119,7 +119,7 @@ CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( std::string strFilename
{
return supportedFmts[i].formatFct;
}
else if( strFilename.find( supportedFmts[i].formatExt ) != std::string::npos )
else if( strFilename.find( supportedFmts[i].formatExt ) != String::npos )
{
return supportedFmts[i].formatFct;
}
@@ -150,16 +150,16 @@ PlaYUVerStream::~PlaYUVerStream()
close();
}
std::string PlaYUVerStream::getFormatName()
String PlaYUVerStream::getFormatName()
{
return !m_pcHandler ? "" : m_pcHandler->getFormatName();
}
std::string PlaYUVerStream::getCodecName()
String PlaYUVerStream::getCodecName()
{
return !m_pcHandler ? "" : m_pcHandler->getCodecName();
}
Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput )
Bool PlaYUVerStream::open( String filename, String resolution, String input_format_name, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput )
{
UInt width;
UInt height;
@@ -184,7 +184,7 @@ Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::st
return open( filename, width, height, input_format, bitsPel, endianness, frame_rate, bInput );
}
Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput )
Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput )
{
if( m_bInit )
{
@@ -331,7 +331,7 @@ Void PlaYUVerStream::close()
m_bInit = false;
}
std::string PlaYUVerStream::getFileName()
String PlaYUVerStream::getFileName()
{
return m_cFilename;
}
@@ -488,12 +488,12 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame )
return;
}
Bool PlaYUVerStream::saveFrame( const std::string& filename )
Bool PlaYUVerStream::saveFrame( const String& filename )
{
return saveFrame( filename, m_pcCurrFrame );
}
Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame )
Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame *saveFrame )
{
PlaYUVerStream auxSaveStream;
if( !auxSaveStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), saveFrame->getBitsPel(), saveFrame->getEndianness(), 1, false ) )
+12 -12
View File
@@ -38,7 +38,7 @@ class PlaYUVerStreamHandlerIf;
typedef struct
{
std::string shortName;
String shortName;
UInt uiWidth;
UInt uiHeight;
} PlaYUVerStdResolution;
@@ -48,8 +48,8 @@ typedef PlaYUVerStreamHandlerIf* (*CreateStreamHandlerFn)( void );
typedef struct
{
std::string formatName;
std::string formatExt;
String formatName;
String formatExt;
CreateStreamHandlerFn formatFct;
} PlaYUVerSupportedFormat;
@@ -84,7 +84,7 @@ public:
static std::vector<PlaYUVerSupportedFormat> supportedReadFormats();
static std::vector<PlaYUVerSupportedFormat> supportedWriteFormats();
static CreateStreamHandlerFn findStreamHandler( std::string strFilename, bool bRead );
static CreateStreamHandlerFn findStreamHandler( String strFilename, bool bRead );
static std::vector<PlaYUVerStdResolution> stdResolutionSizes();
@@ -100,15 +100,15 @@ public:
END_OF_SEQ,
};
std::string getFormatName();
std::string getCodecName();
String getFormatName();
String getCodecName();
Bool open( std::string filename, std::string resolution, std::string input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput = true );
Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput = true );
Bool open( String filename, String resolution, String input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput = true );
Bool open( String filename, UInt width, UInt height, Int input_format, UInt bitsPel, Int endianness, UInt frame_rate, Bool bInput = true );
Bool reload();
Void close();
std::string getFileName();
String getFileName();
UInt getFrameNum();
UInt getWidth() const;
UInt getHeight() const;
@@ -123,8 +123,8 @@ public:
Void writeFrame();
Void writeFrame( PlaYUVerFrame *pcFrame );
Bool saveFrame( const std::string& filename );
static Bool saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame );
Bool saveFrame( const String& filename );
static Bool saveFrame( const String& filename, PlaYUVerFrame *saveFrame );
Bool setNextFrame();
PlaYUVerFrame* getCurrFrame();
@@ -149,7 +149,7 @@ private:
PlaYUVerStreamHandlerIf* m_pcHandler;
Bool m_bIsInput;
std::string m_cFilename;
String m_cFilename;
UInt64 m_uiTotalFrameNum;
Int64 m_iCurrFrameNum;
+6 -6
View File
@@ -58,7 +58,7 @@ public:
{
}
virtual Bool openHandler( std::string strFilename, Bool bInput ) = 0;
virtual Bool openHandler( String strFilename, Bool bInput ) = 0;
virtual Void closeHandler() = 0;
virtual Bool configureBuffer( PlaYUVerFrame* pcFrame ) = 0;
virtual UInt64 calculateFrameNumber() = 0;
@@ -70,18 +70,18 @@ public:
{
m_uiNBytesPerFrame = uiNBytes;
}
std::string getFormatName()
String getFormatName()
{
return m_strFormatName;
}
std::string getCodecName()
String getCodecName()
{
return m_strCodecName;
}
protected:
Bool m_bIsInput;
std::string m_cFilename;
String m_cFilename;
UInt m_uiWidth;
UInt m_uiHeight;
Int m_iPixelFormat;
@@ -91,8 +91,8 @@ protected:
Byte* m_pStreamBuffer;
UInt64 m_uiNBytesPerFrame;
std::string m_strFormatName;
std::string m_strCodecName;
String m_strFormatName;
String m_strCodecName;
};
#endif // __PLAYUVERSTREAMHANDLERIF_H__
+1 -1
View File
@@ -87,7 +87,7 @@ static int open_codec_context( int *stream_idx, AVFormatContext *m_cFmtCtx, enum
return 0;
}
Bool StreamHandlerLibav::openHandler( std::string strFilename, Bool bInput )
Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
{
const char* filename = strFilename.c_str();
+1 -1
View File
@@ -68,7 +68,7 @@ public:
{
}
Bool openHandler( std::string strFilename, Bool bInput );
Bool openHandler( String strFilename, Bool bInput );
Void closeHandler();
Bool configureBuffer( PlaYUVerFrame* pcFrame );
UInt64 calculateFrameNumber();
+4 -3
View File
@@ -29,7 +29,8 @@
#include "PlaYUVerFramePixelFormats.h"
#include "LibMemory.h"
using namespace cv;
using cv::Mat;
using cv::VideoCapture;
std::vector<PlaYUVerSupportedFormat> StreamHandlerOpenCV::supportedReadFormats()
@@ -56,7 +57,7 @@ StreamHandlerOpenCV::StreamHandlerOpenCV()
pcVideoCapture = NULL;
}
Bool StreamHandlerOpenCV::openHandler( std::string strFilename, Bool bInput )
Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput )
{
m_cFilename = strFilename;
if( bInput )
@@ -66,7 +67,7 @@ Bool StreamHandlerOpenCV::openHandler( std::string strFilename, Bool bInput )
/*
* Special filename to handle webcam input
*/
if( m_cFilename.find( "/dev/video" ) != std::string::npos )
if( m_cFilename.find( "/dev/video" ) != String::npos )
{
m_strFormatName = "DEV";
m_strCodecName = "Raw Video";
+1 -1
View File
@@ -55,7 +55,7 @@ public:
{
}
Bool openHandler( std::string strFilename, Bool bInput );
Bool openHandler( String strFilename, Bool bInput );
Void closeHandler();
Bool configureBuffer( PlaYUVerFrame* pcFrame );
UInt64 calculateFrameNumber();
+1 -1
View File
@@ -31,7 +31,7 @@
#include "LibMemory.h"
Bool StreamHandlerPortableMap::openHandler( std::string strFilename, Bool bInput )
Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput )
{
m_bIsInput = bInput;
m_pFile = NULL;
+1 -1
View File
@@ -44,7 +44,7 @@ public:
StreamHandlerPortableMap() {}
~StreamHandlerPortableMap() {}
Bool openHandler( std::string strFilename, Bool bInput );
Bool openHandler( String strFilename, Bool bInput );
Void closeHandler();
Bool configureBuffer( PlaYUVerFrame* pcFrame );
UInt64 calculateFrameNumber();
+1 -1
View File
@@ -30,7 +30,7 @@
#include "LibMemory.h"
Bool PlaYUVerRawHandler::openHandler( std::string strFilename, Bool bInput )
Bool PlaYUVerRawHandler::openHandler( String strFilename, Bool bInput )
{
m_bIsInput = bInput;
m_pFile = NULL;
+1 -1
View File
@@ -45,7 +45,7 @@ public:
PlaYUVerRawHandler() {}
~PlaYUVerRawHandler() {}
Bool openHandler( std::string strFilename, Bool bInput );
Bool openHandler( String strFilename, Bool bInput );
Void closeHandler();
Bool configureBuffer( PlaYUVerFrame* pcFrame );
UInt64 calculateFrameNumber();