The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Enumerations | Functions | Variables
validation.hpp File Reference
#include <vector>
#include <string>
Include dependency graph for validation.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  ADDON_TYPE {
  ADDON_UNKNOWN, ADDON_CORE, ADDON_SP_CAMPAIGN, ADDON_SP_SCENARIO,
  ADDON_SP_MP_CAMPAIGN, ADDON_MP_CAMPAIGN, ADDON_MP_SCENARIO, ADDON_MP_MAPS,
  ADDON_MP_ERA, ADDON_MP_FACTION, ADDON_MP_MOD, ADDON_MEDIA,
  ADDON_OTHER, ADDON_TYPES_COUNT
}
 Values used for add-on classification; UI-only at the moment, in the future it could be used for directory allocation too, removing the need for the ADDON_GROUP constants (TODO). More...
 

Functions

ADDON_TYPE get_addon_type (const std::string &str)
 
std::string get_addon_type_string (ADDON_TYPE type)
 
bool addon_name_legal (const std::string &name)
 Checks whether an add-on id/name is legal or not. More...
 
bool addon_filename_legal (const std::string &name)
 Checks whether an add-on file name is legal or not. More...
 
bool check_names_legal (const config &dir, std::vector< std::string > *badlist=nullptr)
 Scans an add-on archive for illegal names. More...
 
bool check_case_insensitive_duplicates (const config &dir, std::vector< std::string > *badlist=nullptr)
 Scans an add-on archive for case-conflicts. More...
 
std::string encode_binary (const std::string &str)
 
std::string unencode_binary (const std::string &str)
 
bool needs_escaping (char c)
 

Variables

const unsigned short default_campaignd_port
 Default port number for the addon server. More...
 

Enumeration Type Documentation

enum ADDON_TYPE

Values used for add-on classification; UI-only at the moment, in the future it could be used for directory allocation too, removing the need for the ADDON_GROUP constants (TODO).

Note
If you change the order or content of these, you'll also need to update the addon_type_strings table found in validation.cpp.
Enumerator
ADDON_UNKNOWN 

a.k.a.

anything.

ADDON_CORE 

Total Conversion Core.

ADDON_SP_CAMPAIGN 

Single-player campaign.

ADDON_SP_SCENARIO 

Single-player scenario.

ADDON_SP_MP_CAMPAIGN 

Hybrid campaign.

ADDON_MP_CAMPAIGN 

Multiplayer campaign.

ADDON_MP_SCENARIO 

Multiplayer scenario.

ADDON_MP_MAPS 

Multiplayer plain (no WML) map pack.

ADDON_MP_ERA 

Multiplayer era.

ADDON_MP_FACTION 

Multiplayer faction.

ADDON_MP_MOD 

Modification of the game for MP.

ADDON_MEDIA 

Miscellaneous content/media (unit packs, terrain packs, music packs, etc.).

ADDON_OTHER 

an add-on that fits in no other category

ADDON_TYPES_COUNT 

Definition at line 40 of file validation.hpp.

Function Documentation

bool addon_filename_legal ( const std::string &  name)

Checks whether an add-on file name is legal or not.

Definition at line 90 of file validation.cpp.

References name(), and unicode_cast().

Referenced by BOOST_AUTO_TEST_CASE().

bool addon_name_legal ( const std::string &  name)

Checks whether an add-on id/name is legal or not.

Definition at line 80 of file validation.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), campaignd::server::handle_upload(), and addons_client::upload_addon().

bool check_case_insensitive_duplicates ( const config dir,
std::vector< std::string > *  badlist = nullptr 
)

Scans an add-on archive for case-conflicts.

Case conflicts may cause trouble on case-insensitive filesystems.

Parameters
dirThe WML container for the root [dir] node where the search should begin.
badlistIf provided and not null, any case conflicts encountered will be added to this list. This also makes the archive scan more thorough instead of returning on the first conflict encountered.
Returns
True if no conflicts were found.

Definition at line 207 of file validation.cpp.

Referenced by campaignd::server::handle_upload(), addons_client::install_addon(), and addons_client::upload_addon().

bool check_names_legal ( const config dir,
std::vector< std::string > *  badlist = nullptr 
)

Scans an add-on archive for illegal names.

Parameters
dirThe WML container for the root [dir] node where the search should begin.
badlistIf provided and not null, any illegal names encountered will be added to this list. This also makes the archive scan more thorough instead of returning on the first illegal name encountered.
Returns
True if no illegal names were found.

Definition at line 198 of file validation.cpp.

Referenced by campaignd::server::handle_upload(), addons_client::install_addon(), and addons_client::upload_addon().

std::string encode_binary ( const std::string &  str)

Definition at line 249 of file validation.cpp.

References n, and needs_escaping().

Referenced by archive_file(), and BOOST_AUTO_TEST_CASE().

ADDON_TYPE get_addon_type ( const std::string &  str)

Definition at line 211 of file validation.cpp.

References ADDON_TYPES_COUNT, and ADDON_UNKNOWN.

Referenced by campaignd::server::handle_upload(), and addon_info::read().

std::string get_addon_type_string ( ADDON_TYPE  type)

Definition at line 227 of file validation.cpp.

References ADDON_TYPES_COUNT.

Referenced by addon_info::write(), and addon_info::write_minimal().

bool needs_escaping ( char  c)

Definition at line 237 of file validation.cpp.

Referenced by encode_binary().

std::string unencode_binary ( const std::string &  str)

Definition at line 267 of file validation.cpp.

References n.

Referenced by BOOST_AUTO_TEST_CASE(), and unarchive_file().

Variable Documentation

const unsigned short default_campaignd_port

Default port number for the addon server.

Note
This might not be the best place to declare the variable, but it's one of the few files shared by the server and the game.

Definition at line 24 of file validation.cpp.

Referenced by addons_client::addons_client(), and campaignd::server::load_config().