@@ -204,6 +204,7 @@ class ELibGRPCWrapperException : public std::exception {
204
204
case LIBGRPCWRAPPER_ERROR_MESSAGREFLECTIONISNULL: return " MESSAGREFLECTIONISNULL" ;
205
205
case LIBGRPCWRAPPER_ERROR_COULDNOTRETRIEVETEMPPATHS: return " COULDNOTRETRIEVETEMPPATHS" ;
206
206
case LIBGRPCWRAPPER_ERROR_COULDNOTCONVERTUNICODESTRING: return " COULDNOTCONVERTUNICODESTRING" ;
207
+ case LIBGRPCWRAPPER_ERROR_MESSAGEFIELDNOTFOUND: return " MESSAGEFIELDNOTFOUND" ;
207
208
}
208
209
return " UNKNOWN" ;
209
210
}
@@ -239,6 +240,7 @@ class ELibGRPCWrapperException : public std::exception {
239
240
case LIBGRPCWRAPPER_ERROR_MESSAGREFLECTIONISNULL: return " Internal error: Message reflection is null" ;
240
241
case LIBGRPCWRAPPER_ERROR_COULDNOTRETRIEVETEMPPATHS: return " Could not retrieve temp paths" ;
241
242
case LIBGRPCWRAPPER_ERROR_COULDNOTCONVERTUNICODESTRING: return " Could not convert unicode string" ;
243
+ case LIBGRPCWRAPPER_ERROR_MESSAGEFIELDNOTFOUND: return " Message field not found" ;
242
244
}
243
245
return " unknown error" ;
244
246
}
@@ -438,6 +440,8 @@ class CMessage : public CBase {
438
440
439
441
inline bool HasField (const std::string & sFieldName );
440
442
inline bool HasStringField (const std::string & sFieldName );
443
+ inline bool HasMessageField (const std::string & sFieldName );
444
+ inline PMessage GetMessageField (const std::string & sFieldName );
441
445
inline void SetStringField (const std::string & sFieldName , const std::string & sValue );
442
446
inline std::string GetStringField (const std::string & sFieldName );
443
447
inline void SetInt32Field (const std::string & sFieldName , const LibGRPCWrapper_int32 nValue);
@@ -453,7 +457,7 @@ class CMessage : public CBase {
453
457
inline void SetFloatField (const std::string & sFieldName , const LibGRPCWrapper_single fValue );
454
458
inline LibGRPCWrapper_single GetFloatField (const std::string & sFieldName );
455
459
inline void SetDoubleField (const std::string & sFieldName , const LibGRPCWrapper_double dValue);
456
- inline LibGRPCWrapper_int32 GetDoubleField (const std::string & sFieldName );
460
+ inline LibGRPCWrapper_double GetDoubleField (const std::string & sFieldName );
457
461
};
458
462
459
463
/* ************************************************************************************************************************
@@ -629,6 +633,8 @@ class CProtocol : public CBase {
629
633
pWrapperTable->m_LibraryHandle = nullptr ;
630
634
pWrapperTable->m_Message_HasField = nullptr ;
631
635
pWrapperTable->m_Message_HasStringField = nullptr ;
636
+ pWrapperTable->m_Message_HasMessageField = nullptr ;
637
+ pWrapperTable->m_Message_GetMessageField = nullptr ;
632
638
pWrapperTable->m_Message_SetStringField = nullptr ;
633
639
pWrapperTable->m_Message_GetStringField = nullptr ;
634
640
pWrapperTable->m_Message_SetInt32Field = nullptr ;
@@ -729,6 +735,24 @@ class CProtocol : public CBase {
729
735
if (pWrapperTable->m_Message_HasStringField == nullptr )
730
736
return LIBGRPCWRAPPER_ERROR_COULDNOTFINDLIBRARYEXPORT;
731
737
738
+ #ifdef _WIN32
739
+ pWrapperTable->m_Message_HasMessageField = (PLibGRPCWrapperMessage_HasMessageFieldPtr) GetProcAddress (hLibrary, " libgrpcwrapper_message_hasmessagefield" );
740
+ #else // _WIN32
741
+ pWrapperTable->m_Message_HasMessageField = (PLibGRPCWrapperMessage_HasMessageFieldPtr) dlsym (hLibrary, " libgrpcwrapper_message_hasmessagefield" );
742
+ dlerror ();
743
+ #endif // _WIN32
744
+ if (pWrapperTable->m_Message_HasMessageField == nullptr )
745
+ return LIBGRPCWRAPPER_ERROR_COULDNOTFINDLIBRARYEXPORT;
746
+
747
+ #ifdef _WIN32
748
+ pWrapperTable->m_Message_GetMessageField = (PLibGRPCWrapperMessage_GetMessageFieldPtr) GetProcAddress (hLibrary, " libgrpcwrapper_message_getmessagefield" );
749
+ #else // _WIN32
750
+ pWrapperTable->m_Message_GetMessageField = (PLibGRPCWrapperMessage_GetMessageFieldPtr) dlsym (hLibrary, " libgrpcwrapper_message_getmessagefield" );
751
+ dlerror ();
752
+ #endif // _WIN32
753
+ if (pWrapperTable->m_Message_GetMessageField == nullptr )
754
+ return LIBGRPCWRAPPER_ERROR_COULDNOTFINDLIBRARYEXPORT;
755
+
732
756
#ifdef _WIN32
733
757
pWrapperTable->m_Message_SetStringField = (PLibGRPCWrapperMessage_SetStringFieldPtr) GetProcAddress (hLibrary, " libgrpcwrapper_message_setstringfield" );
734
758
#else // _WIN32
@@ -1041,6 +1065,14 @@ class CProtocol : public CBase {
1041
1065
if ( (eLookupError != 0 ) || (pWrapperTable->m_Message_HasStringField == nullptr ) )
1042
1066
return LIBGRPCWRAPPER_ERROR_COULDNOTFINDLIBRARYEXPORT;
1043
1067
1068
+ eLookupError = (*pLookup)(" libgrpcwrapper_message_hasmessagefield" , (void **)&(pWrapperTable->m_Message_HasMessageField ));
1069
+ if ( (eLookupError != 0 ) || (pWrapperTable->m_Message_HasMessageField == nullptr ) )
1070
+ return LIBGRPCWRAPPER_ERROR_COULDNOTFINDLIBRARYEXPORT;
1071
+
1072
+ eLookupError = (*pLookup)(" libgrpcwrapper_message_getmessagefield" , (void **)&(pWrapperTable->m_Message_GetMessageField ));
1073
+ if ( (eLookupError != 0 ) || (pWrapperTable->m_Message_GetMessageField == nullptr ) )
1074
+ return LIBGRPCWRAPPER_ERROR_COULDNOTFINDLIBRARYEXPORT;
1075
+
1044
1076
eLookupError = (*pLookup)(" libgrpcwrapper_message_setstringfield" , (void **)&(pWrapperTable->m_Message_SetStringField ));
1045
1077
if ( (eLookupError != 0 ) || (pWrapperTable->m_Message_SetStringField == nullptr ) )
1046
1078
return LIBGRPCWRAPPER_ERROR_COULDNOTFINDLIBRARYEXPORT;
@@ -1208,6 +1240,35 @@ class CProtocol : public CBase {
1208
1240
return resultStringFieldExists;
1209
1241
}
1210
1242
1243
+ /* *
1244
+ * CMessage::HasMessageField - Returns if the message has a field of a certain name and this field is a submessage field.
1245
+ * @param[in] sFieldName - Name of the field.
1246
+ * @return True if field exists and is of type message.
1247
+ */
1248
+ bool CMessage::HasMessageField (const std::string & sFieldName )
1249
+ {
1250
+ bool resultMessageFieldExists = 0 ;
1251
+ CheckError (m_pWrapper->m_WrapperTable .m_Message_HasMessageField (m_pHandle, sFieldName .c_str (), &resultMessageFieldExists));
1252
+
1253
+ return resultMessageFieldExists;
1254
+ }
1255
+
1256
+ /* *
1257
+ * CMessage::GetMessageField - Returns the submessage of a field. Fails if the field does not exist or is not a submessage field.
1258
+ * @param[in] sFieldName - Name of the field.
1259
+ * @return Sub message object
1260
+ */
1261
+ PMessage CMessage::GetMessageField (const std::string & sFieldName )
1262
+ {
1263
+ LibGRPCWrapperHandle hMessageFieldInstance = nullptr ;
1264
+ CheckError (m_pWrapper->m_WrapperTable .m_Message_GetMessageField (m_pHandle, sFieldName .c_str (), &hMessageFieldInstance));
1265
+
1266
+ if (!hMessageFieldInstance) {
1267
+ CheckError (LIBGRPCWRAPPER_ERROR_INVALIDPARAM);
1268
+ }
1269
+ return std::make_shared<CMessage>(m_pWrapper, hMessageFieldInstance);
1270
+ }
1271
+
1211
1272
/* *
1212
1273
* CMessage::SetStringField - Sets a string field of the message. Fails if the field does not exist or is not a string field.
1213
1274
* @param[in] sFieldName - Name of the field.
@@ -1387,9 +1448,9 @@ class CProtocol : public CBase {
1387
1448
* @param[in] sFieldName - Name of the field.
1388
1449
* @return Current value of the field.
1389
1450
*/
1390
- LibGRPCWrapper_int32 CMessage::GetDoubleField (const std::string & sFieldName )
1451
+ LibGRPCWrapper_double CMessage::GetDoubleField (const std::string & sFieldName )
1391
1452
{
1392
- LibGRPCWrapper_int32 resultValue = 0 ;
1453
+ LibGRPCWrapper_double resultValue = 0 ;
1393
1454
CheckError (m_pWrapper->m_WrapperTable .m_Message_GetDoubleField (m_pHandle, sFieldName .c_str (), &resultValue));
1394
1455
1395
1456
return resultValue;
0 commit comments