1
我已經使用共享區域中的C++ Boost庫編寫了一個映射(鍵,值)。如何閱讀使用Boost C++(在共享區域)編寫的php web應用程序中的地圖?
void CreateIndexMap()
{
shared_memory_object::remove(Getsharedmemoryregion());
managed_shared_memory segment(create_only,Getsharedmemoryregion(), 10000000);
void_allocator alloc_inst (segment.get_segment_manager());
complex_map_type *mymap = segment.construct<complex_map_type>("MyMap")(std::less<char_string>(), alloc_inst);
}
在共享區域創建內存映射:
void UpdateIndexMap(std::string str, std::string index, const char* SharedMemory)
{
managed_shared_memory segment(open_only,SharedMemory);
void_allocator alloc_inst (segment.get_segment_manager());
complex_map_type *mymap = segment.find<complex_map_type>("MyMap").first;
std::string h = ConvertTolowercase(str);
char_string patternvalue(h.c_str(), alloc_inst);
char_string indexvalue((index).c_str(), alloc_inst);
mymap->insert(std::pair<char_string, char_string>(patternvalue,indexvalue));
}
現在我正在開發使用PHP一個Web應用程序,並希望閱讀共享區域地圖來獲取數據。如何實現它?
您需要在C++中實現並將擴展模塊暴露給PHP。換句話說,更好地區分你的擔憂,因爲你不想這樣做(相反,例如,製作一個可以從PHP使用的網絡API?)。如果你還好奇:http://www.php-cpp.com/ – sehe 2014-11-23 20:41:19