From c029d90d1975e124d237605f1edb2be16bd05b5d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 28 Feb 2017 21:50:44 +0100 Subject: Initial commit --- src/character.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/character.cc (limited to 'src/character.cc') diff --git a/src/character.cc b/src/character.cc new file mode 100644 index 0000000..98166ee --- /dev/null +++ b/src/character.cc @@ -0,0 +1,31 @@ +// -*- mode: c++; c-basic-offset: 2; -*- + +#include "common.hh" + +#include "character.hh" + +// static +bool Character::isspace(std::string const& str, size_t pos) { + switch (str[pos]) { + case ' ': + case '\t': + case '\r': + case '\n': + return true; + } + return false; +} + +// static +bool Character::isseparator(std::string const& str, size_t pos) { + if (isspace(str, pos)) return true; + switch (str[pos]) { + case '.': + case ':': + case '-': + case ',': + case ';': + return true; + } + return false; +} -- cgit v1.2.3-70-g09d2