Tutorial

Vstr is a string library designed to work easily and efficiently in network applications. This means that it is designed to perform IO operations in a non-blocking fashion, and allow the programer to take data from various places and join them in an IO operation without having to do any copies.

Often IO primitives are assumed to be blocking (Ie. all possible data will be done before IO operation completes). This does make "Hello World" type applications somewhat simpler, however networked applications have different requirements. However, don't be detered functions will be introduced for those simple applications to make them more readable.

Also note that all error checking is included in every example, it may make the examples somewhat easier to read if it wasn't included ... however including error checking is what the code must look like in a real application.

Simplest Hello World

Here is about the most simple Vstr application, this is a single function that prints "Hello World" on a single line in a POSIX environment...

/* hello world - Self contained, using a single piece of data at
 *               initialisation time (no data copying) */ 

#define VSTR_COMPILE_INCLUDE 1
#include <vstr.h>
#include <errno.h>  /* errno variable */
#include <err.h>    /* BSD/Linux header see: man errx */
#include <unistd.h> /* for STDOUT_FILENO */

int main(void)
{
  Vstr_base *s1 = NULL;

  if (!vstr_init()) /* initialize the library */
    err(EXIT_FAILURE, "init");

  /* create a string with data */
  if (!(s1 = vstr_dup_cstr_buf(NULL, "Hello World\n")))
    err(EXIT_FAILURE, "Create string");

  /* output the data to the user -- assumes POSIX */
  while (s1->len)
    if (!vstr_sc_write_fd(s1, 1, s1->len, STDOUT_FILENO, NULL))
    {
      if ((errno != EAGAIN) && (errno != EINTR))
        err(EXIT_FAILURE, "write");
    }

  /* cleanup allocated resources */
  vstr_free_base(s1);

  vstr_exit();

  exit (EXIT_SUCCESS);
}

...however this example is somewhat too simplistic because, normally, a Vstr string contains multiple nodes of informtion that are treated internally as a single entity.

Hello World Header

So first we'll clean up the above example to move all the header inclusion into one file and create some helper functions to simplify the actually "hello world" code. Here's a quick overview of the functions moved into the header file...

/* *****************************************************************************
   Beg of hello_world.h header file which will be used in the following examples
   ****************************************************************************/
#ifndef HELLO_WORLD_H
#define HELLO_WORLD_H

/* ************************************************************************** */
/* headers: Vstr (and all supporting system headers), plus extra ones we need */
/* ************************************************************************** */

#define VSTR_COMPILE_INCLUDE 1 /* make Vstr include it's system headers */
#include <vstr.h>
#include <errno.h>
#include <err.h> /* BSD/Linux header see: man errx */
#include <unistd.h> /* for STDOUT_FILENO */

/* ********************************* */
/* generic POSIX IO helper functions */
/* ********************************* */

#define IO_OK    0
/* the missing values will be explained later in the tutorial... */
#define IO_NONE  3

static int io_put(Vstr_base *io_w, int fd)
{ /* assumes POSIX */
  if (!io_w->len)
    return (IO_NONE);
  
  if (!vstr_sc_write_fd(io_w, 1, io_w->len, fd, NULL))
  {
    if (errno != EINTR)
      err(EXIT_FAILURE, "write");
  }

  return (IO_OK);
}

/* ************************ */
/* generic helper functions */
/* ************************ */

/* hello world init function, init library and create a string */
static Vstr_base *hw_init(void)
{
  Vstr_base *s1 = NULL;

  if (!vstr_init())
    errno = ENOMEM, err(EXIT_FAILURE, "init");

  if (!(s1 = vstr_make_base(NULL))) /* create an empty string */
    errno = ENOMEM, err(EXIT_FAILURE, "Create string");

  return (s1);
}

/* hello world exit function, cleanup what was allocated in hw_init() */
static int hw_exit(Vstr_base *s1)
{
  vstr_free_base(s1);

  vstr_exit();

  return (EXIT_SUCCESS);
}

#endif
/* *****************************************************************************
   End of hello_world.h header file which will be used in the following examples
   ****************************************************************************/

Simple Hello World, using the helper functions

Now using the above header file, we can re-write the initial example in a much more readable form...

/* hello world - Using a single piece of data (no data copying) */

#include "ex_hello_world.h" /* helper functions */

int main(void)
{
  Vstr_base *s1 = hw_init();

  vstr_add_cstr_buf(s1, s1->len, "Hello World\n");

  if (s1->conf->malloc_bad)
    errno = ENOMEM, err(EXIT_FAILURE, "Add string data");

  while (io_put(s1, STDOUT_FILENO) != IO_NONE) {}

  exit (hw_exit(s1));
}

Hello World, using multiple sources of data

We can now alter the above to still print "Hello World" on a line, but have the data come from multiple sources which is then stored internally in mutliple nodes (remember there is no copying of data still). However can treat this all as a single string from our point of view. Although this example is obviously contrived, this is much more representative of what a networked application looks like...

/* hello world - multiple sources of data (still no data copying) */

#include "ex_hello_world.h" /* helper functions */

int main(void)
{
  Vstr_base *s1 = hw_init();

  vstr_add_cstr_ptr(s1, s1->len, "Hello");
  vstr_add_cstr_ptr(s1, s1->len, " ");
  vstr_add_cstr_ptr(s1, s1->len, "World\n");

  /* we are checking whether any of the above three functions failed here */
  if (s1->conf->malloc_bad)
    errno = ENOMEM, err(EXIT_FAILURE, "Add string data");

  /* loop until all data is output... */
  while (io_put(s1, STDOUT_FILENO) != IO_NONE) {}

  exit (hw_exit(s1));
}

Complicated Hello World

This is the final Hello World example, this is the first one that actually copies some of the data for the string. It also shows how you can add data at any point in the string, and substitute data within the string. Note that when giving the position to add data to the string you give the position before the position you wish the start of the data to be at, and when giving the position/length for a section (or sub-string) the position given is included within the section.

For people familiar with C++ this works out to be the same way that C++ std::string encodes positions for adding data (Ie. insert()), but not for getting sections (C++ often explains it as having a 0 index'd string and data is added before the point given, Vstr does uses a 1 poition for the first byte as that means that appending data is always done at the current length ... and a position of 0 can be used as invalid for searching etc.).

Description of operationPositionLegnth
Prepend data to X0 (Zero)N/A
Append data to XX->len (Length of Vstr string)N/A
Last byteX->len (Length of Vstr string)1 (One)
First byte1 (One)1 (One)
Entire Vstr string1 (One)X->len (Length of Vstr string)
All of X, but the first and last bytes2 (Two)X->len - 2 (Length of Vstr string minus Two)
/* hello world - multiple pieces of data, includes substitution and
 *               inserting data into the middle of a string */

#include "ex_hello_world.h" /* helper functions */

int main(void)
{
  Vstr_base *s1 = hw_init();
  Vstr_ref *ref = NULL;

  vstr_add_cstr_ptr(s1, s1->len, "Hello");

  vstr_add_rep_chr(s1, s1->len, 'W', 5); /* add "WWWWWW" */

  if (s1->conf->malloc_bad)
    errno = ENOMEM, err(EXIT_FAILURE, "Add string data");

  /* substitute an 'o' for a 'W' */
  if (!vstr_sub_rep_chr(s1, strlen("HelloWW"), 1, 'o', 1))
    errno = ENOMEM, err(EXIT_FAILURE, "Substitute string data");

  /* substitute "WWW" for a "rld\n" -- */
  if (!vstr_sub_cstr_buf(s1, strlen("HelloWoW"), strlen("WWW"), "rld\n"))
    errno = ENOMEM, err(EXIT_FAILURE, "Substitute string data");

  if (!(ref = vstr_ref_make_ptr((char *)"XYZ ", vstr_ref_cb_free_ref)))
    errno = ENOMEM, err(EXIT_FAILURE, "Create data reference");
  /* now ref->ptr is "XYZ " */

  /* add space after "Hello", by skipping "XYZ" in reference */
  vstr_add_ref(s1, strlen("Hello"), ref, strlen("XYZ"), strlen(" "));

  vstr_ref_del(ref); /* delete our reference to the Vstr_ref */

  if (s1->conf->malloc_bad)
    errno = ENOMEM, err(EXIT_FAILURE, "Add string data");

  while (io_put(s1, STDOUT_FILENO) != IO_NONE) {}

  exit (hw_exit(s1));
}

IO header file

This is a full header file needed to do simple non-blocking IO operations, it also puts into functions the common init and exit sections. This will be used by all of the following examples. The Simple GETOPT implementation isn't used for a while, so you can ignore that for now. A quick overview of the changes from the hello_world.h header file are...

And a quick review of the additions...

#ifndef EX_UTILS_H
#define EX_UTILS_H 1

/* ************************************************************************** */
/* headers: Vstr (and all supporting system headers), plus extra ones we need */
/* ************************************************************************** */

#define VSTR_COMPILE_INCLUDE 1 /* make Vstr include it's system headers */
#include <vstr.h>

#include <errno.h>

#include <err.h> /* BSD/Linux header see: man errx */

#include <sys/poll.h>

#include <sys/types.h> /* stat + open + STDXXX_FILENO */
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#include <string.h> /* strncmp() etc. in GETOPT macros */

/* **************************************************************** */
/* defines: TRUE/FALSE and assert(), Note that GETOPT is used later */
/* **************************************************************** */

#ifndef FALSE
# define FALSE 0
#endif

#ifndef TRUE
# define TRUE 1
#endif

/* Simple getopt code... */
#define EX_UTILS_GETOPT_NUM(name, var) \
    else if (!strncmp("--" name, argv[count], strlen("--" name))) \
    { \
      if (!strncmp("--" name "=", argv[count], strlen("--" name "="))) \
        (var) = strtol(argv[count] + strlen("--" name "="), NULL, 0); \
      else \
      { \
        (var) = 0; \
        \
        ++count; \
        if (count >= argc) \
          break; \
        \
        (var) = strtol(argv[count], NULL, 0); \
      } \
    } \
    else if (0) ASSERT(FALSE)

#define EX_UTILS_GETOPT_CSTR(name, var) \
    else if (!strncmp("--" name, argv[count], strlen("--" name))) \
    { \
      if (!strncmp("--" name "=", argv[count], strlen("--" name "="))) \
        (var) = argv[count] + strlen("--" name "="); \
      else \
      { \
        (var) = NULL; \
        \
        ++count; \
        if (count >= argc) \
          break; \
        \
        (var) = argv[count]; \
      } \
    } \
    else if (0) ASSERT(FALSE)



#define assert(x) do { if (x) {} else errx(EXIT_FAILURE, "Assert=\"" #x "\""); } while (FALSE)
#define ASSERT(x) do { if (x) {} else errx(EXIT_FAILURE, "Assert=\"" #x "\""); } while (FALSE)



/* ********************************* */
/* generic POSIX IO helper functions */
/* ********************************* */

/* limits on amount of data we keep in core -- can be overridden */
/* Note that EX_UTILS_NO_USE_INPUT should be defined if Input IO isn't needed */
#ifndef EX_MAX_R_DATA_INCORE
#define EX_MAX_R_DATA_INCORE (8 * 1024)
#endif
#ifndef EX_MAX_W_DATA_INCORE
#define EX_MAX_W_DATA_INCORE (8 * 1024)
#endif

#define IO_OK    0
#define IO_BLOCK 1
#define IO_EOF   2
#define IO_NONE  3

/* block waiting for IO read, write or both... */
static void io_block(int io_r_fd, int io_w_fd)
{
  struct pollfd ios_beg[2];
  struct pollfd *ios = ios_beg;
  unsigned int num = 0;
  
  ios[0].revents = ios[1].revents = 0;
  
  if (io_r_fd == io_w_fd)
  { /* block on both read and write, same fds */
    num = 1;
    ios[0].events = POLLIN | POLLOUT;
    ios[0].fd     = io_w_fd;
  }
  else
  { /* block on read or write or both */
    if (io_r_fd != -1)
    {
      ios->events = POLLIN;
      ios->fd     = io_r_fd;
      ++num; ++ios;
    }
    if (io_w_fd != -1)
    {
      ios->events = POLLOUT;
      ios->fd     = io_w_fd;
      ++num; ++ios;
    }
  }
  
  while (poll(ios_beg, num, -1) == -1) /* can't timeout */
  {
    if (errno != EINTR)
      err(EXIT_FAILURE, "poll");
  }
}

/* Try and move some data from Vstr string to fd */
static int io_put(Vstr_base *io_w, int fd)
{
  if (!io_w->len)
    return (IO_NONE);

  if (!vstr_sc_write_fd(io_w, 1, io_w->len, fd, NULL))
  {
    if (errno == EAGAIN)
      return (IO_BLOCK);
    
    if (errno != EINTR)
      err(EXIT_FAILURE, "write");
  }

  return (IO_OK);
}

/* loop outputting data, blocking when needed */
static void io_put_all(Vstr_base *io_w, int fd)
{
  int state = IO_NONE;

  while ((state = io_put(io_w, fd)) != IO_NONE)
  {
    if (state == IO_BLOCK)
      io_block(-1, fd);
  }
}
    
#ifndef EX_UTILS_NO_USE_INPUT
/* Try and move some data from fd to Vstr string */
static int io_get(Vstr_base *io_r, int fd)
{
  if (io_r->len < EX_MAX_R_DATA_INCORE)
  {
    unsigned int ern = 0;

    vstr_sc_read_iov_fd(io_r, io_r->len, fd, 8, 16, &ern);
    
    if (ern == VSTR_TYPE_SC_READ_FD_ERR_EOF)
      return (IO_EOF);
    else if ((ern == VSTR_TYPE_SC_READ_FD_ERR_READ_ERRNO) && (errno == EAGAIN))
      return (IO_BLOCK);
    else if ((ern == VSTR_TYPE_SC_READ_FD_ERR_READ_ERRNO) && (errno == EINTR))
      return (IO_OK); /* ignore this */
    else if (ern)
      err(EXIT_FAILURE, "read");
  }

  return (IO_OK);
}

/* block read or writting, depending on limits */
static void io_limit(int io_r_state, int io_r_fd,
                     int io_w_state, int io_w_fd, Vstr_base *s_w)
{
  if (io_w_state == IO_BLOCK) /* allow 16k to build up */
  {
    if (io_r_state == IO_BLOCK) /* block to either get or put some data */
      io_block(io_r_fd, io_w_fd);
    else if (s_w->len > EX_MAX_W_DATA_INCORE)
      io_block(-1, io_w_fd); /* block to put more data */
  }
  else if ((io_w_state == IO_NONE) && (io_r_state == IO_BLOCK))
    io_block(io_r_fd, -1); /* block to get more data */
}
#endif

/* generic POSIX IO functions that _don't_ call Vstr functions */

static int io_fd_set_o_nonblock(int fd)
{
  int flags = 0;

  /* see if the NONBLOCK flag is set... */
  if ((flags = fcntl(fd, F_GETFL)) == -1)
    return (FALSE);

  /* if it isn't try and add it to the current flags */
  if (!(flags & O_NONBLOCK) &&
      (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1))
    return (FALSE);

  return (TRUE);
}

#ifndef VSTR_AUTOCONF_HAVE_OPEN64
# define open64 open
#endif
static int io_open(const char *filename)
{
  int fd = open64(filename, O_RDONLY | O_NOCTTY);

  if (fd == -1)
    err(EXIT_FAILURE, "open(%s)", filename);

  /* When doing IO, it should always be non-blocking */
  io_fd_set_o_nonblock(fd);

  return (fd);
}

/* ********************************* */
/* generic helper functions */
/* ********************************* */

/* Example init function */
static Vstr_base *ex_init(Vstr_base **s2)
{
  Vstr_base *s1 = NULL;
  struct stat stat_buf;

  if (!vstr_init()) /* init the library */
    errno = ENOMEM, err(EXIT_FAILURE, "init");

  
  /* alter the node buffer size to be whatever the stdout block size is */
  if (fstat(1, &stat_buf) == -1)
    warn("fstat(STDOUT)");
  else
  {
    if (!stat_buf.st_blksize) /* this is allowed to be Zero */
      stat_buf.st_blksize = 4096;

    if (!vstr_cntl_conf(NULL, VSTR_CNTL_CONF_SET_NUM_BUF_SZ,
                        stat_buf.st_blksize / 8))
      warnx("Couldn't alter node size to match block size");
  }

  /* create strings... */  
  if (!(s1 = vstr_make_base(NULL)) ||
      (s2 && !(*s2 = vstr_make_base(NULL))))
    errno = ENOMEM, err(EXIT_FAILURE, "Create string");

  /* create some data storage for _both_ of the above strings */
  vstr_make_spare_nodes(NULL, VSTR_TYPE_NODE_BUF, 32);
  
  /* Try and make stdout non-blocking, if it is a file this won't do anything */
  io_fd_set_o_nonblock(STDOUT_FILENO);

  return (s1);
}

/* Example exit function */
static int ex_exit(Vstr_base *s1, Vstr_base *s2)
{
  /* These next calls are only really needed for debugging,
   * in that when they are done any memory leaks can be seen in debugging mode.
   */

  /* As with the system free() both of these are ok if passed NULL */
  
  /* free s1, our String object */
  vstr_free_base(s1);
  /* free s2, our String object */
  vstr_free_base(s2);

  /* "exit" Vstr, this free's all internal data and no library calls apart from
   * vstr_init() should be called after this.
   */
  vstr_exit();

  return (EXIT_SUCCESS);
}

#endif

Unix cat command

This is the unix cat command, implemented with the help of the functions in the above ex_utils.h header file. This uses the same Vstr string for both input and output and uses non-blocking IO, both of which are done for efficiency.

If you have seen something like the "simple" cat in LAD this version looks much bigger. However one of the main reasons for this is that the LAD version has many bugs. The main problem is the lack of checking on the IO calls, this is most easily demonstrated by running it like so...

perl -e 'use Fcntl; fcntl(STDIN, F_SETFL, O_NONBLOCK); exec(@ARGV);' ./cat

...will cause the LAD version to exit immediatley due to an EAGAIN being returned from read. This problem also affects the LAD version being used in a blocking pipe due to the fact that write() isn't required to write() all it's data.

The LAD version also doesn't open() any files, which is significant functionality. So after fixing those bugs we get something that is much closer to the Vstr version and it still suffers from performance problems due to the need to block on input and output separately. It is possible to create a version using read, write and poll that would perform the same as the Vstr version ... however even the simplest method would have to implement it's own ring buffer which is very prone to error and would almost certainly make it bigger than ex_cat.c and ex_utils.h combined.

/* This is a _simple_ cat program, no command line options. And no use of mmap.
 * Reads from stdin if no args are given.
 *
 * This file is more commented than normal code, so as to make it easy to follow
 * while knowing almost nothing about Vstr or Linux IO programming.
 */
#include "ex_utils.h"

/*  Keep reading on the file descriptor until there is no more data (ERR_EOF)
 * abort if there is an error reading or writing */
static void ex_cat_read_fd_write_stdout(Vstr_base *s1, int fd)
{
  while (TRUE)
  {
    int io_w_state = IO_OK;
    int io_r_state = io_get(s1, fd);

    if (io_r_state == IO_EOF)
      break;
    
    io_w_state = io_put(s1, 1);

    io_limit(io_r_state, fd, io_w_state, 1, s1);    
  }
}

int main(int argc, char *argv[])
{ /* This is "cat", without any command line options */
  
  Vstr_base *s1 = ex_init(NULL); /* init the library etc. */
  int count = 1; /* skip the program name */

  /* if no arguments are given just do stdin to stdout */
  if (count >= argc)
  {
    io_fd_set_o_nonblock(STDIN_FILENO);
    ex_cat_read_fd_write_stdout(s1, STDIN_FILENO);
  }

  
  /* loop through all arguments, open the file specified
   * and do the read/write loop */
  while (count < argc)
  {
    int fd = io_open(argv[count]);

    ex_cat_read_fd_write_stdout(s1, fd);

    if (close(fd) == -1)
      warn("close(%s)", argv[count]);

    ++count;
  }

  /* output all remaining data */
  io_put_all(s1, STDOUT_FILENO);

  exit (ex_exit(s1, NULL));
}

Unix nl command

This si somewhat like the "nl" unix command, this is implemented in much the same way as the cat command. However the data has to have something added to the start of each line before it can be output, so we now have two string objects: One for iunput and one for output. Note that as the data is "moved" from the input to the output, it isn't copied instead a reference is created and shared between the two strings.

/* Unix nl command -- no arguments */
#include "ex_utils.h"

static int ex_nl_process(Vstr_base *s1, Vstr_base *s2, int last)
{
  static unsigned int count = 0;
  size_t pos = 0;

  /* we don't want to create more data, if we are over our limit */
  if (s1->len > EX_MAX_W_DATA_INCORE)
    return (FALSE);

  if (!s2->len)
    return (TRUE);

  while ((pos = vstr_srch_chr_fwd(s2, 1, s2->len, '\n')))
  {
    vstr_add_fmt(s1, s1->len, "% 6d\t", ++count);

    /* The flag turns _BUF nodes into sharable _REF nodes */
    vstr_add_vstr(s1, s1->len, s2, 1, pos, VSTR_TYPE_ADD_BUF_REF);
    vstr_del(s2, 1, pos);
    
    if (s1->len > EX_MAX_W_DATA_INCORE)
      return (TRUE);
  }

  if (s2->len && last)
  {
    vstr_add_fmt(s1, s1->len, "% 6d\t", ++count);
    if (s2->len)
      vstr_mov(s1, s1->len, s2, 1, s2->len);
    vstr_add_cstr_buf(s1, s1->len, "\n");
  }

  return (TRUE);
}
#endif

/* files are merged */
static void ex_nl_read_fd_write_stdout(Vstr_base *s1, Vstr_base *s2, int fd)
{
  while (TRUE)
  {
    int io_w_state = IO_OK;
    int io_r_state = io_get(s2, fd);

    if (io_r_state == IO_EOF)
      break;

    ex_nl_process(s1, s2, FALSE);

    io_w_state = io_put(s1, 1);

    io_limit(io_r_state, fd, io_w_state, 1, s1);
  }
}

static void ex_nl_process_limit(Vstr_base *s1, Vstr_base *s2, unsigned int lim)
{
  while (s2->len > lim)
  {
    int proc_data = ex_nl_process(s1, s2, !lim);
    if (!proc_data && (io_put(s1, STDOUT_FILENO) == IO_BLOCK))
      io_block(-1, STDOUT_FILENO);
  }
}


int main(int argc, char *argv[])
{
  Vstr_base *s2 = NULL;
  Vstr_base *s1 = ex_init(&s2);
  int count = 1;

  /* if no arguments are given just do stdin to stdout */
  if (count >= argc)
  {
    io_fd_set_o_nonblock(STDIN_FILENO);
    ex_nl_read_fd_write_stdout(s1, s2, STDIN_FILENO);
  }

  /* loop through all arguments, open the file specified
   * and do the read/write loop */
  while (count < argc)
  {
    unsigned int ern = 0;

    if (s2->len <= EX_MAX_R_DATA_INCORE)
      vstr_sc_mmap_file(s2, s2->len, argv[count], 0, 0, &ern);

    if ((ern == VSTR_TYPE_SC_MMAP_FILE_ERR_FSTAT_ERRNO) ||
        (ern == VSTR_TYPE_SC_MMAP_FILE_ERR_MMAP_ERRNO) ||
        (ern == VSTR_TYPE_SC_MMAP_FILE_ERR_TOO_LARGE))
    {
      int fd = io_open(argv[count]);

      ex_nl_read_fd_write_stdout(s1, s2, fd);

      if (close(fd) == -1)
        warn("close(%s)", argv[count]);
    }
    else if (ern && (ern != VSTR_TYPE_SC_MMAP_FILE_ERR_CLOSE_ERRNO))
      err(EXIT_FAILURE, "add");
    else
      ex_nl_process_limit(s1, s2, EX_MAX_R_DATA_INCORE);
    
    ++count;
  }

  ex_nl_process_limit(s1, s2, 0);

  io_put_all(s1, STDOUT_FILENO);

  exit (ex_exit(s1, s2));
}

Convertion table for C functions to Vstr functions

This is a mapping from std. C functions operating on C-style strings to Vstr string functions...

Common C string functionsVstr string functions
memcpyvstr_add_buf
memmovevstr_add_vstr
memmovevstr_sub_vstr
memmovevstr_mov
strcpyvstr_add_cstr_buf
strncpyvstr_add_cstr_buf
strcatvstr_add_cstr_buf
strncatvstr_add_cstr_buf
memcmpvstr_cmp_buf
strcmpvstr_cmp_cstr_buf
strcmpvstr_cmp
strncmpvstr_cmp_buf
strncmpvstr_cmp
strcasecmpvstr_cmp_case_cstr_buf
strcasecmpvstr_cmp_case
strncasecmpvstr_cmp_case_buf
strncasecmpvstr_cmp_case
strncmpvstr_cmp_cstr_buf
strcollN/A
strxfrmN/A
memchrvstr_srch_chr_fwd
strchrvstr_srch_chr_fwd
strnchrvstr_srch_chr_fwd
strrchrvstr_srch_chr_rev
strtokvstr_split_chrs
memsetvstr_add_rep_chr
memmemvstr_srch_buf_fwd
strstrvstr_srch_cstr_buf_fwd
strspnvstr_spn_chrs_buf_fwd
strcspnvstr_cspn_chrs_buf_fwd
sprintfvstr_add_sysfmt
strlen->len (member variable, also always passed to functions)

Convertion table for C++ std::string functions to Vstr functions

This is a mapping from C++ std::string functions to Vstr string functions...

Common C++ string functionsVstr string functions
appendvstr_add_buf
appendvstr_add_rep_chr
appendvstr_add_vstr
insertvstr_add_buf
insertvstr_add_rep_chr
insertvstr_add_vstr
replacevstr_sub_buf
replacevstr_sub_rep_chr
replacevstr_sub_vstr
substrFundamental part of Vstr
findvstr_srch_cstr_buf_fwd
findvstr_srch_buf_fwd
findvstr_srch_chr_fwd
findvstr_srch_vstr_fwd
find_first_ofvstr_srch_cstr_chrs_fwd
find_last_ofvstr_srch_cstr_chrs_rev
find_first_not_ofvstr_csrch_cstr_chrs_fwd
find_last_not_ofvstr_csrch_cstr_chrs_rev
rfindvstr_srch_cstr_buf_rev
rfindvstr_srch_buf_rev
rfindvstr_srch_chr_rev
rfindvstr_srch_vstr_rev
erasevstr_del
resizevstr_sc_reduce
comparevstr_cmp
comparevstr_cmp_cstr
swapvstr_mov
==vstr_cmp_eq
==vstr_cmp_cstr_eq
c_strvstr_export_cstr_ptr
datavstr_export_cstr_ref
reservevstr_make_spare_nodes
assignvstr_sub_vstr
copyvstr_export_cstr_buf
copyvstr_export_cstr_ptr
copyvstr_export_cstr_malloc
copyvstr_dup_vstr
length->len (member variable, also always passed to functions)

James Antill
Last modified: Mon Sep 22 20:55:20 EDT 2003