File: parse_primitives.cc

package info (click to toggle)
vowpal-wabbit 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 20,200 kB
  • sloc: cpp: 6,724; perl: 449; makefile: 71; sh: 57
file content (29 lines) | stat: -rw-r--r-- 602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
Copyright (c) 2009 Yahoo! Inc.  All rights reserved.  The copyrights
embodied in the content of this file are licensed under the BSD
(revised) open source license
 */

#include "parse_primitives.h"

void tokenize(char delim, substring s, v_array<substring>& ret)
{
  ret.erase();
  char *last = s.begin;
  for (; s.begin != s.end; s.begin++) {
    if (*s.begin == delim) {
      if (s.begin != last)
	{
	  substring temp = {last,s.begin};
	  push(ret, temp);
	}
      last = s.begin+1;
    }
  }
  if (s.begin != last)
    {
      substring final = {last, s.begin};
      push(ret, final);
    }
}