From bc0864e2d3bea3aed4700660feb5de577b94b89b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 23 Aug 2016 18:25:52 -0400 Subject: [PATCH] add new test stringstyle() for identify variable styles that return stored strings directly --- src/variable.cpp | 13 +++++++++++++ src/variable.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/variable.cpp b/src/variable.cpp index 05c55ec7c6..37e47465cb 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -804,6 +804,19 @@ int Variable::internalstyle(int ivar) return 0; } +/* ---------------------------------------------------------------------- + return 1 if variable is INDEX or WORLD or STRING or SCALARFILE, 0 if not + this is used to discriminate between variables that return a pointer to + the stored string and others that do evaluations or return numbers. +------------------------------------------------------------------------- */ + +int Variable::stringstyle(int ivar) +{ + if (style[ivar] == INDEX || style[ivar] == WORLD + || style[ivar] == STRING || style[ivar] == SCALARFILE) return 1; + return 0; +} + /* ---------------------------------------------------------------------- return ptr to the data text associated with a variable if INDEX or WORLD or UNIVERSE or STRING or SCALARFILE, diff --git a/src/variable.h b/src/variable.h index c24706430d..a54b4d01d5 100644 --- a/src/variable.h +++ b/src/variable.h @@ -38,6 +38,7 @@ class Variable : protected Pointers { int vectorstyle(int); char *pythonstyle(char *, char *); int internalstyle(int); + int stringstyle(int); char *retrieve(char *); double compute_equal(int);