![]() |
TrinityCore
|
#include "Util.h"#include "Common.h"#include "Containers.h"#include "IpAddress.h"#include "StringConvert.h"#include "StringFormat.h"#include <utf8.h>#include <algorithm>#include <iomanip>#include <sstream>#include <string>#include <cctype>#include <cstdarg>#include <ctime>#include <boost/core/demangle.hpp>
Include dependency graph for Util.cpp:Go to the source code of this file.
Functions | |
| tm | TimeBreakdown (time_t time) |
| time_t | GetLocalHourTimestamp (time_t time, uint8 hour, bool onlyAfterTime) |
| std::string | secsToTimeString (uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly) |
| Optional< int32 > | MoneyStringToMoney (std::string const &moneyString) |
| uint32 | TimeStringToSecs (std::string const ×tring) |
| std::string | TimeToTimestampStr (time_t t) |
| std::string | TimeToHumanReadable (time_t t) |
| bool | IsIPAddress (char const *ipaddress) |
| Check if the string is a valid ip address representation. | |
| uint32 | CreatePIDFile (std::string const &filename) |
| create PID file | |
| uint32 | GetPID () |
| size_t | utf8length (std::string &utf8str) |
| void | utf8truncate (std::string &utf8str, size_t len) |
| bool | Utf8toWStr (char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize) |
| bool | Utf8toWStr (std::string_view utf8str, std::wstring &wstr) |
| bool | WStrToUtf8 (wchar_t const *wstr, size_t size, std::string &utf8str) |
| bool | WStrToUtf8 (std::wstring_view wstr, std::string &utf8str) |
| void | wstrToUpper (std::wstring &str) |
| void | wstrToLower (std::wstring &str) |
| void | strToUpper (std::string &str) |
| void | strToLower (std::string &str) |
| std::wstring | GetMainPartOfName (std::wstring const &wname, uint32 declension) |
| bool | utf8ToConsole (std::string_view utf8str, std::string &conStr) |
| bool | consoleToUtf8 (std::string_view conStr, std::string &utf8str) |
| bool | Utf8FitTo (std::string_view str, std::wstring_view search) |
| void | utf8printf (FILE *out, const char *str,...) |
| void | vutf8printf (FILE *out, const char *str, va_list *ap) |
| bool | Utf8ToUpperOnlyLatin (std::string &utf8String) |
| bool | ReadWinConsole (std::string &str, size_t size) |
| bool | WriteWinConsole (std::string_view str, bool error) |
| TC_COMMON_API Optional< std::size_t > | RemoveCRLF (std::string &str) |
| bool | StringEqualI (std::string_view a, std::string_view b) |
| bool | StringContainsStringI (std::string_view haystack, std::string_view needle) |
| bool | StringCompareLessI (std::string_view a, std::string_view b) |
| bool consoleToUtf8 | ( | std::string_view | conStr, |
| std::string & | utf8str | ||
| ) |
Definition at line 550 of file Util.cpp.
References WStrToUtf8().
| uint32 CreatePIDFile | ( | std::string const & | filename | ) |
| time_t GetLocalHourTimestamp | ( | time_t | time, |
| uint8 | hour, | ||
| bool | onlyAfterTime | ||
| ) |
Definition at line 100 of file Util.cpp.
References DAY, HOUR, and TimeBreakdown().
Referenced by GetNextDailyResetTime(), InstanceSaveManager::GetSubsequentResetTime(), World::InitCalendarOldEventsDeletionTime(), InstanceSaveManager::LoadResetTimes(), and World::TriggerGuidWarning().
| std::wstring GetMainPartOfName | ( | std::wstring const & | wname, |
| uint32 | declension | ||
| ) |
Definition at line 484 of file Util.cpp.
References isCyrillicCharacter().
Referenced by ObjectMgr::CheckDeclinedNames().
| uint32 GetPID | ( | ) |
Definition at line 338 of file Util.cpp.
Referenced by CreatePIDFile().
| 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().
Definition at line 216 of file Util.cpp.
References Trinity::Tokenize().
Referenced by modify_commandscript::HandleModifyMoneyCommand().
| bool ReadWinConsole | ( | std::string & | str, |
| size_t | size | ||
| ) |
| TC_COMMON_API Optional< std::size_t > RemoveCRLF | ( | std::string & | str | ) |
Definition at line 654 of file Util.cpp.
Referenced by CliThread().
| std::string secsToTimeString | ( | uint64 | timeInSecs, |
| TimeFormat | timeFormat, | ||
| bool | hoursOnly | ||
| ) |
Definition at line 115 of file Util.cpp.
References DAY, FullText, HOUR, MINUTE, Numeric, ShortText, and Trinity::StringFormat().
Referenced by GmTicket::FormatMessageString(), ban_commandscript::HandleBanCharacterCommand(), ban_commandscript::HandleBanHelper(), ban_commandscript::HandleBanInfoCharacterCommand(), ban_commandscript::HandleBanInfoHelper(), ban_commandscript::HandleBanInfoIPCommand(), WorldSession::HandleChatMessage(), event_commandscript::HandleEventInfoCommand(), gobject_commandscript::HandleGameObjectTargetCommand(), instance_commandscript::HandleInstanceListBindsCommand(), instance_commandscript::HandleInstanceUnbindCommand(), list_commandscript::HandleListRespawnsCommand(), npc_commandscript::HandleNpcInfoCommand(), misc_commandscript::HandlePInfoCommand(), server_commandscript::HandleServerInfoCommand(), WorldSession::HandleTextEmoteOpcode(), main(), GmTicket::SetChatLog(), World::ShutdownMsg(), and Warden::Update().
| bool StringCompareLessI | ( | std::string_view | a, |
| std::string_view | b | ||
| ) |
Definition at line 717 of file Util.cpp.
Referenced by StringCompareLessI_T::operator()().
| bool StringContainsStringI | ( | std::string_view | haystack, |
| std::string_view | needle | ||
| ) |
Definition at line 711 of file Util.cpp.
Referenced by arena_commandscript::HandleArenaLookupCommand(), message_commandscript::HandleChannelSetOwnership(), go_commandscript::HandleGoBossCommand(), go_commandscript::HandleGoInstanceCommand(), and ValueContainsStringI().
| bool StringEqualI | ( | std::string_view | a, |
| std::string_view | b | ||
| ) |
Definition at line 706 of file Util.cpp.
Referenced by Trinity::Impl::StringConvertImpl::For< T, std::enable_if_t< std::is_integral_v< T > &&!std::is_same_v< T, bool > > >::FromString(), Trinity::Impl::StringConvertImpl::For< bool, void >::FromString(), Trinity::Impl::StringConvertImpl::For< T, std::enable_if_t< std::is_floating_point_v< T > > >::FromString(), ArenaTeamMgr::GetArenaTeamByName(), Trinity::Impl::ChatCommands::ChatCommandNode::GetAutoCompletionsFor(), GuildMgr::GetGuildByName(), debug_commandscript::HandleDebugTransportCommand(), misc_commandscript::HandleLinkGraveCommand(), misc_commandscript::HandleNearGraveCommand(), npc_commandscript::HandleNpcAddTempSpawnCommand(), Trinity::Impl::ChatCommands::ArgInfo< T, std::enable_if_t< std::is_enum_v< T > > >::Match(), Trinity::Impl::ChatCommands::ChatCommandNode::SendCommandHelpFor(), StringStartsWithI(), Trinity::ChatCommands::ExactSequence< chars >::TryConsume(), and Trinity::Impl::ChatCommands::ChatCommandNode::TryExecuteCommand().
| void strToLower | ( | std::string & | str | ) |
Definition at line 482 of file Util.cpp.
References charToLower.
Referenced by ExtractGameobjectModels(), and IpLocationStore::Load().
| void strToUpper | ( | std::string & | str | ) |
Definition at line 481 of file Util.cpp.
References charToUpper.
| tm TimeBreakdown | ( | time_t | time | ) |
Definition at line 93 of file Util.cpp.
Referenced by GetLocalHourTimestamp(), GetNextMonthlyResetTime(), GetNextWeeklyResetTime(), and Trinity::Timezone::GetSystemZoneOffsetAt().
| uint32 TimeStringToSecs | ( | std::string const & | timestring | ) |
Definition at line 258 of file Util.cpp.
References DAY, HOUR, and MINUTE.
Referenced by World::BanAccount(), World::BanCharacter(), ban_commandscript::HandleBanCharacterCommand(), ban_commandscript::HandleBanHelper(), and server_commandscript::ShutdownServer().
| std::string TimeToHumanReadable | ( | time_t | t | ) |
Definition at line 303 of file Util.cpp.
Referenced by debug_commandscript::HandleDebugQuestResetCommand().
| std::string TimeToTimestampStr | ( | time_t | t | ) |
Definition at line 290 of file Util.cpp.
References Trinity::StringFormat().
Referenced by ban_commandscript::HandleBanInfoCharacterCommand(), character_commandscript::HandleCharacterDeletedListHelper(), event_commandscript::HandleEventInfoCommand(), and list_commandscript::HandleListMailCommand().
| bool Utf8FitTo | ( | std::string_view | str, |
| std::wstring_view | search | ||
| ) |
Definition at line 565 of file Util.cpp.
References Utf8toWStr(), and wstrToLower().
Referenced by AuctionHouseObject::BuildListAuctionItems(), learn_commandscript::HandleLearnAllRecipesCommand(), 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::HandleLookupTitleCommand(), WorldSession::HandleWhoOpcode(), and list_commandscript::ShouldListAura().
| size_t utf8length | ( | std::string & | utf8str | ) |
Definition at line 349 of file Util.cpp.
Referenced by AccountMgr::ChangeEmail(), AccountMgr::ChangePassword(), AccountMgr::ChangeRegEmail(), AccountMgr::ChangeUsername(), AccountMgr::CreateAccount(), and WorldSession::HandleJoinChannel().
| void utf8printf | ( | FILE * | out, |
| const char * | str, | ||
| ... | |||
| ) |
Definition at line 581 of file Util.cpp.
References vutf8printf().
Referenced by AppenderConsole::Print().
| bool utf8ToConsole | ( | std::string_view | utf8str, |
| std::string & | conStr | ||
| ) |
Definition at line 533 of file Util.cpp.
References Utf8toWStr().
| bool Utf8ToUpperOnlyLatin | ( | std::string & | utf8String | ) |
Definition at line 610 of file Util.cpp.
References Utf8toWStr(), wcharToUpperOnlyLatin, and WStrToUtf8().
Referenced by AccountMgr::ChangeEmail(), AccountMgr::ChangePassword(), AccountMgr::ChangeRegEmail(), AccountMgr::ChangeUsername(), RASession::CheckAccessLevel(), AccountMgr::CheckEmail(), RASession::CheckPassword(), AccountMgr::CheckPassword(), AccountMgr::CreateAccount(), account_commandscript::HandleAccountDeleteCommand(), account_commandscript::HandleAccountSet2FACommand(), account_commandscript::HandleAccountSetAddonCommand(), account_commandscript::HandleAccountSetEmailCommand(), account_commandscript::HandleAccountSetPasswordCommand(), account_commandscript::HandleAccountSetRegEmailCommand(), account_commandscript::HandleAccountSetSecLevelCommand(), ban_commandscript::HandleBanHelper(), ban_commandscript::HandleBanInfoAccountCommand(), debug_commandscript::HandleDebugQuestResetCommand(), lookup_commandscript::HandleLookupPlayerAccountCommand(), misc_commandscript::HandleMuteHistoryCommand(), ban_commandscript::HandleUnBanHelper(), PlayerDump::InitializeTables(), AccountInfo::LoadResult(), StringsEqualCaseInsensitive(), and Trinity::ChatCommands::AccountIdentifier::TryConsume().
| 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().
| bool Utf8toWStr | ( | std::string_view | utf8str, |
| std::wstring & | wstr | ||
| ) |
Definition at line 417 of file Util.cpp.
Referenced by Utf8toWStr().
| void utf8truncate | ( | std::string & | utf8str, |
| size_t | len | ||
| ) |
Definition at line 362 of file Util.cpp.
Referenced by PlayerSocial::SetFriendNote().
| void vutf8printf | ( | FILE * | out, |
| const char * | str, | ||
| va_list * | ap | ||
| ) |
| bool WriteWinConsole | ( | std::string_view | str, |
| bool | error | ||
| ) |
Definition at line 641 of file Util.cpp.
References Utf8toWStr().
Referenced by AppenderConsole::Print(), and utf8print().
| void wstrToLower | ( | std::wstring & | str | ) |
Definition at line 480 of file Util.cpp.
References wcharToLower.
Referenced by ObjectMgr::AddGameTele(), ObjectMgr::CheckPlayerName(), ChannelMgr::CreateCustomChannel(), ObjectMgr::DeleteGameTele(), ChannelMgr::GetChannel(), ChannelMgr::GetChannelForPlayerByNamePart(), ChannelMgr::GetCustomChannel(), ObjectMgr::GetGameTele(), ObjectMgr::GetGameTeleExactName(), WorldSession::HandleAuctionListItems(), learn_commandscript::HandleLearnAllRecipesCommand(), 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::HandleWhoOpcode(), ObjectMgr::IsReservedName(), list_commandscript::ListAurasCommand(), ObjectMgr::LoadGameTele(), ObjectMgr::LoadReservedPlayersNames(), normalizePlayerName(), WhoListStorageMgr::Update(), and Utf8FitTo().
| void wstrToUpper | ( | std::wstring & | str | ) |
Definition at line 479 of file Util.cpp.
References wcharToUpper.
| bool WStrToUtf8 | ( | std::wstring_view | wstr, |
| std::string & | utf8str | ||
| ) |
| 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().