URL:
  <http://gna.org/patch/?1139>

                 Summary: class config: change non-const operator[] to return
a proxy class
                 Project: Battle for Wesnoth
            Submitted by: None
            Submitted on: Monday 03/23/2009 at 15:18 CET
                Priority: 4
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: [email protected]
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

The motivation for this change is to move away from returning t_string&s that
point directly into the storage map to allow different, more memory-efficient
storage later.

Notes on the changes:
    *  Some places store return values in t_string&. The idea is to change
these to config::proxy_string, as that type should ideally behave like
t_string&.
    * config::proxy_string can cast to both std::string and t_string. 

The first is necessary as t_string can cast to it as well; the second is
necessary to support use of a config::proxy_string where a const t_string& is
expected. Unfortunately, this introduces an ambiguity in cases where a
config::proxy_string is passed to methods that can take either of std::string
or t_string. The ambiguity was solved in some places by using .str(). It would
also go away when proxy_string operator[] is removed.

    * the variables_set class has a member (get_variable_const()) that
returns a t_string&. game_state descends from this class; it's
get_variable_const() implementation supposedly returns a value from a config.
To ensure the ref is valid, the value as a t_string is stored in a map. This
is clearly not ideal. 



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Monday 03/23/2009 at 15:18 CET  Name: config_string_proxy.diff  Size:
13kB   By: None

<http://gna.org/patch/download.php?file_id=5493>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?1139>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to