mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Remove CStr::Pad
It was only used once. It can be replaced by fmt.
This commit is contained in:
@@ -434,37 +434,6 @@ CStr CStr::Trim(PS_TRIM_MODE mode) const
|
|||||||
return substr(left, right - left + 1);
|
return substr(left, right - left + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CStr CStr::Pad(PS_TRIM_MODE mode, size_t len) const
|
|
||||||
{
|
|
||||||
size_t left = 0, right = 0;
|
|
||||||
|
|
||||||
if (len <= length())
|
|
||||||
return *this;
|
|
||||||
|
|
||||||
// From here: Length-length() >= 1
|
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case PS_TRIM_LEFT:
|
|
||||||
left = len - length();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PS_TRIM_RIGHT:
|
|
||||||
right = len - length();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PS_TRIM_BOTH:
|
|
||||||
left = (len - length() + 1) / 2;
|
|
||||||
right = (len - length() - 1) / 2; // cannot be negative
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
debug_warn(L"CStr::Trim: invalid Mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
return StrBase(left, ' ') + *this + StrBase(right, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t CStr::GetHashCode() const
|
size_t CStr::GetHashCode() const
|
||||||
{
|
{
|
||||||
return (size_t)fnv_hash(data(), length()*sizeof(value_type));
|
return (size_t)fnv_hash(data(), length()*sizeof(value_type));
|
||||||
|
|||||||
+1
-10
@@ -24,7 +24,7 @@
|
|||||||
#define INCLUDED_CSTR
|
#define INCLUDED_CSTR
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whitespace trim identifier for Trim and Pad functions
|
* Whitespace trim identifier for Trim functions
|
||||||
**/
|
**/
|
||||||
enum PS_TRIM_MODE
|
enum PS_TRIM_MODE
|
||||||
{
|
{
|
||||||
@@ -233,15 +233,6 @@ public:
|
|||||||
**/
|
**/
|
||||||
CStr Trim(PS_TRIM_MODE mode) const;
|
CStr Trim(PS_TRIM_MODE mode) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a space padded copy of the CStr.
|
|
||||||
*
|
|
||||||
* @param PS_TRIM_MODE Mode value from trim mode enumeration.
|
|
||||||
* @param size_t Length number of pad spaces to add
|
|
||||||
* @return CStr copy of padded CStr.
|
|
||||||
**/
|
|
||||||
CStr Pad(PS_TRIM_MODE mode, size_t len) const;
|
|
||||||
|
|
||||||
// Conversion to u16string
|
// Conversion to u16string
|
||||||
std::u16string utf16() const { return std::u16string(begin(), end()); }
|
std::u16string utf16() const { return std::u16string(begin(), end()); }
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <SDL_keycode.h>
|
#include <SDL_keycode.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <fmt/ostream.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <js/RootingAPI.h>
|
#include <js/RootingAPI.h>
|
||||||
#include <js/TypeDecls.h>
|
#include <js/TypeDecls.h>
|
||||||
@@ -405,8 +406,8 @@ namespace
|
|||||||
for (size_t r = 0; r < data.size()/cols; ++r)
|
for (size_t r = 0; r < data.size()/cols; ++r)
|
||||||
{
|
{
|
||||||
for (size_t c = 0; c < cols; ++c)
|
for (size_t c = 0; c < cols; ++c)
|
||||||
m_OutputStream << (c ? " | " : "\n")
|
fmt::print(m_OutputStream, "{}{:<{}}", c ? " | " : "\n", data[r * cols + c],
|
||||||
<< data[r*cols + c].Pad(PS_TRIM_RIGHT, columnWidths[c]);
|
columnWidths[c]);
|
||||||
|
|
||||||
// Add dividers under some rows. (Currently only the first, since
|
// Add dividers under some rows. (Currently only the first, since
|
||||||
// that contains the column headers.)
|
// that contains the column headers.)
|
||||||
|
|||||||
Reference in New Issue
Block a user