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 <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  CStringBoundedSentinel< Iterator >
 
struct  CStringSentinel_T
 
struct  StringContainsStringI_T
 
struct  StringCompareLessI_T
 
class  HookList< T >
 
struct  NonDefaultConstructible< T >
 

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< int64 > 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 >
float GetPctOf (T value, T max)
 
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)
 
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 isLatin1Character (wchar_t wchar)
 
bool isCyrillicCharacter (wchar_t wchar)
 
bool isKoreanCharacter (wchar_t wchar)
 
bool isChineseCharacter (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 isKoreanString (std::wstring_view wstr, bool numericOrSpace)
 
bool isChineseString (std::wstring_view wstr, bool numericOrSpace)
 
bool isLower (wchar_t wchar)
 
bool isUpper (wchar_t wchar)
 
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 wstrCaseAccentInsensitiveParse (std::wstring_view wstr, LocaleConstant locale)
 
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 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 float DegToRad (float degrees)
 
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)
 
TC_COMMON_API bool StringCompareLessI (std::string_view a, std::string_view b)
 
TC_COMMON_API void StringReplaceAll (std::string *str, std::string_view text, std::string_view replacement)
 
std::string StringReplaceAll (std::string_view str, std::string_view text, std::string_view replacement)
 
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>
constexpr 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
 
struct CStringSentinel_T CStringSentinel
 

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 532 of file Util.h.

◆ TimeFormat

enum class TimeFormat : uint8
strong
Enumerator
FullText 
ShortText 
Numeric 

Definition at line 34 of file Util.h.

Function Documentation

◆ AddPct()

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

Definition at line 85 of file Util.h.

References CalculatePct().

Referenced by spell_sha_lava_lash::AddBonusFlametongueDamage(), Unit::ApplyStatPctModifier(), Unit::CalcArmorReducedDamage(), spell_pri_prayerful_litany::CalcPrimaryTargetHealing(), spell_pri_power_word_shield::CalculateAbsorb(), spell_monk_life_cocoon::CalculateAbsorb(), spell_dk_anti_magic_shell::CalculateAmount(), spell_pal_shield_of_vengeance::CalculateAmount(), spell_dru_guardian_of_elune_healing::CalculateAmount(), spell_mage_ice_barrier::CalculateAmount(), spell_rog_improved_garrote_damage::CalculateBonus(), spell_pri_mind_devourer_buff_aura::CalculateDamage(), spell_warl_drain_soul::CalculateDamage(), spell_dru_galactic_guardian_moonfire::CalculateDamage(), spell_dru_rake::CalculateDamage(), spell_pri_mind_devourer_buff::CalculateDamage(), spell_dru_mangle::CalculateDamage(), spell_mage_scald::CalculateDamage(), spell_warr_overpowering_finish::CalculateDamage(), spell_warr_vicious_contempt::CalculateDamage(), spell_pri_power_of_the_dark_side_damage_bonus::CalculateDamageBonus(), spell_pri_lights_wrath::CalculateDamageBonus(), spell_pri_empowered_renew_heal::CalculateHealing(), spell_pal_eternal_flame_aura::CalculateHealing(), spell_pal_eternal_flame::CalculateHealing(), spell_gen_major_healing_cooldown_modifier_aura::CalculateHealingBonus(), spell_gen_major_healing_cooldown_modifier::CalculateHealingBonus(), spell_pri_focused_mending::CalculateHealingBonus(), spell_pri_power_of_the_dark_side_healing_bonus::CalculateHealingBonus(), spell_dh_shattered_restoration::CalculateHealingBonus(), spell_pri_abyssal_reverie::CalculateHealingBonus(), spell_pri_divine_service::CalculateHealingBonus(), spell_sha_deluge::CalculateHealingBonus(), Unit::CalculateMeleeDamage(), Player::CalculateMinMaxDamage(), Unit::CalculateSpellDamageTaken(), spell_hun_pet_scaling_01::spell_hun_pet_scaling_01_AuraScript::CalculateStaminaAmount(), Spell::Delayed(), Spell::DelayedChannel(), spell_pri_shadow_word_death::DetermineKillStatus(), Spell::EffectEnergize(), Player::GetQuestXPReward(), RestMgr::GetRestBonusFor(), Unit::GetTotalAuraMultiplier(), Unit::GetTotalStatValue(), spell_dru_umbral_embrace_damage::HandleDamage(), spell_pal_justicars_vengeance::HandleDamage(), spell_mage_supernova::HandleDamage(), spell_warr_meat_cleaver_damage_bonus::HandleDamageBonus(), spell_pri_shadow_word_death::HandleDamageCalculation(), spell_warl_deaths_embrace_impl::HandleDamageOrHealingCalculation(), spell_pri_sanctuary_trigger::HandleEffectHit(), spell_rog_backstab::HandleHitDamage(), spell_dh_blade_dance_damage::HandleHitTarget(), spell_dru_wild_growth_aura::HandleTickUpdate(), Unit::MeleeDamageBonusDone(), Unit::MeleeDamageBonusTaken(), WorldObject::ModSpellDuration(), spell_pri_twilight_equilibrium_shadow_word_pain::OnApply(), spell_evo_snapfire::OnPrecast(), Player::RewardHonor(), Unit::RewardRage(), Battleground::RewardReputationToTeam(), spell_sha_earthquake::SnapshotDamageMultiplier(), Unit::SpellAbsorbPctDone(), Unit::SpellCriticalDamageBonus(), Unit::SpellDamageBonusTaken(), Unit::SpellDamagePctDone(), Unit::SpellHealingBonusTaken(), Unit::SpellHealingPctDone(), spell_sha_stormblast_damage::TriggerDamage(), Player::UpdateHealingDonePercentMod(), Unit::UpdateSpeed(), and Unit::UpdateStatBuffMod().

◆ ApplyPct()

◆ AsUnderlyingType()

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

Definition at line 565 of file Util.h.

Referenced by SpellInfo::_LoadSqrtTargetLimit(), Player::_LoadTraits(), Player::_LoadTransmogOutfits(), Player::_SaveCurrency(), Conversation::AddActor(), Conversation::AddActor(), AuctionHouseObject::AddAuction(), InstanceScript::AddDoor(), StoredLootContainer::AddLootItem(), Guild::AddMember(), BattlePets::BattlePetMgr::AddPet(), Player::AddSpellMod(), CollectionMgr::AddToy(), Player::AddTraitConfig(), Player::ApplyArtifactPowerRank(), Player::ApplyAzeritePower(), BattlePets::BattlePetMgr::BattlePetMgr(), BattlegroundMgr::BGQueueTypeId(), AuctionHouseMgr::BuildAuctionMailSubject(), Battleground::BuildPvPLogDataPacket(), Unit::CalcArmorReducedDamage(), AuraEffect::CalculateSpellMod(), Player::CanBankItem(), Player::CanStoreItems(), Player::CastItemCombatSpell(), BattlePets::BattlePetMgr::ChangeBattlePetQuality(), Battlenet::AccountMgr::ChangePassword(), Guild::Member::ChangeRank(), Spell::CheckCast(), SceneObject::Create(), GameObject::Create(), Battlenet::AccountMgr::CreateBattlenetAccount(), Guild::RankInfo::CreateMissingTabsIfNeeded(), instance_stratholme::instance_stratholme_InstanceMapScript::DoGateTrap(), Spell::EffectCreateTraitTreeConfig(), Player::EquipTransmogOutfit(), RealmList::FillRealmEntry(), Group::GetCountdownInfo(), Unit::GetCreateStat(), Map::GetDebugInfo(), TerrainInfo::GetFullTerrainStatusForPosition(), TerrainInfo::GetLiquidStatus(), TransmogMgr::GetNextOutfitToUnlock(), TraitMgr::PlayerDataAccessor::GetPrimarySpecialization(), Player::GetPrimarySpecializationEntry(), TransmogMgr::GetSlotAndOption(), Creature::GetSpawnTrackingStateDataForPlayer(), GameObject::GetSpawnTrackingStateDataForPlayer(), Unit::GetTotalStatValue(), WorldSession::HandleAuctionBrowseQuery(), WorldSession::HandleAzeriteEssenceActivateEssence(), WorldSession::HandleClassTalentsRequestNewConfig(), Battlenet::Services::ClubService::HandleCreateMessage(), Battlenet::Services::ClubService::HandleGetMembers(), Battlenet::Services::ClubService::HandleGetStreams(), WorldSession::HandleInspectOpcode(), WorldSession::HandlePlayerLogin(), Guild::HandleQuery(), Guild::HandleRemoveRank(), Guild::HandleSetRankInfo(), Guild::HandleShiftRank(), WorldSession::HandleSpawnTrackingUpdate(), Battlenet::Services::ClubService::HandleSubscribe(), Battlenet::Services::ClubService::HandleSubscribeStream(), WorldSession::HandleTraitsCommitConfig(), WorldSession::HandleTransmogOutfitUpdateSlots(), Guild::HandleUpdateMemberRank(), wp_commandscript::HandleWpAddCommand(), wp_commandscript::HandleWpShowCommand(), WorldPackets::Inspect::PlayerModelDisplayInfo::Initialize(), WorldPackets::Party::PartyMemberFullState::Initialize(), Player::InitializeNewTransmogOutfit(), WorldPackets::Movement::MonsterMove::InitializeSplineData(), Guardian::InitStatsForLevel(), SmartAIMgr::IsEventValid(), ConditionMgr::IsPlayerMeetingCondition(), ItemTemplate::IsUsableByLootSpecialization(), Player::LearnSpecializationSpells(), TransmogMgr::Load(), AzeriteItem::LoadAzeriteItemData(), ObjectMgr::LoadCreatureAddons(), ObjectMgr::LoadCreatureTemplateAddons(), CriteriaMgr::LoadCriteriaList(), BattlePets::BattlePetMgr::LoadDefaultPetQualities(), Creature::LoadFromDB(), GameObject::LoadFromDB(), ObjectMgr::LoadGossipMenuItems(), TerrainInfo::LoadMMapImpl(), WaypointMgr::LoadPathFromDB(), ObjectMgr::LoadPlayerInfo(), Quest::LoadRewardDisplaySpell(), ObjectMgr::LoadSpawnTrackingStates(), ObjectMgr::LoadVehicleSeatAddon(), Battlenet::LoginRESTService::MigrateLegacyPasswordHashes(), battleground_eye_of_the_storm::OnFlagStateChange(), 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::OnGossipSelect(), battleground_silvershard_mines::OnTrackSwitched(), Player::PrepareGossipMenu(), AuctionHouseObject::RemoveAuction(), StoredLootContainer::RemoveItem(), Player::RewardHonor(), ComplaintTicket::SaveToDB(), Guild::Member::SaveToDB(), Guild::RankInfo::SaveToDB(), Player::SaveToDB(), WorldSession::SendAuctionCommandResult(), Player::SendCurrencies(), BattlePets::BattlePetMgr::SendError(), Guild::SendEventNewLeader(), WorldSession::SendFeatureSystemStatus(), WorldSession::SendFeatureSystemStatusGlueScreen(), Guild::SendGuildRankInfo(), Guild::SendGuildRanksUpdate(), WorldSession::SendListInventory(), LootRoll::SendLootRollWon(), Spell::SendMountResult(), Guild::SendPermissions(), WorldSession::SendPetStableResult(), Player::SendPushToPartyResponse(), PlayerMenu::SendQuestGiverStatus(), LootRoll::SendRoll(), Trainer::Trainer::SendSpells(), WorldSession::SendTabardVendorActivate(), Player::SendTalentsInfoData(), Player::SendTameFailure(), Trainer::Trainer::SendTeachFailure(), Unit::SetAnimTier(), Guild::RankInfo::SetBankMoneyPerDay(), Guild::RankInfo::SetBankTabSlotsAndRights(), Player::SetBattlePetData(), Unit::SetCreateStat(), npc_webwrap::SetGUID(), Guild::RankInfo::SetName(), Creature::SetPetitioner(), Guild::RankInfo::SetRights(), Creature::SetScriptStringId(), GameObject::SetScriptStringId(), Player::SetTraitConfigUseSharedActionBars(), Player::SetTraitConfigUseStarterBuild(), Creature::SetVendor(), WorldObject::SetVisibilityDistanceOverride(), Player::SetVisibleItemSlot(), boss_volazj::SpellHitTarget(), Group::StartCountdown(), CreatureMovementData::ToString(), BattlePets::BattlePetMgr::UnlockSlot(), npc_demolitionist_legoso::npc_demolitionist_legosoAI::UpdateAI(), GameObject::UpdateCapturePoint(), Creature::UpdateEntry(), battleground_twin_peaks::UpdateFlagState(), battleground_warsong_gulch::UpdateFlagState(), Creature::UpdateLevelDependantStats(), Creature::UpdateMaxPower(), Guardian::UpdateMaxPower(), Player::UpdateMaxPower(), Player::UpdatePowerRegen(), Player::UpdateQuestObjectiveProgress(), Unit::UpdateStatBuffMod(), Player::UpdateTransmogOutfit(), Player::UpdateTransmogOutfitSlots(), TransmogMgr::ValidateSituations(), TransmogMgr::ValidateSlots(), and npc_demolitionist_legoso::npc_demolitionist_legosoAI::WaypointReached().

◆ ByteArrayToHexStr()

◆ CalculatePct()

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

Definition at line 72 of file Util.h.

Referenced by spell_monk_stagger::Absorb(), AddPct(), spell_sha_earth_shock::AddScriptedDamageMods(), spell_sha_elemental_blast::AddScriptedDamageMods(), Player::AddSpellMod(), ThreatManager::AddThreat(), Player::ApplyBaseModPctValue(), spell_sha_mastery_elemental_overload_proc::ApplyDamageModifier(), ApplyPct(), Unit::Attack(), Player::BuyItemFromVendorSlot(), Unit::CalcAbsorbResist(), spell_dh_critical_chaos::CalcAmount(), spell_dh_know_your_enemy::CalcAmount(), spell_hun_penetrating_shots::CalcAmount(), spell_mage_improved_combustion::CalcAmount(), spell_rog_swift_slasher::CalcAmount(), Unit::CalcArmorReducedDamage(), spell_dh_consume_soul_vengeance_lesser::CalcHealingFromDamageTaken(), SpellInfo::CalcPowerCost(), spell_doom_lord_kazzak_mark_of_kazzak::CalculateAmount(), spell_dk_anti_magic_shell::CalculateAmount(), spell_pal_shield_of_vengeance::CalculateAmount(), spell_dru_rip::CalculateAmount(), spell_mage_prismatic_barrier::CalculateAmount(), spell_warl_dark_pact::CalculateAmount(), spell_mage_ice_barrier::CalculateAmount(), spell_gen_mixology_bonus::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(), AuctionHouseObject::CalculateAuctionHouseCut(), 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(), Unit::CalculateMeleeDamage(), AuctionPosting::CalculateMinIncrement(), 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(), Unit::CalculateSpellDamageTaken(), AuraEffect::CalculateSpellMod(), spell_warl_pet_scaling_01::spell_warl_pet_scaling_01_AuraScript::CalculateStaminaAmount(), Player::CastItemCombatSpell(), Pet::CastPetAura(), spell_garothi_eradication::ChangeDamage(), spell_sha_maelstrom_weapon_base::ConsumeMaelstromWeapon(), Unit::CountPctFromCurHealth(), Unit::CountPctFromMaxHealth(), Unit::CountPctFromMaxPower(), Unit::DealDamage(), Spell::DelayedChannel(), spell_pri_shadow_word_death::DetermineKillStatus(), Spell::DoSpellEffectHit(), Spell::EffectEnergizePct(), Spell::EffectResurrect(), Spell::EffectResurrectWithAura(), Spell::EffectSelfResurrect(), Unit::GetCombatRatingDamageReduction(), Player::GetSpellModValues(), spell_warl_chaotic_energies::HandleAbsorb(), spell_pri_crystalline_reflection::HandleAfterAbsorb(), spell_dh_charred_warblades::HandleAfterProc(), WorldSession::HandleAuctionRemoveItem(), AuraEffect::HandleAuraModIncreaseHealthPercent(), Aura::HandleAuraSpecificMods(), npc_sparring_partner_enhanced_combat_training_priest::HandleClassEvent(), npc_sparring_partner_enhanced_combat_training_warlock::HandleClassEvent(), npc_sparring_partner_enhanced_combat_training_druid::HandleClassEvent(), spell_pri_shadow_word_death::HandleDeathsTormentEnergize(), spell_dk_death_strike::HandleDummy(), spell_warl_chaos_bolt::HandleDummy(), spell_dru_thorns_of_iron_damage::HandleEffectHit(), spell_pri_sanctuary_trigger::HandleEffectHit(), spell_mage_arcane_barrage::HandleEffectHitTarget(), spell_mandokir_bloodletting::HandleEffectPeriodic(), spell_dk_permafrost::HandleEffectProc(), spell_dru_moonless_night::HandleEffectProc(), spell_mage_tempest_barrier::HandleEffectProc(), spell_pri_vampiric_embrace::HandleEffectProc(), spell_sha_ancestral_guidance::HandleEffectProc(), spell_pri_searing_light::HandleEffectProc(), spell_pri_binding_heals::HandleEffectProc(), spell_dh_darkglare_boon::HandleEffectRemove(), spell_warr_execute::HandleExecuteCast(), spell_pri_expiation::HandleHitTarget(), spell_evo_living_flame::HandleLaunchTarget(), WorldSession::HandleLootMoneyOpcode(), AuraEffect::HandleModTotalPercentStat(), AuraEffect::HandleObsModPowerAuraTick(), spell_warl_healthstone_heal::HandleOnHit(), spell_pri_trail_of_light::HandleOnProc(), spell_argaloth_consuming_darkness::HandlePeriodic(), spell_dru_elunes_favored_proc::HandlePeriodic(), AuraEffect::HandlePeriodicDamageAurasTick(), spell_volkhan_cool_down::HandlePeriodicDummyEffect(), AuraEffect::HandlePeriodicManaLeechAuraTick(), spell_devourer_of_souls_mirrored_soul_proc::HandleProc(), spell_dk_t20_2p_rune_empowered::HandleProc(), spell_yogg_saron_grim_reprisal::spell_yogg_saron_grim_reprisal_AuraScript::HandleProc(), spell_dru_t3_8p_bonus::HandleProc(), spell_dru_t10_balance_4p_bonus::HandleProc(), spell_hun_roar_of_sacrifice::HandleProc(), spell_hun_t29_2p_marksmanship_bonus::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_mage_ignite::HandleProc(), spell_mage_touch_of_the_magi_aura::HandleProc(), spell_pal_light_s_beacon::HandleProc(), spell_pal_t8_2p_bonus::HandleProc(), spell_warr_brutal_vitality::HandleProc(), spell_warr_critical_thinking::HandleProc(), spell_warr_trauma::HandleProc(), spell_pal_t30_2p_protection_bonus::HandleProc(), spell_pal_execution_sentence_aura::HandleProc(), spell_pri_aq_3p_bonus::HandleProc(), spell_hun_rejuvenating_wind::HandleProc(), spell_dru_astral_smolder::HandleProc(), spell_pri_t10_heal_2p_bonus::HandleProc(), spell_sha_item_mana_surge::HandleProc(), spell_sha_t8_elemental_4p_bonus::HandleProc(), spell_sha_t9_elemental_4p_bonus::HandleProc(), spell_sha_t10_restoration_4p_bonus::HandleProc(), spell_pri_dispersing_light::HandleProc(), spell_warl_siphon_life::HandleProc(), spell_dru_ursocs_fury::HandleProc(), spell_hun_master_marksman::HandleProc(), spell_pri_divine_aegis::HandleProc(), spell_warr_frothing_berserker::HandleProc(), spell_warr_fueled_by_violence::HandleProc(), spell_warr_item_t10_prot_4p_bonus::HandleProc(), spell_dru_wild_growth_aura::HandleTickUpdate(), BattlePets::BattlePetMgr::HealBattlePetsPct(), spell_valanar_kinetic_bomb_absorb::OnAbsorb(), spell_anduin_wrynn_befouled_barrier_absorb::OnHealAbsorb(), spell_blood_queen_essence_of_the_blood_queen::OnProc(), spell_sha_ascendance_restoration::OnProcHeal(), Unit::RecalculateObjectScale(), WorldSession::SendListInventory(), Player::SendSpellModifiers(), Unit::SpellBaseDamageBonusDone(), Unit::SpellBaseHealingBonusDone(), Unit::SpellHealingPctDone(), spell_dk_anti_magic_shell::Trigger(), spell_sha_unrelenting_storms::Trigger(), spell_pri_atonement::TriggerAtonementHealOnTargets(), spell_sha_stormblast_damage::TriggerDamage(), Aura::Update(), Guardian::UpdateArmor(), Player::UpdateArmor(), Player::UpdateAttackPowerAndDamage(), Player::UpdateItemLevelAreaBasedScaling(), Player::UpdateRating(), Guardian::UpdateResistances(), Unit::UpdateSpeed(), and Guardian::UpdateStats().

◆ Coalesce()

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

Definition at line 572 of file Util.h.

◆ CompareValues()

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

Definition at line 543 of file Util.h.

References ABORT, COMP_TYPE_EQ, COMP_TYPE_HIGH, COMP_TYPE_HIGH_EQ, COMP_TYPE_LOW, and COMP_TYPE_LOW_EQ.

Referenced by Condition::Meets().

◆ consoleToUtf8()

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

Definition at line 692 of file Util.cpp.

References WStrToUtf8().

◆ CreatePIDFile()

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

create PID file

Definition at line 277 of file Util.cpp.

References GetPID().

Referenced by main().

◆ DegToRad()

TC_COMMON_API float DegToRad ( float  degrees)

Definition at line 880 of file Util.cpp.

References M_PI.

Referenced by ObjectMgr::LoadWorldSafeLocs(), and Spell::SelectImplicitConeTargets().

◆ 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 622 of file Util.cpp.

References isCyrillicCharacter().

Referenced by ObjectMgr::CheckDeclinedNames().

◆ GetPctOf()

template<class T >
float GetPctOf ( T  value,
T  max 
)
inline

◆ GetPID()

TC_COMMON_API uint32 GetPID ( )

Definition at line 291 of file Util.cpp.

Referenced by CreatePIDFile(), and Battlenet::Services::V1::Connection::HandleConnect().

◆ HexStrToByteArray() [1/2]

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

Definition at line 442 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 437 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 449 of file Util.h.

References Trinity::Impl::HexStrToByteArray().

Referenced by ConditionMgr::IsMeetingWorldStateExpression().

◆ isBasicLatinCharacter()

bool isBasicLatinCharacter ( wchar_t  wchar)
inline

◆ isBasicLatinString()

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

Definition at line 231 of file Util.h.

References isBasicLatinCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ isChineseCharacter()

bool isChineseCharacter ( wchar_t  wchar)
inline

Definition at line 194 of file Util.h.

Referenced by isChineseString().

◆ isChineseString()

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

Definition at line 263 of file Util.h.

References isChineseCharacter(), 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 247 of file Util.h.

References isCyrillicCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ isExtendedLatinCharacter()

bool isExtendedLatinCharacter ( wchar_t  wchar)
inline

Definition at line 130 of file Util.h.

References isBasicLatinCharacter().

Referenced by isExtendedLatinString().

◆ isExtendedLatinString()

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

Definition at line 239 of file Util.h.

References isExtendedLatinCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ isKoreanCharacter()

bool isKoreanCharacter ( wchar_t  wchar)
inline

Definition at line 181 of file Util.h.

Referenced by isKoreanString().

◆ isKoreanString()

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

Definition at line 255 of file Util.h.

References isKoreanCharacter(), and isNumericOrSpace().

Referenced by isValidString().

◆ isLatin1Character()

bool isLatin1Character ( wchar_t  wchar)
inline

Definition at line 151 of file Util.h.

References isBasicLatinCharacter().

◆ isLower()

bool isLower ( wchar_t  wchar)
inline

Definition at line 339 of file Util.h.

Referenced by isUpper().

◆ isNumeric() [1/3]

bool isNumeric ( char  c)
inline

Definition at line 212 of file Util.h.

◆ isNumeric() [2/3]

bool isNumeric ( char const *  str)
inline

Definition at line 217 of file Util.h.

References isNumeric().

◆ isNumeric() [3/3]

bool isNumeric ( wchar_t  wchar)
inline

◆ isNumericOrSpace()

bool isNumericOrSpace ( wchar_t  wchar)
inline

◆ isUpper()

bool isUpper ( wchar_t  wchar)
inline

Definition at line 352 of file Util.h.

References isLower().

Referenced by LanguageMgr::Translate().

◆ MoneyStringToMoney()

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

Definition at line 180 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 764 of file Util.cpp.

References WStrToUtf8().

Referenced by CliThread().

◆ RemoveCRLF()

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

Definition at line 797 of file Util.cpp.

Referenced by CliThread(), and LoadGameTable().

◆ RoundToInterval()

◆ secsToTimeString()

◆ StringCompareLessI()

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

Definition at line 860 of file Util.cpp.

References charToLower.

Referenced by StringCompareLessI_T::operator()().

◆ StringContainsStringI()

◆ StringEqualI()

TC_COMMON_API bool StringEqualI ( std::string_view  str1,
std::string_view  str2 
)

Definition at line 849 of file Util.cpp.

Referenced by StringStartsWithI().

◆ StringReplaceAll() [1/2]

TC_COMMON_API void StringReplaceAll ( std::string *  str,
std::string_view  text,
std::string_view  replacement 
)

◆ StringReplaceAll() [2/2]

std::string StringReplaceAll ( std::string_view  str,
std::string_view  text,
std::string_view  replacement 
)
inline

Definition at line 480 of file Util.h.

References StringReplaceAll().

◆ StringStartsWith()

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

Definition at line 461 of file Util.h.

Referenced by cast_commandscript::GetTriggerFlags().

◆ StringStartsWithI()

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

◆ strToLower()

TC_COMMON_API void strToLower ( std::string &  str)

Definition at line 435 of file Util.cpp.

References charToLower.

Referenced by DB2Manager::GetPowerTypeByName(), and IpLocationStore::Load().

◆ strToUpper()

TC_COMMON_API void strToUpper ( std::string &  str)

Definition at line 434 of file Util.cpp.

References charToUpper.

◆ TimeBreakdown()

◆ TimeStringToSecs()

◆ TimeToHumanReadable()

TC_COMMON_API std::string TimeToHumanReadable ( time_t  t)

Definition at line 267 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 723 of file Util.cpp.

References vutf8printf().

◆ utf8ToConsole()

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

Definition at line 675 of file Util.cpp.

References Utf8toWStr().

◆ Utf8ToUpperOnlyLatin()

TC_COMMON_API bool Utf8ToUpperOnlyLatin ( std::string &  utf8String)

◆ Utf8toWStr() [1/3]

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

Definition at line 336 of file Util.cpp.

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

Referenced by AuctionHouseObject::AddAuction(), ObjectMgr::AddGameTele(), ObjectMgr::CheckDeclinedNames(), ObjectMgr::CheckPetName(), ObjectMgr::CheckPlayerName(), ChannelMgr::CreateCustomChannel(), ObjectMgr::DeleteGameTele(), ChannelMgr::GetChannel(), ChannelMgr::GetChannelForPlayerByNamePart(), ChannelMgr::GetCustomChannel(), ObjectMgr::GetGameTele(), ObjectMgr::GetGameTeleExactName(), WorldSession::HandleAuctionBrowseQuery(), 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(), DB2Manager::IndexLoadedStores(), ObjectMgr::IsReservedName(), ObjectMgr::IsValidCharterName(), ChannelMgr::LoadFromDB(), ObjectMgr::LoadGameTele(), ObjectMgr::LoadReservedPlayersNames(), normalizePlayerName(), LanguageMgr::Translate(), Trinity::ChatCommands::WTail::TryConsume(), Trinity::Impl::ChatCommands::ArgInfo< std::wstring >::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 370 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 108 of file Util.h.

References Utf8toWStr().

◆ utf8truncate()

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

Definition at line 315 of file Util.cpp.

Referenced by PlayerSocial::SetFriendNote(), and Guild::BankTab::SetText().

◆ vutf8printf()

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

Definition at line 731 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 783 of file Util.cpp.

References Utf8toWStr().

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

◆ wstrCaseAccentInsensitiveParse()

TC_COMMON_API std::wstring wstrCaseAccentInsensitiveParse ( std::wstring_view  wstr,
LocaleConstant  locale 
)

◆ wstrToLower()

◆ wstrToUpper()

TC_COMMON_API void wstrToUpper ( std::wstring &  str)

Definition at line 432 of file Util.cpp.

References wcharToUpper.

◆ WStrToUtf8() [1/2]

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

Definition at line 409 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 386 of file Util.cpp.

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

Variable Documentation

◆ charToLower

◆ charToUpper

◆ CStringSentinel

◆ wcharToLower

struct WcharToLower wcharToLower

◆ wcharToUpper

◆ wcharToUpperOnlyLatin

struct WcharToUpperOnlyLatin wcharToUpperOnlyLatin

Referenced by Utf8ToUpperOnlyLatin().