本文整理汇总了C++中GET_LENGTH函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_LENGTH函数的具体用法?C++ GET_LENGTH怎么用?C++ GET_LENGTH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GET_LENGTH函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rsqlite_query_send
SEXP rsqlite_query_send(SEXP handle, SEXP statement, SEXP bind_data) {
SQLiteConnection* con = rsqlite_connection_from_handle(handle);
sqlite3* db_connection = con->drvConnection;
sqlite3_stmt* db_statement = NULL;
int state, bind_count;
int rows = 0, cols = 0;
if (con->resultSet) {
if (con->resultSet->completed != 1)
warning("Closing result set with pending rows");
rsqlite_result_free(con);
}
rsqlite_result_alloc(con);
SQLiteResult* res = con->resultSet;
/* allocate and init a new result set */
res->completed = 0;
char* dyn_statement = RS_DBI_copyString(CHAR(asChar(statement)));
res->statement = dyn_statement;
res->drvResultSet = db_statement;
state = sqlite3_prepare_v2(db_connection, dyn_statement, -1,
&db_statement, NULL);
if (state != SQLITE_OK) {
exec_error(con, "error in statement");
}
if (db_statement == NULL) {
exec_error(con, "nothing to execute");
}
res->drvResultSet = (void*) db_statement;
bind_count = sqlite3_bind_parameter_count(db_statement);
if (bind_count > 0 && bind_data != R_NilValue) {
rows = GET_LENGTH(GET_ROWNAMES(bind_data));
cols = GET_LENGTH(bind_data);
}
res->isSelect = sqlite3_column_count(db_statement) > 0;
res->rowCount = 0; /* fake's cursor's row count */
res->rowsAffected = -1; /* no rows affected */
rsqlite_exception_set(con, state, "OK");
if (res->isSelect) {
if (bind_count > 0) {
select_prepared_query(db_statement, bind_data, bind_count, rows, con);
}
} else {
if (bind_count > 0) {
non_select_prepared_query(db_statement, bind_data, bind_count, rows, con);
} else {
state = sqlite3_step(db_statement);
if (state != SQLITE_DONE) {
exec_error(con, "rsqlite_query_send: could not execute1");
}
}
res->completed = 1;
res->rowsAffected = sqlite3_changes(db_connection);
}
return handle;
}
开发者ID:fmichonneau,项目名称:RSQLite,代码行数:60,代码来源:fetch.c
示例2: R_wxSlider_new
SEXP
R_wxSlider_new(SEXP r_parent, SEXP r_id, SEXP r_value, SEXP r_min, SEXP r_max, SEXP r_pos, SEXP r_size, SEXP r_style)
{
wxWindow *parent;
wxWindowID id;
wxSlider *ans;
SEXP r_ans;
int value, min, max;
long style;
wxPoint pos = wxDefaultPosition;
wxSize size = wxDefaultSize;
parent = (wxWindow *) R_get_wxWidget_Ref(r_parent, NULL);
id = INTEGER(r_id)[0];
value = INTEGER(r_value)[0];
min = INTEGER(r_min)[0];
max = INTEGER(r_max)[0];
style = (long) REAL(r_style)[0];
if(GET_LENGTH(r_pos)) pos = R_to_wxPoint(r_pos);
if(GET_LENGTH(r_size)) size = R_to_wxSize(r_size);
ans = new wxSlider(parent, id, value, min, max, pos, size, style);
r_ans = R_make_wxWidget_Ref(ans, "wxSlider");
return(r_ans);
}
开发者ID:omegahat,项目名称:RwxWidgets,代码行数:30,代码来源:RwxSlider.cpp
示例3: BigSum
void BigSum(BigMatrix *mat, SEXP colIndices, SEXP rowIndices, double *value) {
BMAccessorType m( *mat );
double *cols = NUMERIC_DATA(colIndices);
double *rows = NUMERIC_DATA(rowIndices);
index_type i=0;
index_type j=0;
index_type xj=0;
index_type numCols = GET_LENGTH(colIndices);
index_type numRows = GET_LENGTH(rowIndices);
CType *pColumn;
double s = 0;
for (i = 0; i < numCols; ++i) {
pColumn = m[static_cast<index_type>(cols[i])-1];
for (j = 0; j < numRows; ++j) {
xj = static_cast<index_type>(rows[j])-1;
s += (double)pColumn[xj];
}
}
value[0] = s;
return;
}
开发者ID:czarrar,项目名称:bigextensions,代码行数:27,代码来源:biganalyticsplus.cpp
示例4: geoddist_alongpath
SEXP geoddist_alongpath(SEXP lat, SEXP lon, SEXP a, SEXP f)
{
if (!isReal(lat))
error("latitude must be a numeric (floating-point) vector");
if (!isReal(lon))
error("longitude must be a numeric (floating-point) vector");
SEXP res;
//int n = INTEGER(GET_LENGTH(lat));
//int nlon = INTEGER(GET_LENGTH(lon));
int n = GET_LENGTH(lat);
int nlon = GET_LENGTH(lon);
if (n != nlon)
error("lengths of latitude and longitude vectors must match, but they are %d and %d, respectively", n, nlon);
double *latp = REAL(lat);
double *lonp = REAL(lon);
double *ap = REAL(a);
double *fp = REAL(f);
PROTECT(res = allocVector(REALSXP, n));
double *resp = REAL(res);
double last = 0.0;
resp[0] = ISNA(lonp[0]) ? NA_REAL : 0.0;
for (int i = 0; i < n-1; i++) {
double faz, baz, s;
if (ISNA(latp[i]) || ISNA(lonp[i]) || ISNA(latp[i+1]) || ISNA(lonp[i+1])) {
resp[i+1] = NA_REAL;
last = 0.0; // reset
} else {
geoddist_core(latp+i, lonp+i, latp+i+1, lonp+i+1, ap, fp, &faz, &baz, &s);
resp[i+1] = last + s;
last = resp[i+1];
}
}
UNPROTECT(1);
return(res);
}
开发者ID:AnneMTreasure,项目名称:oce,代码行数:35,代码来源:geod.c
示例5: geoddist
SEXP geoddist(SEXP lat1, SEXP lon1, SEXP lat2, SEXP lon2, SEXP a, SEXP f)
{
if (!isReal(lat1)) error("lat1 must be a numeric (floating-point) vector");
if (!isReal(lon1)) error("lon1 must be a numeric (floating-point) vector");
if (!isReal(lat2)) error("lat2 must be a numeric (floating-point) vector");
if (!isReal(lon2)) error("lon2 must be a numeric (floating-point) vector");
int n = GET_LENGTH(lat1);
if (n != GET_LENGTH(lon1))
error("lengths of lat1 and lon1 must match, but they are %d and %d respectively.", n, GET_LENGTH(lon1));
if (n != GET_LENGTH(lat2))
error("lengths of lat1 and lat2 must match, but they are %d and %d respectively.", n, GET_LENGTH(lat2));
if (n != GET_LENGTH(lon2))
error("lengths of lon1 and lon2 must match, but they are %d and %d respectively.", n, GET_LENGTH(lon2));
double *lat1p = REAL(lat1);
double *lon1p = REAL(lon1);
double *lat2p = REAL(lat2);
double *lon2p = REAL(lon2);
double *ap = REAL(a);
double *fp = REAL(f);
SEXP res;
PROTECT(res = allocVector(REALSXP, n));
double *resp = REAL(res);
for (int i = 0; i < n; i++) {
double faz, baz, s;
geoddist_core(lat1p+i, lon1p+i, lat2p+i, lon2p+i, ap, fp, &faz, &baz, &s);
resp[i] = s;
}
UNPROTECT(1);
return(res);
}
开发者ID:AnneMTreasure,项目名称:oce,代码行数:30,代码来源:geod.c
示例6: m_chain
////////////////////////////////////////////////////////////
// C'tor
RootChainManager::RootChainManager(SEXP treeName, SEXP fileList, bool verbose, bool trace) :
m_chain(0),
m_verbose(verbose),
m_trace(trace)
{
// Check arguments
if ( ! IS_CHARACTER(treeName) ) error("treeName must be a string");
if ( GET_LENGTH(treeName) != 1) error("treeName must have length 1");
if ( ! IS_CHARACTER(fileList) ) error("fileList must be a list of strings");
// Get the tree name
std::string treeNameC = CHAR(STRING_ELT(treeName, 0));
if (m_verbose) REprintf("Will read tree %s\n", treeNameC.c_str());
// Get the list of files to chain
if (m_verbose)
REprintf("There are %d files to add to the chain\n", GET_LENGTH(fileList) );
// Form the chain from the file lists
m_chain = new TChain(treeNameC.c_str());
// Add files
for ( unsigned int i = 0; i < GET_LENGTH(fileList); ++i ) {
std::string fileNameC = CHAR(STRING_ELT(fileList, i) );
if (m_verbose) REprintf("Adding file %s to chain\n", fileNameC.c_str());
m_chain->Add( fileNameC.c_str(), 0 );
}
}
开发者ID:lyonsquark,项目名称:RootTreeToR,代码行数:31,代码来源:rootChainManager.cpp
示例7: DeepCopy
void DeepCopy(BigMatrix *pInMat, BigMatrix *pOutMat, SEXP rowInds, SEXP colInds)
{
in_BMAccessorType inMat( *pInMat );
out_BMAccessorType outMat( *pOutMat );
double *pRows = NUMERIC_DATA(rowInds);
double *pCols = NUMERIC_DATA(colInds);
index_type nRows = GET_LENGTH(rowInds);
index_type nCols = GET_LENGTH(colInds);
if (nRows != pOutMat->nrow())
Rf_error("length of row indices does not equal # of rows in new matrix");
if (nCols != pOutMat->ncol())
Rf_error("length of col indices does not equal # of cols in new matrix");
index_type i = 0;
index_type j = 0;
in_CType *pInColumn;
out_CType *pOutColumn;
for (i = 0; i < nCols; ++i) {
pInColumn = inMat[static_cast<index_type>(pCols[i])-1];
pOutColumn = outMat[i];
for (j = 0; j < nRows; ++j) {
pOutColumn[j] = static_cast<out_CType>(
pInColumn[static_cast<index_type>(pRows[j])-1]);
}
}
return;
}
开发者ID:eddelbuettel,项目名称:bigmemory,代码行数:31,代码来源:deepcopy.cpp
示例8: RGnumeric_setCellComment
USER_OBJECT_
RGnumeric_setCellComment(USER_OBJECT_ scell, USER_OBJECT_ stext, USER_OBJECT_ sauthor)
{
char *text = NULL, *author = NULL;
CellComment *comment;
Cell *cell;
USER_OBJECT_ ans = NULL_USER_OBJECT;
cell = RGnumeric_resolveCellReference(scell);
if(!cell)
PROBLEM "invalid cell reference object"
ERROR;
if(GET_LENGTH(stext))
text = CHAR_DEREF(STRING_ELT(stext, 0));
if(GET_LENGTH(sauthor))
author = CHAR_DEREF(STRING_ELT(sauthor, 0));
comment = cell_has_comment(cell);
if(!comment) {
Sheet *sheet;
sheet = RGnumeric_resolveSheetReference(VECTOR_ELT(scell, 1));
cell_set_comment(sheet, &(cell->pos), (const char*) author, (const char *)text);
} else {
if(text)
cell_comment_text_set(comment, text);
if(author)
cell_comment_author_set(comment, author);
}
return(ans);
}
开发者ID:omegahat,项目名称:Gnumeric,代码行数:33,代码来源:RCell.c
示例9: php_is_r_primitive
static int php_is_r_primitive(SEXP val, SEXPTYPE *type) /* {{{ */
{
int is = 0;
if (GET_LENGTH(GET_DIM(val))) {
return 0;
}
if (GET_LENGTH(GET_CLASS(val))) {
return 0;
}
*type = TYPEOF(val);
switch (*type) {
case REALSXP:
case LGLSXP:
case STRSXP:
case INTSXP:
is = 1;
default:
break;
}
return is;
}
开发者ID:tony2001,项目名称:arrr,代码行数:25,代码来源:arrr.c
示例10: toRPointerWithFinalizer
USER_OBJECT_
toRPointerWithFinalizer(gconstpointer val, const gchar *typeName, RPointerFinalizer finalizer)
{
USER_OBJECT_ ans;
USER_OBJECT_ r_finalizer = NULL_USER_OBJECT;
USER_OBJECT_ klass = NULL, rgtk_class;
int i = 0;
GType type = 0;
if(!val)
return(NULL_USER_OBJECT);
if (finalizer) {
PROTECT(r_finalizer = R_MakeExternalPtr(finalizer, NULL_USER_OBJECT, NULL_USER_OBJECT));
}
PROTECT(ans = R_MakeExternalPtr((gpointer)val, r_finalizer, NULL_USER_OBJECT));
if (finalizer) {
R_RegisterCFinalizer(ans, RGtk_finalizer);
}
if (typeName)
type = g_type_from_name(typeName);
if(type) {
if (G_TYPE_IS_INSTANTIATABLE(type) || G_TYPE_IS_INTERFACE(type))
type = G_TYPE_FROM_INSTANCE(val);
if (G_TYPE_IS_DERIVED(type)) {
setAttrib(ans, install("interfaces"), R_internal_getInterfaces(type));
PROTECT(klass = R_internal_getGTypeAncestors(type));
}
}
if (!klass && typeName) {
PROTECT(klass = asRString(typeName));
}
if (klass) { /* so much trouble just to add "RGtkObject" onto the end */
PROTECT(rgtk_class = NEW_CHARACTER(GET_LENGTH(klass)+1));
for (i = 0; i < GET_LENGTH(klass); i++)
SET_STRING_ELT(rgtk_class, i, STRING_ELT(klass, i));
} else {
PROTECT(rgtk_class = NEW_CHARACTER(1));
}
SET_STRING_ELT(rgtk_class, i, COPY_TO_USER_STRING("RGtkObject"));
SET_CLASS(ans, rgtk_class);
if (g_type_is_a(type, S_TYPE_G_OBJECT)) {
USER_OBJECT_ public_sym = install(".public");
setAttrib(ans, public_sym, findVar(public_sym, S_GOBJECT_GET_ENV(val)));
}
if (klass)
UNPROTECT(1);
if (finalizer)
UNPROTECT(1);
UNPROTECT(2);
return(ans);
}
开发者ID:cran,项目名称:RGtk2.10,代码行数:57,代码来源:conversion.c
示例11: Expect_matrix
SEXP Expect_matrix(SEXP S1, SEXP S, SEXP lambda, SEXP time, SEXP theta0, SEXP theta1, SEXP matdiag){
int nvar, npoints, nprotect=0;
nvar = GET_LENGTH(lambda);
npoints = GET_LENGTH(time);
PROTECT(time = coerceVector(time,REALSXP)); nprotect++;
PROTECT(theta0 = coerceVector(theta0,REALSXP)); nprotect++;
PROTECT(theta1 = coerceVector(theta1,REALSXP)); nprotect++;
// results
SEXP expectation = PROTECT(allocVector(REALSXP,nvar*npoints)); nprotect++;
if(!isComplex(lambda)){
// eigenvectors
PROTECT(S1 = coerceVector(S1,REALSXP)); nprotect++;
PROTECT(S = coerceVector(S,REALSXP)); nprotect++;
// matrix exponential
SEXP matexp = PROTECT(allocVector(REALSXP,nvar*nvar*npoints)); nprotect++;
// Compute the exponential matrix
multi_exp_matrix (&nvar, &npoints, REAL(time), REAL(lambda), REAL(S), REAL(S1), REAL(matexp));
// Compute the expectations
optimum (&nvar, &npoints, REAL(time), REAL(theta0), REAL(theta1), REAL(expectation), REAL(matexp), REAL(matdiag));
// Done.
}else{
double complex *matexp;
// complex eigenvalues & eigenvectors
PROTECT(S1 = coerceVector(S1,CPLXSXP)); nprotect++;
PROTECT(S = coerceVector(S,CPLXSXP)); nprotect++;
// alloc a complex vector in C rather than R structure...
matexp = Calloc(nvar*nvar*npoints,double complex);
// Compute the exponential matrix
multi_exp_matrix_complex (&nvar, &npoints, REAL(time), COMPLEX(lambda), COMPLEX(S), COMPLEX(S1), matexp);
// Compute the expectations
optimum_complex(&nvar, &npoints, REAL(time), REAL(theta0), REAL(theta1), REAL(expectation), matexp, REAL(matdiag));
// Done.
// Free the memory
Free(matexp);
}
UNPROTECT(nprotect);
return expectation;
}
开发者ID:JClavel,项目名称:mvMORPH,代码行数:52,代码来源:time_serie_expectation.c
示例12: Weight_matrix
// Weight matrix
SEXP Weight_matrix(SEXP S1, SEXP S, SEXP lambda, SEXP time, SEXP matdiag){
int nvar, npoints, vdim[2], nprotect = 0;
nvar = GET_LENGTH(lambda);
npoints = GET_LENGTH(time);
SEXP expectation;
vdim[0] = npoints*nvar; vdim[1] = nvar*2;
PROTECT(expectation = makearray(2,vdim)); nprotect++;
if(!isComplex(lambda)){
// eigenvectors
PROTECT(S1 = coerceVector(S1,REALSXP)); nprotect++;
PROTECT(S = coerceVector(S,REALSXP)); nprotect++;
// matrix exponential
SEXP matexp = PROTECT(allocVector(REALSXP,nvar*nvar*npoints)); nprotect++;
// Compute the exponential matrix
multi_exp_matrix (&nvar, &npoints, REAL(time), REAL(lambda), REAL(S), REAL(S1), REAL(matexp));
// Compute the expectations
build_w (&nvar, &npoints, REAL(time), REAL(expectation), REAL(matexp), REAL(matdiag));
// Done.
}else{
double complex *matexp;
// complex eigenvalues & eigenvectors
PROTECT(S1 = coerceVector(S1,CPLXSXP)); nprotect++;
PROTECT(S = coerceVector(S,CPLXSXP)); nprotect++;
// alloc a complex vector in C rather than R structure...
matexp = Calloc(nvar*nvar*npoints,double complex);
// Compute the exponential matrix
multi_exp_matrix_complex (&nvar, &npoints, REAL(time), COMPLEX(lambda), COMPLEX(S), COMPLEX(S1), matexp);
// Compute the expectations
build_w_complex (&nvar, &npoints, REAL(time), REAL(expectation), matexp, REAL(matdiag));
// Done.
// Free the memory
Free(matexp);
}
UNPROTECT(nprotect);
return expectation;
}
开发者ID:JClavel,项目名称:mvMORPH,代码行数:51,代码来源:time_serie_expectation.c
示例13: RS_PerlUndef
USER_OBJECT_
RS_PerlUndef(USER_OBJECT_ ids, USER_OBJECT_ types, USER_OBJECT_ interpreter)
{
int n, nt;
int i,j;
const char *id;
int count;
USER_OBJECT_ ans;
n = GET_LENGTH(ids);
nt = GET_LENGTH(types);
PROTECT(ans = NEW_LIST(n));
for(i = 0; i < n; i++) {
id = CHAR_DEREF(STRING_ELT(ids, i));
count = 0;
for(j = 0; i < nt; i++) {
if(LOGICAL_DATA(types)[i] == TRUE) {
count++;
switch(i) {
case PERL_SCALAR:
break;
case PERL_ARRAY:
break;
case PERL_HASH:
break;
case PERL_SUB:
break;
default:
break;
} /* switch() */
} /* end of if LOGICAL_DATA() */
} /* type loop */
if(count == 0) {
/* Was a composite identifier such as $x{'y'} so have to handle it specially. */
}
} /* ids loop */
UNPROTECT(1);
return(ans);
}
开发者ID:sboehringer,项目名称:RSPerl,代码行数:49,代码来源:RPerlVars.c
示例14: do_getEntityHandler
static xmlEntityPtr
do_getEntityHandler(void *userData, const xmlChar *name, const char * r_funName)
{
SEXP opArgs, r_ans;
xmlEntityPtr ans = NULL;
RS_XMLParserData *parserData = (RS_XMLParserData*) userData;
DECL_ENCODING_FROM_EVENT_PARSER(parserData)
PROTECT(opArgs = NEW_LIST(1)) ;
SET_VECTOR_ELT(opArgs, 0, ScalarString(ENC_COPY_TO_USER_STRING(name))); /*XXX should we encode this? Done now! */
r_ans = RS_XML(callUserFunction)(r_funName, NULL, (RS_XMLParserData *) userData, opArgs);
PROTECT(r_ans) ;
if(r_ans != NULL_USER_OBJECT && GET_LENGTH(r_ans) > 0) {
if(TYPEOF(r_ans) == STRSXP) {
const char *value;
value = CHAR_DEREF(STRING_ELT(r_ans, 0));
ans = (xmlEntityPtr) malloc(sizeof(xmlEntity));
memset(ans, 0, sizeof(xmlEntity));
ans->type = XML_ENTITY_DECL;
ans->etype = XML_INTERNAL_GENERAL_ENTITY;
ans->name = xmlStrdup(name);
ans->orig = NULL; // xmlStrdup(CHAR_TO_XMLCHAR(value));
ans->content = xmlStrdup(CHAR_TO_XMLCHAR(value));
ans->length = strlen(value);
#ifndef NO_CHECKED_ENTITY_FIELD
ans->checked = 1;
#endif
}
}
UNPROTECT(2);
return(ans);
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:34,代码来源:XMLEventParse.c
示例15: isInEventList
/////////////////////////
// Return a logical vector if entries are in the event list
SEXP isInEventList(SEXP eventList, SEXP entryNums)
{
TEventList* el = checkForEventListWrapper(eventList);
SEXP l;
PROTECT(l = NEW_LOGICAL( GET_LENGTH(entryNums) ) );
for ( unsigned int i = 0; i < GET_LENGTH(entryNums); ++i ) {
LOGICAL(l)[i] = el->Contains( INTEGER(entryNums)[i] ) == 1;
}
UNPROTECT(1);
return l;
}
开发者ID:Homer-Wolfe,项目名称:RootTreeToR,代码行数:18,代码来源:eventListWrapper.cpp
示例16: R_isInstanceOf
Rboolean
R_isInstanceOf(USER_OBJECT_ obj, const char *klass)
{
USER_OBJECT_ klasses;
int n, i;
SEXP e, r_ans;
Rboolean ans;
klasses = GET_CLASS(obj);
n = GET_LENGTH(klasses);
for(i = 0; i < n ; i++) {
if(strcmp(CHAR_DEREF(STRING_ELT(klasses, i)), klass) == 0)
return(TRUE);
}
PROTECT(e = allocVector(LANGSXP, 3));
SETCAR(e, Rf_install("is"));
SETCAR(CDR(e), obj);
SETCAR(CDR(CDR(e)), mkString(klass));
r_ans = Rf_eval(e, R_GlobalEnv);
ans = LOGICAL(r_ans)[0];
UNPROTECT(1);
return(ans);
}
开发者ID:beanumber,项目名称:Sxslt,代码行数:28,代码来源:Rsupport.c
示例17: asCFlag
guint
asCFlag(USER_OBJECT_ s_flag, GType ftype)
{
GFlagsClass* fclass = g_type_class_ref(ftype);
guint flags = 0;
if (IS_INTEGER(s_flag) || IS_NUMERIC(s_flag)) {
if (asCNumeric(s_flag) > fclass->mask) {
PROBLEM "The flags value %f is too high", asCNumeric(s_flag)
ERROR;
}
flags = asCNumeric(s_flag);
} else {
int i;
for (i = 0; i < GET_LENGTH(s_flag); i++) {
const gchar *fname = CHAR_DEREF(STRING_ELT(s_flag, i));
/*Rprintf("Searching for flag value %s\n", fname);*/
GFlagsValue *fvalue = g_flags_get_value_by_name(fclass, fname);
if (!fvalue)
fvalue = g_flags_get_value_by_nick(fclass, fname);
if (!fvalue && atoi(fname) <= fclass->mask) {
flags |= atoi(fname);
continue;
}
if (!fvalue) {
PROBLEM "Could not find flag by name %s", fname
ERROR;
}
/*Rprintf("Found: %d\n", fvalue->value);*/
flags |= fvalue->value;
}
}
return(flags);
}
开发者ID:cran,项目名称:RGtk2.10,代码行数:35,代码来源:conversion.c
示例18: C_TRACE
// KErrBadDescriptor, if message length too small
// KErrUnderFlow, if message length too big.
// KErrCouldNotConnect, if receiver object is out of scope.
TInt DISICLTransceiver::ValidateISIMessage(
TDes8& aMessage
)
{
C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage 0x%x>" ), &aMessage ) );
const TUint16 descLength( aMessage.Length() );
TInt msgOk( KErrNone );
msgOk = ( ISI_HEADER_OFFSET_MESSAGEID >= descLength ) ? KErrBadDescriptor : msgOk;
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
// Get ISI message length after known that the descriptor is big enough.
const TUint8* msgPtr( aMessage.Ptr() );
const TUint16 isiMsgLength( GET_LENGTH( msgPtr ) + PN_HEADER_SIZE );
// If the descriptor length is less than ISI message length.
msgOk = ( ( msgOk == KErrNone && isiMsgLength > descLength ) ? KErrUnderflow : msgOk );
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
// If the ISI message length is bigger that the largest supported.
msgOk = ( ( msgOk == KErrNone && isiMsgLength > KMaxISIMsgSize ) ? KErrUnderflow : msgOk );
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
// If the ISI message length with PN_HEADER_SIZE is less or equal than ISI_HEADER_OFFSET_MESSAGEID.
msgOk = ( ( msgOk == KErrNone && isiMsgLength <= ISI_HEADER_OFFSET_MESSAGEID ) ? KErrUnderflow : msgOk );
TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk );
TRACE_ASSERT_INFO( msgOk == KErrNone, isiMsgLength );
TRACE_ASSERT_INFO( msgOk == KErrNone, descLength );
C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage %d<" ), msgOk ) );
return msgOk;
}
开发者ID:wannaphongcom,项目名称:symbian-incubation-projects.fcl-modemadaptation,代码行数:30,代码来源:isicltransceiver.cpp
示例19: convertNodeSetToR
#include "RS_XML.h"
#include <libxml/xpath.h>
#include "Utils.h"
static SEXP
convertNodeSetToR(xmlNodeSetPtr obj, SEXP fun, int encoding, SEXP manageMemory)
{
SEXP ans, expr = NULL, arg = NULL, ref;
int i;
if(!obj)
return(NULL_USER_OBJECT);
PROTECT(ans = NEW_LIST(obj->nodeNr));
if(GET_LENGTH(fun) && (TYPEOF(fun) == CLOSXP || TYPEOF(fun) == BUILTINSXP)) {
PROTECT(expr = allocVector(LANGSXP, 2));
SETCAR(expr, fun);
arg = CDR(expr);
} else if(TYPEOF(fun) == LANGSXP) {
expr = fun;
arg = CDR(expr);
}
for(i = 0; i < obj->nodeNr; i++) {
xmlNodePtr el;
el = obj->nodeTab[i];
if(el->type == XML_ATTRIBUTE_NODE) {
#if 0
PROTECT(ref = mkString((el->children && el->children->content) ? XMLCHAR_TO_CHAR(el->children->content) : ""));
SET_NAMES(ref, mkString(el->name));
#else
PROTECT(ref = ScalarString(mkCharCE((el->children && el->children->content) ? XMLCHAR_TO_CHAR(el->children->content) : "", encoding)));
SET_NAMES(ref, ScalarString(mkCharCE(el->name, encoding)));
#endif
SET_CLASS(ref, mkString("XMLAttributeValue"));
UNPROTECT(1);
} else if(el->type == XML_NAMESPACE_DECL)
ref = R_createXMLNsRef((xmlNsPtr) el);
else
ref = R_createXMLNodeRef(el, manageMemory);
if(expr) {
PROTECT(ref);
SETCAR(arg, ref);
PROTECT(ref = Rf_eval(expr, R_GlobalEnv)); /*XXX do we want to catch errors here? Maybe to release the namespaces. */
SET_VECTOR_ELT(ans, i, ref);
UNPROTECT(2);
} else
SET_VECTOR_ELT(ans, i, ref);
}
if(expr) {
if(TYPEOF(fun) == CLOSXP || TYPEOF(fun) == BUILTINSXP)
UNPROTECT(1);
} else
SET_CLASS(ans, mkString("XMLNodeSet"));
UNPROTECT(1);
return(ans);
}
SEXP
convertXPathObjectToR(xmlXPathObjectPtr obj, SEXP fun, int encoding, SEXP manageMemory)
{
SEXP ans = NULL_USER_OBJECT;
switch(obj->type) {
case XPATH_NODESET:
ans = convertNodeSetToR(obj->nodesetval, fun, encoding, manageMemory);
break;
case XPATH_BOOLEAN:
ans = ScalarLogical(obj->boolval);
break;
case XPATH_NUMBER:
ans = ScalarReal(obj->floatval);
if(xmlXPathIsInf(obj->floatval))
REAL(ans)[0] = xmlXPathIsInf(obj->floatval) < 0 ? R_NegInf : R_PosInf;
else if(xmlXPathIsNaN(obj->floatval))
REAL(ans)[0] = NA_REAL;
break;
case XPATH_STRING:
ans = mkString(XMLCHAR_TO_CHAR(obj->stringval)); //XXX encoding
break;
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
case XPATH_USERS:
PROBLEM "currently unsupported xmlXPathObject type %d in convertXPathObjectToR. Please send mail to maintainer.", obj->type
WARN
default:
ans = R_NilValue;
}
return(ans);
}
//.........这里部分代码省略.........
开发者ID:jetaber,项目名称:XML,代码行数:101,代码来源:xpath.c
示例20: asCNumeric
double
asCNumeric(USER_OBJECT_ s_num)
{
if (GET_LENGTH(s_num) == 0)
return(0);
return(NUMERIC_DATA(s_num)[0]);
}
开发者ID:cran,项目名称:rggobi,代码行数:7,代码来源:conversion.c
注:本文中的GET_LENGTH函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论