Skip to content

Commit

Permalink
feat(Core/DBLayer): replace char const* to std::string_view (#10211)
Browse files Browse the repository at this point in the history
* feat(Core/DBLayer): replace `char const*` to `std::string_view`

* CString

* 1

* chore(Core/Misc): code cleanup

* cl

* db fix

* fmt style sql

* to fmt

* py

* del old

* 1

* 2

* 3

* 1

* 1
  • Loading branch information
Winfidonarleyan authored Feb 4, 2022
1 parent d6ead1d commit de13bf4
Show file tree
Hide file tree
Showing 140 changed files with 4,966 additions and 4,793 deletions.
66 changes: 36 additions & 30 deletions apps/Fmt/FormatReplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ def islog(line):
# else :
# return False

# def isPQuery(line):
# substring = 'PQuery'
# if substring in line:
# return True
# else :
# return False
def isPQuery(line):
substring = 'PQuery'
if substring in line:
return True
else :
return False

# def isPExecute(line):
# substring = 'PExecute'
# if substring in line:
# return True
# else :
# return False
def isPExecute(line):
substring = 'PExecute'
if substring in line:
return True
else :
return False

# def isPAppend(line):
# substring = 'PAppend'
# if substring in line:
# return True
# else :
# return False
def isPAppend(line):
substring = 'PAppend'
if substring in line:
return True
else :
return False

# def isStringFormat(line):
# substring = 'StringFormat'
Expand All @@ -83,12 +83,15 @@ def checkSoloLine(line):
return handleCleanup(line), False
elif islog(line):
return handleCleanup(line), False
# elif isPExecute(line):
# return handleCleanup(line), False
# elif isPQuery(line):
# return handleCleanup(line), False
# elif isPAppend(line):
# return handleCleanup(line), False
elif isPExecute(line):
line = line.replace("PExecute", "Execute");
return handleCleanup(line), False
elif isPQuery(line):
line = line.replace("PQuery", "Query");
return handleCleanup(line), False
elif isPAppend(line):
line = line.replace("PAppend", "Append");
return handleCleanup(line), False
# elif isSendSysMessage(line):
# return handleCleanup(line), False
# elif isPSendSysMessage(line):
Expand All @@ -110,12 +113,15 @@ def startMultiLine(line):
# return handleCleanup(line), True
# elif isPSendSysMessage(line):
# return handleCleanup(line), True
# elif isPQuery(line):
# return handleCleanup(line), True
# elif isPExecute(line):
# return handleCleanup(line), True
# elif isPAppend(line):
# return handleCleanup(line), True
elif isPQuery(line):
line = line.replace("PQuery", "Query");
return handleCleanup(line), True
elif isPExecute(line):
line = line.replace("PExecute", "Execute");
return handleCleanup(line), True
elif isPAppend(line):
line = line.replace("PAppend", "Append");
return handleCleanup(line), True
# elif isStringFormat(line):
# return handleCleanup(line), True
else :
Expand Down
5 changes: 5 additions & 0 deletions data/sql/updates/pending_db_world/rev_1643662892603722900.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1643662892603722900');

UPDATE `creature_template` SET `RegenHealth` = 0 WHERE `RegenHealth` >= 2;
UPDATE `creature_onkill_reputation` SET `IsTeamAward1` = 0 WHERE `IsTeamAward1` >= 2;
UPDATE `creature_onkill_reputation` SET `IsTeamAward2` = 0 WHERE `IsTeamAward2` >= 2;
118 changes: 118 additions & 0 deletions doc/changelog/pendings/changes_1643570355041139200.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
## How to upgrade
- `PrepareStatment`

```diff
- setNull(...)
+ SetData(...)
```
```diff
- setBool(...)
+ SetData(...)
```
```diff
- setUInt8(...)
+ SetData(...)
```
```diff
- setInt8(...)
+ SetData(...)
```
```diff
- setUInt16(...)
+ SetData(...)
```
```diff
- setInt16(...)
+ SetData(...)
```
```diff
- setUInt32(...)
+ SetData(...)
```
```diff
- setUInt64(...)
+ SetData(...)
```
```diff
- setInt64(...)
+ SetData(...)
```
```diff
- setFloat(...)
+ SetData(...)
```
```diff
- setDouble(...)
+ SetData(...)
```
```diff
- setString(...)
+ SetData(...)
```
```diff
- setStringView(...)
+ SetData(...)
```
```diff
- setBinary(...)
+ SetData(...)
```

- `Fields`

```diff
- GetBool()
+ Get<bool>()
```
```diff
- GetUInt8()
+ Get<uint8>()
```
```diff
- GetInt8()
+ Get<int8>()
```
```diff
- GetUInt16()
+ Get<uint16>()
```
```diff
- GetInt16()
+ Get<int16>()
```
```diff
- GetUInt32()
+ Get<uint32>()
```
```diff
- GetInt32()
+ Get<int32>()
```
```diff
- GetUInt64()
+ Get<uint64>()
```
```diff
- GetInt64()
+ Get<int64>()
```
```diff
- GetFloat()
+ Get<float>()
```
```diff
- GetDouble()
+ Get<double>()
```
```diff
- GetString()
+ Get<std::string>()
```
```diff
- GetStringView()
+ Get<std::string_view>()
```
```diff
- GetBinary()
+ Get<Binary>()
```
6 changes: 6 additions & 0 deletions src/cmake/compiler/msvc/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ target_compile_options(acore-compile-option-interface
/wd4351 # C4351: new behavior: elements of array 'x' will be default initialized
/wd4091) # C4091: 'typedef ': ignored on left of '' when no variable is declared

# Define NOMINMAX
target_compile_definitions(acore-compile-option-interface
INTERFACE
-DNOMINMAX)
message(STATUS "MSVC: Enable NOMINMAX")

if(NOT WITH_WARNINGS)
target_compile_options(acore-warning-interface
INTERFACE
Expand Down
9 changes: 0 additions & 9 deletions src/common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ AC_COMMON_API extern char const* localeNames[TOTAL_LOCALES];
AC_COMMON_API LocaleConstant GetLocaleByName(const std::string& name);
AC_COMMON_API void CleanStringForMysqlQuery(std::string& str);

// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
#ifdef max
#undef max
#endif

#ifdef min
#undef min
#endif

#define MAX_QUERY_LEN 32*1024

namespace Acore
Expand Down
2 changes: 1 addition & 1 deletion src/common/Utilities/StringFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define _STRING_FORMAT_H_

#include "Define.h"
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/printf.h>

namespace Acore
Expand Down
2 changes: 1 addition & 1 deletion src/common/Utilities/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ inline T ApplyPct(T& base, U pct)
template <class T>
inline T RoundToInterval(T& num, T floor, T ceil)
{
return num = std::min(std::max(num, floor), ceil);
return num = std::min<T>(std::max<T>(num, floor), ceil);
}

// UTF8 handling
Expand Down
Loading

0 comments on commit de13bf4

Please sign in to comment.