0
message HealthOccurrenceCount
{
    required int64 HealthID=1; 
    required int32 OccCount=2; 
    optional bytes wci=3;
}

I would like to add data based on HealthID; If HealthID is already entered then instead of adding a new entry, the program should instead just increment the existing entry's OccCount.

HealthOccurrenceCount objHelthOccCount;
if(objHelthOccCount.healthid() == healthID) // Is this right or do I need to iterate all the nodes?
{
    occCount++;  
    objHelthOccCount.set_occcount(occCount);  
}
else       
    occCount = 1;   

Is this code correct or I should convert HealthID into string?

Generated Code:

// required int64 HealthID = 1;
inline bool has_healthid() const;
inline void clear_healthid();
static const int kHealthIDFieldNumber = 1;
inline ::google::protobuf::int64 healthid() const;
inline void set_healthid(::google::protobuf::int64 value);
Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Sijith
  • 3,740
  • 17
  • 61
  • 101
  • 2
    possible duplicate of [PROTOBUFF INT64 check aganist previously entered data c++](http://stackoverflow.com/questions/32184021/protobuff-int64-check-aganist-previously-entered-data-c) – psv Aug 28 '15 at 11:24

1 Answers1

0
HealthOccurrenceCount objHelthOccCount;
if(objHelthOccCount.has_healthid())
{
    occCount++;  
    objHelthOccCount.set_occcount(occCount);  
}
else       
    occCount = 1;   
psv
  • 688
  • 6
  • 19