Skip to content

Commit

Permalink
New STG API functions to check the type of TypeIdentifier [21005] (#140)
Browse files Browse the repository at this point in the history
* Refs #20424. New STG API functions to check the type of TypeIdentifier

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #20424. Apply suggestion

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware authored and EduPonz committed May 14, 2024
1 parent 8957372 commit 1762bfc
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 9 deletions.
31 changes: 26 additions & 5 deletions src/main/java/com/eprosima/idl/parser/typecode/ArrayTypeCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,39 @@ public boolean isIsType_f()
return true;
}

@Override
public String getTypeIdentifier()
/*!
* @ingroup api_for_stg
* @brief This function can be used to check if TypeIdentifier's kind is the small one or the large one.
* @return @e false if all dimensions of the array are smaller than 256.
* Otherwise @e true is returned.
*/
public boolean getIsTypeIdentifierKindLarge()
{
String type_id = "TI_PLAIN_ARRAY_SMALL";
for (int count = 0; count < evaluated_dimensions_.size(); ++count)
{
if (Integer.parseInt(evaluated_dimensions_.get(count)) >= 256)
{
return "TI_PLAIN_ARRAY_LARGE";
return true;
}
}
return type_id;

return false;
}

/*!
* @ingroup api_for_stg
* @brief This function can be used to retrieve the TypeIdentifier's kind.
* @return @e TI_PLAIN_ARRAY_SMALL if all dimensions of the array are smaller than 256.
* Otherwise @e TI_PLAIN_ARRAY_LARGE is returned.
*/
@Override
public String getTypeIdentifier()
{
if (getIsTypeIdentifierKindLarge())
{
return "TI_PLAIN_ARRAY_LARGE";
}
return "TI_PLAIN_ARRAY_SMALL";
}

@Override
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/com/eprosima/idl/parser/typecode/MapTypeCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,33 @@ public boolean isIsType_19()
return true;
}


/*!
* @ingroup api_for_stg
* @brief This function can be used to check if TypeIdentifier's kind is the small one or the large one.
* @return @e false if map is unbound or smaller than 256.
* Otherwise @e true is returned.
*/
public boolean getIsTypeIdentifierKindLarge()
{
if (!isUnbound() && Integer.parseInt(evaluated_maxsize_) >= 256)
{
return true;
}

return false;
}

/*!
* @ingroup api_for_stg
* @brief This function can be used to retrieve the TypeIdentifier's kind.
* @return @e TI_PLAIN_MAP_SMALL if map is unbound or smaller than 256.
* Otherwise @e TI_PLAIN_MAP_LARGE is returned.
*/
@Override
public String getTypeIdentifier()
{
if (!isUnbound() && Integer.parseInt(evaluated_maxsize_) >= 256)
if (getIsTypeIdentifierKindLarge())
{
return "TI_PLAIN_MAP_LARGE";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,32 @@ public boolean isIsType_e()
return true;
}

/*!
* @ingroup api_for_stg
* @brief This function can be used to check if TypeIdentifier's kind is the small one or the large one.
* @return @e false if sequence is unbound or smaller than 256.
* Otherwise @e true is returned.
*/
public boolean getIsTypeIdentifierKindLarge()
{
if (!isUnbound() && Integer.parseInt(evaluated_maxsize_) >= 256)
{
return true;
}

return false;
}

/*!
* @ingroup api_for_stg
* @brief This function can be used to retrieve the TypeIdentifier's kind.
* @return @e TI_PLAIN_SEQUENCE_SMALL if sequence is unbound or smaller than 256.
* Otherwise @e TI_PLAIN_SEQUENCE_LARGE is returned.
*/
@Override
public String getTypeIdentifier()
{
if (!isUnbound() && Integer.parseInt(evaluated_maxsize_) >= 256)
if (getIsTypeIdentifierKindLarge())
{
return "TI_PLAIN_SEQUENCE_LARGE";
}
Expand Down
26 changes: 24 additions & 2 deletions src/main/java/com/eprosima/idl/parser/typecode/StringTypeCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,35 @@ public boolean isIsType_d()
return true;
}

/*!
* @ingroup api_for_stg
* @brief This function can be used to check if TypeIdentifier's kind is the small one or the large one.
* @return @e false if string is unbound or smaller than 256.
* Otherwise @e true is returned.
*/
public boolean getIsTypeIdentifierKindLarge()
{
if (isIsBounded() && Integer.parseInt(evaluated_maxsize_) >= 256)
{
return true;
}

return false;
}

/*!
* @ingroup api_for_stg
* @brief This function can be used to retrieve the TypeIdentifier's kind.
* @return @e TI_STRING8_SMALL or TI_STRING16_SMALL if string is unbound or smaller than 256.
* Otherwise @e TI_STRING8_LARGE or TI_STRING16_LARGE is returned.
*/
@Override
public String getTypeIdentifier()
{
switch (getKind())
{
case Kind.KIND_STRING:
if (isIsBounded() && Integer.parseInt(evaluated_maxsize_) >= 256)
if (getIsTypeIdentifierKindLarge())
{
return "TI_STRING8_LARGE";
}
Expand All @@ -51,7 +73,7 @@ public String getTypeIdentifier()
return "TI_STRING8_SMALL";
}
case Kind.KIND_WSTRING:
if (isIsBounded() && Integer.parseInt(evaluated_maxsize_) >= 256)
if (getIsTypeIdentifierKindLarge())
{
return "TI_STRING16_LARGE";
}
Expand Down

0 comments on commit 1762bfc

Please sign in to comment.