libsim Versione 7.2.6

◆ csv_record_addfield_char()

subroutine, private csv_record_addfield_char ( type(csv_record), intent(inout) this,
character(len=*), intent(in) field,
logical, intent(in), optional force_quote )
private

Add a field from a CHARACTER variable to the csv record this.

The field will be quoted if necessary.

Da fare
Improve the trailing blank quoting.
Parametri
[in,out]thisobject where to add field
[in]fieldfield to be added
[in]force_quoteif provided and .TRUE. , the field will be quoted even if not necessary

Definizione alla linea 551 del file file_utilities.F90.

552!! csv_record_addfield calls (csv encoding mode). Both \a csv_record
553!! objects \a this and \a record must use the same delimiter and
554!! quoting characters, otherwise the operation will silently fail.
555SUBROUTINE csv_record_addfield_csv_record(this, record)
556TYPE(csv_record),INTENT(INOUT) :: this !< object where to add record
557TYPE(csv_record),INTENT(IN) :: record !< record to be added
558
559IF (this%csep /= record%csep .OR. this%cquote /= record%cquote) RETURN ! error
560CALL checkrealloc(this, record%cursor)
561IF (this%nfield > 0) CALL add_byte(this, this%csep)
562
563this%record(this%cursor+1:this%cursor+record%cursor) = &
564 record%record(1:record%cursor)
565this%cursor = this%cursor + record%cursor
566this%nfield = this%nfield + record%nfield
567
568END SUBROUTINE csv_record_addfield_csv_record
569
570
571!> Return current csv-coded record as a \a CHARACTER variable, ready to be written
572!! to a file. It is not necessary to trim the result for trailing blanks.
573FUNCTION csv_record_getrecord(this, nfield)
574TYPE(csv_record),INTENT(IN) :: this !< object to be coded, the object is not modified, so that other fields can still be added after the call to ::csv_record_getrecord
575INTEGER, INTENT(out), OPTIONAL :: nfield !< number of fields contained in the record
576
577CHARACTER(len=this%cursor) :: csv_record_getrecord
578
579csv_record_getrecord = transfer(this%record(1:this%cursor), csv_record_getrecord)
580IF (present(nfield)) nfield = this%nfield
581
582END FUNCTION csv_record_getrecord
583
584
585!> Returns next field from the record \a this as a \c CHARACTER variable.
586!! The field pointer is advanced to the next field.
587!! If all the fields have already been interpreted it returns an empty string
588!! anyway; in order to verify the end-of-record condition the \a ier parameter
589!! must be used.
590SUBROUTINE csv_record_getfield_char(this, field, flen, ier)
591TYPE(csv_record),INTENT(INOUT) :: this !< object to be decoded
592CHARACTER(len=*),INTENT(OUT),OPTIONAL :: field !< contents of the field, if not provided, the field pointer is increased only; if the variable is not long enough, a warning is printed and the part that fits is returned;
593!< the variable is space-terminated anyway, so the \a flen parameter has to be used in order to evaluate possible significant trailing spaces
594INTEGER,INTENT(OUT),OPTIONAL :: flen !< actual length of the field including trailing blanks, it is correctly computed also when \a field is not provided or too short
595INTEGER,INTENT(OUT),OPTIONAL :: ier!< error code, 0 = OK, 1 = \a field too short, 2 = end of record
596
597LOGICAL :: inquote, inpre, inpost, firstquote
598INTEGER :: i, ocursor, ofcursor
599
600! check end of record
601IF (csv_record_end(this)) THEN
602 IF (PRESENT(field)) field = cmiss
603 IF (PRESENT(ier))THEN

Generated with Doxygen.