Example #1
0
File: var.cpp Project: hyln9/nV
bool var::ahead::operator()(const var& x, const var& y) const {
    long r = x.primary() - y.primary();
    if (r)
        return r < 0;
    switch (x.primary()) {
    case Primary::Object: {
        r = reinterpret_cast<long>(x.object().type) - reinterpret_cast<long>(y.object().type);
        if (r)
            return r < 0;
        return x.object().compare(y.object()) < 0;
    }
    case Primary::Key:  {
        r = x.key().kind() - y.key().kind();
        if (r)
            return r < 0;
        return x.key().key < y.key().key;
    }
    case Primary::Symbol:
        return x.ptr < y.ptr;
    case Primary::Tuple: {
        r = x.tuple().size - y.tuple().size;
        if (r)
            return r < 0;
        for (uint i = 0; i < x.tuple().size; ++i)
            if ((*this)(x.tuple()[i], y.tuple()[i]))
                return true;
    }
    return false;
    }
    return 0;
}
Example #2
0
void MQwt::axes(var iXLabel, var iYLabel)
{
    mPlot->setAxisTitle(QwtPlot::xBottom, iXLabel.str());
    mPlot->setAxisTitle(QwtPlot::yLeft, iYLabel.str());
}
Example #3
0
    /**
     * The inverse hyperbolic tangent function for variables (C99).
     *
     * The derivative is defined by
     *
     * \f$\frac{d}{dx} \mbox{atanh}(x) = \frac{1}{1 - x^2}\f$.
     *
       \f[
       \mbox{atanh}(x) =
       \begin{cases}
         \textrm{NaN} & \mbox{if } x < -1\\
         \tanh^{-1}(x) & \mbox{if } -1\leq x \leq 1 \\
         \textrm{NaN} & \mbox{if } x > 1\\[6pt]
         \textrm{NaN} & \mbox{if } x = \textrm{NaN}
       \end{cases}
       \f]

       \f[
       \frac{\partial\, \mbox{atanh}(x)}{\partial x} =
       \begin{cases}
         \textrm{NaN} & \mbox{if } x < -1\\
         \frac{\partial\, \tanh^{-1}(x)}{\partial x} & \mbox{if } -1\leq x\leq 1 \\
         \textrm{NaN} & \mbox{if } x > 1\\[6pt]
         \textrm{NaN} & \mbox{if } x = \textrm{NaN}
       \end{cases}
       \f]

       \f[
       \tanh^{-1}(x)=\frac{1}{2}\ln\left(\frac{1+x}{1-x}\right)
       \f]

       \f[
       \frac{\partial \, \tanh^{-1}(x)}{\partial x} = \frac{1}{1-x^2}
       \f]
       *
       * @param a The variable.
       * @return Inverse hyperbolic tangent of the variable.
       * @throw std::domain_error if a < -1 or a > 1
       */
    inline var atanh(const var& a) {
      return var(new atanh_vari(atanh(a.val()), a.vi_));
    }
Example #4
0
 /**
  * Equality operator comparing a variable's value and a double
  * (C++).
  *
  * @param a First variable.  
  * @param b Second value.
  * @return True if the first variable's value is the same as the
  * second value.
  */
 inline bool operator==(const var& a, const double b) {
   return a.val() == b;
 }
inline static std::string convertVar(const var& val)
{
    const std::type_info* x = &val.GetType();


    if (*x == typeid(int)) {

        /*64Bit*/
        char  str[24];
#ifndef _SAFE_C
        sprintf(str, "%d", val.var_cast<int>());
#else
        sprintf_s(str, "%d", val.var_cast<int>());
#endif

        return std::string(str);
    }

    else if (*x == typeid(double)) {


        char  str[40];
#ifndef _SAFE_C
        sprintf(str, "%.8lf", val.var_cast<double>());
#else
        sprintf_s(str, "%.8lf", val.var_cast<double>());
#endif
        return std::string(str);
    }

    else if(*x == typeid(unsigned int)) {

        /*64Bit*/
        char  str[24];
#ifndef _SAFE_C
        sprintf(str, "0x%x", val.var_cast<unsigned int>());
#else
        sprintf_s(str, "0x%x", val.var_cast<unsigned int>());
#endif
        return std::string(str);
    }

    else if (*x == typeid(std::string)) {
        std::string str = '\"' + val.var_cast<std::string>() + '\"';
        return str;
    }

    else if (*x == typeid(bool)) {
        if (val.var_cast<bool>())
            return std::string("true");
        else
            return std::string("false");
    }

    else if (*x == typeid(char)) {
        char str[2] = { 0 };
        str[0] = val.var_cast<char>();
        return std::string(str);
    }

    else if (*x == typeid(unsigned char)) {
        char str[2] = { 0 };
        str[0] = val.var_cast<unsigned char>();
        return std::string(str);
    }

    else if (*x == typeid(float)) {
        char  str[32];
#ifndef _SAFE_C
        sprintf(str, "%.6f", val.var_cast<unsigned int>());
#else
        sprintf_s(str, "%.6f", val.var_cast<unsigned int>());
#endif
        return std::string(str);
    }

    else if(*x == typeid(short)) {

        char  str[8];
#ifndef _SAFE_C
        sprintf(str, "%d", val.var_cast<short>());
#else
        sprintf_s(str, "%d", val.var_cast<short>());
#endif
        return std::string(str);
    }

    else if (*x==typeid(unsigned short)) {

        char  str[8];
#ifndef _SAFE_C
        sprintf(str, "%d", val.var_cast<unsigned short>());
#else
        sprintf_s(str, "%d", val.var_cast<unsigned short>());
#endif
        return std::string(str);
    }

    else {
        /* Warning */
#ifdef _DEBUG
        Except("数据类型有误!");
#endif
    }
    /* Bug */
    return NULL;
}
bool operator== (const var& v1, const String& v2)           { return v1.toString() == v2; }
Example #7
0
 void stan_print(std::ostream* o, const var& x) {
   *o << x.val();
 }
Example #8
0
function main(in mode0) {

	//WHATSNEW returns in ANS
	ANS="";

	var mode=mode0;

	var keywords = "MEDIA" _VM_ "JOBS" _VM_ "FINANCE" _VM_ "TIMESHEETS" _VM_ "TECHNICAL" _VM_ "USER INTERFACE";

	var nkeywords = keywords.count(VM) + 1;

	if (not(openfile("CHANGELOG", changelog))) {
		call fsmsg();
		return 0;
	}
	if (not(openfile("DICT_CHANGELOG", DICT))) {
		call fsmsg();
		return 0;
	}

	if (mode.a(1) == "SELECTANDLIST") {

		//call changelog.subs('SELECT':fm:data)
		gosub select0(mode);
		if (not LISTACTIVE) {
			call mssg("Error: No records found");
			return 0;
		}

		//call changelog.subs('LIST':fm:data)
		gosub list(mode);

	//returns outputfilename in ANS
	} else if (mode.a(1) == "WHATSNEW") {

		var menucodes = mode.a(2);
		mode = mode.a(1);
		ANS = "";

		var users;
		if (not(users.open("USERS", ""))) {
			return 0;
		}

		var userrec;
		if (userrec.read(users, USERNAME)) {

			//backward compatible ... can be deleted after all upgraded
			//leave in case reloading ancient data
			if (not userrec.a(17)) {
				var changelogkey = "USER*" ^ USERNAME;
				if (changelog.read(DEFINITIONS, changelogkey)) {
					userrec.r(17, changelog.a(8));
					(userrec.a(17)).writev(users, USERNAME, 17);
					var("").writev(DEFINITIONS, changelogkey, 8);
				}
			}

			//mode<2>=changelog<7>
			mode.r(3, userrec.a(17));

			//fix a problem where people were missing most changes
			//due to sv being represented as : eg user:support:technical
			if (mode.a(3) and mode.a(3) < 14773) {
				mode.r(3, 14153);
			}

		}else{

			//show everything the first time they logon
			//mode<3>=iconv('1/1/2004','D/E')

			//show nothing the very first time they logon
			ANS = "";
			return 0;

		}

		//get last upgradedate

		var temp = var(".\\GENERAL\\VERSION.DAT").xlate("DOS", 1, "X");
		var lastupgradedatetime = (temp.trim().field(" ", 2, 999)).iconv("D");
		lastupgradedatetime ^= "." ^ ((temp.trim().field(" ", 1)).iconv("MT")).oconv("R(0)#5");

		//nothing to see if seen after lastupgradedate
		if (mode.a(3) >= lastupgradedatetime) {
			ANS = "";
			return 0;
		}

		lastupgradedatetime.writev(users, USERNAME, 17);

		//build preferences from menus if not specified
		if (not mode.a(2)) {

			//tt=capitalise(menucodes)
			//swap 'Support' with 'Technical' in tt
			//mode<2>=tt
			if (menucodes.index("FINANCE", 1)) {
				mode.r(2, -1, "Finance");
			}
			if (menucodes.index("MEDIA", 1)) {
				mode.r(2, -1, "Media");
			}
			if (menucodes.index("JOBS", 1)) {
				mode.r(2, -1, "Jobs");
			}
			if (menucodes.index("TIMESHEETS", 1)) {
				mode.r(2, -1, "Timesheets");
			}
			if (menucodes.index("SUPPORT", 1)) {
				mode.r(2, -1, "Technical");
			}

			//everybody gets User Interface changes
			mode.r(2, -1, "User Interface");

			//if no preferences then no whats new
			//if mode<2> else
			// @ans=''
			// return 0
			// end

		}

		//indicate need to select whats new preferences (by numeric whatsnew)
		//if mode<2> else
		// if lastupgradedate else lastupgradedate='0'
		// @ans=lastupgradedate
		// return 0
		// end

		//find and new items else quit
		gosub select(mode);
		if (not LISTACTIVE) {
			ANS = "";
			return 0;
		}

		//make a suitable output filename based on the responsefilename
		temp = PRIORITYINT.a(100);
		temp.splicer(-1, 1, "HTM");
		SYSTEM.r(2, temp);

		//get new items in new filename and return the filename in @ans
		gosub list(mode);
		ANS = SYSTEM.a(2);

	} else if (mode == "GETUPGRADEDATES") {
		gosub getupgradedates();

	} else if (mode.a(1) == "SELECT") {
		gosub select0(mode);

	} else if (mode.a(1) == "LIST") {
		gosub list(mode);

	}

	return 0;

}
Example #9
0
 static Colour getColourFromVar (const var& col)
 {
     return col.isString() ? Colour::fromString (col.toString())
                           : Colours::transparentBlack;
 }
bool enigma_user::is_array(const var& v)
{
  //There is no way (currently) to downsize an array from >1 element, so this might not be accurate.
  return (v.array_height() > 1) || (v.array_len() > 1);
}
void FilterAudioProcessor::setState(const var & state)
{
	frequency->setValue(state.getProperty("frequency", frequency->getDefaultValue()));
	resonance->setValue(state.getProperty("resonance", resonance->getDefaultValue()));
	setFilterType(state.getProperty("filterType", 0));
}
int enigma_user::array_height_2d(const var& v)
{
  return v.array_height();
}
int enigma_user::array_length_2d(const var& v, int n)
{
  return v.array_len(n);
}
int enigma_user::array_length_1d(const var& v)
{
  return v.array_len();
}
Example #15
0
 /**
  * Returns 1 if the input's value is infinite and 0 otherwise.
  *
  * Delegates to <code>is_inf</code>.
  *
  * @param v Value to test.
  *
  * @return <code>1</code> if the value is infinite and <code>0</code> otherwise.
  */
 inline int is_inf(const var& v) {
   return is_inf(v.val());
 }
Example #16
0
 static float getOpacityFromVar (const var& v)
 {
     return v.isVoid() ? 1.0f : static_cast<float> (v);
 }
Example #17
0
bool operator!= (const var& v1, const var& v2) noexcept     { return ! v1.equals (v2); }
Example #18
0
function main(in mode, in subject0, in body0, in groupids0, in jobids0, in userids0, in options, io emaillog) {

	//options
	//R = REPLYTO=@username email address if exists
	//W = Groups by Word eg user with dept MEDIA BUYING matches group MEDIA

	var interactive = not SYSTEM.a(33);

	if (false) print(jobids0);//evade compiler warning on unused argument

	if (mode.field(" ", 1) eq "UPGRADE") {

		var subject = "NEOSYS Upgrade: " ^ SYSTEM.a(23);
		if (SYSTEM.a(17) ne SYSTEM.a(23)) {
			subject ^= " (" ^ SYSTEM.a(17) ^ ")";
		}
		var version = mode.field(" ", 2);
		subject ^= version;

		var body = "";
		body ^= "The NEOSYS system software has been upgraded.";
		body ^= VM;
		body ^= VM ^ "Before you login to NEOSYS, please follow the instructions at";
		body ^= VM ^ "http://userwiki.neosys.com/index.php/cache to avoid errors using NEOSYS.";
		body ^= VM;
		body ^= VM ^ "Please email [email protected] for any assistance.";
		//body:=vm
		//body:=vm:'This is an automated email. You cannot reply to it.'
		body.converter(VM, var().chr(13));

		call emailusers(mode, subject, body, "", "", "", "R", emaillog);

		if (not emaillog) {
			emaillog = "(nobody)";
		}
		emaillog = "Upgrade Notification emailed to:" ^ VM ^ emaillog;
		emaillog.swapper(VM, var().chr(13));

		call sysmsg(emaillog, "Upgrade to version " ^ version);

		return 0;

	} else if (mode ne "") {
		var msg = DQ ^ (mode ^ DQ) ^ " is invalid in EMAILUSERS";
		if (interactive) {
			call mssg(msg);
		}else{
			call sysmsg(msg);
		}
		return 1;
	}

//init:

	//if target and options='' or index(options,'U',1) then
	// end
	var groupword = options.index("W", 1);
	nsent = 0;

	var subject = subject0;
	var body = body0;

	//read fromuser from users,@username else fromuser=''
	var replyto = "";
	if (options.index("R", 1)) {
		if (USERNAME == "NEOSYS" or USERNAME == "ADAGENCY" or USERNAME == "ACCOUNTS") {
			replyto = "*****@*****.**";
		}else{
			var fromuser = USERNAME.xlate("USERS", "", "X");
			replyto = fromuser.a(7);
			var fromline = "From " ^ fromuser.a(1);
			if (USERNAME ne fromuser.a(1)) {
				fromline ^= " (" ^ USERNAME ^ ")";
			}
			subject.splicer(1, 0, fromline ^ " : ");
		}
	}

	var usercodes = SECURITY.a(1);
	var nusers = usercodes.count(VM) + 1;
	var usern = 0;
	emaillog = "";
	var alreadyemailed = "";
	body.converter(FM ^ VM, var().chr(13) ^ var().chr(13));

	var groupids = groupids0;
	groupids.converter(",", VM);
	var ngroups = groupids.count(VM) + 1;

	var userids = userids0;
	userids.converter(",", VM);

	toemails = "";
	ccemails = "";

	var currdept = "";

	var users;
	if (not(users.open("USERS", ""))) {
		call fsmsg();
		return 0;
	}

	for (usern=1; usern<=nusers;++usern) {

		//interrupt
		if (esctoexit()) {
			break;
		}

		//skip empty users
		var usercode = usercodes.a(1, usern);
		if (usercode == "") {
			continue;
		}

		//only users on file
		var USER;
		if (not(USER.read(users, usercode))) {
			continue;
		}

		//not expired users
		var expirydate = USER.a(35);
		if (expirydate and expirydate <= var().date()) {
			continue;
		}

		//skip users with no email at all
		//users may have 0 or more email addresses eg [email protected];[email protected] etc
		var emails = USER.a(7);
		if (emails == "") {
			continue;
		}

		//always email to self last
		if (usercode == USERNAME and replyto) {
			continue;
		}

		var ok = 0;
		if (not ok and userids) {
			if (userids.locate(usercode, xx, 1)) {
				ok = 1;
			}
			if (not ok and not groupids) {
				continue;
			}
		}

		//skip users not of required type (eg FINANCE is ok in FINANCE CONTROLLER)
		//could determine user type from what menus they can access eg MEDIA
		if (not ok and groupids) {
			if (groupword) {
				//eq search for MEDIA in user department like MEDIA BUYER
				for (var groupn = 1; groupn <= ngroups; ++groupn) {
					ok = (USER.a(5)).index(groupids.a(1, groupn), 1);

					if (not(not ok))
						break;;
				};//groupn;
			}else{
				//exact groups
				if (groupids.locate(USER.a(21), xx, 1)) {
					ok = 1;
				}
			}
			if (not ok) {
				continue;
			}
		}

		//must be last to avoid adding emails to sent list unless actually sent
		//remove any emails that have already been emailed before
		emails.converter(" ", "");
		emails.converter(";", VM);
		var nn = emails.count(VM) + (emails ne "");
		for (var ii = nn; ii >= 1; --ii) {
			var email = emails.a(1, ii);
			if (alreadyemailed.locateusing(email, VM)) {
				emails.eraser(1, ii);
			}else{
				alreadyemailed ^= VM ^ email;
			}
		};//ii;
		emails.converter(VM, ";");

		//skip users that have already been emailed before
		if (emails == "") {
			continue;
		}

//userinit:

		print(usercode, " ");

		if (currdept and USER.a(5) ne currdept) {
			gosub sendemails(emaillog);
		}
		currdept = USER.a(5);

		if (toemails == "") {
			toemails = emails;

		//sending to users (or groups and users)
		} else if (userids) {
			toemails ^= ";" ^ emails;

		//sending to groups then to the first and cc the rest
		}else{
			ccemails ^= ";" ^ emails;
		}

		emaillog ^= VM ^ usercode ^ " " ^ emails;

	}//usern

//exit:
	gosub sendemails(emaillog);

	//trim trailing . vm and fm
	emaillog.trimmerb("."^VM^FM);

	//always email to self
	if (nsent and replyto) {
		toemails = replyto;
		body ^= VM ^ VM ^ "-- Sent to --" ^ emaillog;
		body.swapper(VM, var().chr(13));
		gosub sendemails(emaillog);
	}

	if (not nsent) {
		emaillog = "";
	}

	//trim trailing . vm and fm
	emaillog.trimmerb("."^VM^FM);

	return 0;

}
Example #19
0
bool operator!= (const var& v1, const char* const v2)       { return v1.toString() != v2; }
Example #20
0
 /**
  * Greater than operator comparing variables' values (C++).
  *
    \f[
    \mbox{operator\textgreater}(x, y) =
    \begin{cases}
      0 & \mbox{if } x \leq y\\
      1 & \mbox{if } x > y \\[6pt]
      0 & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN}
    \end{cases}
    \f]
  *
  * @param a First variable.
  * @param b Second variable.
  * @return True if first variable's value is greater than second's.
  */
 inline bool operator>(const var& a, const var& b) {
   return a.val() > b.val();
 }
Example #21
0
 /**
  * Equality operator comparing two variables' values (C++).
  *
  * @param a First variable.  
  * @param b Second variable. 
  * @return True if the first variable's value is the same as the
  * second's.
  */
 inline bool operator==(const var& a, const var& b) {
   return a.val() == b.val();
 }
Example #22
0
 /**
  * Greater than operator comparing variable's value and double
  * (C++).
  *
  * @param a First variable.
  * @param b Second value.
  * @return True if first variable's value is greater than second value.
  */
 inline bool operator>(const var& a, double b) {
   return a.val() > b;
 }
Example #23
0
 /**
  * Equality operator comparing a scalar and a variable's value
  * (C++).
  *
  * @param a First scalar.
  * @param b Second variable.
  * @return True if the variable's value is equal to the scalar.
  */
 inline bool operator==(const double a, const var& b) {
   return a == b.val();
 }
Example #24
0
 /**
  * Greater than operator comparing a double and a variable's value
  * (C++).
  *
  * @param a First value.
  * @param b Second variable.
  * @return True if first value is greater than second variable's value.
  */
 inline bool operator>(double a, const var& b) {
   return a > b.val();
 }
Example #25
0
void PanAudioProcessor::setState(const var & state)
{
	panning->setValue(state.getProperty("panning", panning->getDefaultValue()));
}
Example #26
0
 bool operator()(const var<Alloc>&   a) const { return a.match(m_pattern, m_binding); }