#include "CSV.h"#include <string>#include <iostream>#include <vector>#include <stdlib.h>Namespaces | |
| namespace | std |
| Definido por la biblioteca estándar C++. | |
Definiciones | |
| #define | Spanish_dox "Documentación en español" |
| Documentación en español. | |
| #define | CSV_line_h |
| Evita la inclusión múltiple. | |
| #define | Spanish_dox "Documentación en español" |
| Documentación en español. | |
Funciones | |
| int | getNextCSV (char *res, size_t res_size, int(getChar)(void *context)) |
Retrieves from the input character stream getChar() then next CSV value. | |
| char * | putCSV (char *res, size_t res_size, const char *line) |
Prepares line for output into a CSV file. | |
| char * | trim (char *str) |
Retorna la mayor subhilera de "str" que no tiene blancos al principio o al final. | |
| void | chop (char *str, char ch) |
Elimina ch si es el último caracter de str. | |
| #define Spanish_dox "Documentación en español" |
| #define CSV_line_h |
| #define Spanish_dox "Documentación en español" |
| int getNextCSV | ( | char * | res, | |
| size_t | res_size, | |||
| int(getChar)(void *context) | ||||
| ) |
Retrieves from the input character stream getChar() then next CSV value.
getChar() a single character is retrieved.getChar() must retorn -1.res.res can hold up to res_size char's.res can hold only as many char's as will fit into res are retrieved; in this case, the full value will not be read.res returns 1, otherwise signals failure returning 0.getChar() always is strlen(res). | char* putCSV | ( | char * | res, | |
| size_t | res_size, | |||
| const char * | line | |||
| ) |
Prepares line for output into a CSV file.
res.res can hold up to res_size char's.NULL is returned whenever more than res_size char's are required.res.
line has whitespace.line has double-quotes.line has commas ','.line with 2 double-quotes [""]. | char* trim | ( | char * | str | ) |
Retorna la mayor subhilera de "str" que no tiene blancos al principio o al final.
"str" y retorna un puntero dentro de ella."str" tiene blancos al final, los elimina insertándole un char(0)." \f\n\r\t\v".isspace(ch) para determinar si una letra es o no es algún tipo de espacio whitespace.
{{ // test::trim_C()
char str[20];
strcpy( str , " a b " ); assertTrue( strcmp( trim(str), "a b" ) == 0 );
strcpy( str , " a\nb " ); assertTrue( strcmp( trim(str), "a\nb") == 0 );
strcpy( str , "" ); assertTrue( strcmp( trim(str), "" ) == 0 );
strcpy( str , "\r\t\n " ); assertTrue( strcmp( trim(str), "" ) == 0 );
strcpy( str , " a b " ); assertTrue( strcmp( trim(str), "a b" ) == 0 );
strcpy( str , " ab " ); assertTrue( strcmp( trim(str), "ab" ) == 0 );
}}
| void chop | ( | char * | str, | |
| char | ch | |||
| ) |
Elimina ch si es el último caracter de str.
ch.
{{ // test::chop_C()
char str[20]; char ch;
strcpy( str , "12345") ; assertTrue( strcmp(str ,"12345")==0 );
chop(str,'0'); assertTrue( strcmp(str ,"12345")==0 );
for ( ch='5'; ch != '0'; --ch ) {
assertTrue( str[strlen(str)-1] == ch );
chop(str,ch);
}
assertTrue( *str == 0 );
chop(str,'3'); assertTrue( *str == 0 );
}}
1.5.8