Skip to content

Commit eacd0ed

Browse files
author
Clement Champetier
committed
Option: clean
* hasChild function uses vector::size(). * getChilds function is const.
1 parent 7c180d6 commit eacd0ed

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/AvTranscoder/option/Option.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void Option::setFlag( const std::string& flag, const bool enable )
9595
{
9696
int64_t optVal;
9797
int error = av_opt_get_int( _avContext, getName().c_str(), AV_OPT_SEARCH_CHILDREN, &optVal );
98-
if( error != 0 )
98+
if( ! error )
9999
{
100100
char err[AV_ERROR_MAX_STRING_SIZE];
101101
av_strerror( error, err, AV_ERROR_MAX_STRING_SIZE );
@@ -119,7 +119,7 @@ void Option::setFlag( const std::string& flag, const bool enable )
119119
void Option::setValueBool( const bool value )
120120
{
121121
int error = av_opt_set_int( _avContext, getName().c_str(), value, AV_OPT_SEARCH_CHILDREN );
122-
if( error != 0 )
122+
if( ! error )
123123
{
124124
char err[AV_ERROR_MAX_STRING_SIZE];
125125
av_strerror( error, err, AV_ERROR_MAX_STRING_SIZE );
@@ -130,7 +130,7 @@ void Option::setValueBool( const bool value )
130130
void Option::setValueInt( const int value )
131131
{
132132
int error = av_opt_set_int( _avContext, getName().c_str(), value, AV_OPT_SEARCH_CHILDREN );
133-
if( error != 0 )
133+
if( ! error )
134134
{
135135
std::ostringstream os;
136136
os << value;
@@ -146,7 +146,7 @@ void Option::setValueRatio( const int num, const int den )
146146
ratio.num = num;
147147
ratio.den = den;
148148
int error = av_opt_set_q( _avContext, getName().c_str(), ratio, AV_OPT_SEARCH_CHILDREN );
149-
if( error != 0 )
149+
if( ! error )
150150
{
151151
std::ostringstream os;
152152
os << num << "/" << den;
@@ -159,7 +159,7 @@ void Option::setValueRatio( const int num, const int den )
159159
void Option::setValueDouble( const double value )
160160
{
161161
int error = av_opt_set_double( _avContext, getName().c_str(), value, AV_OPT_SEARCH_CHILDREN );
162-
if( error != 0 )
162+
if( ! error )
163163
{
164164
std::ostringstream os;
165165
os << value;
@@ -172,7 +172,7 @@ void Option::setValueDouble( const double value )
172172
void Option::setValueString( const std::string& value )
173173
{
174174
int error = av_opt_set( _avContext, getName().c_str(), value.c_str(), AV_OPT_SEARCH_CHILDREN );
175-
if( error != 0 )
175+
if( ! error )
176176
{
177177
char err[AV_ERROR_MAX_STRING_SIZE];
178178
av_strerror( error, err, AV_ERROR_MAX_STRING_SIZE );

src/AvTranscoder/option/Option.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class Option
7171
void setValueString( const std::string& value );
7272

7373
// array of childs
74-
bool hasChild() const { return ! _childOptions.empty(); }
75-
const std::vector<Option>& getChilds() { return _childOptions; }
74+
bool hasChild() const { return _childOptions.size(); }
75+
const std::vector<Option>& getChilds() const { return _childOptions; }
7676
const Option& getChildAtIndex( const size_t index ) const { return _childOptions.at( index ); }
7777
int getDefaultChildIndex() const { return _defaultChildIndex; }
7878

0 commit comments

Comments
 (0)