DeveloperFieldDefinition in C++ sdk should implement operator= to do a deep copy

Former Member
Former Member

To let the following code work correctly, DeveloperFieldDefinition in C++ sdk  should implement operator= to do a deep copy.

//MesgDefinition& mesgDef
//And MesgDefinition has a member: std::vector<DeveloperFieldDefinition> devFields
lastMesgDefinition[mesgDef.GetLocalNum()] = mesgDef;




DeveloperFieldDefinition& DeveloperFieldDefinition::operator=(const DeveloperFieldDefinition& other){
    if (this != &other){
        num = other.num;
        size = other.size;
        developerDataIndex = other.developerDataIndex;
        if (mesg != nullptr){
            delete mesg;
            mesg = nullptr;
        }

        if (other.mesg != nullptr) {
            mesg = new FieldDescriptionMesg(*other.mesg);
        }
        
        if (developer != nullptr){
            delete developer;
            developer = nullptr;
        }

        if (other.developer != nullptr){
            developer = new DeveloperDataIdMesg( *other.developer );
        }
    }
    return *this;
}

  • This issue is on our list of things to investigate, but right now there is no ETA. We will let you know when we start looking into this.

  • Former Member
    Former Member over 4 years ago in reply to Ben FIT

    ok

  • The operator=() that was missing from the DeveloperFieldDefinition class was added to version 21.47 of the FIT C++ SDK. The C++ DeveloperFieldDefinition class is used by the FIT Objective-C++ SDK as well, so the issue should be resolved in that SDK too. The example C++ encode project was also updated to provide a better example of how to use Developer Fields in the C++ SDK. Let us know if you run into any issues with this change.