diff --git a/qse/include/qse/Types.hpp b/qse/include/qse/Types.hpp index 19b158ab..2354c5b5 100644 --- a/qse/include/qse/Types.hpp +++ b/qse/include/qse/Types.hpp @@ -36,6 +36,9 @@ #if (__cplusplus >= 201103L) // C++11 + #define QSE_CPP_NOEXCEPT noexcept(true) + #define QSE_CPP_EXPLICIT explicit + /// The QSE_CPP_ENABLE_CPP11_MOVE macro enables C++11 move semantics /// in various classes. #define QSE_CPP_ENABLE_CPP11_MOVE 1 @@ -49,13 +52,18 @@ #define QSE_CPP_TEMPLATE_QUALIFIER template + #elif (__cplusplus >= 199711L) // C++98 + #define QSE_CPP_NOEXCEPT throw() + #define QSE_CPP_EXPLICIT + #define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name()) #define QSE_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete((ptr), (arg1))) #define QSE_CPP_TEMPLATE_QUALIFIER template - #else + #define QSE_CPP_NOEXCEPT + #define QSE_CPP_EXPLICIT #if defined(__BORLANDC__) diff --git a/qse/include/qse/cmn/HashList.hpp b/qse/include/qse/cmn/HashList.hpp index 411568a2..5744ab05 100644 --- a/qse/include/qse/cmn/HashList.hpp +++ b/qse/include/qse/cmn/HashList.hpp @@ -300,26 +300,15 @@ public: return this->datum_list->isEmpty (); } - Node* getHeadNode () - { - return this->datum_list->getHeadNode (); - } - - const Node* getHeadNode () const - { - return this->datum_list->getHeadNode (); - } - - Node* getTailNode () - { - return this->datum_list->getTailNode (); - } - - const Node* getTailNode () const - { - return this->datum_list->getTailNode (); - } + Node* getHeadNode () { return this->datum_list->getHeadNode (); } + const Node* getHeadNode () const { return this->datum_list->getHeadNode (); } + Node* getFirstNode () { return this->datum_list->getHeadNode (); } + const Node* getFirstNode () const { return this->datum_list->getHeadNode (); } + Node* getTailNode () { return this->datum_list->getTailNode (); } + const Node* getTailNode () const { return this->datum_list->getTailNode (); } + Node* getLastNode () { return this->datum_list->getTailNode (); } + const Node* getLastNode () const { return this->datum_list->getTailNode (); } protected: Node* find_node (const T& datum) const { diff --git a/qse/include/qse/cmn/HashTable.hpp b/qse/include/qse/cmn/HashTable.hpp index 283f154b..5832cf06 100644 --- a/qse/include/qse/cmn/HashTable.hpp +++ b/qse/include/qse/cmn/HashTable.hpp @@ -174,25 +174,15 @@ public: return this->pair_list.isEmpty (); } - PairNode* getHeadNode () - { - return this->pair_list.getHeadNode (); - } + PairNode* getHeadNode () { return this->pair_list.getHeadNode (); } + const PairNode* getHeadNode () const { return this->pair_list.getHeadNode (); } + PairNode* getFirstNode () { return this->pair_list.getHeadNode (); } + const PairNode* getFirstNode () const { return this->pair_list.getHeadNode (); } - const PairNode* getHeadNode () const - { - return this->pair_list.getHeadNode (); - } - - PairNode* getTailNode () - { - return this->pair_list.getTailNode (); - } - - const PairNode* getTailNode () const - { - return this->pair_list.getTailNode (); - } + PairNode* getTailNode () { return this->pair_list.getTailNode (); } + const PairNode* getTailNode () const { return this->pair_list.getTailNode (); } + PairNode* getLastNode () { return this->pair_list.getTailNode (); } + const PairNode* getLastNode () const { return this->pair_list.getTailNode (); } Pair* inject (const K& key, const V& value, int mode, bool* injected = QSE_NULL) { diff --git a/qse/include/qse/cmn/LinkedList.hpp b/qse/include/qse/cmn/LinkedList.hpp index a6a6680a..8781bcea 100644 --- a/qse/include/qse/cmn/LinkedList.hpp +++ b/qse/include/qse/cmn/LinkedList.hpp @@ -325,17 +325,13 @@ public: /// The prependNode() function adds an externally created \a node /// to the front of the list. - Node* prependNode (Node* node) - { - return this->insertNode (this->head_node, node); - } + Node* prependNode (Node* node) { return this->insertNode (this->head_node, node); } + Node* insertFirstNode (Node* node) { return this->insertNode (this->head_node, node); } /// The appendNode() function adds an externally created \a node /// to the back of the list. - Node* appendNode (Node* node) - { - return this->insertNode (QSE_NULL, node); - } + Node* appendNode (Node* node) { return this->insertNode (QSE_NULL, node); } + Node* insertLastNode (Node* node) { return this->insertNode (QSE_NULL, node); } // create a new node to hold the value and insert it. Node* insert (Node* pos, const T& value) @@ -344,15 +340,11 @@ public: return this->insertNode (pos, node); } - Node* prepend (const T& value) - { - return this->insert (this->head_node, value); - } + Node* prepend (const T& value) { return this->insert (this->head_node, value); } + Node* insertFirst (const T& value) { return this->insert (this->head_node, value); } - Node* append (const T& value) - { - return this->insert ((Node*)QSE_NULL, value); - } + Node* append (const T& value) { return this->insert ((Node*)QSE_NULL, value); } + Node* insertLast (const T& value) { return this->insert ((Node*)QSE_NULL, value); } void prependAll (const SelfType& list) { @@ -475,15 +467,11 @@ public: return cnt; } - void removeHead () - { - this->remove (this->head_node); - } + void removeHead () { this->remove (this->head_node); } + void removeFirst () { this->remove (this->head_node); } - void removeTail () - { - this->remove (this->tail_node); - } + void removeTail () { this->remove (this->tail_node); } + void removeLast () { this->remove (this->tail_node); } /// The getHeadNode() function returns the first node. /// \code @@ -494,15 +482,11 @@ public: /// printf ("%d\n", np->value); /// } /// \endcode - Node* getHeadNode () - { - return this->head_node; - } + Node* getHeadNode () { return this->head_node; } + const Node* getHeadNode () const { return this->head_node; } - const Node* getHeadNode () const - { - return this->head_node; - } + Node* getFirstNode () { return this->head_node; } + const Node* getFirstNode () const { return this->head_node; } /// The getTailNode() function returns the last node. /// \code @@ -513,15 +497,11 @@ public: /// printf ("%d\n", np->value); /// } /// \endcode - Node* getTailNode () - { - return this->tail_node; - } + Node* getTailNode () { return this->tail_node; } + const Node* getTailNode () const { return this->tail_node; } - const Node* getTailNode () const - { - return this->tail_node; - } + Node* getLastNode () { return this->tail_node; } + const Node* getLastNode () const { return this->tail_node; } protected: Node* get_node_at (qse_size_t index) const diff --git a/qse/include/qse/si/Socket.hpp b/qse/include/qse/si/Socket.hpp index 6f824ec3..5a9727f6 100644 --- a/qse/include/qse/si/Socket.hpp +++ b/qse/include/qse/si/Socket.hpp @@ -37,14 +37,14 @@ QSE_BEGIN_NAMESPACE(QSE) class Socket { public: - Socket (); - ~Socket (); + Socket () QSE_CPP_NOEXCEPT; + ~Socket () QSE_CPP_NOEXCEPT; - int open (int domain, int type, int protocol); - void close (); + int open (int domain, int type, int protocol) QSE_CPP_NOEXCEPT; + void close () QSE_CPP_NOEXCEPT; - int connect (const SocketAddress& target); - int beginConnect (const SocketAddress& target); + int connect (const SocketAddress& target) QSE_CPP_NOEXCEPT; + int beginConnect (const SocketAddress& target) QSE_CPP_NOEXCEPT; protected: qse_sck_hnd_t handle; diff --git a/qse/include/qse/si/SocketAddress.hpp b/qse/include/qse/si/SocketAddress.hpp index a7231a0e..cd5c00b4 100644 --- a/qse/include/qse/si/SocketAddress.hpp +++ b/qse/include/qse/si/SocketAddress.hpp @@ -27,6 +27,7 @@ #ifndef _QSE_SI_SOCKETADDRESS_HPP_ #define _QSE_SI_SOCKETADDRESS_HPP_ +#include #include ///////////////////////////////// diff --git a/qse/lib/cmn/hwad.c b/qse/lib/cmn/hwad.c index 7f11d989..0ad013a0 100644 --- a/qse/lib/cmn/hwad.c +++ b/qse/lib/cmn/hwad.c @@ -27,6 +27,7 @@ #include #include #include +#include int qse_mbstoethwad (const qse_mchar_t* mbs, qse_ethwad_t* hwaddr) { diff --git a/qse/lib/si/Socket.cpp b/qse/lib/si/Socket.cpp index 79b7d110..00c81604 100644 --- a/qse/lib/si/Socket.cpp +++ b/qse/lib/si/Socket.cpp @@ -25,22 +25,43 @@ */ #include +#include ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) ///////////////////////////////// -Socket::Socket (): handle(QSE_INVALID_SCKHND) +Socket::Socket () QSE_CPP_NOEXCEPT: handle(QSE_INVALID_SCKHND) { } -Socket::~Socket () +Socket::~Socket () QSE_CPP_NOEXCEPT { this->close (); } +#if 0 +int Socket::fdopen (int handle) QSE_CPP_NOEXCEPT +{ + this->handle = handle; +} +#endif -void Socket::close () +int Socket::open (int domain, int type, int protocol) QSE_CPP_NOEXCEPT +{ + int x; + + x = ::socket (domain, type, protocol); + if (x != -1) + { + this->close (); + this->handle = x; + } + + return x; +} + +void Socket::close () QSE_CPP_NOEXCEPT { if (this->handle != QSE_INVALID_SCKHND) { @@ -49,20 +70,17 @@ void Socket::close () } } -//int Socket::open (int domain, int type, int protocol) -//{ -//} - - -int Socket::connect (const SocketAddress& target) +int Socket::connect (const SocketAddress& target) QSE_CPP_NOEXCEPT { - if (this->handle == QSE_INVALID_SCKHND) - { - //::socket (target.getFamily(), this->type, 0); - } + //if (this->handle == QSE_INVALID_SCKHND) + //{ + // + //} + + return -1; } -int Socket::beginConnect (const SocketAddress &target) +int Socket::beginConnect (const SocketAddress &target) QSE_CPP_NOEXCEPT { }