On Wednesday, May 6, 2015 at 3:53:03 PM UTC-4, Henner Zeller wrote:
>
> On 6 May 2015 at 06:29, rhlake <rhl...@comcast.net <javascript:>> wrote:
>
>> I have the following message definition in a proto file which is causing 
>> a *serialization error*:
>>  
>>  
>> message   Request {
>>  
>>          repeated          LanguageType              LanguageList = 1;
>> }
>>  
>>  
>> enum     LanguageType   {
>>  
>>               English = 0;
>>               German = 1;
>>               Spanish = 2;
>> }
>>  
>>  
>> *If I make the following change:*
>>  
>>  
>> message   Request {
>>  
>>          repeated          LanguageTypeList              
>> LanguageListParam = 1;
>> }
>>  
>>  
>> message   LanguageTypeList  {
>>  
>>          optional         LanguageType              LanguageList = 1;
>> }
>>  
>> enum     LanguageType   {
>>  
>>               English = 0;
>>               German = 1;
>>               Spanish = 2;
>> }
>>  
>>  
>> can anyone explain what is happening?  does *repeated* *NOT WORK* with* 
>> enums*?
>>
>
> Repeated does work with enums.
>
> Can you give a bit more context, e.g. what is the language you are 
> creating code for, and what exactly does the "serialization error" manifest 
> (error message or error code).
>
> How do you serialize and deserialize the data ? A common problem is to not 
> deal with NUL bytes properly in the stream, i.e. if you interpret something 
> as a NUL-terminated C-string somewhere in the process it might look like a 
> too short buffer.
>
> -h
>
 
 
Version:   C++ / 2.5.0 version
 
Error:

1.       level_         LOGLEVEL_FATAL (3)           
google::protobuf::LogLevel

2.       filename_                  "d:\\svn\\lg_radiosimulator\\01. 
src\\gpb_lib\\src\\component\\protocal\\src\\google\\protobuf\\repeated_field.h"
       


3.       line_           625

4.       message_                  "CHECK failed: (index) < (size())

 
 Trace:

1.  GeneratedMessageReflection::SetRepeatedEnum

2.  void GeneratedMessageReflection::SetRepeatedEnum(

3.      Message* message,

4.      const FieldDescriptor* field, int index,

5.      const EnumValueDescriptor* value) const {

6.    USAGE_CHECK_ALL(SetRepeatedEnum, REPEATED, ENUM);

7.    USAGE_CHECK_ENUM_VALUE(SetRepeatedEnum);

8.    if (field->is_extension()) {    
MutableExtensionSet(message)->SetRepeatedEnum(

9.        field->number(), index, value->number());

10.   } else {

11.       SetRepeatedField<int>(message, field, index, 
value->number());        ß---- 

12.   }

 

template <typename Type>

inline void GeneratedMessageReflection::SetRepeatedField(

    Message* message, const FieldDescriptor* field,

    int index, Type value) const {

  MutableRaw<RepeatedField<Type> >(message, field)->Set(index, value);     ß--- 
Set.

}

 

template <typename Element>

inline void RepeatedField<Element>::Set(int index, const Element& value) {

  GOOGLE_DCHECK_LT(index, size());                                          
ß---- Error happens.

  elements_[index] = value;
 
 
Thank You

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to