bglibs
Data Structures | Macros | Functions
striter: Iterator over substrings of a str.

Data Structures

struct  striter
 

Macros

#define str_copyiter(STR, ITER)   str_copyb(STR,(ITER)->startptr,(ITER)->len)
 
#define str_catiter(STR, ITER)   str_catb(STR,(ITER)->startptr,(ITER)->len)
 
#define obuf_putiter(OBUF, ITER)   obuf_write(OBUF,(ITER)->startptr,(ITER)->len)
 
#define striter_loop(ITER, STR, SEP)   for(striter_start(ITER,STR,SEP);striter_valid(ITER);striter_advance(ITER))
 

Functions

void striter_start (striter *iter, const struct str *s, char sep)
 
int striter_valid (striter *)
 
int striter_advance (striter *)
 

Detailed Description

Calling Convention
All non-void functions return 0 (false) if the function failed or the iterator is no longer valid, and non-zero (true) otherwise.

Macro Definition Documentation

◆ obuf_putiter

#define obuf_putiter (   OBUF,
  ITER 
)    obuf_write(OBUF,(ITER)->startptr,(ITER)->len)

Output the current striter substring to an obuf.

Referenced by path_match().

◆ str_catiter

#define str_catiter (   STR,
  ITER 
)    str_catb(STR,(ITER)->startptr,(ITER)->len)

Append the current striter substring to a str.

◆ str_copyiter

#define str_copyiter (   STR,
  ITER 
)    str_copyb(STR,(ITER)->startptr,(ITER)->len)

Assign the current striter substring to a str.

◆ striter_loop

#define striter_loop (   ITER,
  STR,
  SEP 
)    for(striter_start(ITER,STR,SEP);striter_valid(ITER);striter_advance(ITER))

Loop macro; use in place of for(...)

Referenced by dns_read_resolvconf(), and envstr_find().

Function Documentation

◆ striter_advance()

int striter_advance ( striter iter)

Advance a striter to the next substring.

References len, str::len, str::s, sep, start, startptr, str, and str_findnext().

Referenced by envstr_make_array(), and path_match().

◆ striter_start()

void striter_start ( striter iter,
const struct str s,
char  sep 
)

Start (initialize) a striter.

References len, str::s, start, startptr, and str.

Referenced by envstr_make_array(), and path_match().

◆ striter_valid()

int striter_valid ( striter iter)

Determine if a striter is valid (after initialization or advancing).

References str::len, start, and str.

Referenced by envstr_make_array(), and path_match().