RInside Version 0.2.16
Main Page
+
Classes
Class List
+
Class Members
+
All
a
b
g
i
m
o
p
r
s
v
x
~
Functions
Variables
+
Files
File List
+
File Members
All
Functions
Variables
Macros
•
All
Classes
Files
Functions
Variables
Macros
MemBuf.cpp
Go to the documentation of this file.
1
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2
//
3
// MemBuf.cpp: R/C++ interface class library -- Easier R embedding into C++
4
//
5
// Copyright (C) 2009 Dirk Eddelbuettel
6
// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
7
//
8
// This file is part of RInside.
9
//
10
// RInside is free software: you can redistribute it and/or modify it
11
// under the terms of the GNU General Public License as published by
12
// the Free Software Foundation, either version 2 of the License, or
13
// (at your option) any later version.
14
//
15
// RInside is distributed in the hope that it will be useful, but
16
// WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU General Public License for more details.
19
//
20
// You should have received a copy of the GNU General Public License
21
// along with RInside. If not, see <http://www.gnu.org/licenses/>.
22
23
#include <iostream>
24
#include <cstdlib>
25
#include <string>
26
27
#include <
MemBuf.h
>
28
29
extern
bool
verbose
;
30
extern
const
char
*
programName
;
31
32
MemBuf::~MemBuf
() {}
33
34
MemBuf::MemBuf
(
int
sizebytes) :
buffer
() {
35
buffer
.reserve(sizebytes) ;
36
}
37
38
void
MemBuf::resize
() {
// Use power of 2 resizing
39
buffer
.reserve( 2*
buffer
.capacity() ) ;
40
}
41
42
void
MemBuf::rewind
(){
43
buffer
.clear() ;
44
}
45
46
void
MemBuf::add
(
const
std::string& buf){
47
int
buflen = buf.size() ;
48
while
( ( buflen +
buffer
.size() ) >=
buffer
.capacity() ) {
49
resize
();
50
}
51
buffer
+= buf ;
52
}
53
MemBuf::~MemBuf
~MemBuf()
Definition:
MemBuf.cpp:32
MemBuf::rewind
void rewind()
Definition:
MemBuf.cpp:42
MemBuf::buffer
std::string buffer
Definition:
MemBuf.h:25
MemBuf::MemBuf
MemBuf(int sizebytes=1024)
Definition:
MemBuf.cpp:34
MemBuf::add
void add(const std::string &)
Definition:
MemBuf.cpp:46
MemBuf.h
verbose
bool verbose
MemBuf::resize
void resize()
Definition:
MemBuf.cpp:38
programName
const char * programName
Definition:
RInside.cpp:32
src
MemBuf.cpp
Generated on Wed Mar 11 2020 22:33:48 for RInside Version 0.2.16 by
1.8.13