diff --git a/libs/container/stack.h b/libs/container/stack.h index de814223..06901db6 100644 --- a/libs/container/stack.h +++ b/libs/container/stack.h @@ -37,10 +37,7 @@ class Stack : public DefaultAllocator { typedef DefaultAllocator 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 ); diff --git a/libs/scenelib.h b/libs/scenelib.h index 57ce015b..4fc318b5 100644 --- a/libs/scenelib.h +++ b/libs/scenelib.h @@ -116,7 +116,7 @@ template class StaticNodeType { public: - enum unnamed0 { SIZE = NODETYPEID_MAX }; + static constexpr size_t SIZE = NODETYPEID_MAX; static TypeId getTypeId(){ return Static< NodeType >::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 class StaticInstanceType { public: - enum unnamed0 { SIZE = INSTANCETYPEID_MAX }; + static constexpr size_t SIZE = INSTANCETYPEID_MAX; static TypeId getTypeId(){ return Static< InstanceType >::instance().getTypeId(); } diff --git a/libs/stream/textstream.h b/libs/stream/textstream.h index 96ee3cd8..3c20f42c 100644 --- a/libs/stream/textstream.h +++ b/libs/stream/textstream.h @@ -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(); diff --git a/libs/xml/xmlparser.h b/libs/xml/xmlparser.h index 86c2811c..b25ca60a 100644 --- a/libs/xml/xmlparser.h +++ b/libs/xml/xmlparser.h @@ -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( 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( res ), 0 ); } diff --git a/plugins/archivezip/zlibstream.h b/plugins/archivezip/zlibstream.h index 7245948f..2997dd50 100644 --- a/plugins/archivezip/zlibstream.h +++ b/plugins/archivezip/zlibstream.h @@ -23,6 +23,7 @@ #include "zlib.h" #include "idatastream.h" +#include // std::size /// \brief A wrapper around an InputStream of data compressed with the zlib deflate algorithm. /// @@ -32,8 +33,7 @@ class DeflatedInputStream : public InputStream { InputStream& m_istream; z_stream m_zipstream; - enum unnamed0 { m_bufsize = 1024 }; - unsigned char m_buffer[m_bufsize]; + unsigned char m_buffer[1024]; public: DeflatedInputStream( InputStream& istream ) @@ -54,7 +54,7 @@ public: { if ( m_zipstream.avail_in == 0 ) { m_zipstream.next_in = m_buffer; - m_zipstream.avail_in = static_cast( m_istream.read( m_buffer, m_bufsize ) ); + m_zipstream.avail_in = static_cast( m_istream.read( m_buffer, std::size( m_buffer ) ) ); } if ( inflate( &m_zipstream, Z_SYNC_FLUSH ) != Z_OK ) { break; diff --git a/radiant/points.cpp b/radiant/points.cpp index 623613a1..2c402e81 100644 --- a/radiant/points.cpp +++ b/radiant/points.cpp @@ -55,11 +55,7 @@ void Pointfile_Parse( CPointfile& pointfile ); class CPointfile : public ISAXHandler, public Renderable, public OpenGLRenderable { - enum - { - MAX_POINTFILE = 8192, - }; - Vector3 s_pointvecs[MAX_POINTFILE]; + Vector3 s_pointvecs[8192]; std::size_t s_num_points; int m_displaylist; static Shader* m_renderstate; @@ -149,7 +145,7 @@ void CPointfile::Init(){ } void CPointfile::PushPoint( const Vector3& v ){ - if ( s_num_points < MAX_POINTFILE ) { + if ( s_num_points < std::size( s_pointvecs ) ) { s_pointvecs[s_num_points] = v; ++s_num_points; } diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index a7acc021..6c247c1e 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -61,7 +61,7 @@ void message_print( message_info_t* self, const char* characters, std::size_t le const char* end = characters + length; while ( characters != end ) { - std::size_t space = message_info_t::bufsize - 1 - self->m_length; + std::size_t space = std::size( self->m_buffer ) - 1 - self->m_length; if ( space == 0 ) { message_flush( self ); } diff --git a/radiant/xmlstuff.h b/radiant/xmlstuff.h index 6c1428f8..99ca6c79 100644 --- a/radiant/xmlstuff.h +++ b/radiant/xmlstuff.h @@ -57,8 +57,7 @@ struct message_info_t int geometry_depth; // are we parsing some geometry information (i.e. do we forward the SAX calls?) ISAXHandler* pGeometry; // the handler - enum unnamed0 { bufsize = 1024 }; - char m_buffer[bufsize]; + char m_buffer[1024]; std::size_t m_length; };