StrIterPeek
- Macro
- October 8, 2025
Table of Contents
StrIterPeek
StrIterPeekDescription
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)
- 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); \