And another question about Decode::Read

Former Member
Former Member

Why is there no consistency in the stream arguments to Decode::Read ?

grep "Decode::Read(" fit_decode.* :-
fit_decode.cpp:FIT_BOOL Decode::Read(std::istream* file)
fit_decode.cpp:FIT_BOOL Decode::Read(std::istream &file, MesgListener& mesgListener)
fit_decode.cpp:FIT_BOOL Decode::Read(std::istream &file, MesgListener& mesgListener, MesgDefinitionListener& mesgDefinitionListener)

IsFIT and CheckIntegrity both use std::istream &file :-

fit_decode.cpp:FIT_BOOL Decode::IsFIT(std::istream &file)

fit_decode.cpp:FIT_BOOL Decode::CheckIntegrity(std::istream &file)

These little inconsistencies make following the documentation more difficult than it needs to be.

  • Former Member
    0 Former Member

    And I forgot to add :-

    make justread
    g++ -std=c++11 -Wall -I ../include -I ../include/fitsdk -o justread justread.c++ -L../lib -lgarminfit
    In file included from justread.c++:17:0:
    ../include/fitsdk/fit_decode.hpp: In function ‘int main(int, char**)’:
    ../include/fitsdk/fit_decode.hpp:221:14: error: ‘FIT_BOOL fit::Decode::Read(std::istream*)’ is private
    FIT_BOOL Read(std::istream* file);
    ^
    justread.c++:37:26: error: within this context
    decoder.Read(& fitStream);
    ^
    make: *** [justread] Error 1

    Why is Decode::Read private ?

  • The method signatures are consistent across the public methods. Read(std::stream *file) is a private method, so there is some leeway on what its signature can be. 

    Decoding a FIT file with the C++ SDK requires more than input stream. The caller also needs to provide messages listeners to receive the data, which is why there are multiple overloaded public Read() methods.

    The example C++ Decode shows how to setup the message listeners and use them with the Read() methods.
    developer.garmin.com/.../