void Blob::CharAt(const ValueList& args, SharedValue result) { // https://developer.mozilla.org/en/core_javascript_1.5_reference/global_objects/string/charat args.VerifyException("Blob.charAt", "n"); int position = args.at(0)->ToInt(); char buf[2] = {'\0', '\0'}; if (position >= 0 && position < this->length) { buf[0] = this->buffer[position]; } result->SetString(buf); }
void HttpServerRequest::GetHeader(const ValueList& args, SharedValue result) { std::string name = args.at(0)->ToString(); if (request.has(name)) { std::string value = request.get(name); result->SetString(value); } else { result->SetNull(); } }
void ResultSetBinding::FieldName(const ValueList& args, SharedValue 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 Blob::ToUpperCase(const ValueList& args, SharedValue result) { if (this->length > 0) { std::string target = this->buffer; std::string r = Poco::toUpper(target); result->SetString(r); } else { result->SetNull(); } }
void AppBinding::GetIcon(const ValueList& args, SharedValue result) { const SharedApplication app = this->host->GetApplication(); if (app->image.empty()) { result->SetNull(); } else { std::string iconPath = app->image; result->SetString(iconPath); } }
void AppBinding::GetStreamURL(const ValueList& args, SharedValue result) { SharedApplication app = this->host->GetApplication(); std::string url(app->GetStreamURL("https")); for (size_t c = 0; c < args.size(); c++) { SharedValue arg = args.at(c); if (arg->IsString()) { url.append("/"); url.append(arg->ToString()); } } result->SetString(url); }
void HTTPClientBinding::GetResponseHeader(const ValueList& args, SharedValue result) { if (this->response!=NULL) { std::string name = args.at(0)->ToString(); if (this->response->has(name)) { result->SetString(this->response->get(name).c_str()); } else { result->SetNull(); } } else { throw ValueException::FromString("no available response"); } }
void Pipe::Read(const ValueList& args, SharedValue result) { if (closed) { throw ValueException::FromString("Pipe is already closed"); } Poco::PipeInputStream *is = dynamic_cast<Poco::PipeInputStream*>(pipe); if (is==NULL) { throw ValueException::FromString("Stream is not readable"); } char *buf = NULL; try { int size = 1024; // allow the size of the returned buffer to be // set by the caller - defaults to 1024 if not specified if (args.size()>0 && args.at(0)->IsInt()) { size = args.at(0)->ToInt(); } buf = new char[size]; is->read(buf,size); int count = is->gcount(); if (count <=0) { result->SetNull(); } else { buf[count] = '\0'; result->SetString(buf); } delete [] buf; } catch (Poco::ReadFileException &e) { if (buf) delete[] buf; throw ValueException::FromString(e.what()); } }
void NetworkBinding::DecodeURIComponent(const ValueList &args, SharedValue result) { std::string src = args.at(0)->ToString(); std::string sResult = kroll::FileUtils::DecodeURIComponent(src); result->SetString(sResult); }
void AppBinding::GetVersion(const ValueList& args, SharedValue result) { result->SetString(AppConfig::Instance()->GetVersion().c_str()); }
void IPAddressBinding::ToString(const ValueList& args, SharedValue result) { result->SetString(this->address->toString().c_str()); }
void AsyncCopy::ToString(const ValueList& args, SharedValue result) { result->SetString("[Async Copy]"); }
void ComponentBinding::_GetVersion(const ValueList& args, SharedValue result) { result->SetString(this->component->version); }
void ComponentBinding::_GetPath(const ValueList& args, SharedValue result) { result->SetString(this->component->path); }
void AppBinding::GetGUID(const ValueList& args, SharedValue result) { std::string guid = host->GetApplication()->guid; result->SetString(guid); }
void ComponentBinding::_GetName(const ValueList& args, SharedValue result) { result->SetString(this->component->name); }
void Event::_GetType(const ValueList&, SharedValue result) { result->SetString(this->eventName); }
void HttpServerRequest::GetURI(const ValueList& args, SharedValue result) { std::string uri = request.getURI(); result->SetString(uri); }
void HttpServerRequest::GetMethod(const ValueList& args, SharedValue result) { std::string method = request.getMethod(); result->SetString(method); }
void AppBinding::GetHome(const ValueList& args, SharedValue result) { static std::string path(host->GetApplicationHomePath()); result->SetString(path); }
void AppBinding::GetPath(const ValueList& args, SharedValue result) { static std::string path(host->GetCommandLineArg(0)); result->SetString(path); }
void HttpServerRequest::GetVersion(const ValueList& args, SharedValue result) { std::string version = request.getVersion(); result->SetString(version); }
void AppBinding::GetUpdateURL(const ValueList& args, SharedValue result) { result->SetString(AppConfig::Instance()->GetUpdateSite().c_str()); }
void HttpServerRequest::GetContentType(const ValueList& args, SharedValue result) { std::string ct = request.getContentType(); result->SetString(ct); }
void MenuItem::_GetLabel(const ValueList& args, SharedValue result) { result->SetString(this->label); }
void HostBinding::GetName(const ValueList& args, SharedValue result) { result->SetString(this->host.name().c_str()); }
void MenuItem::_GetIcon(const ValueList& args, SharedValue result) { result->SetString(this->iconURL); }