cgv
token.h
1
#pragma once
2
3
#include <string>
4
#include <iostream>
5
6
#include "lib_begin.h"
7
8
namespace
cgv
{
9
namespace
utils {
10
15
struct
CGV_API
token
16
{
18
const
char
*
begin
, *end;
20
token
();
22
token
(
const
char
* _str);
24
token
(
const
char
* _b,
const
char
* _e);
26
token
(
const
std::string& s);
28
size_t
get_length()
const
;
30
size_t
size()
const
;
32
bool
empty()
const
;
34
void
skip(
const
std::string& skip_chars);
36
void
reverse_skip(
const
std::string& skip_chars);
38
char
operator [] (
unsigned
int
i)
const
;
40
bool
operator == (
const
char
* s)
const
;
42
bool
operator == (
const
std::string& s)
const
;
44
bool
operator != (
const
char
* s)
const
;
46
bool
operator != (
const
std::string& s)
const
;
47
};
48
50
inline
size_t
token::get_length
()
const
{
return
end-
begin
; }
52
inline
size_t
token::size
()
const
{
return
end-
begin
; }
54
inline
bool
token::empty
()
const
{
return
begin
== end; }
56
inline
char
token::operator []
(
unsigned
int
i)
const
{
return
begin
[i]; }
58
inline
std::string
to_string
(
const
token
& t) {
return
t.
empty
()?std::string():std::string(t.
begin
, t.
get_length
()); }
60
inline
std::ostream& operator << (std::ostream& os,
const
token
& t) {
if
(!t.
empty
()) os << std::string(t.
begin
, t.
get_length
());
return
os; }
61
62
}
63
}
64
65
#include <cgv/config/lib_end.h>
cgv::utils::token::operator[]
char operator[](unsigned int i) const
return the i-th character of the token
Definition:
token.h:56
cgv::utils::token
Definition:
token.h:16
cgv::utils::token::size
size_t size() const
return the length of the token in number of characters
Definition:
token.h:52
cgv::utils::token::empty
bool empty() const
return whether the token is empty
Definition:
token.h:54
cgv::utils::token::get_length
size_t get_length() const
return the length of the token in number of characters
Definition:
token.h:50
cgv::utils::token::begin
const char * begin
pointers that define the range of characters
Definition:
token.h:18
cgv::utils::to_string
std::string to_string(const std::string &v, unsigned int w, unsigned int p)
specialization of conversion from string to strings
Definition:
convert_string.cxx:7
cgv
the cgv namespace
Definition:
vr_calib.cxx:9
projects
git
cgv
cgv
utils
token.h
Generated by
1.8.18