replace enums use for compile time constants

This commit is contained in:
Garux
2021-11-22 12:29:43 +03:00
parent 7be3cbda79
commit 86ba294cf4
8 changed files with 21 additions and 29 deletions

View File

@@ -37,10 +37,7 @@ class Stack : public DefaultAllocator<Type>
{
typedef DefaultAllocator<Type> Allocator;
enum
{
DEFAULT_CAPACITY = 4,
};
static constexpr size_t DEFAULT_CAPACITY = 4;
typedef Type* pointer;
typedef const Type* const_pointer;
@@ -58,7 +55,7 @@ private:
Allocator::construct( m_end++, value );
}
void insert_overflow( const Type& value ){
const std::size_t new_capacity = ( m_capacity ) ? m_capacity + m_capacity : std::size_t( DEFAULT_CAPACITY );
const std::size_t new_capacity = ( m_capacity ) ? m_capacity + m_capacity : DEFAULT_CAPACITY;
const pointer new_data = Allocator::allocate( new_capacity );
const pointer new_end = std::copy( m_data, m_end, new_data );

View File

@@ -116,7 +116,7 @@ template<typename Type>
class StaticNodeType
{
public:
enum unnamed0 { SIZE = NODETYPEID_MAX };
static constexpr size_t SIZE = NODETYPEID_MAX;
static TypeId getTypeId(){
return Static< NodeType<Type> >::instance().getTypeId();
}
@@ -154,10 +154,12 @@ namespace scene
class Node
{
public:
enum unnamed0 { eVisible = 0 };
enum unnamed1 { eHidden = 1 << 0 };
enum unnamed2 { eFiltered = 1 << 1 };
enum unnamed3 { eExcluded = 1 << 2 };
enum : unsigned int {
eVisible = 0,
eHidden = 1 << 0,
eFiltered = 1 << 1,
eExcluded = 1 << 2,
};
class Symbiot
{
@@ -450,7 +452,7 @@ template<typename Type>
class StaticInstanceType
{
public:
enum unnamed0 { SIZE = INSTANCETYPEID_MAX };
static constexpr size_t SIZE = INSTANCETYPEID_MAX;
static TypeId getTypeId(){
return Static< InstanceType<Type> >::instance().getTypeId();
}

View File

@@ -398,9 +398,8 @@ public:
/// \brief A wrapper for a TextOutputStream, optimised for writing a single character at a time.
class SingleCharacterOutputStream : public TextOutputStream
{
enum unnamed0 { m_bufsize = 1024 };
TextOutputStream& m_ostream;
char m_buffer[m_bufsize];
char m_buffer[1024];
char* m_pos;
const char* m_end;
@@ -415,7 +414,7 @@ class SingleCharacterOutputStream : public TextOutputStream
reset();
}
public:
SingleCharacterOutputStream( TextOutputStream& ostream ) : m_ostream( ostream ), m_pos( m_buffer ), m_end( m_buffer + m_bufsize ){
SingleCharacterOutputStream( TextOutputStream& ostream ) : m_ostream( ostream ), m_pos( m_buffer ), m_end( m_buffer + std::size( m_buffer ) ){
}
~SingleCharacterOutputStream(){
flush();

View File

@@ -180,7 +180,6 @@ public:
class XMLStreamParser : public XMLExporter
{
enum unnamed0 { BUFSIZE = 1024 };
public:
XMLStreamParser( TextInputStream& istream )
: m_istream( istream ){
@@ -188,7 +187,7 @@ public:
virtual void exportXML( XMLImporter& importer ){
//bool wellFormed = false;
char chars[BUFSIZE];
char chars[1024];
std::size_t res = m_istream.read( chars, 4 );
if ( res > 0 ) {
XMLSAXImporter sax( importer );
@@ -196,7 +195,7 @@ public:
xmlParserCtxtPtr ctxt = xmlCreatePushParserCtxt( sax.callbacks(), sax.context(), chars, static_cast<int>( res ), 0 );
ctxt->replaceEntities = 1;
while ( ( res = m_istream.read( chars, BUFSIZE ) ) > 0 )
while ( ( res = m_istream.read( chars, std::size( chars ) ) ) > 0 )
{
xmlParseChunk( ctxt, chars, static_cast<int>( res ), 0 );
}