AnnotationParameterValue.h 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /*!
  15. * @file AnnotationParameterValue.h
  16. * This header file contains the declaration of the described types in the IDL file.
  17. *
  18. * This file was generated by the tool gen.
  19. */
  20. #ifndef _ANNOTATIONPARAMETERVALUE_H_
  21. #define _ANNOTATIONPARAMETERVALUE_H_
  22. #include <fastrtps/types/TypesBase.h>
  23. #include <fastrtps/types/TypeIdentifier.h>
  24. #include <stdint.h>
  25. #include <array>
  26. #include <string>
  27. #include <vector>
  28. #include <codecvt>
  29. #include <locale>
  30. namespace eprosima
  31. {
  32. namespace fastcdr
  33. {
  34. class Cdr;
  35. }
  36. }
  37. namespace eprosima{
  38. namespace fastrtps{
  39. namespace types{
  40. /*!
  41. * @brief This class represents the structure ExtendedAnnotationParameterValue defined by the user in the IDL file.
  42. * @ingroup ANNOTATIONPARAMETERVALUE
  43. */
  44. class ExtendedAnnotationParameterValue
  45. {
  46. public:
  47. /*!
  48. * @brief Default constructor.
  49. */
  50. ExtendedAnnotationParameterValue();
  51. /*!
  52. * @brief Default destructor.
  53. */
  54. ~ExtendedAnnotationParameterValue();
  55. /*!
  56. * @brief Copy constructor.
  57. * @param x Reference to the object ExtendedAnnotationParameterValue that will be copied.
  58. */
  59. ExtendedAnnotationParameterValue(const ExtendedAnnotationParameterValue &x);
  60. /*!
  61. * @brief Move constructor.
  62. * @param x Reference to the object ExtendedAnnotationParameterValue that will be copied.
  63. */
  64. ExtendedAnnotationParameterValue(ExtendedAnnotationParameterValue &&x);
  65. /*!
  66. * @brief Copy assignment.
  67. * @param x Reference to the object ExtendedAnnotationParameterValue that will be copied.
  68. */
  69. ExtendedAnnotationParameterValue& operator=(const ExtendedAnnotationParameterValue &x);
  70. /*!
  71. * @brief Move assignment.
  72. * @param x Reference to the object ExtendedAnnotationParameterValue that will be copied.
  73. */
  74. ExtendedAnnotationParameterValue& operator=(ExtendedAnnotationParameterValue &&x);
  75. /*!
  76. * @brief This function returns the serialized size of a data depending on the buffer alignment.
  77. * @param data Data which is calculated its serialized size.
  78. * @param current_alignment Buffer alignment.
  79. * @return Serialized size.
  80. */
  81. static size_t getCdrSerializedSize(const ExtendedAnnotationParameterValue& data, size_t current_alignment = 0);
  82. /*!
  83. * @brief This function serializes an object using CDR serialization.
  84. * @param cdr CDR serialization object.
  85. */
  86. void serialize(eprosima::fastcdr::Cdr &cdr) const;
  87. /*!
  88. * @brief This function deserializes an object using CDR serialization.
  89. * @param cdr CDR serialization object.
  90. */
  91. void deserialize(eprosima::fastcdr::Cdr &cdr);
  92. /*!
  93. * @brief This function returns the maximum serialized size of the Key of an object
  94. * depending on the buffer alignment.
  95. * @param current_alignment Buffer alignment.
  96. * @return Maximum serialized size.
  97. */
  98. static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
  99. /*!
  100. * @brief This function tells you if the Key has been defined for this type
  101. */
  102. static bool isKeyDefined();
  103. /*!
  104. * @brief This function serializes the key members of an object using CDR serialization.
  105. * @param cdr CDR serialization object.
  106. */
  107. void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
  108. bool operator==(const ExtendedAnnotationParameterValue&) const { return true; }
  109. private:
  110. };
  111. /*!
  112. * @brief This class represents the union AnnotationParameterValue defined by the user in the IDL file.
  113. * @ingroup ANNOTATIONPARAMETERVALUE
  114. */
  115. class AnnotationParameterValue
  116. {
  117. public:
  118. /*!
  119. * @brief Default constructor.
  120. */
  121. AnnotationParameterValue();
  122. /*!
  123. * @brief Default destructor.
  124. */
  125. ~AnnotationParameterValue();
  126. /*!
  127. * @brief Copy constructor.
  128. * @param x Reference to the object AnnotationParameterValue that will be copied.
  129. */
  130. AnnotationParameterValue(const AnnotationParameterValue &x);
  131. /*!
  132. * @brief Move constructor.
  133. * @param x Reference to the object AnnotationParameterValue that will be copied.
  134. */
  135. AnnotationParameterValue(AnnotationParameterValue &&x);
  136. /*!
  137. * @brief Copy assignment.
  138. * @param x Reference to the object AnnotationParameterValue that will be copied.
  139. */
  140. AnnotationParameterValue& operator=(const AnnotationParameterValue &x);
  141. /*!
  142. * @brief Move assignment.
  143. * @param x Reference to the object AnnotationParameterValue that will be copied.
  144. */
  145. AnnotationParameterValue& operator=(AnnotationParameterValue &&x);
  146. /*!
  147. * @brief This function sets the discriminator value.
  148. * @param __d New value for the discriminator.
  149. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the new value doesn't correspond to the selected union member.
  150. */
  151. void _d(char __d);
  152. /*!
  153. * @brief This function returns the value of the discriminator.
  154. * @return Value of the discriminator
  155. */
  156. char _d() const;
  157. /*!
  158. * @brief This function returns a reference to the discriminator.
  159. * @return Reference to the discriminator.
  160. */
  161. char& _d();
  162. /*!
  163. * @brief This function sets a value in member boolean_value
  164. * @param _boolean_value New value for member boolean_value
  165. */
  166. void boolean_value(bool _boolean_value);
  167. /*!
  168. * @brief This function returns the value of member boolean_value
  169. * @return Value of member boolean_value
  170. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  171. */
  172. bool boolean_value() const;
  173. /*!
  174. * @brief This function returns a reference to member boolean_value
  175. * @return Reference to member boolean_value
  176. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  177. */
  178. bool& boolean_value();
  179. /*!
  180. * @brief This function sets a value in member byte_value
  181. * @param _byte_value New value for member byte_value
  182. */
  183. void byte_value(uint8_t _byte_value);
  184. /*!
  185. * @brief This function returns the value of member byte_value
  186. * @return Value of member byte_value
  187. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  188. */
  189. uint8_t byte_value() const;
  190. /*!
  191. * @brief This function returns a reference to member byte_value
  192. * @return Reference to member byte_value
  193. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  194. */
  195. uint8_t& byte_value();
  196. /*!
  197. * @brief This function sets a value in member int16_value
  198. * @param _int16_value New value for member int16_value
  199. */
  200. void int16_value(int16_t _int16_value);
  201. /*!
  202. * @brief This function returns the value of member int16_value
  203. * @return Value of member int16_value
  204. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  205. */
  206. int16_t int16_value() const;
  207. /*!
  208. * @brief This function returns a reference to member int16_value
  209. * @return Reference to member int16_value
  210. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  211. */
  212. int16_t& int16_value();
  213. /*!
  214. * @brief This function sets a value in member uint_16_value
  215. * @param _uint_16_value New value for member uint_16_value
  216. */
  217. void uint_16_value(uint16_t _uint_16_value);
  218. /*!
  219. * @brief This function returns the value of member uint_16_value
  220. * @return Value of member uint_16_value
  221. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  222. */
  223. uint16_t uint_16_value() const;
  224. /*!
  225. * @brief This function returns a reference to member uint_16_value
  226. * @return Reference to member uint_16_value
  227. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  228. */
  229. uint16_t& uint_16_value();
  230. /*!
  231. * @brief This function sets a value in member int32_value
  232. * @param _int32_value New value for member int32_value
  233. */
  234. void int32_value(int32_t _int32_value);
  235. /*!
  236. * @brief This function returns the value of member int32_value
  237. * @return Value of member int32_value
  238. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  239. */
  240. int32_t int32_value() const;
  241. /*!
  242. * @brief This function returns a reference to member int32_value
  243. * @return Reference to member int32_value
  244. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  245. */
  246. int32_t& int32_value();
  247. /*!
  248. * @brief This function sets a value in member uint32_value
  249. * @param _uint32_value New value for member uint32_value
  250. */
  251. void uint32_value(uint32_t _uint32_value);
  252. /*!
  253. * @brief This function returns the value of member uint32_value
  254. * @return Value of member uint32_value
  255. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  256. */
  257. uint32_t uint32_value() const;
  258. /*!
  259. * @brief This function returns a reference to member uint32_value
  260. * @return Reference to member uint32_value
  261. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  262. */
  263. uint32_t& uint32_value();
  264. /*!
  265. * @brief This function sets a value in member int64_value
  266. * @param _int64_value New value for member int64_value
  267. */
  268. void int64_value(int64_t _int64_value);
  269. /*!
  270. * @brief This function returns the value of member int64_value
  271. * @return Value of member int64_value
  272. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  273. */
  274. int64_t int64_value() const;
  275. /*!
  276. * @brief This function returns a reference to member int64_value
  277. * @return Reference to member int64_value
  278. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  279. */
  280. int64_t& int64_value();
  281. /*!
  282. * @brief This function sets a value in member uint64_value
  283. * @param _uint64_value New value for member uint64_value
  284. */
  285. void uint64_value(uint64_t _uint64_value);
  286. /*!
  287. * @brief This function returns the value of member uint64_value
  288. * @return Value of member uint64_value
  289. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  290. */
  291. uint64_t uint64_value() const;
  292. /*!
  293. * @brief This function returns a reference to member uint64_value
  294. * @return Reference to member uint64_value
  295. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  296. */
  297. uint64_t& uint64_value();
  298. /*!
  299. * @brief This function sets a value in member float32_value
  300. * @param _float32_value New value for member float32_value
  301. */
  302. void float32_value(float _float32_value);
  303. /*!
  304. * @brief This function returns the value of member float32_value
  305. * @return Value of member float32_value
  306. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  307. */
  308. float float32_value() const;
  309. /*!
  310. * @brief This function returns a reference to member float32_value
  311. * @return Reference to member float32_value
  312. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  313. */
  314. float& float32_value();
  315. /*!
  316. * @brief This function sets a value in member float64_value
  317. * @param _float64_value New value for member float64_value
  318. */
  319. void float64_value(double _float64_value);
  320. /*!
  321. * @brief This function returns the value of member float64_value
  322. * @return Value of member float64_value
  323. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  324. */
  325. double float64_value() const;
  326. /*!
  327. * @brief This function returns a reference to member float64_value
  328. * @return Reference to member float64_value
  329. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  330. */
  331. double& float64_value();
  332. /*!
  333. * @brief This function sets a value in member float128_value
  334. * @param _float128_value New value for member float128_value
  335. */
  336. void float128_value(long double _float128_value);
  337. /*!
  338. * @brief This function returns the value of member float128_value
  339. * @return Value of member float128_value
  340. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  341. */
  342. long double float128_value() const;
  343. /*!
  344. * @brief This function returns a reference to member float128_value
  345. * @return Reference to member float128_value
  346. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  347. */
  348. long double& float128_value();
  349. /*!
  350. * @brief This function sets a value in member char_value
  351. * @param _char_value New value for member char_value
  352. */
  353. void char_value(char _char_value);
  354. /*!
  355. * @brief This function returns the value of member char_value
  356. * @return Value of member char_value
  357. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  358. */
  359. char char_value() const;
  360. /*!
  361. * @brief This function returns a reference to member char_value
  362. * @return Reference to member char_value
  363. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  364. */
  365. char& char_value();
  366. /*!
  367. * @brief This function sets a value in member wchar_value
  368. * @param _wchar_value New value for member wchar_value
  369. */
  370. void wchar_value(wchar_t _wchar_value);
  371. /*!
  372. * @brief This function returns the value of member wchar_value
  373. * @return Value of member wchar_value
  374. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  375. */
  376. wchar_t wchar_value() const;
  377. /*!
  378. * @brief This function returns a reference to member wchar_value
  379. * @return Reference to member wchar_value
  380. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  381. */
  382. wchar_t& wchar_value();
  383. /*!
  384. * @brief This function sets a value in member enumerated_value
  385. * @param _enumerated_value New value for member enumerated_value
  386. */
  387. void enumerated_value(int32_t _enumerated_value);
  388. /*!
  389. * @brief This function returns the value of member enumerated_value
  390. * @return Value of member enumerated_value
  391. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  392. */
  393. int32_t enumerated_value() const;
  394. /*!
  395. * @brief This function returns a reference to member enumerated_value
  396. * @return Reference to member enumerated_value
  397. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  398. */
  399. int32_t& enumerated_value();
  400. /*!
  401. * @brief This function copies the value in member string8_value
  402. * @param _string8_value New value to be copied in member string8_value
  403. */
  404. void string8_value(const std::string &_string8_value);
  405. /*!
  406. * @brief This function moves the value in member string8_value
  407. * @param _string8_value New value to be moved in member string8_value
  408. */
  409. void string8_value(std::string &&_string8_value);
  410. /*!
  411. * @brief This function returns a constant reference to member string8_value
  412. * @return Constant reference to member string8_value
  413. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  414. */
  415. const std::string& string8_value() const;
  416. /*!
  417. * @brief This function returns a reference to member string8_value
  418. * @return Reference to member string8_value
  419. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  420. */
  421. std::string& string8_value();
  422. /*!
  423. * @brief This function copies the value in member string16_value
  424. * @param _string16_value New value to be copied in member string16_value
  425. */
  426. void string16_value(const std::wstring &_string16_value);
  427. /*!
  428. * @brief This function moves the value in member string16_value
  429. * @param _string16_value New value to be moved in member string16_value
  430. */
  431. void string16_value(std::wstring &&_string16_value);
  432. /*!
  433. * @brief This function returns a constant reference to member string16_value
  434. * @return Constant reference to member string16_value
  435. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  436. */
  437. const std::wstring& string16_value() const;
  438. /*!
  439. * @brief This function returns a reference to member string16_value
  440. * @return Reference to member string16_value
  441. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  442. */
  443. std::wstring& string16_value();
  444. /*!
  445. * @brief This function copies the value in member extended_value
  446. * @param _extended_value New value to be copied in member extended_value
  447. */
  448. void extended_value(const ExtendedAnnotationParameterValue &_extended_value);
  449. /*!
  450. * @brief This function moves the value in member extended_value
  451. * @param _extended_value New value to be moved in member extended_value
  452. */
  453. void extended_value(ExtendedAnnotationParameterValue &&_extended_value);
  454. /*!
  455. * @brief This function returns a constant reference to member extended_value
  456. * @return Constant reference to member extended_value
  457. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  458. */
  459. const ExtendedAnnotationParameterValue& extended_value() const;
  460. /*!
  461. * @brief This function returns a reference to member extended_value
  462. * @return Reference to member extended_value
  463. * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection.
  464. */
  465. ExtendedAnnotationParameterValue& extended_value();
  466. /*!
  467. * @brief This function returns the serialized size of a data depending on the buffer alignment.
  468. * @param data Data which is calculated its serialized size.
  469. * @param current_alignment Buffer alignment.
  470. * @return Serialized size.
  471. */
  472. static size_t getCdrSerializedSize(const AnnotationParameterValue& data, size_t current_alignment = 0);
  473. /*!
  474. * @brief This function serializes an object using CDR serialization.
  475. * @param cdr CDR serialization object.
  476. */
  477. void serialize(eprosima::fastcdr::Cdr &cdr) const;
  478. /*!
  479. * @brief This function deserializes an object using CDR serialization.
  480. * @param cdr CDR serialization object.
  481. */
  482. void deserialize(eprosima::fastcdr::Cdr &cdr);
  483. /*!
  484. * @brief This function returns the maximum serialized size of the Key of an object
  485. * depending on the buffer alignment.
  486. * @param current_alignment Buffer alignment.
  487. * @return Maximum serialized size.
  488. */
  489. static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
  490. /*!
  491. * @brief This function tells you if the Key has been defined for this type
  492. */
  493. static bool isKeyDefined();
  494. /*!
  495. * @brief This function serializes the key members of an object using CDR serialization.
  496. * @param cdr CDR serialization object.
  497. */
  498. void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
  499. bool operator==(const AnnotationParameterValue& other) const;
  500. /**
  501. * Aux method to return value as its string representation.
  502. */
  503. std::string to_string() const
  504. {
  505. switch(m__d)
  506. {
  507. case TK_BOOLEAN:
  508. return (m_boolean_value) ? "true" : "false";
  509. case TK_BYTE:
  510. return std::to_string(m_byte_value);
  511. case TK_INT16:
  512. return std::to_string(m_int16_value);
  513. case TK_UINT16:
  514. return std::to_string(m_uint_16_value);
  515. case TK_INT32:
  516. return std::to_string(m_int32_value);
  517. case TK_UINT32:
  518. return std::to_string(m_uint32_value);
  519. case TK_INT64:
  520. return std::to_string(m_int64_value);
  521. case TK_UINT64:
  522. return std::to_string(m_uint64_value);
  523. case TK_FLOAT32:
  524. return std::to_string(m_float32_value);
  525. case TK_FLOAT64:
  526. return std::to_string(m_float64_value);
  527. case TK_FLOAT128:
  528. return std::to_string(m_float128_value);
  529. case TK_CHAR8:
  530. return std::to_string(m_char_value);
  531. case TK_CHAR16:
  532. return std::to_string(m_wchar_value);
  533. case TK_ENUM:
  534. return std::to_string(m_enumerated_value);
  535. case TK_STRING16:
  536. {
  537. std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
  538. return conv.to_bytes(m_string16_value);
  539. }
  540. case TK_STRING8:
  541. case TK_NONE: // Cheat!
  542. return m_string8_value;
  543. default:
  544. return "";
  545. }
  546. }
  547. /**
  548. * Aux method to set value from its string representation.
  549. */
  550. void from_string(const std::string& value)
  551. {
  552. switch(m__d)
  553. {
  554. case TK_BOOLEAN:
  555. {
  556. std::string val_ = value;
  557. std::transform(val_.begin(), val_.end(), val_.begin(),
  558. [](unsigned char c){ return static_cast<char>(std::tolower(c));});
  559. boolean_value(val_.compare("0") != 0 || val_.compare(CONST_TRUE) == 0);
  560. }
  561. break;
  562. case TK_BYTE:
  563. {
  564. byte_value(static_cast<uint8_t>(std::stoul(value)));
  565. }
  566. break;
  567. case TK_INT16:
  568. {
  569. int16_value(static_cast<int16_t>(std::stoi(value)));
  570. }
  571. break;
  572. case TK_INT32:
  573. {
  574. int32_value(static_cast<int32_t>(std::stoi(value)));
  575. }
  576. break;
  577. case TK_INT64:
  578. {
  579. int64_value(static_cast<int64_t>(std::stoll(value)));
  580. }
  581. break;
  582. case TK_UINT16:
  583. {
  584. uint_16_value(static_cast<uint16_t>(std::stoul(value)));
  585. }
  586. break;
  587. case TK_UINT32:
  588. {
  589. uint32_value(static_cast<uint32_t>(std::stoul(value)));
  590. }
  591. break;
  592. case TK_UINT64:
  593. {
  594. uint64_value(static_cast<uint64_t>(std::stoull(value)));
  595. }
  596. break;
  597. case TK_FLOAT32:
  598. {
  599. float32_value(std::stof(value));
  600. }
  601. break;
  602. case TK_FLOAT64:
  603. {
  604. float64_value(std::stod(value));
  605. }
  606. break;
  607. case TK_FLOAT128:
  608. {
  609. float128_value(std::stold(value));
  610. }
  611. break;
  612. case TK_CHAR8:
  613. {
  614. char_value(value.c_str()[0]);
  615. }
  616. break;
  617. case TK_CHAR16:
  618. {
  619. std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
  620. wchar_value(conv.from_bytes(value).c_str()[0]);
  621. }
  622. break;
  623. case TK_STRING8:
  624. case TK_NONE: // Cheat!
  625. {
  626. string8_value(value);
  627. }
  628. break;
  629. case TK_STRING16:
  630. {
  631. std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
  632. string16_value(conv.from_bytes(value));
  633. }
  634. break;
  635. case TK_ENUM:
  636. {
  637. // TODO Translate from enum value name to integer value
  638. enumerated_value(static_cast<uint32_t>(std::stoul(value)));
  639. }
  640. break;
  641. default:
  642. break;
  643. }
  644. }
  645. private:
  646. char m__d;
  647. bool m_boolean_value;
  648. uint8_t m_byte_value;
  649. int16_t m_int16_value;
  650. uint16_t m_uint_16_value;
  651. int32_t m_int32_value;
  652. uint32_t m_uint32_value;
  653. int64_t m_int64_value;
  654. uint64_t m_uint64_value;
  655. float m_float32_value;
  656. double m_float64_value;
  657. long double m_float128_value;
  658. char m_char_value;
  659. wchar_t m_wchar_value;
  660. int32_t m_enumerated_value;
  661. std::string m_string8_value;
  662. std::wstring m_string16_value;
  663. ExtendedAnnotationParameterValue m_extended_value;
  664. };
  665. /*!
  666. * @brief This class represents the structure AppliedAnnotationParameter defined by the user in the IDL file.
  667. * @ingroup ANNOTATIONPARAMETERVALUE
  668. */
  669. class AppliedAnnotationParameter
  670. {
  671. public:
  672. /*!
  673. * @brief Default constructor.
  674. */
  675. AppliedAnnotationParameter();
  676. /*!
  677. * @brief Default destructor.
  678. */
  679. ~AppliedAnnotationParameter();
  680. /*!
  681. * @brief Copy constructor.
  682. * @param x Reference to the object AppliedAnnotationParameter that will be copied.
  683. */
  684. AppliedAnnotationParameter(const AppliedAnnotationParameter &x);
  685. /*!
  686. * @brief Move constructor.
  687. * @param x Reference to the object AppliedAnnotationParameter that will be copied.
  688. */
  689. AppliedAnnotationParameter(AppliedAnnotationParameter &&x);
  690. /*!
  691. * @brief Copy assignment.
  692. * @param x Reference to the object AppliedAnnotationParameter that will be copied.
  693. */
  694. AppliedAnnotationParameter& operator=(const AppliedAnnotationParameter &x);
  695. /*!
  696. * @brief Move assignment.
  697. * @param x Reference to the object AppliedAnnotationParameter that will be copied.
  698. */
  699. AppliedAnnotationParameter& operator=(AppliedAnnotationParameter &&x);
  700. /*!
  701. * @brief This function copies the value in member paramname_hash
  702. * @param _paramname_hash New value to be copied in member paramname_hash
  703. */
  704. inline void paramname_hash(const NameHash &_paramname_hash)
  705. {
  706. m_paramname_hash = _paramname_hash;
  707. }
  708. /*!
  709. * @brief This function moves the value in member paramname_hash
  710. * @param _paramname_hash New value to be moved in member paramname_hash
  711. */
  712. inline void paramname_hash(NameHash &&_paramname_hash)
  713. {
  714. m_paramname_hash = std::move(_paramname_hash);
  715. }
  716. /*!
  717. * @brief This function returns a constant reference to member paramname_hash
  718. * @return Constant reference to member paramname_hash
  719. */
  720. inline const NameHash& paramname_hash() const
  721. {
  722. return m_paramname_hash;
  723. }
  724. /*!
  725. * @brief This function returns a reference to member paramname_hash
  726. * @return Reference to member paramname_hash
  727. */
  728. inline NameHash& paramname_hash()
  729. {
  730. return m_paramname_hash;
  731. }
  732. /*!
  733. * @brief This function copies the value in member value
  734. * @param _value New value to be copied in member value
  735. */
  736. inline void value(const AnnotationParameterValue &_value)
  737. {
  738. m_value = _value;
  739. }
  740. /*!
  741. * @brief This function moves the value in member value
  742. * @param _value New value to be moved in member value
  743. */
  744. inline void value(AnnotationParameterValue &&_value)
  745. {
  746. m_value = std::move(_value);
  747. }
  748. /*!
  749. * @brief This function returns a constant reference to member value
  750. * @return Constant reference to member value
  751. */
  752. inline const AnnotationParameterValue& value() const
  753. {
  754. return m_value;
  755. }
  756. /*!
  757. * @brief This function returns a reference to member value
  758. * @return Reference to member value
  759. */
  760. inline AnnotationParameterValue& value()
  761. {
  762. return m_value;
  763. }
  764. /*!
  765. * @brief This function returns the serialized size of a data depending on the buffer alignment.
  766. * @param data Data which is calculated its serialized size.
  767. * @param current_alignment Buffer alignment.
  768. * @return Serialized size.
  769. */
  770. static size_t getCdrSerializedSize(const AppliedAnnotationParameter& data, size_t current_alignment = 0);
  771. /*!
  772. * @brief This function serializes an object using CDR serialization.
  773. * @param cdr CDR serialization object.
  774. */
  775. void serialize(eprosima::fastcdr::Cdr &cdr) const;
  776. /*!
  777. * @brief This function deserializes an object using CDR serialization.
  778. * @param cdr CDR serialization object.
  779. */
  780. void deserialize(eprosima::fastcdr::Cdr &cdr);
  781. /*!
  782. * @brief This function returns the maximum serialized size of the Key of an object
  783. * depending on the buffer alignment.
  784. * @param current_alignment Buffer alignment.
  785. * @return Maximum serialized size.
  786. */
  787. static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
  788. /*!
  789. * @brief This function tells you if the Key has been defined for this type
  790. */
  791. static bool isKeyDefined();
  792. /*!
  793. * @brief This function serializes the key members of an object using CDR serialization.
  794. * @param cdr CDR serialization object.
  795. */
  796. void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
  797. bool operator==(const AppliedAnnotationParameter& other) const;
  798. private:
  799. NameHash m_paramname_hash;
  800. AnnotationParameterValue m_value;
  801. };
  802. // The application of an annotation to some type or type member
  803. /*struct AppliedAnnotationParameter {
  804. NameHash paramname_hash;
  805. AnnotationParameterValue value;
  806. };*/
  807. /*
  808. class AppliedAnnotationParameter
  809. {
  810. public:
  811. AppliedAnnotationParameter();
  812. ~AppliedAnnotationParameter();
  813. AppliedAnnotationParameter(const AppliedAnnotationParameter &x);
  814. AppliedAnnotationParameter(AppliedAnnotationParameter &&x);
  815. AppliedAnnotationParameter& operator=(const AppliedAnnotationParameter &x);
  816. AppliedAnnotationParameter& operator=(AppliedAnnotationParameter &&x);
  817. inline void paramname_hash(const NameHash &_paramname_hash) { m_paramname_hash = _paramname_hash; }
  818. inline void paramname_hash(NameHash &&_paramname_hash) { m_paramname_hash = std::move(_paramname_hash); }
  819. inline const NameHash& paramname_hash() const { return m_paramname_hash; }
  820. inline NameHash& paramname_hash() { return m_paramname_hash; }
  821. inline void value(const AnnotationParameterValue &_value) { m_value = _value; }
  822. inline void value(AnnotationParameterValue &&_value) { m_value = std::move(_value); }
  823. inline const AnnotationParameterValue& value() const { return m_value; }
  824. inline AnnotationParameterValue& value() { return m_value; }
  825. static size_t getCdrSerializedSize(const AppliedAnnotationParameter& data, size_t current_alignment = 0);
  826. void serialize(eprosima::fastcdr::Cdr &cdr) const;
  827. void deserialize(eprosima::fastcdr::Cdr &cdr);
  828. static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
  829. static bool isKeyDefined();
  830. void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
  831. private:
  832. NameHash m_paramname_hash;
  833. AnnotationParameterValue m_value;
  834. };
  835. */
  836. // Sorted by AppliedAnnotationParameter.paramname_hash
  837. typedef std::vector<AppliedAnnotationParameter> AppliedAnnotationParameterSeq;
  838. /*struct AppliedAnnotation {
  839. TypeIdentifier annotation_typeid;
  840. AppliedAnnotationParameterSeq param_seq; // @Optional
  841. };*/
  842. class AppliedAnnotation
  843. {
  844. public:
  845. AppliedAnnotation();
  846. ~AppliedAnnotation();
  847. AppliedAnnotation(const AppliedAnnotation &x);
  848. AppliedAnnotation(AppliedAnnotation &&x);
  849. AppliedAnnotation& operator=(const AppliedAnnotation &x);
  850. AppliedAnnotation& operator=(AppliedAnnotation &&x);
  851. inline void annotation_typeid(const TypeIdentifier &_annotation_typeid) { m_annotation_typeid = _annotation_typeid; }
  852. inline void annotation_typeid(TypeIdentifier &&_annotation_typeid) { m_annotation_typeid = std::move(_annotation_typeid); }
  853. inline const TypeIdentifier& annotation_typeid() const { return m_annotation_typeid; }
  854. inline TypeIdentifier& annotation_typeid() { return m_annotation_typeid; }
  855. inline void param_seq(const AppliedAnnotationParameterSeq &_param_seq) { m_param_seq = _param_seq; }
  856. inline void param_seq(AppliedAnnotationParameterSeq &&_param_seq) { m_param_seq = std::move(_param_seq); }
  857. inline const AppliedAnnotationParameterSeq& param_seq() const { return m_param_seq; }
  858. inline AppliedAnnotationParameterSeq& param_seq() { return m_param_seq; }
  859. static size_t getCdrSerializedSize(const AppliedAnnotation& data, size_t current_alignment = 0);
  860. void serialize(eprosima::fastcdr::Cdr &cdr) const;
  861. void deserialize(eprosima::fastcdr::Cdr &cdr);
  862. static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
  863. static bool isKeyDefined();
  864. void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
  865. bool operator==(const AppliedAnnotation& other) const;
  866. private:
  867. TypeIdentifier m_annotation_typeid;
  868. AppliedAnnotationParameterSeq m_param_seq;
  869. };
  870. // Sorted by AppliedAnnotation.annotation_typeid
  871. typedef std::vector<AppliedAnnotation> AppliedAnnotationSeq;
  872. // @verbatim(placement="<placement>", language="<lang>", text="<text>")
  873. /*struct AppliedVerbatimAnnotation {
  874. std::string placement; // 32
  875. std::string language; // 32
  876. std::string text;
  877. };*/
  878. class AppliedVerbatimAnnotation
  879. {
  880. public:
  881. AppliedVerbatimAnnotation();
  882. ~AppliedVerbatimAnnotation();
  883. AppliedVerbatimAnnotation(const AppliedVerbatimAnnotation &x);
  884. AppliedVerbatimAnnotation(AppliedVerbatimAnnotation &&x);
  885. AppliedVerbatimAnnotation& operator=(const AppliedVerbatimAnnotation &x);
  886. AppliedVerbatimAnnotation& operator=(AppliedVerbatimAnnotation &&x);
  887. inline void placement(const std::string &_placement) { m_placement = _placement; }
  888. inline void placement(std::string &&_placement) { m_placement = std::move(_placement); }
  889. inline const std::string& placement() const { return m_placement; }
  890. inline std::string& placement() { return m_placement; }
  891. inline void language(const std::string &_language) { m_language = _language; }
  892. inline void language(std::string &&_language) { m_language = std::move(_language); }
  893. inline const std::string& language() const { return m_language; }
  894. inline std::string& language() { return m_language; }
  895. inline void text(const std::string &_text) { m_text = _text; }
  896. inline void text(std::string &&_text) { m_text = std::move(_text); }
  897. inline const std::string& text() const { return m_text; }
  898. inline std::string& text() { return m_text; }
  899. static size_t getCdrSerializedSize(const AppliedVerbatimAnnotation& data, size_t current_alignment = 0);
  900. void serialize(eprosima::fastcdr::Cdr &cdr) const;
  901. void deserialize(eprosima::fastcdr::Cdr &cdr);
  902. static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
  903. static bool isKeyDefined();
  904. void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
  905. bool operator==(const AppliedVerbatimAnnotation& other) const;
  906. private:
  907. std::string m_placement;
  908. std::string m_language;
  909. std::string m_text;
  910. };
  911. // --- Aggregate types: -----------------------------------------------
  912. /*struct AppliedBuiltinMemberAnnotations {
  913. std::string unit; // @unit("<unit>") // @Optional
  914. AnnotationParameterValue min; // @min , @range // @Optional
  915. AnnotationParameterValue max; // @max , @range // @Optional
  916. std::string hash_id; // @hash_id("<membername>") // @Optional
  917. };
  918. */
  919. class AppliedBuiltinMemberAnnotations
  920. {
  921. public:
  922. AppliedBuiltinMemberAnnotations();
  923. ~AppliedBuiltinMemberAnnotations();
  924. AppliedBuiltinMemberAnnotations(const AppliedBuiltinMemberAnnotations &x);
  925. AppliedBuiltinMemberAnnotations(AppliedBuiltinMemberAnnotations &&x);
  926. AppliedBuiltinMemberAnnotations& operator=(const AppliedBuiltinMemberAnnotations &x);
  927. AppliedBuiltinMemberAnnotations& operator=(AppliedBuiltinMemberAnnotations &&x);
  928. inline void unit(const std::string &_unit) { m_unit = _unit; }
  929. inline void unit(std::string &&_unit) { m_unit = std::move(_unit); }
  930. inline const std::string& unit() const { return m_unit; }
  931. inline std::string& unit() { return m_unit; }
  932. inline void min(const AnnotationParameterValue &_min) { m_min = _min; }
  933. inline void min(AnnotationParameterValue &&_min) { m_min = std::move(_min); }
  934. inline const AnnotationParameterValue& min() const { return m_min; }
  935. inline AnnotationParameterValue& min() { return m_min; }
  936. inline void max(const AnnotationParameterValue &_max) { m_max = _max; }
  937. inline void max(AnnotationParameterValue &&_max) { m_max = std::move(_max); }
  938. inline const AnnotationParameterValue& max() const { return m_max; }
  939. inline AnnotationParameterValue& max() { return m_max; }
  940. inline void hash_id(const std::string &_hash_id) { m_hash_id = _hash_id; }
  941. inline void hash_id(std::string &&_hash_id) { m_hash_id = std::move(_hash_id); }
  942. inline const std::string& hash_id() const { return m_hash_id; }
  943. inline std::string& hash_id() { return m_hash_id; }
  944. static size_t getCdrSerializedSize(const AppliedBuiltinMemberAnnotations& data, size_t current_alignment = 0);
  945. void serialize(eprosima::fastcdr::Cdr &cdr) const;
  946. void deserialize(eprosima::fastcdr::Cdr &cdr);
  947. static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
  948. static bool isKeyDefined();
  949. void serializeKey(eprosima::fastcdr::Cdr &cdr) const;
  950. bool operator==(const AppliedBuiltinMemberAnnotations& other) const;
  951. private:
  952. std::string m_unit;
  953. AnnotationParameterValue m_min;
  954. AnnotationParameterValue m_max;
  955. std::string m_hash_id;
  956. };
  957. } // namespace types
  958. } // namespace fastrtps
  959. } // namespace eprosima
  960. #endif // _ANNOTATIONPARAMETERVALUE_H_