Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FB2K_STREAM_READER/WRITER_OVERLOAD for enum and lists (Read 1614 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

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.