Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features: string bracketing, CSV operators, and JSON array value reader #23

Merged
merged 5 commits into from
Oct 27, 2024

Conversation

rouson
Copy link

@rouson rouson commented Oct 27, 2024

This PR adds

  1. A unary operator(.csv.) with a string_t result encapsulating a comma-separated value (CSV) created from
    a. a string_t array or
    b. a character array,
  2. A binary operator(.sv.) with a string_t result encapsulating a CSV created from left- and right-hand operands:
    a. a string_t array and a string_t separator or
    b. a string_t array and a character separator.
    c. a character array and a character separator
    d. a character array and a string_t separator
  3. A unit test that verifies the following identities:
"a,bc,def" == .csv. [string_t("a"), string_t("bc"), string_t("def")]
"abc,def"  == .csv. ["abc", "def"]
    
"do|re|mi" == (string_t(["do", "re", "mi"])         .sv.          "|" )
"dore|mi"  == (([string_t("dore"), string_t("mi")]) .sv. string_t("|"))
"do|re|mi" == (         ["do", "re", "mi"]          .sv.          "|" )
"do|re|mi" == (         ["do", "re", "mi"]          .sv. string_t("|"))
  1. A bracket type-bound procedure and a test verifying the following identities:
scalar%bracket()           == string_t("[do re mi]") &
all(array%bracket()        == [string_t("[do]"), string_t("[re]"), string_t("[mi]")]) &
all(array%bracket('"')     == [string_t('"do"'), string_t('"re"'), string_t('"mi"')]) &
all(array%bracket("{","}") == [string_t('{do}'), string_t('{re}'), string_t('{mi}')]) &
  1. A get_string_t_array specific procedure supporting the generic get_json_value binding and test verifying the following identities:
associate(json_line  => string_t('"lead singer" : ["stevie", "ray", "vaughn"],'))
  all( json_line%get_json_value(key=string_t("lead singer"), mold=[string_t::]) == [string_t("stevie"), string_t("ray"), string_t("vaughn")]))
end associate

This commit adds

1. A unary operator(.csv.) that produces a string_t object
   encapsulating a comma-separated value (CSV) created from
   a. a string_t array or
   b. a character array,
2. A binary operator(.sv.) that produces a string_t object
   encapsulating a comma-separated value (CSV) created from
   left- and right-hand sides, respectively corresponding to
   a. a string_t array and a string_t separator or
   b. a string_t array and a character separator.
   c. a character array and a character separator
   d. a character array and a string_t separator
3. A unit test that verifies the following identities:

  "a,bc,def" == .csv. [string_t("a"), string_t("bc"), string_t("def")]
  "abc,def"  == .csv. ["abc", "def"]

  "do|re|mi" == (string_t(["do", "re", "mi"])         .sv.          "|" )
  "dore|mi"  == (([string_t("dore"), string_t("mi")]) .sv. string_t("|"))
  "do|re|mi" == (         ["do", "re", "mi"]          .sv.          "|" )
  "do|re|mi" == (         ["do", "re", "mi"]          .sv. string_t("|"))

corresponding to cases 1a-b and 2a-d, respectively.
@rouson rouson changed the title String bracketing csv json array Features: character/string_t bracketing, CSV operators, and JSON array value reader Oct 27, 2024
@rouson rouson changed the title Features: character/string_t bracketing, CSV operators, and JSON array value reader Features: string bracketing, CSV operators, and JSON array value reader Oct 27, 2024
@rouson rouson merged commit ed308b1 into main Oct 27, 2024
8 checks passed
@rouson rouson deleted the string-bracketing-csv-json-array branch October 27, 2024 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant