TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StringFormat.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITYCORE_STRING_FORMAT_H
20 #define TRINITYCORE_STRING_FORMAT_H
21 
22 #include "cppformat/format.h"
23 
24 namespace Trinity
25 {
27  template<typename Format, typename... Args>
28  inline std::string StringFormat(Format&& fmt, Args&&... args)
29  {
30  return fmt::sprintf(std::forward<Format>(fmt), std::forward<Args>(args)...);
31  }
32 
34  inline bool IsFormatEmptyOrNull(const char* fmt)
35  {
36  return fmt == nullptr;
37  }
38 
40  inline bool IsFormatEmptyOrNull(std::string const& fmt)
41  {
42  return fmt.empty();
43  }
44 }
45 
46 #endif
bool IsFormatEmptyOrNull(const char *fmt)
Returns true if the given char pointer is null.
Definition: StringFormat.h:34
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
std::string StringFormat(Format &&fmt, Args &&...args)
Default TC string format function.
Definition: StringFormat.h:28
Definition: format.h:285
Definition: Common.h:172