Skip to content

Commit 9f0d45a

Browse files
committed
Update based on review comments
Signed-off-by: Barry Xu <barry.xu@sony.com>
1 parent 24aacb6 commit 9f0d45a

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

rcl_yaml_param_parser/src/parse.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ void * get_value(
8888
RCUTILS_CHECK_ALLOCATOR_WITH_MSG(
8989
&allocator, "allocator is invalid", return NULL);
9090

91-
bool str_tag_enabled = tag != NULL && strcmp(YAML_STR_TAG, (char *)tag) == 0;
91+
/// Check for yaml string tag
92+
if (tag != NULL && strcmp(YAML_STR_TAG, (char *)tag) == 0) {
93+
*val_type = DATA_TYPE_STRING;
94+
return rcutils_strdup(value, allocator);
95+
}
9296

9397
/// Check if it is bool
9498
if (style != YAML_SINGLE_QUOTED_SCALAR_STYLE &&
95-
style != YAML_DOUBLE_QUOTED_SCALAR_STYLE &&
96-
!str_tag_enabled)
99+
style != YAML_DOUBLE_QUOTED_SCALAR_STYLE)
97100
{
98101
if ((0 == strcmp(value, "Y")) ||
99102
(0 == strcmp(value, "y")) ||
@@ -140,8 +143,7 @@ void * get_value(
140143

141144
/// Check for int
142145
if (style != YAML_SINGLE_QUOTED_SCALAR_STYLE &&
143-
style != YAML_DOUBLE_QUOTED_SCALAR_STYLE &&
144-
!str_tag_enabled)
146+
style != YAML_DOUBLE_QUOTED_SCALAR_STYLE)
145147
{
146148
errno = 0;
147149
ival = strtol(value, &endptr, 0);
@@ -162,8 +164,7 @@ void * get_value(
162164

163165
/// Check for float
164166
if (style != YAML_SINGLE_QUOTED_SCALAR_STYLE &&
165-
style != YAML_DOUBLE_QUOTED_SCALAR_STYLE &&
166-
!str_tag_enabled)
167+
style != YAML_DOUBLE_QUOTED_SCALAR_STYLE)
167168
{
168169
errno = 0;
169170
endptr = NULL;

rcl_yaml_param_parser/test/correct_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ string_tag:
5353
ros__parameters:
5454
string_bool: !!str yes
5555
string_int: !!str 1234
56-
string_double: !!str 12.34
56+
string_double: !!str 12.34

0 commit comments

Comments
 (0)