data_t * _any_or(data_t *self, char *name, arguments_t *args) { data_t *asbool; data_t *data; int boolval; int ix; (void) name; for (ix = -1; ix < arguments_args_size(args); ix++) { data = (ix < 0) ? self : arguments_get_arg(args, ix); asbool = data_cast(data, Bool); if (!asbool) { return data_exception(ErrorSyntax, "or(): Cannot convert value '%s' of type '%s' to boolean", arguments_arg_tostring(args, ix), data_typename(arguments_get_arg(args, ix))); } boolval = data_intval(asbool); data_free(asbool); if (boolval) { return data_true(); } } return data_false(); }
FILE* file_data_loader_start(const std::string& name) { FILE *fh = nullptr; #ifdef _MSC_VER if(fopen_s(&f, name.c_str(), "rb") != 0) { fh = nullptr; } #else fh = fopen(name.c_str(), "rb"); #endif if (fh == nullptr) { throw data_exception(std::string("Could not open file '")+name+"'."); } return fh; }
data_t * _any_not(data_t *self, char *name, arguments_t *args) { data_t *asbool = data_cast(self, Bool); data_t *ret; (void) name; (void) args; if (!asbool) { ret = data_exception(ErrorSyntax, "not(): Cannot convert value '%s' of type '%s' to boolean", data_tostring(self), data_typename(self)); } else { ret = int_as_bool(data_intval(asbool) == 0); data_free(asbool); } return ret; }