Quellcode durchsuchen

Add missing prefix to network module's enum values

Patrick-Christopher Mattulat vor 1 Jahr
Ursprung
Commit
83ce9fbd97

+ 3 - 3
include/ls_std/network/core/ProtocolFamilyType.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-16
- * Changed:         2022-11-16
+ * Changed:         2022-12-28
  *
  * */
 
@@ -14,8 +14,8 @@ namespace ls::std::network
 {
   enum ProtocolFamilyType
   {
-    PROTOCOL_FAMILY_TYPE_NOT_INITIALIZED = 0,
-    PROTOCOL_FAMILY_TYPE_IPV4
+    LS_STD_PROTOCOL_FAMILY_TYPE_NOT_INITIALIZED = 0,
+    LS_STD_PROTOCOL_FAMILY_TYPE_IPV4
   };
 }
 

+ 4 - 4
include/ls_std/network/core/ProtocolType.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-16
- * Changed:         2022-12-12
+ * Changed:         2022-12-28
  *
  * */
 
@@ -14,9 +14,9 @@ namespace ls::std::network
 {
   enum ProtocolType
   {
-    PROTOCOL_TYPE_NOT_INITIALIZED = 0,
-    PROTOCOL_TYPE_UDP,
-    PROTOCOL_TYPE_TCP
+    LS_STD_PROTOCOL_TYPE_NOT_INITIALIZED = 0,
+    LS_STD_PROTOCOL_TYPE_UDP,
+    LS_STD_PROTOCOL_TYPE_TCP
   };
 }
 

+ 3 - 3
source/ls_std/network/core/ProtocolFamilyMapper.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-16
- * Changed:         2022-12-26
+ * Changed:         2022-12-28
  *
  * */
 
@@ -31,11 +31,11 @@ ls::std::network::ConvertedProtocolFamily ls::std::network::ProtocolFamilyMapper
 
   switch(_protocolFamilyType)
   {
-    case ls::std::network::ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4:
+    case ls::std::network::ProtocolFamilyType::LS_STD_PROTOCOL_FAMILY_TYPE_IPV4:
     {
       convertedProtocolFamily.unixDomain = AF_INET;
     } break;
-    case ls::std::network::ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_NOT_INITIALIZED:
+    case ls::std::network::ProtocolFamilyType::LS_STD_PROTOCOL_FAMILY_TYPE_NOT_INITIALIZED:
     {
       throw ls::std::core::IllegalArgumentException{};
     }

+ 4 - 4
source/ls_std/network/core/ProtocolMapper.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2022-11-17
- * Changed:         2022-12-26
+ * Changed:         2022-12-28
  *
  * */
 
@@ -31,15 +31,15 @@ ls::std::network::Protocol ls::std::network::ProtocolMapper::_toUnixProtocol(con
 
   switch (_protocolType)
   {
-    case ls::std::network::ProtocolType::PROTOCOL_TYPE_UDP:
+    case ls::std::network::ProtocolType::LS_STD_PROTOCOL_TYPE_UDP:
     {
       protocol.unixProtocol = SOCK_DGRAM;
     } break;
-    case ls::std::network::ProtocolType::PROTOCOL_TYPE_TCP:
+    case ls::std::network::ProtocolType::LS_STD_PROTOCOL_TYPE_TCP:
     {
       protocol.unixProtocol = SOCK_STREAM;
     } break;
-    case ls::std::network::ProtocolType::PROTOCOL_TYPE_NOT_INITIALIZED:
+    case ls::std::network::ProtocolType::LS_STD_PROTOCOL_TYPE_NOT_INITIALIZED:
     {
       throw ls::std::core::IllegalArgumentException{};
     }

+ 2 - 2
source/ls_std/network/socket/Socket.cpp

@@ -62,7 +62,7 @@ bool ls::std::network::Socket::write(const ls::std::core::type::byte_field &_dat
 
 ls::std::core::type::connection_id ls::std::network::Socket::accept()
 {
-  if (this->parameter.socketAddress.protocolType != PROTOCOL_TYPE_TCP)
+  if (this->parameter.socketAddress.protocolType != LS_STD_PROTOCOL_TYPE_TCP)
   {
     throw ls::std::core::WrongProtocolException{};
   }
@@ -108,7 +108,7 @@ bool ls::std::network::Socket::isInitialized() const
 
 bool ls::std::network::Socket::listen()
 {
-  if (this->parameter.socketAddress.protocolType != PROTOCOL_TYPE_TCP)
+  if (this->parameter.socketAddress.protocolType != LS_STD_PROTOCOL_TYPE_TCP)
   {
     throw ls::std::core::WrongProtocolException{};
   }

+ 3 - 3
test/cases/network/core/ProtocolFamilyMapperTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-16
- * Changed:         2022-12-26
+ * Changed:         2022-12-28
  *
  * */
 
@@ -41,7 +41,7 @@ namespace
 
   TEST_F(ProtocolFamilyMapperTest, from)
   {
-    ConvertedProtocolFamily convertedProtocolFamily = ProtocolFamilyMapper::from(ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4);
+    ConvertedProtocolFamily convertedProtocolFamily = ProtocolFamilyMapper::from(ProtocolFamilyType::LS_STD_PROTOCOL_FAMILY_TYPE_IPV4);
 
     #if LS_STD_UNIX_PLATFORM
     ASSERT_EQ(AF_INET, convertedProtocolFamily.unixDomain);
@@ -53,7 +53,7 @@ namespace
     EXPECT_THROW({
                    try
                    {
-                     ConvertedProtocolFamily convertedProtocolFamily = ProtocolFamilyMapper::from(ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_NOT_INITIALIZED);
+                     ConvertedProtocolFamily convertedProtocolFamily = ProtocolFamilyMapper::from(ProtocolFamilyType::LS_STD_PROTOCOL_FAMILY_TYPE_NOT_INITIALIZED);
                    }
                    catch (const IllegalArgumentException &_exception)
                    {

+ 3 - 3
test/cases/network/core/ProtocolMapperTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-17
- * Changed:         2022-12-26
+ * Changed:         2022-12-28
  *
  * */
 
@@ -41,7 +41,7 @@ namespace
 
   TEST_F(ProtocolMapperTest, from)
   {
-    Protocol protocol = ProtocolMapper::from(ProtocolType::PROTOCOL_TYPE_TCP);
+    Protocol protocol = ProtocolMapper::from(ProtocolType::LS_STD_PROTOCOL_TYPE_TCP);
 
     #if LS_STD_UNIX_PLATFORM
     ASSERT_EQ(SOCK_STREAM, protocol.unixProtocol);
@@ -53,7 +53,7 @@ namespace
     EXPECT_THROW({
                    try
                    {
-                     Protocol protocol = ProtocolMapper::from(ProtocolType::PROTOCOL_TYPE_NOT_INITIALIZED);
+                     Protocol protocol = ProtocolMapper::from(ProtocolType::LS_STD_PROTOCOL_TYPE_NOT_INITIALIZED);
                    }
                    catch (const IllegalArgumentException &_exception)
                    {

+ 3 - 3
test/cases/network/socket/SocketAddressMapperTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-18
- * Changed:         2022-12-27
+ * Changed:         2022-12-28
  *
  * */
 
@@ -37,11 +37,11 @@ namespace
       static SocketAddressMapperParameter createSocketAddressMapperParameter()
       {
         SocketAddressMapperParameter parameter{};
-        parameter.protocolFamilyType = ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4;
+        parameter.protocolFamilyType = ProtocolFamilyType::LS_STD_PROTOCOL_FAMILY_TYPE_IPV4;
 
         SocketAddress socketAddress{};
         socketAddress.port = 8080;
-        socketAddress.protocolType = PROTOCOL_TYPE_TCP;
+        socketAddress.protocolType = LS_STD_PROTOCOL_TYPE_TCP;
         socketAddress.ipAddress = "127.0.0.1";
         parameter.socketAddress = socketAddress;
 

+ 5 - 5
test/cases/network/socket/SocketIT.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-27
- * Changed:         2022-12-27
+ * Changed:         2022-12-28
  *
  * */
 
@@ -33,16 +33,16 @@ namespace
     // create server parameter
 
     SocketParameter serverParameter{};
-    serverParameter.protocolFamilyType = PROTOCOL_FAMILY_TYPE_IPV4; // TODO: add library prefix to constant value
-    serverParameter.socketAddress.protocolType = PROTOCOL_TYPE_TCP; // TODO: add library prefix to constant value
+    serverParameter.protocolFamilyType = LS_STD_PROTOCOL_FAMILY_TYPE_IPV4;
+    serverParameter.socketAddress.protocolType = LS_STD_PROTOCOL_TYPE_TCP;
     serverParameter.socketAddress.port = 5099;
     serverParameter.queueSize = 5;
 
     // create client parameter
 
     SocketParameter clientParameter{};
-    clientParameter.protocolFamilyType = PROTOCOL_FAMILY_TYPE_IPV4;
-    clientParameter.socketAddress.protocolType = PROTOCOL_TYPE_TCP;
+    clientParameter.protocolFamilyType = LS_STD_PROTOCOL_FAMILY_TYPE_IPV4;
+    clientParameter.socketAddress.protocolType = LS_STD_PROTOCOL_TYPE_TCP;
     clientParameter.socketAddress.ipAddress = "127.0.0.1";
     clientParameter.socketAddress.port = 5099;
 

+ 4 - 4
test/cases/network/socket/SocketTest.cpp

@@ -40,10 +40,10 @@ namespace
       static SocketParameter generateSocketParameter()
       {
         SocketParameter socketParameter{};
-        socketParameter.protocolFamilyType = ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4;
+        socketParameter.protocolFamilyType = ProtocolFamilyType::LS_STD_PROTOCOL_FAMILY_TYPE_IPV4;
 
         SocketAddress socketAddress{};
-        socketAddress.protocolType = ProtocolType::PROTOCOL_TYPE_TCP;
+        socketAddress.protocolType = ProtocolType::LS_STD_PROTOCOL_TYPE_TCP;
         socketAddress.ipAddress = "127.0.0.1";
         socketAddress.port = 2220;
         socketParameter.socketAddress = socketAddress;
@@ -200,7 +200,7 @@ namespace
   TEST_F(SocketTest, accept_wrong_protocol)
   {
     SocketParameter parameter = generateSocketParameter();
-    parameter.socketAddress.protocolType = PROTOCOL_TYPE_UDP;
+    parameter.socketAddress.protocolType = LS_STD_PROTOCOL_TYPE_UDP;
 
     #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();
@@ -382,7 +382,7 @@ namespace
   TEST_F(SocketTest, listen_wrong_protocol)
   {
     SocketParameter parameter = generateSocketParameter();
-    parameter.socketAddress.protocolType = PROTOCOL_TYPE_UDP;
+    parameter.socketAddress.protocolType = LS_STD_PROTOCOL_TYPE_UDP;
 
     #if LS_STD_UNIX_PLATFORM
     shared_ptr<MockPosixSocket> mockSocket = make_shared<MockPosixSocket>();