Lines Matching refs:string
33 #include <string.h>
36 #include <string>
52 virtual const string& Path() = 0;
53 virtual const string& Referrer() = 0;
54 virtual const string& Host() = 0;
55 virtual const string& UserAgent() = 0;
68 virtual bool Initialize(map<string, string>* options,
69 map<string, string>* output) = 0;
85 JsHttpRequestProcessor(Isolate* isolate, Local<String> script)
89 virtual bool Initialize(map<string, string>* opts,
90 map<string, string>* output);
96 bool ExecuteScript(Local<String> script);
100 bool InstallMaps(map<string, string>* opts, map<string, string>* output);
108 static void GetPath(Local<String> name,
110 static void GetReferrer(Local<String> name,
112 static void GetHost(Local<String> name,
114 static void GetUserAgent(Local<String> name,
124 Local<Object> WrapMap(map<string, string>* obj);
125 static map<string, string>* UnwrapMap(Local<Object> obj);
132 Local<String> script_;
149 String::Utf8Value value(arg);
155 bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
156 map<string, string>* output) {
163 global->Set(String::NewFromUtf8(GetIsolate(), "log", NewStringType::kNormal)
189 Local<String> process_name =
190 String::NewFromUtf8(GetIsolate(), "Process", NewStringType::kNormal)
212 bool JsHttpRequestProcessor::ExecuteScript(Local<String> script) {
224 String::Utf8Value error(try_catch.Exception());
234 String::Utf8Value error(try_catch.Exception());
243 bool JsHttpRequestProcessor::InstallMaps(map<string, string>* opts,
244 map<string, string>* output) {
256 String::NewFromUtf8(GetIsolate(), "options", NewStringType::kNormal)
264 String::NewFromUtf8(GetIsolate(), "output", NewStringType::kNormal)
298 String::Utf8Value error(try_catch.Exception());
326 Local<Object> JsHttpRequestProcessor::WrapMap(map<string, string>* obj) {
360 map<string, string>* JsHttpRequestProcessor::UnwrapMap(Local<Object> obj) {
363 return static_cast<map<string, string>*>(ptr);
367 // Convert a JavaScript string to a std::string. To not bother too
368 // much with string encodings we just use ascii.
369 string ObjectToString(Local<Value> value) {
370 String::Utf8Value utf8_value(value);
371 return string(*utf8_value);
380 map<string, string>* obj = UnwrapMap(info.Holder());
382 // Convert the JavaScript string to a std::string.
383 string key = ObjectToString(Local<String>::Cast(name));
386 map<string, string>::iterator iter = obj->find(key);
391 // Otherwise fetch the value and wrap it in a JavaScript string
392 const string& value = (*iter).second;
394 String::NewFromUtf8(info.GetIsolate(), value.c_str(),
405 map<string, string>* obj = UnwrapMap(info.Holder());
408 string key = ObjectToString(Local<String>::Cast(name));
409 string value = ObjectToString(value_obj);
483 void JsHttpRequestProcessor::GetPath(Local<String> name,
489 const string& path = request->Path();
491 // Wrap the result in a JavaScript string and return it.
493 String::NewFromUtf8(info.GetIsolate(), path.c_str(),
500 Local<String> name,
503 const string& path = request->Referrer();
505 String::NewFromUtf8(info.GetIsolate(), path.c_str(),
511 void JsHttpRequestProcessor::GetHost(Local<String> name,
514 const string& path = request->Host();
516 String::NewFromUtf8(info.GetIsolate(), path.c_str(),
523 Local<String> name,
526 const string& path = request->UserAgent();
528 String::NewFromUtf8(info.GetIsolate(), path.c_str(),
543 String::NewFromUtf8(isolate, "path", NewStringType::kInternalized)
547 String::NewFromUtf8(isolate, "referrer", NewStringType::kInternalized)
551 String::NewFromUtf8(isolate, "host", NewStringType::kInternalized)
555 String::NewFromUtf8(isolate, "userAgent", NewStringType::kInternalized)
577 StringHttpRequest(const string& path,
578 const string& referrer,
579 const string& host,
580 const string& user_agent);
581 virtual const string& Path() { return path_; }
582 virtual const string& Referrer() { return referrer_; }
583 virtual const string& Host() { return host_; }
584 virtual const string& UserAgent() { return user_agent_; }
586 string path_;
587 string referrer_;
588 string host_;
589 string user_agent_;
593 StringHttpRequest::StringHttpRequest(const string& path,
594 const string& referrer,
595 const string& host,
596 const string& user_agent)
605 map<string, string>* options,
606 string* file) {
608 string arg = argv[i];
610 if (index == string::npos) {
613 string key = arg.substr(0, index);
614 string value = arg.substr(index+1);
621 // Reads a file into a v8 string.
622 MaybeLocal<String> ReadFile(Isolate* isolate, const string& name) {
624 if (file == NULL) return MaybeLocal<String>();
636 return MaybeLocal<String>();
640 MaybeLocal<String> result = String::NewFromUtf8(
670 void PrintMap(map<string, string>* m) {
671 for (map<string, string>::iterator i = m->begin(); i != m->end(); i++) {
672 pair<string, string> entry = *i;
684 map<string, string> options;
685 string file;
697 Local<String> source;
703 map<string, string> output;