Skip to content

Commit 6c91e7a

Browse files
author
Clement Champetier
committed
Option: update getters
* Use constant member functions as much as possible. * Return const elements when getting sub options of a Group or a Choice.
1 parent d011d69 commit 6c91e7a

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/AvTranscoder/Option.hpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ class Option
4343
~Option() {}
4444

4545
OptionType getType() const;
46-
const std::string getName() { return std::string( m_avOption.name ? m_avOption.name : "" ); }
47-
const std::string getHelp() { return std::string( m_avOption.help ? m_avOption.help : "" ); }
48-
const std::string getUnit() { return std::string( m_avOption.unit ? m_avOption.unit : "" ); }
46+
std::string getName() const { return std::string( m_avOption.name ? m_avOption.name : "" ); }
47+
std::string getHelp() const { return std::string( m_avOption.help ? m_avOption.help : "" ); }
48+
std::string getUnit() const { return std::string( m_avOption.unit ? m_avOption.unit : "" ); }
49+
int getOffset() const { return m_avOption.offset; }
4950

5051
// flags
51-
int getFlags() { return m_avOption.flags; }
52-
bool isEncodingOpt(){ return m_avOption.flags & AV_OPT_FLAG_ENCODING_PARAM; }
53-
bool isDecodingOpt(){ return m_avOption.flags & AV_OPT_FLAG_DECODING_PARAM; }
54-
bool isAudioOpt(){ return m_avOption.flags & AV_OPT_FLAG_AUDIO_PARAM; }
55-
bool isVideoOpt(){ return m_avOption.flags & AV_OPT_FLAG_VIDEO_PARAM; }
56-
bool isSubtitleOpt(){ return m_avOption.flags & AV_OPT_FLAG_SUBTITLE_PARAM; }
52+
int getFlags() const { return m_avOption.flags; }
53+
bool isEncodingOpt() const { return m_avOption.flags & AV_OPT_FLAG_ENCODING_PARAM; }
54+
bool isDecodingOpt() const { return m_avOption.flags & AV_OPT_FLAG_DECODING_PARAM; }
55+
bool isAudioOpt() const { return m_avOption.flags & AV_OPT_FLAG_AUDIO_PARAM; }
56+
bool isVideoOpt() const { return m_avOption.flags & AV_OPT_FLAG_VIDEO_PARAM; }
57+
bool isSubtitleOpt() const { return m_avOption.flags & AV_OPT_FLAG_SUBTITLE_PARAM; }
5758

5859
// default value
5960
bool getDefaultValueBool() const;
@@ -63,11 +64,12 @@ class Option
6364
std::pair<int, int> getDefaultValueRatio() const;
6465

6566
// array of childs
66-
bool hasChild() { return ! m_options.empty(); }
67-
std::vector<Option> getChilds() { return m_options; }
68-
Option& getChild( size_t index ) { return m_options.at( index ); }
69-
size_t getNbChilds() { return m_options.size(); }
67+
bool hasChild() const { return ! m_options.empty(); }
68+
const std::vector<Option>& getChilds() { return m_options; }
69+
const Option& getChild( size_t index ) { return m_options.at( index ); }
70+
size_t getNbChilds() const { return m_options.size(); }
7071
int getDefaultChildIndex() const { return m_defaultChildIndex; }
72+
7173
void setDefaultChildIndex( size_t index ) { m_defaultChildIndex = index; }
7274
void appendChild( const Option& child );
7375

0 commit comments

Comments
 (0)