add resolved_as_cstring() method to State classes
authorJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 6 Sep 2002 00:40:30 +0000 (00:40 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 6 Sep 2002 00:40:30 +0000 (00:40 +0000)
include/FLAC++/decoder.h
include/FLAC++/encoder.h
src/libFLAC++/file_decoder.cc
src/libFLAC++/file_encoder.cc
src/libFLAC++/seekable_stream_decoder.cc
src/libFLAC++/seekable_stream_encoder.cc
src/libFLAC++/stream_decoder.cc
src/libFLAC++/stream_encoder.cc

index 52316a0..bd18625 100644 (file)
@@ -81,6 +81,7 @@ namespace FLAC {
                                inline State(::FLAC__StreamDecoderState state): state_(state) { }
                                inline operator ::FLAC__StreamDecoderState() const { return state_; }
                                inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
+                               const char *resolved_as_cstring(const Stream &) const;
                        protected:
                                ::FLAC__StreamDecoderState state_;
                        };
@@ -166,6 +167,7 @@ namespace FLAC {
                                inline State(::FLAC__SeekableStreamDecoderState state): state_(state) { }
                                inline operator ::FLAC__SeekableStreamDecoderState() const { return state_; }
                                inline const char *as_cstring() const { return ::FLAC__SeekableStreamDecoderStateString[state_]; }
+                               const char *resolved_as_cstring(const SeekableStream &) const;
                        protected:
                                ::FLAC__SeekableStreamDecoderState state_;
                        };
@@ -260,6 +262,7 @@ namespace FLAC {
                                inline State(::FLAC__FileDecoderState state): state_(state) { }
                                inline operator ::FLAC__FileDecoderState() const { return state_; }
                                inline const char *as_cstring() const { return ::FLAC__FileDecoderStateString[state_]; }
+                               const char *resolved_as_cstring(const File &) const;
                        protected:
                                ::FLAC__FileDecoderState state_;
                        };
index 90aafad..26bfe6e 100644 (file)
@@ -82,6 +82,7 @@ namespace FLAC {
                                inline State(::FLAC__StreamEncoderState state): state_(state) { }
                                inline operator ::FLAC__StreamEncoderState() const { return state_; }
                                inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
+                               const char *resolved_as_cstring(const Stream &) const;
                        protected:
                                ::FLAC__StreamEncoderState state_;
                        };
@@ -174,6 +175,7 @@ namespace FLAC {
                                inline State(::FLAC__SeekableStreamEncoderState state): state_(state) { }
                                inline operator ::FLAC__SeekableStreamEncoderState() const { return state_; }
                                inline const char *as_cstring() const { return ::FLAC__SeekableStreamEncoderStateString[state_]; }
+                               const char *resolved_as_cstring(const SeekableStream &) const;
                        protected:
                                ::FLAC__SeekableStreamEncoderState state_;
                        };
@@ -267,6 +269,7 @@ namespace FLAC {
                                inline State(::FLAC__FileEncoderState state): state_(state) { }
                                inline operator ::FLAC__FileEncoderState() const { return state_; }
                                inline const char *as_cstring() const { return ::FLAC__FileEncoderStateString[state_]; }
+                               const char *resolved_as_cstring(const File &) const;
                        protected:
                                ::FLAC__FileEncoderState state_;
                        };
index e574cb3..9d84f20 100644 (file)
 namespace FLAC {
        namespace Decoder {
 
+               const char *File::State::resolved_as_cstring(const File &decoder) const
+               {
+                       if(state_ == ::FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR) {
+                               FLAC::Decoder::SeekableStream::State state__ = decoder.get_seekable_stream_decoder_state();
+                               if(state__ == ::FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR)
+                                       return decoder.get_stream_decoder_state().as_cstring();
+                               else
+                                       return state__.as_cstring();
+                       }
+                       else
+                               return as_cstring();
+               }
+
                File::File():
                decoder_(::FLAC__file_decoder_new())
                { }
index b95186b..f430b4a 100644 (file)
 namespace FLAC {
        namespace Encoder {
 
+               const char *File::State::resolved_as_cstring(const File &encoder) const
+               {
+                       if(state_ == ::FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR) {
+                               FLAC::Encoder::SeekableStream::State state__ = encoder.get_seekable_stream_encoder_state();
+                               if(state__ == ::FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR) {
+                                       FLAC::Encoder::Stream::State state___ = encoder.get_stream_encoder_state();
+                                       if(state___ == ::FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR)
+                                               return encoder.get_verify_decoder_state().as_cstring();
+                                       else
+                                               return state___.as_cstring();
+                               }
+                               else
+                                       return state__.as_cstring();
+                       }
+                       else
+                               return as_cstring();
+               }
+
                File::File():
                encoder_(::FLAC__file_encoder_new())
                { }
index 84fdb73..b2bf344 100644 (file)
 namespace FLAC {
        namespace Decoder {
 
+               const char *SeekableStream::State::resolved_as_cstring(const SeekableStream &decoder) const
+               {
+                       if(state_ == ::FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR)
+                               return decoder.get_stream_decoder_state().as_cstring();
+                       else
+                               return as_cstring();
+               }
+
                SeekableStream::SeekableStream():
                decoder_(::FLAC__seekable_stream_decoder_new())
                { }
index 2ee432f..66aa4a6 100644 (file)
 namespace FLAC {
        namespace Encoder {
 
+               const char *SeekableStream::State::resolved_as_cstring(const SeekableStream &encoder) const
+               {
+                       if(state_ == ::FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR) {
+                               FLAC::Encoder::Stream::State state__ = encoder.get_stream_encoder_state();
+                               if(state__ == ::FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR)
+                                       return encoder.get_verify_decoder_state().as_cstring();
+                               else
+                                       return state__.as_cstring();
+                       }
+                       else
+                               return as_cstring();
+               }
+
+
                SeekableStream::SeekableStream():
                encoder_(::FLAC__seekable_stream_encoder_new())
                { }
index 6f2887c..ca1fe0b 100644 (file)
 namespace FLAC {
        namespace Decoder {
 
+               const char *Stream::State::resolved_as_cstring(const Stream &) const
+               {
+                       return as_cstring();
+               }
+
                Stream::Stream():
                decoder_(::FLAC__stream_decoder_new())
                { }
index e8a6a68..b4bb590 100644 (file)
 namespace FLAC {
        namespace Encoder {
 
+               const char *Stream::State::resolved_as_cstring(const Stream &encoder) const
+               {
+                       if(state_ == ::FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR)
+                               return encoder.get_verify_decoder_state().as_cstring();
+                       else
+                               return as_cstring();
+               }
+
                Stream::Stream():
                encoder_(::FLAC__stream_encoder_new())
                { }