void PropertiesBinding::Getter(const ValueList& args, KValueRef result, Type type)
	{
		if (args.size() > 0 && args.at(0)->IsString())
		{
			std::string eprefix = "PropertiesBinding::Get: ";
			try
			{
				std::string property = args.at(0)->ToString();
				if (args.size() == 1)
				{
					switch (type)
					{
						case Bool: 
							result->SetBool(config->getBool(property));
							break;
						case Double:
							result->SetDouble(config->getDouble(property));
							break;
						case Int:
							result->SetInt(config->getInt(property));
							break;
						case String:
							result->SetString(config->getString(property).c_str());
							break;
						default:
							break;
					}
					return;
				}

				else if (args.size() >= 2)
				{
					switch (type)
					{
						case Bool:
							result->SetBool(config->getBool(property, args.at(1)->ToBool()));
							break;
						case Double:
							result->SetDouble(config->getDouble(property, args.at(1)->ToDouble()));
							break;
						case Int:
							result->SetInt(config->getInt(property, args.at(1)->ToInt()));
							break;
						case String:
							result->SetString(config->getString(property, args.at(1)->ToString()).c_str());
							break;
						default: break;
					}
					return;
				}
			}
			catch(Poco::Exception &e)
			{
				throw ValueException::FromString(eprefix + e.displayText());
			}
		}
	}
Example #2
0
void Calc::Minimum(const ValueList& args, KValueRef result)
{
	if (args.at(0)->IsList())
	{
		KListRef list = args.at(0)->ToList();

		double *arr = NULL;

		arr = new double[list->Size()];

		for (unsigned int c = 0; c < list->Size(); c++)
		{
			KValueRef d = list->At(c);
			arr[c] = d->ToDouble();
		}

		double low = Min(arr, list->Size());

		result->SetDouble(low);

		delete [] arr;

   } else {
		throw ValueException::FromString("Minimum takes an array");
   }

}
 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);
     }
 }
Example #4
0
	void KEventObject::_AddEventListener(const ValueList& args, KValueRef result)
	{
		unsigned int listenerId;
		if (args.size() > 1 && args.at(0)->IsString() && args.at(1)->IsMethod())
		{
			std::string eventName(args.GetString(0));
			listenerId = this->AddEventListener(eventName, args.GetMethod(1));
		}
		else if (args.size() > 0 && args.at(0)->IsMethod())
		{
			listenerId = this->AddEventListenerForAllEvents(args.GetMethod(0));
		}
		else
		{
			throw ValueException::FromString("Incorrect arguments passed to addEventListener");
		}

		result->SetDouble((double) listenerId);
	}
Example #5
0
	void Event::_GetTimestamp(const ValueList&, KValueRef result)
	{
		result->SetDouble((int) timestamp.epochMicroseconds() / 1000);
	}
Example #6
0
 void AsyncJob::_GetProgress(const ValueList& args, KValueRef result)
 {
     result->SetDouble(this->GetProgress());
 }
Example #7
0
	void UIBinding::_GetIdleTime(
		const ValueList& args,
		KValueRef result)
	{
		result->SetDouble(this->GetIdleTime());
	}
Example #8
0
	void ZipFile::GetFileCount(const ValueList& args, KValueRef result)
	{
		result->SetDouble(getFileCount());
	}
Example #9
0
 void Sound::GetVolume(const ValueList& args, KValueRef result)
 {
     result->SetDouble(this->GetVolume());
 }