Warning: session_start(): open(/var/lib/php/sessions/sess_jgoqpimd6j6iinni1cqugqdi1q, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// TODO: empty values might not be handled correctly
// (e.g. a,,c)
sclass ExtendedCSVParser {
S csv;
*() {}
*(S *csv) {}
run {
int i = 0, startOfValue = 0;
bool inQuotedValue;
while ping (i < l(csv)) {
char c = csv.charAt(i);
if (c == ',') {
foundValue(substring(csv, startOfValue, i));
startOfValue = i+1;
} else if (c == '\r' || c == '\n') {
if (!inQuotedValue) {
foundValue(substring(csv, startOfValue, i));
endOfRecord();
}
} else if (c == '"') {
if (inQuotedValue) {
if (charAt(s, i+1) == '"') i++; // double quotes inside of a value
else
inQuotedValue = false;
} else
set inQuotedValue;
}
i++;
}
foundValue(substring(csv, startOfValue));
endOfRecord();
}
S unquoteValue(S value) {
ret dropPrefix("\"", dropSuffix("\"", replace(value, "\"\"", "\"")));
}
void foundValue(S value) {
if (nempty(value))
onValueFound(unquoteValue(value));
}
swappable void onValueFound(S value) {}
swappable void endOfRecord() {}
}