Exemple #1
0
/*!
 * Extract an args array and kwargs object parsed from an args string
 */
static void extractArgs(const std::string &argsStr, Poco::JSON::Array::Ptr &args, Poco::JSON::Object::Ptr &kwargs)
{
    for (const auto &arg : splitCommaArgs(argsStr))
    {
        const Poco::StringTokenizer kvpTok(arg, "=", Poco::StringTokenizer::TOK_TRIM);
        const std::vector<std::string> kvp(kvpTok.begin(), kvpTok.end());
        if (kwargs and kvp.size() == 2) kwargs->set(kvp[0], exprToDynVar(kvp[1]));
        else if (args) args->add(exprToDynVar(arg));
    }
}
Exemple #2
0
/** Convert the units specification line from the RKH file into a
*  Mantid unit name
*  @param line :: units specification line
*  @return Mantid unit name
*/
const std::string LoadRKH::readUnit(const std::string & line)
{
    // split the line into words
    const Poco::StringTokenizer codes(line, " ", Poco::StringTokenizer::TOK_TRIM);
    if ( codes.count() < 1 )
    {
        return "C++ no unit found";
    }

    // the symbol for the quantity q = MomentumTransfer, etc.
    const std::string symbol(codes[0]);
    // this is units used to measure the quantity e.g. angstroms, counts, ...
    const std::string unit( *(codes.end()-1) );

    // theQuantity will contain the name of the unit, which can be many words long
    std::string theQuantity;
    Poco::StringTokenizer::Iterator current = codes.begin()+1, end = codes.end();
    for ( ; current != end; ++current)
    {
        if ( current != end - 1 )
        {
            theQuantity += *current;
        }
    }

    //this is a syntax check the line before returning its data
    if ( codes.count() >= 3 )
    {
        if ( unit.find('(') != 0 || unit.find(')') != unit.size() )
        {
            std::string qCode = boost::lexical_cast<std::string>(SaveRKH::Q_CODE);
            if ( symbol == qCode && theQuantity == "q" && unit == "(1/Angstrom)" )
            {   // 6 q (1/Angstrom) is the synatx for MomentumTransfer
                return "MomentumTransfer";
            }

            if ( symbol == "0" && theQuantity != "q" )
            {   // zero means the unit is not q but something else, which I'm assuming is legal
                return theQuantity + " " + unit;
            }
        }
    }
    // the line doesn't contain a valid 2D data file unit line
    return "C++ no unit found";
}
Exemple #3
0
		args.VerifyException("canPreprocess", "s");

		string url(args.GetString(0));
		Poco::URI uri(url);
		
		result->SetBool(false);
		if (Script::HasExtension(uri.getPath().c_str(), "php"))
		{
			result->SetBool(true);
		}
	}
	
	void PHPEvaluator::FillGet(Poco::URI& uri TSRMLS_DC)
	{
		Poco::StringTokenizer tokens(uri.getQuery(), "&=");
		Poco::StringTokenizer::Iterator iter = tokens.begin();
		
		for (; iter != tokens.end(); iter++)
		{
			string key(*iter);
			string value(*(++iter));

			zval *val;
			ALLOC_INIT_ZVAL(val);
			ZVAL_STRING(val, (char *) value.c_str(), 1);
			zend_hash_add(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]),
				(char *) key.c_str(), key.size()+1, &val, sizeof(zval*), NULL);
		}
	}
	
	void PHPEvaluator::Preprocess(const ValueList& args, KValueRef result)