Lines Matching refs:string
33 #include <string>
53 virtual const string& Path() = 0;
54 virtual const string& Referrer() = 0;
55 virtual const string& Host() = 0;
56 virtual const string& UserAgent() = 0;
69 virtual bool Initialize(map<string, string>* options,
70 map<string, string>* output) = 0;
86 JsHttpRequestProcessor(Isolate* isolate, Handle<String> script)
90 virtual bool Initialize(map<string, string>* opts,
91 map<string, string>* output);
97 bool ExecuteScript(Handle<String> script);
101 bool InstallMaps(map<string, string>* opts, map<string, string>* output);
109 static void GetPath(Local<String> name,
111 static void GetReferrer(Local<String> name,
113 static void GetHost(Local<String> name,
115 static void GetUserAgent(Local<String> name,
119 static void MapGet(Local<String> name,
121 static void MapSet(Local<String> name,
127 Handle<Object> WrapMap(map<string, string>* obj);
128 static map<string, string>* UnwrapMap(Handle<Object> obj);
135 Handle<String> script_;
152 String::Utf8Value value(arg);
158 bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
159 map<string, string>* output) {
166 global->Set(String::NewFromUtf8(GetIsolate(), "log"),
191 Handle<String> process_name = String::NewFromUtf8(GetIsolate(), "Process");
210 bool JsHttpRequestProcessor::ExecuteScript(Handle<String> script) {
220 String::Utf8Value error(try_catch.Exception());
230 String::Utf8Value error(try_catch.Exception());
239 bool JsHttpRequestProcessor::InstallMaps(map<string, string>* opts,
240 map<string, string>* output) {
250 context->Global()->Set(String::NewFromUtf8(GetIsolate(), "options"),
254 context->Global()->Set(String::NewFromUtf8(GetIsolate(), "output"),
286 String::Utf8Value error(try_catch.Exception());
314 Handle<Object> JsHttpRequestProcessor::WrapMap(map<string, string>* obj) {
347 map<string, string>* JsHttpRequestProcessor::UnwrapMap(Handle<Object> obj) {
350 return static_cast<map<string, string>*>(ptr);
354 // Convert a JavaScript string to a std::string. To not bother too
355 // much with string encodings we just use ascii.
356 string ObjectToString(Local<Value> value) {
357 String::Utf8Value utf8_value(value);
358 return string(*utf8_value);
362 void JsHttpRequestProcessor::MapGet(Local<String> name,
365 map<string, string>* obj = UnwrapMap(info.Holder());
367 // Convert the JavaScript string to a std::string.
368 string key = ObjectToString(name);
371 map<string, string>::iterator iter = obj->find(key);
376 // Otherwise fetch the value and wrap it in a JavaScript string
377 const string& value = (*iter).second;
378 info.GetReturnValue().Set(String::NewFromUtf8(
379 info.GetIsolate(), value.c_str(), String::kNormalString,
384 void JsHttpRequestProcessor::MapSet(Local<String> name,
388 map<string, string>* obj = UnwrapMap(info.Holder());
391 string key = ObjectToString(name);
392 string value = ObjectToString(value_obj);
465 void JsHttpRequestProcessor::GetPath(Local<String
471 const string& path = request->Path();
473 // Wrap the result in a JavaScript string and return it.
474 info.GetReturnValue().Set(String::NewFromUtf8(
475 info.GetIsolate(), path.c_str(), String::kNormalString,
481 Local<String> name,
484 const string& path = request->Referrer();
485 info.GetReturnValue().Set(String::NewFromUtf8(
486 info.GetIsolate(), path.c_str(), String::kNormalString,
491 void JsHttpRequestProcessor::GetHost(Local<String> name,
494 const string& path = request->Host();
495 info.GetReturnValue().Set(String::NewFromUtf8(
496 info.GetIsolate(), path.c_str(), String::kNormalString,
502 Local<String> name,
505 const string& path = request->UserAgent();
506 info.GetReturnValue().Set(String::NewFromUtf8(
507 info.GetIsolate(), path.c_str(), String::kNormalString,
521 String::NewFromUtf8(isolate, "path", String::kInternalizedString),
524 String::NewFromUtf8(isolate, "referrer", String::kInternalizedString),
527 String::NewFromUtf8(isolate, "host", String::kInternalizedString),
530 String::NewFromUtf8(isolate, "userAgent", String::kInternalizedString),
551 StringHttpRequest(const string& path,
552 const string& referrer,
553 const string& host,
554 const string& user_agent);
555 virtual const string& Path() { return path_; }
556 virtual const string& Referrer() { return referrer_; }
557 virtual const string& Host() { return host_; }
558 virtual const string& UserAgent() { return user_agent_; }
560 string path_;
561 string referrer_;
562 string host_;
563 string user_agent_;
567 StringHttpRequest::StringHttpRequest(const string& path,
568 const string& referrer,
569 const string& host,
570 const string& user_agent)
579 map<string, string>* options,
580 string* file) {
582 string arg = argv[i];
584 if (index == string::npos) {
587 string key = arg.substr(0, index);
588 string value = arg.substr(index+1);
595 // Reads a file into a v8 string.
596 Handle<String> ReadFile(Isolate* isolate, const string& name) {
598 if (file == NULL) return Handle<String>();
611 Handle<String> result =
612 String::NewFromUtf8(isolate, chars, String::kNormalString, size);
639 void PrintMap(map<string, string>* m) {
640 for (map<string, string>::iterator i = m->begin(); i != m->end(); i++) {
641 pair<string, string> entry = *i;
652 map<string, string> options;
653 string file;
662 Handle<String> source = ReadFile(isolate, file);
668 map<string, string> output;