mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 16:53:30 +01:00
Use size_t for String size types
This commit is contained in:
parent
cff3818e68
commit
b3b29f4b4c
@ -7,6 +7,8 @@
|
|||||||
#ifndef CATCH_STRING_H_INCLUDED
|
#ifndef CATCH_STRING_H_INCLUDED
|
||||||
#define CATCH_STRING_H_INCLUDED
|
#define CATCH_STRING_H_INCLUDED
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class StringData;
|
class StringData;
|
||||||
@ -22,7 +24,7 @@ namespace Catch {
|
|||||||
|
|
||||||
StringData const* m_data = nullptr;
|
StringData const* m_data = nullptr;
|
||||||
public:
|
public:
|
||||||
using size_type = unsigned long;
|
using size_type = size_t;
|
||||||
|
|
||||||
String();
|
String();
|
||||||
String( StringRef const& stringRef );
|
String( StringRef const& stringRef );
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include "catch_stringref.h"
|
#include "catch_stringref.h"
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class String;
|
class String;
|
||||||
@ -22,7 +24,7 @@ namespace Catch {
|
|||||||
class StringBuilder {
|
class StringBuilder {
|
||||||
friend class String;
|
friend class String;
|
||||||
public:
|
public:
|
||||||
using size_type = unsigned long;
|
using size_type = size_t;
|
||||||
|
|
||||||
StringBuilder();
|
StringBuilder();
|
||||||
StringBuilder( size_type initialCapacity );
|
StringBuilder( size_type initialCapacity );
|
||||||
|
@ -21,7 +21,7 @@ namespace Catch {
|
|||||||
auto StringData::create( StringRef const& stringRef ) -> StringData* {
|
auto StringData::create( StringRef const& stringRef ) -> StringData* {
|
||||||
return create( stringRef, stringRef.size() );
|
return create( stringRef, stringRef.size() );
|
||||||
}
|
}
|
||||||
auto StringData::create( StringRef const& stringRef, unsigned long capacity ) -> StringData* {
|
auto StringData::create( StringRef const& stringRef, size_t capacity ) -> StringData* {
|
||||||
if( capacity == 0 ) {
|
if( capacity == 0 ) {
|
||||||
return getEmpty();
|
return getEmpty();
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ namespace Catch {
|
|||||||
: m_refs( initialRef ),
|
: m_refs( initialRef ),
|
||||||
size( 0 )
|
size( 0 )
|
||||||
{}
|
{}
|
||||||
StringData::StringData( StringRef const& stringRef, unsigned long capacity )
|
StringData::StringData( StringRef const& stringRef, size_t capacity )
|
||||||
: m_refs( 1 ),
|
: m_refs( 1 ),
|
||||||
size( capacity)
|
size( capacity)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#define CATCH_STRINGDATA_H_INCLUDED
|
#define CATCH_STRINGDATA_H_INCLUDED
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ namespace Catch {
|
|||||||
class StringData {
|
class StringData {
|
||||||
mutable std::atomic<unsigned int> m_refs;
|
mutable std::atomic<unsigned int> m_refs;
|
||||||
public:
|
public:
|
||||||
unsigned int size;
|
size_t size;
|
||||||
union {
|
union {
|
||||||
char chars[1];
|
char chars[1];
|
||||||
};
|
};
|
||||||
@ -26,7 +27,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
static auto getEmpty() -> StringData*;
|
static auto getEmpty() -> StringData*;
|
||||||
static auto create( StringRef const& stringRef ) -> StringData*;
|
static auto create( StringRef const& stringRef ) -> StringData*;
|
||||||
static auto create( StringRef const& stringRef, unsigned long capacity ) -> StringData*;
|
static auto create( StringRef const& stringRef, size_t capacity ) -> StringData*;
|
||||||
|
|
||||||
void addRef() const noexcept {
|
void addRef() const noexcept {
|
||||||
if( m_refs > 0 )
|
if( m_refs > 0 )
|
||||||
@ -41,7 +42,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
StringData( unsigned int initialRef = 1 );
|
StringData( unsigned int initialRef = 1 );
|
||||||
StringData( StringRef const& stringRef, unsigned long capacity );
|
StringData( StringRef const& stringRef, size_t capacity );
|
||||||
|
|
||||||
StringData( StringData const& ) = delete;
|
StringData( StringData const& ) = delete;
|
||||||
StringData& operator=( StringData const& ) = delete;
|
StringData& operator=( StringData const& ) = delete;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#ifndef CATCH_STRINGREF_H_INCLUDED
|
#ifndef CATCH_STRINGREF_H_INCLUDED
|
||||||
#define CATCH_STRINGREF_H_INCLUDED
|
#define CATCH_STRINGREF_H_INCLUDED
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class String;
|
class String;
|
||||||
@ -24,7 +26,7 @@ namespace Catch {
|
|||||||
friend class StringData;
|
friend class StringData;
|
||||||
friend class StringBuilder;
|
friend class StringBuilder;
|
||||||
|
|
||||||
using size_type = unsigned long;
|
using size_type = size_t;
|
||||||
|
|
||||||
char const* m_start;
|
char const* m_start;
|
||||||
size_type m_size;
|
size_type m_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user