CXXR (C++ R)
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
current-release
src
include
CXXR
IntVector.h
Go to the documentation of this file.
1
/*CXXR $Id: IntVector.h 1351 2013-03-08 15:12:28Z arr $
2
*CXXR
3
*CXXR This file is part of CXXR, a project to refactor the R interpreter
4
*CXXR into C++. It may consist in whole or in part of program code and
5
*CXXR documentation taken from the R project itself, incorporated into
6
*CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7
*CXXR Licence.
8
*CXXR
9
*CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10
*CXXR copyrights and copyright restrictions as may be stated below.
11
*CXXR
12
*CXXR CXXR is not part of the R project, and bugs and other issues should
13
*CXXR not be reported via r-bugs or other R project channels; instead refer
14
*CXXR to the CXXR website.
15
*CXXR */
16
17
/*
18
* R : A Computer Language for Statistical Data Analysis
19
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
20
* Copyright (C) 1999-2006 The R Development Core Team.
21
* Andrew Runnalls (C) 2008
22
*
23
* This program is free software; you can redistribute it and/or modify
24
* it under the terms of the GNU General Public License as published by
25
* the Free Software Foundation; either version 2.1 of the License, or
26
* (at your option) any later version.
27
*
28
* This program is distributed in the hope that it will be useful,
29
* but WITHOUT ANY WARRANTY; without even the implied warranty of
30
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
* GNU Lesser General Public License for more details.
32
*
33
* You should have received a copy of the GNU General Public License
34
* along with this program; if not, a copy is available at
35
* http://www.r-project.org/Licenses/
36
*/
37
42
#ifndef INTVECTOR_H
43
#define INTVECTOR_H
44
45
#include "
CXXR/VectorBase.h
"
46
47
#ifdef __cplusplus
48
49
#include "R_ext/Arith.h"
50
#include "
CXXR/FixedVector.hpp
"
51
#include "
CXXR/SEXP_downcast.hpp
"
52
53
#ifndef USE_TYPE_CHECKING_STRICT
54
#include "
CXXR/LogicalVector.h
"
55
#endif
56
57
namespace
CXXR {
58
// Template specializations:
59
namespace
ElementTraits {
60
template
<>
61
struct
NAFunc<int> {
62
const
int
&
operator()
()
const
63
{
64
static
int
na = NA_INTEGER;
65
return
na;
66
}
67
};
68
}
69
70
template
<>
71
inline
const
char
*
FixedVector<int, INTSXP>::staticTypeName
()
72
{
73
return
"integer"
;
74
}
75
78
typedef
FixedVector<int, INTSXP>
IntVector
;
79
}
// namespace CXXR
80
81
BOOST_CLASS_EXPORT_KEY(
CXXR::IntVector
)
82
83
extern "C" {
84
#endif
/* __cplusplus */
85
94
#ifndef __cplusplus
95
int
*
INTEGER
(
SEXP
x);
96
#else
97
inline
int
*
INTEGER
(
SEXP
x)
98
{
99
using namespace
CXXR;
100
#ifndef USE_TYPE_CHECKING_STRICT
101
// Quicker than dynamic_cast:
102
if
(x && x->
sexptype
() ==
LGLSXP
) {
103
LogicalVector
* lvec =
static_cast<
LogicalVector
*
>
(x);
104
return
&(*lvec)[0];
105
}
106
#endif
107
return
&(*SEXP_downcast<IntVector*>(x,
false
))[0];
108
}
109
#endif
110
111
#ifdef __cplusplus
112
}
113
#endif
114
115
#endif
/* INTVECTOR_H */
Generated by
1.8.1