TrinityCore
Loading...
Searching...
No Matches
Util.h File Reference
#include "Define.h"
#include "Errors.h"
#include "Optional.h"
#include <array>
#include <string>
#include <string_view>
#include <sstream>
#include <typeinfo>
#include <utility>
#include <vector>
+ Include dependency graph for Util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  WcharToUpper
 
struct  WcharToUpperOnlyLatin
 
struct  WcharToLower
 
struct  CharToUpper
 
struct  CharToLower
 
struct  StringCompareLessI_T
 
class  HookList< T >
 
class  flag96
 

Namespaces

namespace  Trinity
 
namespace  Trinity::Impl
 

Enumerations

enum class  TimeFormat : uint8 { FullText , ShortText , Numeric }
 
enum  ComparisionType {
  COMP_TYPE_EQ = 0 , COMP_TYPE_HIGH , COMP_TYPE_LOW , COMP_TYPE_HIGH_EQ ,
  COMP_TYPE_LOW_EQ , COMP_TYPE_MAX
}
 

Functions

TC_COMMON_API void Trinity::VerifyOsVersion ()
 
TC_COMMON_API std::vector< std::string_view > Trinity::Tokenize (std::string_view str, char sep, bool keepEmpty)
 
std::vector< std::string_view > Trinity::Tokenize (std::string &&, char, bool)=delete
 
std::vector< std::string_view > Trinity::Tokenize (std::string const &&, char, bool)=delete
 
std::vector< std::string_view > Trinity::Tokenize (char const *str, char sep, bool keepEmpty)
 
TC_COMMON_API Optional< int32 > MoneyStringToMoney (std::string const &moneyString)
 
TC_COMMON_API time_t GetLocalHourTimestamp (time_t time, uint8 hour, bool onlyAfterTime=true)
 
TC_COMMON_API tm TimeBreakdown (time_t t)
 
TC_COMMON_API std::string secsToTimeString (uint64 timeInSecs, TimeFormat timeFormat=TimeFormat::FullText, bool hoursOnly=false)
 
TC_COMMON_API uint32 TimeStringToSecs (std::string const &timestring)
 
TC_COMMON_API std::string TimeToTimestampStr (time_t t)
 
TC_COMMON_API std::string TimeToHumanReadable (time_t t)
 
template<class T , class U >
T CalculatePct (T base, U pct)
 
template<class T , class U >
T AddPct (T &base, U pct)
 
template<class T , class U >
T ApplyPct (T &base, U pct)
 
template<class T >
T RoundToInterval (T &num, T floor, T ceil)
 
template<class T >
T square (T x)
 
TC_COMMON_API bool Utf8toWStr (std::string_view utf8str, std::wstring &wstr)
 
TC_COMMON_API bool Utf8toWStr (char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
 
bool Utf8toWStr (std::string_view utf8str, wchar_t *wstr, size_t &wsize)
 
TC_COMMON_API bool WStrToUtf8 (std::wstring_view wstr, std::string &utf8str)
 
TC_COMMON_API bool WStrToUtf8 (wchar_t const *wstr, size_t size, std::string &utf8str)
 
TC_COMMON_API size_t utf8length (std::string &utf8str)
 
TC_COMMON_API void utf8truncate (std::string &utf8str, size_t len)
 
bool isBasicLatinCharacter (wchar_t wchar)
 
bool isExtendedLatinCharacter (wchar_t wchar)
 
bool isCyrillicCharacter (wchar_t wchar)
 
bool isEastAsianCharacter (wchar_t wchar)
 
bool isNumeric (wchar_t wchar)
 
bool isNumeric (char c)
 
bool isNumeric (char const *str)
 
bool isNumericOrSpace (wchar_t wchar)
 
bool isBasicLatinString (std::wstring_view wstr, bool numericOrSpace)
 
bool isExtendedLatinString (std::wstring_view wstr, bool numericOrSpace)
 
bool isCyrillicString (std::wstring_view wstr, bool numericOrSpace)
 
bool isEastAsianString (std::wstring_view wstr, bool numericOrSpace)
 
TC_COMMON_API void wstrToUpper (std::wstring &str)
 
TC_COMMON_API void wstrToLower (std::wstring &str)
 
TC_COMMON_API void strToUpper (std::string &str)
 
TC_COMMON_API void strToLower (std::string &str)
 
TC_COMMON_API std::wstring GetMainPartOfName (std::wstring const &wname, uint32 declension)
 
TC_COMMON_API bool utf8ToConsole (std::string_view utf8str, std::string &conStr)
 
TC_COMMON_API bool consoleToUtf8 (std::string_view conStr, std::string &utf8str)
 
TC_COMMON_API bool Utf8FitTo (std::string_view str, std::wstring_view search)
 
TC_COMMON_API void utf8printf (FILE *out, const char *str,...)
 
TC_COMMON_API void vutf8printf (FILE *out, const char *str, va_list *ap)
 
TC_COMMON_API bool Utf8ToUpperOnlyLatin (std::string &utf8String)
 
TC_COMMON_API bool ReadWinConsole (std::string &str, size_t size=256)
 
TC_COMMON_API bool WriteWinConsole (std::string_view str, bool error=false)
 
TC_COMMON_API Optional< std::size_t > RemoveCRLF (std::string &str)
 
TC_COMMON_API bool IsIPAddress (char const *ipaddress)
 Check if the string is a valid ip address representation.
 
TC_COMMON_API uint32 CreatePIDFile (std::string const &filename)
 create PID file
 
TC_COMMON_API uint32 GetPID ()
 
TC_COMMON_API std::string Trinity::Impl::ByteArrayToHexStr (uint8 const *bytes, size_t length, bool reverse=false)
 
TC_COMMON_API void Trinity::Impl::HexStrToByteArray (std::string_view str, uint8 *out, size_t outlen, bool reverse=false)
 
template<typename Container >
std::string ByteArrayToHexStr (Container const &c, bool reverse=false)
 
template<size_t Size>
void HexStrToByteArray (std::string_view str, std::array< uint8, Size > &buf, bool reverse=false)
 
template<size_t Size>
std::array< uint8, Size > HexStrToByteArray (std::string_view str, bool reverse=false)
 
std::vector< uint8 > HexStrToByteVector (std::string_view str, bool reverse=false)
 
TC_COMMON_API bool StringEqualI (std::string_view str1, std::string_view str2)
 
bool StringStartsWith (std::string_view haystack, std::string_view needle)
 
bool StringStartsWithI (std::string_view haystack, std::string_view needle)
 
TC_COMMON_API bool StringContainsStringI (std::string_view haystack, std::string_view needle)
 
template<typename T >
bool ValueContainsStringI (std::pair< T, std::string_view > const &haystack, std::string_view needle)
 
TC_COMMON_API bool StringCompareLessI (std::string_view a, std::string_view b)
 
template<class T >
bool CompareValues (ComparisionType type, T val1, T val2)
 
template<typename E >
constexpr std::underlying_type< E >::type AsUnderlyingType (E enumValue)
 
template<typename Ret , typename T1 , typename... T>
Ret * Coalesce (T1 *first, T *... rest)
 
TC_COMMON_API std::string Trinity::Impl::GetTypeName (std::type_info const &)
 
template<typename T >
std::string Trinity::GetTypeName ()
 
template<typename T >
std::string Trinity::GetTypeName (T &&v)
 

Variables

struct WcharToUpper wcharToUpper
 
struct WcharToUpperOnlyLatin wcharToUpperOnlyLatin
 
struct WcharToLower wcharToLower
 
struct CharToUpper charToUpper
 
struct CharToLower charToLower
 

Enumeration Type Documentation

◆ ComparisionType

Enumerator
COMP_TYPE_EQ 
COMP_TYPE_HIGH 
COMP_TYPE_LOW 
COMP_TYPE_HIGH_EQ 
COMP_TYPE_LOW_EQ 
COMP_TYPE_MAX 

Definition at line 521 of file Util.h.

◆ TimeFormat

enum class TimeFormat : uint8
strong
Enumerator
FullText 
ShortText 
Numeric 

Definition at line 33 of file Util.h.

Function Documentation

◆ AddPct()

template<class T , class U >
T AddPct ( T &  base,
U  pct 
)
inline

Definition at line 77 of file Util.h.

References CalculatePct().

Referenced by Unit::ApplyStatPctModifier(), Unit::CalcArmorReducedDamage(), spell_hun_pet_cower::CalculateAmount(), spell_pri_lightwell_renew::CalculateAmount(), spell_pal_sacred_shield::CalculateAmount(), spell_pri_power_word_shield_aura::CalculateAmount(), spell_warr_rend::CalculateAmount(), AuraEffect::CalculateAmount(), Unit::CalculateSpellDamageTaken(), spell_hun_pet_scaling_01::spell_hun_pet_scaling_01_AuraScript::CalculateStaminaAmount(), Spell::Delayed(), Spell::DelayedChannel(), Spell::EffectEnergize(), Spell::EffectSchoolDMG(), Spell::EffectWeaponDmg(), Player::GetQuestXPReward(), Unit::GetTotalAuraMultiplier(), spell_dk_scourge_strike::HandleAfterHit(), spell_pri_shadow_word_death::HandleDamage(), spell_warl_life_tap::HandleDummy(), spell_dk_death_strike::HandleDummy(), spell_dk_scourge_strike::HandleDummy(), spell_sha_healing_stream_totem::HandleDummy(), spell_sha_lava_lash::HandleDummy(), spell_dru_nourish::HandleHeal(), spell_pri_prayer_of_mending_heal::HandleHeal(), spell_hun_ascpect_of_the_viper::HandleProc(), spell_dk_unholy_blight::HandleProc(), spell_pal_infusion_of_light::HandleProc(), spell_sha_glyph_of_earth_shield::HandleProc(), Unit::MeleeDamageBonusDone(), Unit::MeleeDamageBonusTaken(), WorldObject::ModSpellDuration(), spell_warl_siphon_life::OnProc(), Player::RewardHonor(), Unit::RewardRage(), Battleground::RewardReputationToTeam(), spell_dru_wild_growth_aura::SetTickHeal(), Unit::SpellCriticalDamageBonus(), Unit::SpellDamageBonusDone(), Unit::SpellDamageBonusTaken(), Unit::SpellDamagePctDone(), Unit::SpellHealingBonusDone(), Unit::SpellHealingBonusTaken(), Unit::SpellHealingPctDone(), Guardian::UpdateAttackPowerAndDamage(), Guardian::UpdateDamagePhysical(), Unit::UpdateSpeed(), and Guardian::UpdateStats().

◆ ApplyPct()

◆ AsUnderlyingType()

template<typename E >
constexpr std::underlying_type< E >::type AsUnderlyingType ( E  enumValue)
constexpr

Definition at line 554 of file Util.h.

Referenced by Player::_SaveStats(), BattlegroundAV::AddAVCreature(), Player::AddSpellMod(), Unit::ApplyAttackTimePercentMod(), BattlegroundAV::BattlegroundAV(), BattlegroundSA::BattlegroundSA(), spell_warl_pet_scaling_01::spell_warl_pet_scaling_01_AuraScript::CalculateAttackPowerAmount(), spell_warl_pet_scaling_01::spell_warl_pet_scaling_01_AuraScript::CalculateDamageDoneAmount(), BattlegroundSA::CaptureGraveyard(), Player::CastItemCombatSpell(), GameObject::Create(), instance_stratholme::instance_stratholme_InstanceMapScript::DoGateTrap(), Unit::GetAttackTime(), Player::GetDodgeFromAgility(), Player::GetPowerRegen(), Player::GetRatingBonusValue(), Unit::GetTotalStatValue(), spell_warl_life_tap::HandleDummy(), WorldSession::HandleForceSpeedChangeAck(), WorldPackets::Movement::MonsterMove::InitializeSplineData(), Player::InitStatsForLevel(), Guardian::InitStatsForLevel(), SmartAIMgr::IsEventValid(), ObjectMgr::LoadCreatureAddons(), ObjectMgr::LoadCreatureTemplateAddons(), Creature::LoadFromDB(), GameObject::LoadFromDB(), ObjectMgr::LoadVehicleSeatAddon(), instance_stratholme::instance_stratholme_InstanceMapScript::OnGameObjectCreate(), npc_chromie_start::npc_chromie_startAI::OnGossipHello(), npc_chromie_middle::npc_chromie_middleAI::OnGossipHello(), npc_chromie_start::npc_chromie_startAI::OnGossipSelect(), npc_chromie_middle::npc_chromie_middleAI::OnGossipSelect(), Player::Regenerate(), BattlegroundAV::ResetBGSubclass(), BattlegroundSA::ResetObjs(), WorldSession::SendAuctionCommandResult(), WorldSession::SendListInventory(), Spell::SendMountResult(), PlayerMenu::SendQuestGiverStatus(), Trainer::Trainer::SendSpells(), Trainer::Trainer::SendTeachFailure(), npc_webwrap::SetGUID(), Unit::SetMaxPower(), Unit::SetPower(), Creature::SetScriptStringId(), GameObject::SetScriptStringId(), WorldObject::SetVisibilityDistanceOverride(), Unit::SpellCritChanceDone(), CreatureMovementData::ToString(), npc_demolitionist_legoso::npc_demolitionist_legosoAI::UpdateAI(), npc_train_wrecker::npc_train_wreckerAI::UpdateAI(), Player::UpdateArmorPenetration(), Guardian::UpdateAttackPowerAndDamage(), Guardian::UpdateDamagePhysical(), Creature::UpdateEntry(), Creature::UpdateMaxPower(), Guardian::UpdateMaxPower(), Player::UpdateMaxPower(), Player::UpdatePowerRegen(), Player::UpdateRating(), Unit::UpdateResistanceBuffModsMod(), Unit::UpdateStatBuffMod(), and npc_demolitionist_legoso::npc_demolitionist_legosoAI::WaypointReached().

◆ ByteArrayToHexStr()

template<typename Container >
std::string ByteArrayToHexStr ( Container const &  c,
bool  reverse = false 
)

◆ CalculatePct()

template<class T , class U >
T CalculatePct ( T  base,
U  pct 
)
inline

Definition at line 71 of file Util.h.

Referenced by spell_dk_anti_magic_shell_raid::Absorb(), spell_dk_anti_magic_shell_self::Absorb(), spell_dk_anti_magic_zone::Absorb(), spell_dk_spell_deflection::Absorb(), spell_dk_will_of_the_necropolis::Absorb(), spell_dru_moonkin_form_passive::Absorb(), spell_dru_primal_tenacity::Absorb(), spell_rog_nerves_of_steel::Absorb(), spell_sha_astral_shift::Absorb(), spell_pal_ardent_defender::Absorb(), AddPct(), ThreatManager::AddThreat(), Player::ApplyBaseModPctValue(), ApplyPct(), Player::ApplySpellMod(), Unit::Attack(), Unit::CalcAbsorbResist(), Unit::CalcArmorReducedDamage(), SpellInfo::CalcPowerCost(), spell_doom_lord_kazzak_mark_of_kazzak::CalculateAmount(), spell_dru_owlkin_frenzy::CalculateAmount(), spell_dru_rip::CalculateAmount(), spell_dru_innervate::CalculateAmount(), spell_gen_lifeblood_aura::CalculateAmount(), spell_gen_mixology_bonus::CalculateAmount(), spell_pal_sacred_shield::CalculateAmount(), spell_pri_power_word_shield_aura::CalculateAmount(), spell_warl_pet_passive::spell_warl_pet_passive_AuraScript::CalculateAmountCritMelee(), spell_warl_pet_passive::spell_warl_pet_passive_AuraScript::CalculateAmountCritSpell(), spell_warl_pet_scaling_03::spell_warl_pet_scaling_03_AuraScript::CalculateArcaneResistanceAmount(), spell_hun_pet_scaling_03::spell_hun_pet_scaling_03_AuraScript::CalculateArcaneResistanceAmount(), spell_warl_pet_scaling_02::spell_warl_pet_scaling_02_AuraScript::CalculateArmorAmount(), spell_hun_pet_scaling_03::spell_hun_pet_scaling_03_AuraScript::CalculateArmorAmount(), spell_warl_pet_scaling_01::spell_warl_pet_scaling_01_AuraScript::CalculateAttackPowerAmount(), spell_hun_pet_scaling_01::spell_hun_pet_scaling_01_AuraScript::CalculateAttackPowerAmount(), spell_hun_pet_scaling_01::spell_hun_pet_scaling_01_AuraScript::CalculateDamageDoneAmount(), spell_warl_pet_scaling_02::spell_warl_pet_scaling_02_AuraScript::CalculateFireResistanceAmount(), spell_hun_pet_scaling_02::spell_hun_pet_scaling_02_AuraScript::CalculateFireResistanceAmount(), spell_warl_pet_scaling_03::spell_warl_pet_scaling_03_AuraScript::CalculateFrostResistanceAmount(), spell_hun_pet_scaling_02::spell_hun_pet_scaling_02_AuraScript::CalculateFrostResistanceAmount(), spell_warl_pet_scaling_02::spell_warl_pet_scaling_02_AuraScript::CalculateIntellectAmount(), spell_warl_pet_scaling_03::spell_warl_pet_scaling_03_AuraScript::CalculateNatureResistanceAmount(), spell_hun_pet_scaling_02::spell_hun_pet_scaling_02_AuraScript::CalculateNatureResistanceAmount(), Player::CalculateReputationGain(), spell_warl_pet_scaling_04::spell_warl_pet_scaling_04_AuraScript::CalculateShadowResistanceAmount(), spell_hun_pet_scaling_03::spell_hun_pet_scaling_03_AuraScript::CalculateShadowResistanceAmount(), spell_warl_pet_scaling_01::spell_warl_pet_scaling_01_AuraScript::CalculateStaminaAmount(), spell_dk_pet_scaling_01::spell_dk_pet_scaling_01_AuraScript::CalculateStrengthAmount(), Player::CastItemCombatSpell(), Pet::CastPetAura(), Unit::CountPctFromCurHealth(), Unit::CountPctFromMaxHealth(), Unit::CountPctFromMaxPower(), Unit::DealDamage(), Spell::DelayedChannel(), Spell::EffectDestroyAllTotems(), Spell::EffectEnergize(), Spell::EffectEnergizePct(), Spell::EffectPowerBurn(), Spell::EffectResurrect(), Spell::EffectSchoolDMG(), Spell::EffectSelfResurrect(), AuctionEntry::GetAuctionCut(), AuctionHouseMgr::GetAuctionDeposit(), AuctionEntry::GetAuctionOutBid(), Unit::GetCombatRatingDamageReduction(), spell_warl_haunt::HandleAfterHit(), spell_pri_renew::HandleApplyEffect(), AuraEffect::HandleAuraModIncreaseHealthPercent(), Aura::HandleAuraSpecificMods(), spell_warr_bloodthirst::HandleDamage(), spell_sha_mana_tide_totem::HandleDummy(), spell_warr_concussion_blow::HandleDummy(), AuraEffect::HandleModPowerCostPCT(), AuraEffect::HandleModTotalPercentStat(), spell_hun_rapid_recuperation::HandlePeriodic(), spell_volkhan_cool_down::HandlePeriodicDummyEffect(), AuraEffect::HandlePeriodicManaLeechAuraTick(), spell_devourer_of_souls_mirrored_soul_proc::HandleProc(), spell_hun_ascpect_of_the_viper::HandleProc(), spell_mage_empowered_fire::HandleProc(), spell_sha_shamanistic_rage::HandleProc(), spell_yogg_saron_grim_reprisal::spell_yogg_saron_grim_reprisal_AuraScript::HandleProc(), spell_pet_guard_dog::HandleProc(), spell_dk_improved_blood_presence_triggered::HandleProc(), spell_dk_necrosis::HandleProc(), spell_dk_unholy_blight::HandleProc(), spell_dk_wandering_plague::HandleProc(), spell_dru_glyph_of_innervate::HandleProc(), spell_dru_glyph_of_rejuvenation::HandleProc(), spell_dru_leader_of_the_pack::HandleProc(), spell_dru_living_seed::HandleProc(), spell_dru_savage_defense::HandleProc(), spell_dru_t3_8p_bonus::HandleProc(), spell_dru_t10_balance_4p_bonus::HandleProc(), spell_hun_piercing_shots::HandleProc(), spell_hun_roar_of_sacrifice::HandleProc(), spell_hun_thrill_of_the_hunt::HandleProc(), spell_item_alchemists_stone::HandleProc(), spell_item_blessing_of_ancient_kings::HandleProc(), spell_item_frozen_shadoweave::HandleProc(), spell_item_necrotic_touch::HandleProc(), spell_item_persistent_shield::HandleProc(), spell_item_pet_healing::HandleProc(), spell_item_charm_witch_doctor::HandleProc(), spell_mage_burnout::HandleProc(), spell_mage_ignite::HandleProc(), spell_mage_magic_absorption::HandleProc(), spell_mage_master_of_elements::HandleProc(), spell_pal_glyph_of_holy_light_dummy::HandleProc(), spell_pal_illumination::HandleProc(), spell_pal_infusion_of_light::HandleProc(), spell_pal_judgement_of_wisdom_mana::HandleProc(), spell_pal_light_s_beacon::HandleProc(), spell_pal_righteous_vengeance::HandleProc(), spell_pal_spiritual_attunement::HandleProc(), spell_pal_sheath_of_light::HandleProc(), spell_pal_t8_2p_bonus::HandleProc(), spell_pri_aq_3p_bonus::HandleProc(), spell_pri_blessed_recovery::HandleProc(), spell_pri_divine_aegis::HandleProc(), spell_pri_glyph_of_prayer_of_healing::HandleProc(), spell_pri_vampiric_embrace::HandleProc(), spell_pri_t10_heal_2p_bonus::HandleProc(), spell_rog_quick_recovery::HandleProc(), spell_sha_ancestral_awakening::HandleProc(), spell_sha_glyph_of_healing_wave::HandleProc(), spell_sha_glyph_of_totem_of_wrath::HandleProc(), spell_sha_item_mana_surge::HandleProc(), spell_sha_nature_guardian::HandleProc(), spell_sha_spirit_hunt::HandleProc(), spell_sha_t8_elemental_4p_bonus::HandleProc(), spell_sha_t9_elemental_4p_bonus::HandleProc(), spell_sha_t10_restoration_4p_bonus::HandleProc(), spell_warl_drain_soul::HandleProc(), spell_warl_soul_leech::HandleProc(), spell_warr_item_t10_prot_4p_bonus::HandleProc(), spell_hun_chimera_shot::HandleScriptEffect(), spell_dru_wild_growth_aura::HandleTickUpdate(), spell_valanar_kinetic_bomb_absorb::OnAbsorb(), spell_blood_queen_essence_of_the_blood_queen::OnProc(), spell_pal_eye_for_an_eye::OnProc(), spell_warl_fel_synergy::OnProc(), spell_warl_siphon_life::OnProc(), spell_warr_damage_shield::OnProc(), spell_dru_lifebloom::OnRemoveEffect(), spell_dru_frenzied_regeneration::PeriodicTick(), Unit::RecalculateObjectScale(), spell_pri_power_word_shield_aura::ReflectDamage(), OPvPCapturePoint::SetCapturePointData(), Unit::SpellBaseDamageBonusDone(), Unit::SpellBaseHealingBonusDone(), spell_dk_anti_magic_shell_self::Trigger(), spell_mage_incanters_absorbtion_base_AuraScript::Trigger(), spell_pal_divine_storm::TriggerHeal(), Guardian::UpdateArmor(), Player::UpdateArmor(), Guardian::UpdateAttackPowerAndDamage(), Player::UpdateAttackPowerAndDamage(), Player::UpdatePowerRegen(), Player::UpdateRating(), Guardian::UpdateResistances(), Unit::UpdateSpeed(), and Guardian::UpdateStats().

◆ Coalesce()

template<typename Ret , typename T1 , typename... T>
Ret * Coalesce ( T1 *  first,
T *...  rest 
)

Definition at line 561 of file Util.h.

◆ CompareValues()

template<class T >
bool CompareValues ( ComparisionType  type,
T  val1,
T  val2 
)

◆ consoleToUtf8()

TC_COMMON_API bool consoleToUtf8 ( std::string_view  conStr,
std::string &  utf8str 
)

Definition at line 550 of file Util.cpp.

References WStrToUtf8().

◆ CreatePIDFile()

TC_COMMON_API uint32 CreatePIDFile ( std::string const &  filename)

create PID file

Definition at line 324 of file Util.cpp.

References GetPID().

Referenced by main().

◆ GetLocalHourTimestamp()

TC_COMMON_API time_t GetLocalHourTimestamp ( time_t  time,
uint8  hour,
bool  onlyAfterTime = true 
)

◆ GetMainPartOfName()

TC_COMMON_API std::wstring GetMainPartOfName ( std::wstring const &  wname,
uint32  declension 
)

Definition at line 484 of file Util.cpp.

References isCyrillicCharacter().

Referenced by ObjectMgr::CheckDeclinedNames().

◆ GetPID()

TC_COMMON_API uint32 GetPID ( )

Definition at line 338 of file Util.cpp.

Referenced by CreatePIDFile().

◆ HexStrToByteArray() [1/2]

template<size_t Size>
std::array< uint8, Size > HexStrToByteArray ( std::string_view  str,
bool  reverse = false 
)

Definition at line 346 of file Util.h.

References HexStrToByteArray().

◆ HexStrToByteArray() [2/2]

template<size_t Size>
void HexStrToByteArray ( std::string_view  str,
std::array< uint8, Size > &  buf,
bool  reverse = false 
)

Definition at line 341 of file Util.h.

References Trinity::Impl::HexStrToByteArray().

Referenced by HexStrToByteArray().

◆ HexStrToByteVector()

std::vector< uint8 > HexStrToByteVector ( std::string_view  str,
bool  reverse = false 
)
inline

Definition at line 353 of file Util.h.

References Trinity::Impl::HexStrToByteArray().

◆ isBasicLatinCharacter()

bool isBasicLatinCharacter ( wchar_t  wchar)
inline

◆ isBasicLatinString()

bool isBasicLatinString ( std::wstring_view  wstr,
bool  numericOrSpace 
)
inline

Definition at line 200 of file Util.h.

References isBasicLatinCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ isCyrillicCharacter()

bool isCyrillicCharacter ( wchar_t  wchar)
inline

◆ isCyrillicString()

bool isCyrillicString ( std::wstring_view  wstr,
bool  numericOrSpace 
)
inline

Definition at line 216 of file Util.h.

References isCyrillicCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ isEastAsianCharacter()

bool isEastAsianCharacter ( wchar_t  wchar)
inline

Definition at line 155 of file Util.h.

Referenced by isEastAsianString().

◆ isEastAsianString()

bool isEastAsianString ( std::wstring_view  wstr,
bool  numericOrSpace 
)
inline

Definition at line 224 of file Util.h.

References isEastAsianCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ isExtendedLatinCharacter()

bool isExtendedLatinCharacter ( wchar_t  wchar)
inline

Definition at line 125 of file Util.h.

References isBasicLatinCharacter().

Referenced by isExtendedLatinString().

◆ isExtendedLatinString()

bool isExtendedLatinString ( std::wstring_view  wstr,
bool  numericOrSpace 
)
inline

Definition at line 208 of file Util.h.

References isExtendedLatinCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ IsIPAddress()

TC_COMMON_API bool IsIPAddress ( char const *  ipaddress)

Check if the string is a valid ip address representation.

Definition at line 313 of file Util.cpp.

Referenced by ban_commandscript::HandleBanHelper(), ban_commandscript::HandleBanInfoIPCommand(), and ban_commandscript::HandleUnBanHelper().

◆ isNumeric() [1/3]

bool isNumeric ( char  c)
inline

Definition at line 181 of file Util.h.

◆ isNumeric() [2/3]

bool isNumeric ( char const *  str)
inline

Definition at line 186 of file Util.h.

References isNumeric().

◆ isNumeric() [3/3]

bool isNumeric ( wchar_t  wchar)
inline

◆ isNumericOrSpace()

bool isNumericOrSpace ( wchar_t  wchar)
inline

Definition at line 195 of file Util.h.

References isNumeric().

Referenced by isBasicLatinString(), isCyrillicString(), isEastAsianString(), and isExtendedLatinString().

◆ MoneyStringToMoney()

TC_COMMON_API Optional< int32 > MoneyStringToMoney ( std::string const &  moneyString)

Definition at line 216 of file Util.cpp.

References Trinity::Tokenize().

Referenced by modify_commandscript::HandleModifyMoneyCommand().

◆ ReadWinConsole()

TC_COMMON_API bool ReadWinConsole ( std::string &  str,
size_t  size = 256 
)

Definition at line 622 of file Util.cpp.

References WStrToUtf8().

Referenced by CliThread().

◆ RemoveCRLF()

TC_COMMON_API Optional< std::size_t > RemoveCRLF ( std::string &  str)

Definition at line 654 of file Util.cpp.

Referenced by CliThread().

◆ RoundToInterval()

template<class T >
T RoundToInterval ( T &  num,
T  floor,
T  ceil 
)
inline

◆ secsToTimeString()

◆ square()

◆ StringCompareLessI()

TC_COMMON_API bool StringCompareLessI ( std::string_view  a,
std::string_view  b 
)

Definition at line 717 of file Util.cpp.

Referenced by StringCompareLessI_T::operator()().

◆ StringContainsStringI()

◆ StringEqualI()

◆ StringStartsWith()

bool StringStartsWith ( std::string_view  haystack,
std::string_view  needle 
)
inline

◆ StringStartsWithI()

bool StringStartsWithI ( std::string_view  haystack,
std::string_view  needle 
)
inline

◆ strToLower()

TC_COMMON_API void strToLower ( std::string &  str)

Definition at line 482 of file Util.cpp.

References charToLower.

Referenced by ExtractGameobjectModels(), and IpLocationStore::Load().

◆ strToUpper()

TC_COMMON_API void strToUpper ( std::string &  str)

Definition at line 481 of file Util.cpp.

References charToUpper.

◆ TimeBreakdown()

◆ TimeStringToSecs()

◆ TimeToHumanReadable()

TC_COMMON_API std::string TimeToHumanReadable ( time_t  t)

Definition at line 303 of file Util.cpp.

Referenced by debug_commandscript::HandleDebugQuestResetCommand().

◆ TimeToTimestampStr()

◆ Utf8FitTo()

◆ utf8length()

◆ utf8printf()

TC_COMMON_API void utf8printf ( FILE *  out,
const char *  str,
  ... 
)

Definition at line 581 of file Util.cpp.

References vutf8printf().

Referenced by AppenderConsole::Print().

◆ utf8ToConsole()

TC_COMMON_API bool utf8ToConsole ( std::string_view  utf8str,
std::string &  conStr 
)

Definition at line 533 of file Util.cpp.

References Utf8toWStr().

◆ Utf8ToUpperOnlyLatin()

◆ Utf8toWStr() [1/3]

TC_COMMON_API bool Utf8toWStr ( char const *  utf8str,
size_t  csize,
wchar_t *  wstr,
size_t &  wsize 
)

Definition at line 383 of file Util.cpp.

References Trinity::CheckedBufferOutputIterator< T >::remaining().

Referenced by ObjectMgr::AddGameTele(), ObjectMgr::CheckDeclinedNames(), ObjectMgr::CheckPetName(), ObjectMgr::CheckPlayerName(), ChannelMgr::CreateCustomChannel(), ObjectMgr::DeleteGameTele(), ChannelMgr::GetChannel(), ChannelMgr::GetChannelForPlayerByNamePart(), ChannelMgr::GetCustomChannel(), ObjectMgr::GetGameTele(), ObjectMgr::GetGameTeleExactName(), WorldSession::HandleAuctionListItems(), lookup_commandscript::HandleLookupAreaCommand(), lookup_commandscript::HandleLookupCreatureCommand(), lookup_commandscript::HandleLookupEventCommand(), lookup_commandscript::HandleLookupFactionCommand(), lookup_commandscript::HandleLookupItemCommand(), lookup_commandscript::HandleLookupItemSetCommand(), lookup_commandscript::HandleLookupMapCommand(), lookup_commandscript::HandleLookupObjectCommand(), lookup_commandscript::HandleLookupQuestCommand(), lookup_commandscript::HandleLookupSkillCommand(), lookup_commandscript::HandleLookupSpellCommand(), lookup_commandscript::HandleLookupTaxiNodeCommand(), lookup_commandscript::HandleLookupTeleCommand(), lookup_commandscript::HandleLookupTitleCommand(), modify_commandscript::HandleModifyRepCommand(), WorldSession::HandlePetRename(), WorldSession::HandleSetPlayerDeclinedNames(), WorldSession::HandleWhoOpcode(), ObjectMgr::IsReservedName(), ObjectMgr::IsValidCharterName(), ChannelMgr::LoadFromDB(), ObjectMgr::LoadGameTele(), ObjectMgr::LoadReservedPlayersNames(), normalizePlayerName(), Trinity::ChatCommands::WTail::TryConsume(), Trinity::Impl::ChatCommands::ArgInfo< std::wstring, void >::TryConsume(), WhoListStorageMgr::Update(), Utf8FitTo(), utf8ToConsole(), Utf8ToUpperOnlyLatin(), vutf8printf(), and WriteWinConsole().

◆ Utf8toWStr() [2/3]

TC_COMMON_API bool Utf8toWStr ( std::string_view  utf8str,
std::wstring &  wstr 
)

Definition at line 417 of file Util.cpp.

Referenced by Utf8toWStr().

◆ Utf8toWStr() [3/3]

bool Utf8toWStr ( std::string_view  utf8str,
wchar_t *  wstr,
size_t &  wsize 
)
inline

Definition at line 103 of file Util.h.

References Utf8toWStr().

◆ utf8truncate()

TC_COMMON_API void utf8truncate ( std::string &  utf8str,
size_t  len 
)

Definition at line 362 of file Util.cpp.

Referenced by PlayerSocial::SetFriendNote().

◆ ValueContainsStringI()

template<typename T >
bool ValueContainsStringI ( std::pair< T, std::string_view > const &  haystack,
std::string_view  needle 
)
inline

Definition at line 367 of file Util.h.

References StringContainsStringI().

◆ vutf8printf()

TC_COMMON_API void vutf8printf ( FILE *  out,
const char *  str,
va_list *  ap 
)

Definition at line 589 of file Util.cpp.

References Utf8toWStr().

Referenced by utf8printf().

◆ WriteWinConsole()

TC_COMMON_API bool WriteWinConsole ( std::string_view  str,
bool  error = false 
)

Definition at line 641 of file Util.cpp.

References Utf8toWStr().

Referenced by AppenderConsole::Print(), and utf8print().

◆ wstrToLower()

TC_COMMON_API void wstrToLower ( std::wstring &  str)

◆ wstrToUpper()

TC_COMMON_API void wstrToUpper ( std::wstring &  str)

Definition at line 479 of file Util.cpp.

References wcharToUpper.

◆ WStrToUtf8() [1/2]

TC_COMMON_API bool WStrToUtf8 ( std::wstring_view  wstr,
std::string &  utf8str 
)

Definition at line 456 of file Util.cpp.

◆ WStrToUtf8() [2/2]

TC_COMMON_API bool WStrToUtf8 ( wchar_t const *  wstr,
size_t  size,
std::string &  utf8str 
)

Definition at line 433 of file Util.cpp.

Referenced by consoleToUtf8(), normalizePlayerName(), ReadWinConsole(), and Utf8ToUpperOnlyLatin().

Variable Documentation

◆ charToLower

◆ charToUpper

struct CharToUpper charToUpper

Referenced by strToUpper().

◆ wcharToLower

struct WcharToLower wcharToLower

Referenced by wstrToLower().

◆ wcharToUpper

◆ wcharToUpperOnlyLatin

struct WcharToUpperOnlyLatin wcharToUpperOnlyLatin

Referenced by Utf8ToUpperOnlyLatin().