void ApplicationBinding::_GetRuntime(const ValueList& args, KValueRef result)
	{
		if (!this->application->runtime.isNull())
		{
			result->SetObject(new ComponentBinding(this->application->runtime));
		}
		else
		{
			result->SetNull();
		}
	}
	void MenuItem::_GetSubmenu(const ValueList& args, KValueRef result)
	{
		if (this->submenu.isNull())
		{
			result->SetNull();
		}
		else
		{
			result->SetObject(this->submenu);
		}
	}
示例#3
0
	void UIBinding::_GetMenu(const ValueList& args, KValueRef result)
	{
		AutoMenu menu = this->GetMenu();
		if (menu.isNull())
		{
			result->SetNull();
		}
		else
		{
			result->SetObject(menu);
		}
	}
 void ResultSetBinding::Field(const ValueList& args, KValueRef result)
 {
     if (rs.isNull())
     {
         result->SetNull();
     }
     else
     {
         args.VerifyException("field", "i");
         TransformValue(args.at(0)->ToInt(),result);
     }
 }
示例#5
0
	void Bytes::_ToLowerCase(const ValueList& args, KValueRef result)
	{
		if (this->size > 0)
		{
			std::string target(this->buffer, this->size);
			std::string r = Poco::toLower(target);
			result->SetString(r);
		}
		else
		{
			result->SetNull();
		}
	}
 void ResultSetBinding::FieldName(const ValueList& args, KValueRef result)
 {
     if (rs.isNull())
     {
         result->SetNull();
     }
     else
     {
         args.VerifyException("fieldName", "i");
         const std::string &str = rs->columnName(args.at(0)->ToInt());
         result->SetString(str.c_str());
     }
 }
 void HttpServerRequest::GetHeader(const ValueList& args, KValueRef result)
 {
     args.VerifyException("getHeader", "s");
     std::string name = args.at(0)->ToString();
     if (request.has(name))
     {
         std::string value = request.get(name);
         result->SetString(value);
     }
     else
     {
         result->SetNull();
     }
 }
	void HTTPClientBinding::GetResponseHeader(const ValueList& args, KValueRef result)
	{
		args.VerifyException("getResponseHeader", "s");
		std::string name = args.GetString(0);

		if (this->response.has(name))
		{
			result->SetString(this->response.get(name).c_str());
		}
		else
		{
			result->SetNull();
		}
	}
 void ResultSetBinding::TransformValue(size_t index, KValueRef result)
 {
     MetaColumn::ColumnDataType type = rs->columnType(index);
     Poco::DynamicAny value = rs->value(index);
     
     if (value.isEmpty())
     {
         result->SetNull();
     }
     else if (type == MetaColumn::FDT_STRING)
     {
         std::string str;
         value.convert(str);
         result->SetString(str);
     }
     else if (type == MetaColumn::FDT_BOOL)
     {
         bool v = false;
         value.convert(v);
         result->SetBool(v);
     }
     else if (type == MetaColumn::FDT_FLOAT || type == MetaColumn::FDT_DOUBLE)
     {
         float f = 0;
         value.convert(f);
         result->SetDouble(f);
     }
     else if (type == MetaColumn::FDT_BLOB || type == MetaColumn::FDT_UNKNOWN)
     {
         std::string str;
         value.convert(str);
         result->SetString(str);
     }
     else
     {
         // the rest of these are ints:
         // FDT_INT8,
         // FDT_UINT8,
         // FDT_INT16,
         // FDT_UINT16,
         // FDT_INT32,
         // FDT_UINT32,
         // FDT_INT64,
         // FDT_UINT64,
         int i;
         value.convert(i);
         result->SetInt(i);
     }
 }
示例#10
0
    void APIBinding::_ReadApplicationManifest(const ValueList& args, KValueRef result)
    {
        args.VerifyException("readApplicationManifest", "s,?s");
        string manifestPath = args.at(0)->ToString();
        string appPath = args.GetString(1, FileUtils::Dirname(manifestPath));

        SharedApplication app = Application::NewApplication(manifestPath, appPath);
        if (!app.isNull())
        {
            result->SetObject(new ApplicationBinding(app));
        }
        else
        {
            result->SetNull();
        }
    }
	void HTTPClientBinding::GetCookie(const ValueList& args, KValueRef result)
	{
		args.VerifyException("getCookie", "s");
		std::string cookieName = args.GetString(0);

		if (this->responseCookies.find(cookieName) != this->responseCookies.end())
		{
			KObjectRef cookie = new HTTPCookie(this->responseCookies[cookieName]);
			result->SetObject(cookie);
		}
		else
		{
			// No cookie found with that name.
			result->SetNull();
		}
	}
示例#12
0
 void ResultSetBinding::FieldByName(const ValueList& args, KValueRef result)
 {
     result->SetNull();
     if (!rs.isNull())
     {
         args.VerifyException("fieldByName", "s");
         std::string name = args.at(0)->ToString();
         size_t count = rs->columnCount();
         for (size_t i = 0; i<count; i++)
         {
             const std::string &str = rs->columnName(i);
             if (str == name)
             {
                 TransformValue(i,result);
                 break;
             }
         }
     }
 }