27 #include "../../../common/Exception.h" 28 #include "../../../core/encoding/CharEncoding.h" 29 #include "../../../core/translator/Translator.h" 43 fseek(file, 0, SEEK_END);
45 std::size_t fileSize = ftell(file);
49 char* buff =
new char[fileSize + 1];
51 buff[fileSize] =
'\0';
55 for(std::size_t i = 0; i < fileSize; i += read)
56 read = fread(&buff[i],
sizeof(
char), fileSize - i, file);
60 ::v8::Handle<::v8::String> result = ::v8::String::New(buff, static_cast<int>(fileSize));
67 void te::v8::common::Cache(::v8::Local<::v8::Object>& obj,
const std::string& methodName, ::v8::Persistent<::v8::Function>& outFtor)
69 ::v8::Local<::v8::String> jsMethodName = ::v8::String::New(methodName.c_str());
71 ::v8::Local<::v8::Value> jsMethod = obj->Get(jsMethodName);
73 if(jsMethod.IsEmpty())
76 if(!jsMethod->IsFunction())
79 ::v8::Handle<::v8::Function> jsMethodFtor = ::v8::Handle<::v8::Function>::Cast(jsMethod);
81 outFtor = ::v8::Persistent<::v8::Function>::New(jsMethodFtor);
90 for(
int i = 0; i < args.Length(); ++i)
97 ::v8::String::Utf8Value str(args[i]);
99 const char* cstr = *str;
108 return ::v8::Undefined();
TEV8COMMONEXPORT::v8::Handle<::v8::String > ReadFile(const std::string &fileName)
It reads a file into a v8 string.
static std::string fromUTF8(const std::string &src)
Convert a string in UTF-8 to the current locale encoding.
TEV8COMMONEXPORT void Cache(::v8::Local<::v8::Object > &obj, const std::string &methodName,::v8::Persistent<::v8::Function > &outFtor)
It caches the object method into the persistent output functor.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
TEV8COMMONEXPORT::v8::Handle<::v8::Value > Print(const ::v8::Arguments &args)
This function will print all the arguments to the standard output.
#define TR_V8COMMON(message)
It marks a string in order to get translated. This is a special mark used in the Vector Geometry modu...
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $