Skip to main content

Topic: FB2K_STREAM_READER/WRITER_OVERLOAD for enum and lists (Read 969 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • K_S
  • [*]
FB2K_STREAM_READER/WRITER_OVERLOAD for enum and lists
Hi

I have two problems with FB2K_STREAM_WRITER_OVERLOAD/FB2K_READER_WRITER_OVERLOAD

1. I want to save/read enums. Is this correct way?:

Code: [Select]
enum action_type{NEW=0/**/};

FB2K_STREAM_WRITER_OVERLOAD(action_type){
    unsigned char temp = value;
    return stream << temp;
}
FB2K_STREAM_READER_OVERLOAD(action_type){
    unsigned char temp;
    stream >> temp;
    value = static_cast<action_type>(temp);
    return stream;
}


2. I have short arrays in cfg_vars and don't know how to save/read them. For example pfc::list_t<query_field> (query_field it's simple class with his own FB2K_STREAM reader/writer).

I think WRITER can (?) looks like that:

Code: [Select]
FB2K_STREAM_WRITER_OVERLOAD(pfc::list_t<query_field>){
    for (unsigned i = 0; i<value.get_count();i++)
        stream << value.get_item(i);
    return stream;
}


But READER? Maybe there is better way? stream has stream.read_array() and stream.write_array(), but I don't know how to use those methods.