obstring Public Interface  
More...
#include "offbrand.h"
#include "obvector.h"
#include <regex.h>
 
Go to the source code of this file.
obstring Public Interface 
- Author
 - theck
 
 
      
        
          | char obstring_char_at_index  | 
          ( | 
          const obstring *  | 
          s,  | 
        
        
           | 
           | 
          int64_t  | 
          i  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
returns the character at the specified index 
- Parameters
 - 
  
    | s | A pointer to an instance of obstring  | 
    | i | An integer denoting a characters position in the string. Negative integers are accepted, with -1 indicating the final non-NUL character in the string | 
  
   
- Returns
 - The character at the index within the string, '\0' if the character is out of bounds 
 
 
 
concatenates the two obstring instances into a new instance of obstring 
- Parameters
 - 
  
    | s1 | A pointer to an instance of obstring  | 
    | s2 | A pointer to an instance of obstring | 
  
   
- Returns
 - A pointer to an new instance of obstring that contains string s1+s2 
 
 
 
      
        
          | obstring* obstring_copy_substring  | 
          ( | 
          const obstring *  | 
          s,  | 
        
        
           | 
           | 
          int64_t  | 
          start,  | 
        
        
           | 
           | 
          uint32_t  | 
          length  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Copies a sequence of characters from an obstring to create a new instance of obstring. 
- Parameters
 - 
  
    | s | A pointer to an instance of obstring  | 
    | start | An integer denoting the position of the start of the sequence to copy within the string, character at position start included. Negative integers are accepted, with -1 indicating the final non-NUL character in the string  | 
    | length | An integer denoting the length of the string to be copied | 
  
   
- Returns
 - An instance of obstring containing the seqence of characters selected from the provided obstring
 
- Warning
 - If start and length combine to specify a range beyond the string bounds then any extension beyond the bounds will return only existing characters in the range, an empty string if none exist 
 
 
 
      
        
          | const char* obstring_cstring  | 
          ( | 
          const obstring *  | 
          s) |  | 
           | 
        
      
 
Gets the C string representation of an obstring instance. 
- Parameters
 - 
  
    | s | A pointer to an instance of obstring | 
  
   
- Returns
 - A C string containing the same sequence of characters as the obstring instance
 
- Warning
 - The returned pointer is directed at an internal C string that should not be altered, a new obstring should be created if an alteration is desired 
 
 
 
      
        
          | uint8_t obstring_find_substring  | 
          ( | 
          const obstring *  | 
          s,  | 
        
        
           | 
           | 
          const char *  | 
          to_find  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Searches for an substring in an obstring. 
- Parameters
 - 
  
    | s | A pointer to an instance of obstring to be searched  | 
    | to_find | A NUL terminated C string containing the sequence of characters to find | 
  
   
- Return values
 - 
  
    | 0 | The substring was not found in the search string  | 
    | non-zero | The substring was found in the search string | 
  
   
- Warning
 - Function does not attempt to verify that delim is in fact NUL terminated 
 
 
 
      
        
          | uint32_t obstring_length  | 
          ( | 
          const obstring *  | 
          s) |  | 
           | 
        
      
 
Gets the length of an obstring. 
- Parameters
 - 
  
    | s | A pointer to an instance of obstring | 
  
   
- Returns
 - Integer length of the obstring instance 
 
 
 
Finds the pattern matching an expression in an obstring. 
- Parameters
 - 
  
    | s | A pointer to and instance of obstring to be searched  | 
    | regex | A pointer to an instance of obstring containing the expression to attempt to match | 
  
   
- Returns
 - An obstring containing the first matching sequence in the obstring
 
The POSIX Extended Regular Expression syntax is used to interpret the provided expression
- Warning
 - Function does not attempt to verify that delim is in fact NUL terminated 
 
 
 
      
        
          | obstring* obstring_new  | 
          ( | 
          const char *  | 
          str) |  | 
           | 
        
      
 
Creates a new obstring with the string of characters. 
- Parameters
 - 
  
    | str | A NUL terminated C string | 
  
   
- Returns
 - An instance of obstring encapsulating the given C string
 
The provided C string is not stored directly in an instance of obstring and so can be modified and free'd without affecting the created obstring.
- Warning
 - Constructor assumes that the input string NUL terminated with finite length, any C strings passed to the constructor should be known to meet these constraints 
 
 
 
Tokenizes an obstring over a character sequence. 
- Parameters
 - 
  
    | s | A pointer to an instance of obstring to be tokenized  | 
    | delim | A NUL terminated C string indicating the character or sequence of characters on which to break a string | 
  
   
- Returns
 - An obvector containing the resulting obstrings derived from splitting the original on the delimeter string
 
A multicharacter obstring will not cause the the original string to be split on each character, but rather the original string will be split on complete instances of delim.
- Warning
 - Function does not attempt to verify that delim is in fact NUL terminated