Index of Functions: A B C D E F G H I J K L M N O P Q R S T U V W X
Index Page lparss_c

Table of contents

Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

       lparss_c (Parse a list of items; return a set)

       void lparss_c ( ConstSpiceChar   * list,
                       ConstSpiceChar   * delims,
                       SpiceCell        * set     )

#### Abstract

       Parse a list of items separated by multiple delimiters, placing the
       resulting items into a set.

#### Required_Reading

       None.

#### Keywords

       CHARACTER
       LIST
       PARSING
       STRING

#### Brief_I/O

       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       list       I    List of items delimited by delims.
       delims     I    Single characters which delimit items.
       set        O    Set containing items in the list, left justified.

#### Detailed_Input

       list        is a list of items delimited by any one of the characters
                   in the string `delims'. Consecutive delimiters, and
                   delimiters at the beginning and end of the list, are
                   considered to delimit empty items. A blank or empty list
                   is considered to contain a single, empty item. Leading and
                   trailing blanks in list are ignored.

       delims      contains the individual characters which delimit the
                   items in the list. These may be any ASCII characters,
                   including blanks.

                   However, by definition, consecutive blanks are NOT
                   considered to be consecutive delimiters. Nor are a blank
                   and any other delimiter considered to be consecutive
                   delimiters. In addition, leading and trailing blanks are
                   ignored.

#### Detailed_Output

       set         is a SPICE set containing the items in the list, left
                   justified. Any item in the list too long to fit into an
                   element of `set' is truncated on the right. Empty or blank
                   items in the input string are mapped to empty strings on
                   output.

                   The strings in `set' will be sorted in increasing order,
                   and duplicates will be removed. Trailing blanks are
                   ignored in string comparisons.

                   The size of the set must be initialized prior to calling
                   lparss_c.

                   `set' must be declared as a character SpiceCell.

                   CSPICE provides the following macro, which declares and
                   initializes the cell

                      SPICECHAR_CELL          ( set, SETSZ, SETMLEN );

                   where SETSZ is the maximum capacity of `set' and SETMLEN is the
                   maximum length of any member in the character cell.

#### Parameters

       None.

#### Exceptions

       1)  If the size of the set is not large enough to accommodate all
           of the items in the set, an error is signaled by a routine in
           the call tree of this routine.

       2)  If the string length of `set' is too short to accommodate an
           item, the item will be truncated on the right.

       3)  If the string length of `set' is too short to permit encoding of
           integers via the SPICELIB routine ENCHAR, an error is signaled
           by a routine in the call tree of this routine.

       4)  If any of the `list', `delims' or `list' input string pointers
           is null, the error SPICE(NULLPOINTER) is signaled.

       5)  If any of the `list' or `delims' input strings has zero
           length, the error SPICE(EMPTYSTRING) is signaled.

       6)  If the `set' cell argument has a type other than SpiceChar,
           the error SPICE(TYPEMISMATCH) is signaled.

       7)  If the string length associated with the argument `set' is
           non-positive or too short to be usable when constructing the
           equivalent SPICE character cell required by the wrapped
           SPICELIB routine, an error is signaled by a routine in the
           call tree of this routine.

       8)  An empty input `list' will result in a single, empty string item
           added to `set'. This case is not an error.

#### Files

       None.

#### Particulars

       None.

#### Examples

       The following examples illustrate the operation of lparss_c.

       1) Let

             list   == "  A number of words   separated   by spaces.   "
             delims == " ,."

          Let set be declared with size 20.

          Then

             Element 0 of set == " "
             Element 1 of set == "A"
             Element 2 of set == "by"
             Element 3 of set == "number"
             Element 4 of set == "of"
             Element 5 of set == "separated"
             Element 6 of set == "spaces"
             Element 7 of set == "words"

        2) Let

              list   == "  1986-187// 13:15:12.184 "
              delims == " ,/-:"
              nmax   == 20

           Then

              Element 0 of set == ""
              Element 1 of set == "12.184"
              Element 2 of set == "13"
              Element 3 of set == "15"
              Element 4 of set == "187"
              Element 5 of set == "1986"

#### Restrictions

       1)  String comparisons performed by this routine are Fortran-style:
           trailing blanks in the input array or key value are ignored.
           This gives consistent behavior with CSPICE code generated by
           the f2c translator, as well as with the Fortran SPICE Toolkit.

           Note that this behavior is not identical to that of the ANSI
           C library functions strcmp and strncmp.

#### Literature_References

       None.

#### Author_and_Institution

       N.J. Bachman        (JPL)
       J. Diaz del Rio     (ODC Space)
       I.M. Underwood      (JPL)

#### Version

       -CSPICE Version 1.0.1, 29-OCT-2021 (JDR)

           Edited the header to comply with NAIF standard.

           Extended description of argument "set" in -Detailed_Output to include
           type and preferred declaration method.

           Added entries #2 and #3 in -Exceptions section.

       -CSPICE Version 1.0.0, 27-AUG-2002 (NJB) (IMU)

#### Index_Entries

       parse a list of items

#### Link to routine lparss_c source file lparss_c.c

    Fri Dec 31 18:41:09 2021