StrIterPeek
StrIterPeek
Description
Peek current character without advancing
Parameters
| Name | Direction | Description |
|---|---|---|
mi |
in | StrIter object |
Success
Returns current character
Failure
Returns null character if exhausted
Usage example (Cross-references)
Usage examples (Cross-references)
- In
KvConfig.c:102:
static StrIter kvconfig_consume_line_end(StrIter si) {
if (StrIterPeek(&si) == '\r') {
StrIterNext(&si);
}- In
KvConfig.c:106:
}
if (StrIterPeek(&si) == '\n') {
StrIterNext(&si);
}- In
KvConfig.c:153:
StrIter KvConfigSkipWhitespace(StrIter si) {
while (StrIterRemainingLength(&si) && kvconfig_is_space(StrIterPeek(&si))) {
StrIterNext(&si);
}- In
KvConfig.c:161:
StrIter KvConfigSkipLine(StrIter si) {
while (StrIterRemainingLength(&si) && !kvconfig_is_line_end(StrIterPeek(&si))) {
StrIterNext(&si);
}- In
KvConfig.c:179:
while (StrIterRemainingLength(&si)) {
char c = StrIterPeek(&si);
if (c == '=' || c == ':' || kvconfig_is_space(c) || kvconfig_is_line_end(c) || kvconfig_is_comment_start(c)) {- In
KvConfig.c:209:
si = KvConfigSkipWhitespace(si);
if (!StrIterRemainingLength(&si) || kvconfig_is_line_end(StrIterPeek(&si)) ||
kvconfig_is_comment_start(StrIterPeek(&si))) {
return si;- In
KvConfig.c:210:
if (!StrIterRemainingLength(&si) || kvconfig_is_line_end(StrIterPeek(&si)) ||
kvconfig_is_comment_start(StrIterPeek(&si))) {
return si;
}- In
KvConfig.c:214:
}
quote = StrIterPeek(&si);
if (quote == '"' || quote == '\'') {
StrIterNext(&si);- In
KvConfig.c:219:
while (StrIterRemainingLength(&si)) {
char c = StrIterPeek(&si);
if (c == quote) {- In
KvConfig.c:234:
}
c = StrIterPeek(&si);
switch (c) {
case 'n' :- In
KvConfig.c:268:
}
while (StrIterRemainingLength(&si) && !kvconfig_is_line_end(StrIterPeek(&si))) {
char c = StrIterPeek(&si);- In
KvConfig.c:269:
while (StrIterRemainingLength(&si) && !kvconfig_is_line_end(StrIterPeek(&si))) {
char c = StrIterPeek(&si);
if (kvconfig_is_comment_start(c) && value->length > 0 && kvconfig_is_space(value->data[value->length - 1])) {- In
KvConfig.c:311:
si = KvConfigSkipWhitespace(si);
if (StrIterPeek(&si) != '=' && StrIterPeek(&si) != ':') {
LOG_ERROR("Expected '=' or ':' after config key");
StrClear(key);- In
KvConfig.c:328:
si = KvConfigSkipWhitespace(si);
if (kvconfig_is_comment_start(StrIterPeek(&si))) {
si = KvConfigSkipLine(si);
} else if (!kvconfig_is_line_end(StrIterPeek(&si))) {- In
KvConfig.c:330:
if (kvconfig_is_comment_start(StrIterPeek(&si))) {
si = KvConfigSkipLine(si);
} else if (!kvconfig_is_line_end(StrIterPeek(&si))) {
LOG_ERROR("Unexpected trailing characters after config value");
StrClear(key);- In
KvConfig.c:358:
while (StrIterRemainingLength(&si)) {
char c = StrIterPeek(&si);
if (c == '\n') {- In
KvConfig.c:367:
if (kvconfig_is_space(c)) {
si = KvConfigSkipWhitespace(si);
if (kvconfig_is_line_end(StrIterPeek(&si))) {
si = kvconfig_consume_line_end(si);
continue;- In
KvConfig.c:380:
}
if (kvconfig_is_comment_start(StrIterPeek(&si))) {
si = KvConfigSkipLine(si);
continue;- In
JSON.c:15:
// starting of an object
if (StrIterPeek(&si) != '{') {
LOG_ERROR("Invalid object start. Expected '{'.");
return saved_si;- In
JSON.c:26:
// while not at the end of object.
while (StrIterPeek(&si) && StrIterPeek(&si) != '}') {
if (expect_comma) {
if (StrIterPeek(&si) != ',') {- In
JSON.c:28:
while (StrIterPeek(&si) && StrIterPeek(&si) != '}') {
if (expect_comma) {
if (StrIterPeek(&si) != ',') {
LOG_ERROR(
"Expected ',' between key/value pairs in object. Invalid "- In
JSON.c:51:
si = JSkipWhitespace(si);
if (StrIterPeek(&si) != ':') {
LOG_ERROR("Expected ':' after key string. Failed to read JSON");
StrDeinit(&key);- In
JSON.c:79:
}
char c = StrIterPeek(&si);
if (c != '}') {
LOG_ERROR("Expected end of object '}' but found '{c}'", c);- In
JSON.c:98:
// starting of an object
if (StrIterPeek(&si) != '[') {
LOG_ERROR("Invalid array start. Expected '['.");
return saved_si;- In
JSON.c:109:
// while not at the end of array.
while (StrIterPeek(&si) && StrIterPeek(&si) != ']') {
if (expect_comma) {
if (StrIterPeek(&si) != ',') {- In
JSON.c:111:
while (StrIterPeek(&si) && StrIterPeek(&si) != ']') {
if (expect_comma) {
if (StrIterPeek(&si) != ',') {
LOG_ERROR("Expected ',' between values in array. Invalid JSON array.");
return saved_si;- In
JSON.c:136:
// end of array
if (StrIterPeek(&si) != ']') {
LOG_ERROR("Invalid end of array. Expected ']'.");
return saved_si;- In
JSON.c:150:
}
while (StrIterRemainingLength(&si) && StrIterPeek(&si)) {
switch (StrIterPeek(&si)) {
case ' ' :- In
JSON.c:151:
while (StrIterRemainingLength(&si) && StrIterPeek(&si)) {
switch (StrIterPeek(&si)) {
case ' ' :
case '\t' :- In
JSON.c:180:
// string start
if (StrIterRemainingLength(&si) && StrIterPeek(&si) == '"') {
StrIterNext(&si);- In
JSON.c:184:
// while a printable character
while (StrIterRemainingLength(&si) && StrIterPeek(&si)) {
// three cases
// - end of string (return)
- In
JSON.c:189:
// - an escape sequence (processed and appended)
// - acceptable string character (appended)
switch (StrIterPeek(&si)) {
// end of string
case '"' :- In
JSON.c:204:
}
switch (StrIterPeek(&si)) {
// escape sequence
case '\\' :- In
JSON.c:264:
// default allowed characters
default :
StrPushBack(str, StrIterPeek(&si));
StrIterNext(&si);
break;- In
JSON.c:289:
bool is_neg = false;
if (StrIterPeek(&si) == '-') {
is_neg = true;
StrIterNext(&si);- In
JSON.c:299:
bool is_parsing = true;
while (is_parsing && StrIterRemainingLength(&si) && StrIterPeek(&si)) {
switch (StrIterPeek(&si)) {
case 'E' :- In
JSON.c:300:
while (is_parsing && StrIterRemainingLength(&si) && StrIterPeek(&si)) {
switch (StrIterPeek(&si)) {
case 'E' :
case 'e' :- In
JSON.c:310:
has_exp = true;
is_flt = true;
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;- In
JSON.c:321:
}
is_flt = true;
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;- In
JSON.c:335:
case '8' :
case '9' :
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;- In
JSON.c:359:
}
has_exp_plus_minus = true;
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;- In
JSON.c:473:
if (StrIterRemainingLength(&si) >= 4) {
if (StrIterPeek(&si) == 't') {
const char *pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "true", 4) == 0) {- In
JSON.c:485:
if (StrIterRemainingLength(&si) >= 5) {
if (StrIterPeek(&si) == 'f') {
const char *pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "false", 5) == 0) {- In
JSON.c:523:
*is_null = false;
if (StrIterRemainingLength(&si) >= 4) {
if (StrIterPeek(&si) == 'n') {
const char *pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "null", 4) == 0) {- In
JSON.c:553:
// check for true/false
if (StrIterPeek(&si) == 't' || StrIterPeek(&si) == 'f') {
StrIter before_si = si;
bool b;- In
JSON.c:570:
// check for null
if (StrIterPeek(&si) == 'n') {
StrIter before_si = si;
bool n;- In
JSON.c:588:
// expecting a string
if (StrIterPeek(&si) == '"') {
StrIter before_si = si;
Str s = StrInit();- In
JSON.c:603:
// looks like starting of a number?
if (StrIterPeek(&si) == '-' || (StrIterPeek(&si) >= '0' && StrIterPeek(&si) <= '9')) {
StrIter before_si = si;
Number num;- In
JSON.c:617:
// looks like starting of an object
if (StrIterPeek(&si) == '{') {
StrIter before_si = si;
si = JSkipObject(si);- In
JSON.c:630:
// looks like starting of an array
if (StrIterPeek(&si) == '[') {
StrIter before_si = si;
si = JSkipArray(si); }
if (StrIterPeek(&si) != '{') {
WriteFmt("[DEBUG] Peek check failed: expected '{', got '{c}'\n", StrIterPeek(&si));
success = false;
if (StrIterPeek(&si) != '{') {
WriteFmt("[DEBUG] Peek check failed: expected '{', got '{c}'\n", StrIterPeek(&si));
success = false;
}- In
JSON.h:416:
\
/* starting of an object */ \
if (StrIterPeek(&si) != '[') { \
LOG_ERROR("Invalid array start. Expected '['."); \
si = saved_si; \
- In
JSON.h:428:
\
/* while not at the end of array. */ \
while (StrIterPeek(&si) && StrIterPeek(&si) != ']') { \
if (expect_comma) { \
if (StrIterPeek(&si) != ',') { \
- In
JSON.h:430:
while (StrIterPeek(&si) && StrIterPeek(&si) != ']') { \
if (expect_comma) { \
if (StrIterPeek(&si) != ',') { \
LOG_ERROR("Expected ',' between values in array. Invalid JSON array."); \
failed = true; \
- In
JSON.h:467:
/* end of array */ \
if (!failed) { \
if (StrIterPeek(&si) != ']') { \
LOG_ERROR("Invalid end of array. Expected ']'."); \
failed = true; \
- In
JSON.h:508:
\
/* starting of an object */ \
if (StrIterPeek(&si) != '{') { \
LOG_ERROR("Invalid object start. Expected '{'."); \
si = saved_si; \
- In
JSON.h:521:
\
/* while not at the end of object. */ \
while (StrIterPeek(&si) && StrIterPeek(&si) != '}') { \
if (expect_comma) { \
if (StrIterPeek(&si) != ',') { \
- In
JSON.h:523:
while (StrIterPeek(&si) && StrIterPeek(&si) != '}') { \
if (expect_comma) { \
if (StrIterPeek(&si) != ',') { \
LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object."); \
failed = true; \
- In
JSON.h:550:
\
\
if (StrIterPeek(&si) != ':') { \
LOG_ERROR("Expected ':' after key string. Failed to read JSON"); \
StrDeinit(&key); \
- In
JSON.h:592:
\
if (!failed) { \
char c = StrIterPeek(&si); \
if (c != '}') { \
LOG_ERROR("Expected end of object '}' but found '{c}'", c); \
Last updated on