IPB

Welcome Guest ( Log In | Register )

> foobar2000 Development Forum Rules

This forum is for developer discussions only. If you have a problem / bug report / idea / feature request that isn't related to foobar2000 SDK, post it in an appropiate forum instead - tech support questions go to support forum, everything else goes to general forum.
All non-developer posts on this forum will be removed. Continued abuse of this forum will result in admin actions (warnings, account suspension).

 
Reply to this topicStart new topic
FB2K_STREAM_READER/WRITER_OVERLOAD for enum and lists
K_S
post Mar 25 2012, 10:08
Post #1





Group: Members
Posts: 25
Joined: 14-September 11
Member No.: 93700



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
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
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.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 30th August 2014 - 16:11