The Battle for Wesnoth  1.15.2+dev
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
image::locator Class Reference

#include <picture.hpp>

Classes

struct  value
 

Public Types

enum  type { NONE, FILE, SUB_FILE }
 
typedef std::unordered_map< value, int > locator_finder_t
 

Public Member Functions

 locator ()
 
 locator (const locator &a, const std::string &mods="")
 
 locator (const char *filename)
 
 locator (const std::string &filename)
 
 locator (const std::string &filename, const std::string &modifications)
 
 locator (const std::string &filename, const map_location &loc, int center_x, int center_y, const std::string &modifications="")
 
locatoroperator= (const locator &a)
 
bool operator== (const locator &a) const
 
bool operator!= (const locator &a) const
 
bool operator< (const locator &a) const
 
const std::string & get_filename () const
 
bool is_data_uri () const
 
const map_locationget_loc () const
 
int get_center_x () const
 
int get_center_y () const
 
const std::string & get_modifications () const
 
type get_type () const
 
bool is_void () const
 
bool file_exists () const
 Tests whether the file the locater points at exists. More...
 
template<typename T >
bool in_cache (cache_type< T > &cache) const
 
template<typename T >
T & access_in_cache (cache_type< T > &cache) const
 
template<typename T >
const T & locate_in_cache (cache_type< T > &cache) const
 
template<typename T >
void add_to_cache (cache_type< T > &cache, const T &data) const
 

Private Member Functions

void init_index ()
 
void parse_arguments ()
 

Private Attributes

int index_
 
value val_
 

Friends

struct std::hash< value >
 

Detailed Description

Definition at line 33 of file picture.hpp.

Member Typedef Documentation

◆ locator_finder_t

typedef std::unordered_map<value, int> image::locator::locator_finder_t

Definition at line 65 of file picture.hpp.

Member Enumeration Documentation

◆ type

Enumerator
NONE 
FILE 
SUB_FILE 

Definition at line 36 of file picture.hpp.

Constructor & Destructor Documentation

◆ locator() [1/6]

image::locator::locator ( )

Definition at line 291 of file picture.cpp.

◆ locator() [2/6]

image::locator::locator ( const locator a,
const std::string &  mods = "" 
)

◆ locator() [3/6]

image::locator::locator ( const char *  filename)

Definition at line 310 of file picture.cpp.

References init_index(), and parse_arguments().

◆ locator() [4/6]

image::locator::locator ( const std::string &  filename)

Definition at line 318 of file picture.cpp.

References init_index(), and parse_arguments().

◆ locator() [5/6]

image::locator::locator ( const std::string &  filename,
const std::string &  modifications 
)

Definition at line 326 of file picture.cpp.

References init_index().

◆ locator() [6/6]

image::locator::locator ( const std::string &  filename,
const map_location loc,
int  center_x,
int  center_y,
const std::string &  modifications = "" 
)

Definition at line 333 of file picture.cpp.

References init_index().

Member Function Documentation

◆ access_in_cache()

template<typename T >
T & image::locator::access_in_cache ( cache_type< T > &  cache) const

Definition at line 138 of file picture.cpp.

References dummy, and image::cache_type< T >::get_element().

Referenced by image::get_lighted_image(), and is_void().

◆ add_to_cache()

template<typename T >
void image::locator::add_to_cache ( cache_type< T > &  cache,
const T &  data 
) const

◆ file_exists()

bool image::locator::file_exists ( ) const

Tests whether the file the locater points at exists.

is_void doesn't seem to work before the image is loaded and also in debug mode a placeholder is returned. So it's not possible to test for the existence of a file. So this function does that. (Note it tests for existence not whether or not it's a valid image.)

Returns
Whether or not the file exists.

Definition at line 662 of file picture.cpp.

References image::locator::value::filename_, filesystem::get_binary_file_location(), image::locator::value::is_data_uri_, and val_.

Referenced by adjust_profile(), attack_info(), intf_get_image_size(), is_void(), and gui2::unit_preview_pane::print_attack_details().

◆ get_center_x()

int image::locator::get_center_x ( ) const
inline

◆ get_center_y()

int image::locator::get_center_y ( ) const
inline

◆ get_filename()

const std::string& image::locator::get_filename ( ) const
inline

◆ get_loc()

const map_location& image::locator::get_loc ( ) const
inline

◆ get_modifications()

const std::string& image::locator::get_modifications ( ) const
inline

Definition at line 89 of file picture.hpp.

References image::locator::value::modifications_, and val_.

Referenced by add_simple_anim(), and image::load_image_sub_file().

◆ get_type()

type image::locator::get_type ( ) const
inline

Definition at line 90 of file picture.hpp.

References image::locator::value::type_, and val_.

Referenced by image::exists(), and image::load_from_disk().

◆ in_cache()

template<typename T >
bool image::locator::in_cache ( cache_type< T > &  cache) const

◆ init_index()

void image::locator::init_index ( )
private

Definition at line 251 of file picture.cpp.

References i, and val_.

Referenced by locator().

◆ is_data_uri()

bool image::locator::is_data_uri ( ) const
inline

Definition at line 85 of file picture.hpp.

References image::locator::value::is_data_uri_, and val_.

Referenced by image::exists(), and image::load_from_disk().

◆ is_void()

bool image::locator::is_void ( ) const
inline

◆ locate_in_cache()

template<typename T >
const T & image::locator::locate_in_cache ( cache_type< T > &  cache) const

◆ operator!=()

bool image::locator::operator!= ( const locator a) const
inline

Definition at line 81 of file picture.hpp.

References index_.

◆ operator<()

bool image::locator::operator< ( const locator a) const
inline

Definition at line 82 of file picture.hpp.

References index_.

◆ operator=()

locator & image::locator::operator= ( const locator a)

Definition at line 344 of file picture.cpp.

References index_, and val_.

◆ operator==()

bool image::locator::operator== ( const locator a) const
inline

Definition at line 80 of file picture.hpp.

References index_.

◆ parse_arguments()

void image::locator::parse_arguments ( )
private

Definition at line 263 of file picture.cpp.

References ERR_DP, utils::basic_string_view< charT, traits >::substr(), and val_.

Referenced by locator().

Friends And Related Function Documentation

◆ std::hash< value >

friend struct std::hash< value >
friend

Definition at line 61 of file picture.hpp.

Member Data Documentation

◆ index_

int image::locator::index_
private

Definition at line 120 of file picture.hpp.

Referenced by locator(), operator!=(), operator<(), operator=(), and operator==().

◆ val_

value image::locator::val_
private

The documentation for this class was generated from the following files: