WDbgArkColorHack::InternalUiColor WDbgArkColorHack::ConvertUiColorToInternal(UiColor* ui_color, const UiColorType ui_color_type) { std::string dml_name = wstring_to_string(ui_color->dml_name); std::transform(dml_name.begin(), dml_name.end(), dml_name.begin(), tolower); return { ui_color, false, ui_color_type, wstring_to_string(ui_color->description), dml_name, ui_color->color, 0, ui_color->int_color, 0 }; }
std::wstring* FileDialog::OpenFile (std::wstring* title, std::wstring* filter, std::wstring* defaultPath) { #ifdef HX_WINDOWS std::wstring temp (L"*."); const wchar_t* filters[] = { filter ? (temp + *filter).c_str () : NULL }; const wchar_t* path = tinyfd_openFileDialogW (title ? title->c_str () : 0, defaultPath ? defaultPath->c_str () : 0, filter ? 1 : 0, filter ? filters : NULL, NULL, 0); if (path) { std::wstring* _path = new std::wstring (path); return _path; } #else std::string* _title = wstring_to_string (title); std::string* _filter = wstring_to_string (filter); std::string* _defaultPath = wstring_to_string (defaultPath); const char* filters[] = { NULL }; if (_filter) { _filter->insert (0, "*."); filters[0] = _filter->c_str (); } const char* path = tinyfd_openFileDialog (_title ? _title->c_str () : NULL, _defaultPath ? _defaultPath->c_str () : NULL, _filter ? 1 : 0, _filter ? filters : NULL, NULL, 0); if (_title) delete _title; if (_filter) delete _filter; if (_defaultPath) delete _defaultPath; if (path) { std::string _path = std::string (path); std::wstring* __path = new std::wstring (_path.begin (), _path.end ()); return __path; } #endif return 0; }
Object * Database::load_obj(const wstring & name) { int ret = 0; Object * obj = global->obj_mgr->find(name, ret); if (obj != NULL) return obj; if (!is_existent_in_json(name)) return NULL; obj = new Object(); obj->name = name; string key = wstring_to_string(name); ObjMapMap::iterator it = obj->attr_maps.begin(); for (; it != obj->attr_maps.end(); it++){ ObjMap * map = it->second; string map_name = it->first; Json::Value attr = root[key][map_name]; int size = attr.size(); for (int i = 0; i < size; i++){ Object * other = find(attr[i].asString(), ret); if (other == NULL){ ERR("find object error\n"); continue; } map->insert(ObjMap::value_type(other->name, other)); } } return obj; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Parse the command line for the editor profile option and copy the result to /// [profile_name]. Sets [profile_name] to an empty string if an option isn't found. /// </summary> /// /// <param name="profile_name"> Output buffer for the profile name. </param> void GetCommandLineDefaultProfile(string128 profile_name) { #define CMDLINE_ARG_EDITOR_PROFILE L"-editorProfile:" profile_name[0] = '\0'; int cmds_count = 0; auto cmds = std::unique_ptr<LPWSTR[], winapi_local_deleter>( CommandLineToArgvW(GetCommandLineW(), &cmds_count)); for(int x = 0; x < cmds_count; x++) { wcstring cmd = wcsstr(cmds[x], CMDLINE_ARG_EDITOR_PROFILE); if(cmd != nullptr) { const size_t k_parameter_length = NUMBEROF(CMDLINE_ARG_EDITOR_PROFILE)-1; cmd = cmd + k_parameter_length; const size_t length = wcslen(cmd); if(length > 0) wstring_to_string(profile_name, Enums::k_string_128_length, cmd); } } #undef CMDLINE_ARG_EDITOR_PROFILE }
std::pair<HRESULT, std::string> UnicodeStringStructToString(const ExtRemoteTyped &unicode_string) { std::string output_string = ""; try { ExtRemoteTyped loc_unicode_string = unicode_string; ExtRemoteTyped buffer = *loc_unicode_string.Field("Buffer"); uint16_t len = loc_unicode_string.Field("Length").GetUshort(); uint16_t maxlen = loc_unicode_string.Field("MaximumLength").GetUshort(); if ( len == 0 && maxlen == 1 ) { return std::make_pair(S_OK, output_string); } if ( maxlen >= sizeof(wchar_t) && (maxlen % sizeof(wchar_t) == 0) ) { uint16_t max_len_wide = maxlen / sizeof(wchar_t) + 1; std::unique_ptr<wchar_t[]> test_name(new wchar_t[max_len_wide]); std::memset(test_name.get(), 0, max_len_wide * sizeof(wchar_t)); uint32_t read = buffer.ReadBuffer(test_name.get(), maxlen, true); if ( read == maxlen ) output_string = wstring_to_string(test_name.get()); return std::make_pair(S_OK, output_string); } } catch ( const ExtRemoteException &Ex ) { std::stringstream locerr; locerr << wa::showminus << __FUNCTION__ << ": " << Ex.GetMessage() << wa::endlerr; return std::make_pair(Ex.GetStatus(), output_string); } return std::make_pair(E_INVALIDARG, output_string); }
VRegisteredDatabase::VRegisteredDatabase(const wstring& in_fullstring) { if (in_fullstring.compare(L"")!=0) { std::vector<wstring> split_vec; boost::algorithm::split(split_vec, in_fullstring, boost::is_any_of(L";")); if (split_vec.size()==4) { name = split_vec.at(0); server = split_vec.at(1); database = split_vec.at(2); folder = split_vec.at(3); count_days_backup = 7; } else if(split_vec.size()>=5) { //есть информаци¤ о кол-ве дней, допустимых без резервного копировани¤ name = split_vec.at(0); server = split_vec.at(1); database = split_vec.at(2); folder = split_vec.at(3); count_days_backup = atoi(wstring_to_string(split_vec.at(4).c_str()).c_str()); } else { throw VSimpleException(L"ќшибка разбора строки", in_fullstring, boost::str(boost::wformat(L"%s") % __FILE__), __LINE__); } } };
JSONObjectWrapper::Checker::operator std::vector<std::string>() const { if (key_ == object_.end() || ! key_->second->IsArray()) { valid_ = false; return std::vector<std::string>(); } const JSONArray & ary = key_->second->AsArray(); // Check erroneous string object for (JSONArray::const_iterator it = ary.begin(), end = ary.end(); it != end; ++it) { if (! (*it)->IsString()) { valid_ = false; return std::vector<std::string>(); } } std::vector<std::string> vect(ary.size()); for (JSONArray::size_type i = 0, size = ary.size(); i < size; ++i) vect[i] = wstring_to_string(ary[i]->AsString()); return vect; }
bool Database::is_existent_in_json(const wstring & name) { int ret = open_json(); if (ret != 0) return false; //return !root[wstring_to_string(name)].isNull(); return root.isMember(wstring_to_string(name)); }
//-------------------------------------- ћетоды класса V4fWriter ---------------------------------- V4fWriter::V4fWriter(std::wstring newCameraName) { dataSet = 0; cameraName = newCameraName; Opened = false; counterFrames = -1; cache = new V4fCacheThread(NULL, wstring_to_string(VIDEO_OPTIONS().Value().video_server)); }
void ofxGLEditor::copyToClipBoard() { string script = wstring_to_string(glEditor[currentEditor]->GetText()); #ifndef __APPLE__ // TODO #else clipBoard.setTextToPasteboard(script.c_str()); #endif }
void PasswdManager::create_default_file() { std::wofstream passwd(wstring_to_string(this->passwd_file_path)); passwd.imbue(utf8_locale); if (!std::experimental::filesystem::exists(this->passwd_file_path)) { throw std::runtime_error("Невозможно создать passwd"); } passwd << "ADMIN:1:0:1:1:" << std::endl; passwd.close(); }
int Database::save_obj(Object * & obj) { string key = wstring_to_string(obj->name); Json::Value attrs; ObjMapMap::iterator it = obj->attr_maps.begin(); for (; it != obj->attr_maps.end(); it++){ ObjMap * map = it->second; string map_name = it->first; ObjMap::iterator i = map->begin(); attrs[map_name] = Json::nullValue; for (; i != map->end(); i++){ attrs[map_name].append(wstring_to_string(i->first)); } } root[key] = attrs; return 0; }
//-------------------------------------------------------------- void ofxFileDialog::refresh() { ofLogVerbose("ofxFileDialog") << "loading path: " << wstring_to_string(m_path); m_filenames.clear(); m_directories.clear(); ofDirectory dir(wstring_to_string(m_path)); dir.listDir(); vector<ofFile> files = dir.getFiles(); ofLogVerbose("ofxFileDialog") << files.size() << " files: "; // one level up if(m_path != U"/") { m_directories.insert(0); m_filenames.push_back(U".."); } // first dirs for(int i = 0; i < files.size(); ++i) { if(files[i].isDirectory()) { m_directories.insert(m_filenames.size()); m_filenames.push_back(string_to_wstring(files[i].getFileName())); ofLogVerbose("ofxFileDialog") << "\t" << wstring_to_string(m_filenames.back()); // select previous dir if(m_prevBasename != U"" && m_filenames.back() == m_prevBasename) { m_currentFile = m_filenames.size()-1; } } } // then files for(int i = 0; i < files.size(); ++i) { if(!files[i].isDirectory()) { m_filenames.push_back(string_to_wstring(files[i].getFileName())); ofLogVerbose("ofxFileDialog") << "\t" << wstring_to_string(m_filenames.back()); } } m_prevBasename = U""; }
std::wstring* FileDialog::OpenDirectory (std::wstring* title, std::wstring* filter, std::wstring* defaultPath) { // TODO: Filter? #ifdef HX_WINDOWS const wchar_t* path = tinyfd_selectFolderDialogW (title ? title->c_str () : 0, defaultPath ? defaultPath->c_str () : 0); if (path) { std::wstring* _path = new std::wstring (path); return _path; } #else std::string* _title = wstring_to_string (title); //std::string* _filter = wstring_to_string (filter); std::string* _defaultPath = wstring_to_string (defaultPath); const char* path = tinyfd_selectFolderDialog (_title ? _title->c_str () : NULL, _defaultPath ? _defaultPath->c_str () : NULL); if (_title) delete _title; //if (_filter) delete _filter; if (_defaultPath) delete _defaultPath; if (path) { std::string _path = std::string (path); std::wstring* __path = new std::wstring (_path.begin (), _path.end ()); return __path; } #endif return 0; }
//-------------------------------------------------------------- void ofxFileDialog::keyPressedNewFolder(int key, bool saveAs) { switch(key) { case OF_KEY_RETURN: if(!ofDirectory::createDirectory(wstring_to_string(m_path+m_text))) { ofLogError("ofxFileDialog") << "couldn't create new folder: \"" << wstring_to_string(m_text) << "\""; m_saveAsState = FILENAME; } else { ofLogVerbose("ofxFileDialog") << "created new folder: \"" << wstring_to_string(m_text) << "\""; refresh(); for(int i = 0; i < m_filenames.size(); ++i) { if(m_filenames[i] == m_text) { m_currentFile = i; break; } } if(SAVEAS) { m_saveAsState = BROWSER; } } clearText(); break; case OF_KEY_ESC: if(saveAs) { m_saveAsState = FILENAME; } else { m_active = false; } break; default: keyPressedText(key); break; } }
int Database::save_all_objs() { int ret = 0; ObjMap::iterator it = global->obj_mgr->pool.begin(); for (; it != global->obj_mgr->pool.end(); it++) { ret = save_obj(it->second); if (ret != 0){ ERR("save obj error, obj name: %s\n", wstring_to_string(it->second->name)); return ret; } } return ret; }
void WDbgArkColorHack::PrintMemoryInfo(void) { try { out << wa::showplus << "--------------------------------------------------------------------------"; out << endlout; UiColor* loc_ui_color = m_g_ui_colors; while ( loc_ui_color->description ) { out << wa::showplus << "Description : " << wstring_to_string(loc_ui_color->description) << endlout; out << wa::showplus << "DML name : " << wstring_to_string(loc_ui_color->dml_name) << endlout; out << wa::showplus << "Colorref : " << std::internal << std::setw(8) << std::setfill('0'); out << wa::showplus << std::hex << std::showbase << loc_ui_color->color << endlout; out << wa::showplus << "Intcolorref : " << std::internal << std::setw(8) << std::setfill('0'); out << wa::showplus << std::hex << std::showbase << loc_ui_color->int_color << endlout; out << wa::showplus << "--------------------------------------------------------------------------"; out << endlout; loc_ui_color++; } loc_ui_color = m_g_out_mask_ui_colors; while ( loc_ui_color->description ) { out << wa::showplus << "Description : " << wstring_to_string(loc_ui_color->description) << endlout; out << wa::showplus << "DML name : " << wstring_to_string(loc_ui_color->dml_name) << endlout; out << wa::showplus << "Colorref : " << std::internal << std::setw(8) << std::setfill('0'); out << wa::showplus << std::hex << std::showbase << loc_ui_color->color << endlout; out << wa::showplus << "Intcolorref : " << std::internal << std::setw(8) << std::setfill('0'); out << wa::showplus << std::hex << std::showbase << loc_ui_color->int_color << endlout; out << wa::showplus << "--------------------------------------------------------------------------"; out << endlout; loc_ui_color++; } } catch( ... ) { err << wa::showminus << __FUNCTION__ << ": exception error" << endlerr; } }
bool V4fWriter::Open() { if (Opened || CURRENT_POSITION().Value().direction <= 0) return false; try { SECURITY_ATTRIBUTES sa; sa.nLength= sizeof(sa); sa.lpSecurityDescriptor= NULL; time_t now = time(NULL); localtime(&now); char hms[32]=""; char full_path [MAX_PATH] = "", short_path [128] = ""; strftime(hms, 31, "%Hh%Mm%Ss", localtime(&now)); _snprintf(short_path, 127, "%s_%s.v4f", wstring_to_string(cameraName).c_str(), hms); CreateFullPath(full_path, CURRENT_POSITION().Value().direction, CURRENT_POSITION().Value().way, CURRENT_POSITION().Value().start_time, short_path, wstring_to_string(VIDEO_OPTIONS().Value().video_server)); fullPath = string_to_wstring(full_path); dataSet = new V4fDataSet(wstring_to_string(fullPath), short_path, CURRENT_POSITION().Value().direction, CURRENT_POSITION().Value().way, CURRENT_POSITION().Value().start_time); if(dataSet) { dataSet->OpenWriteFile(); dataSet->WriteHeader(); Opened = true; current_start_time = CURRENT_POSITION().Value().start_time; return true; } } catch(std::exception e) { LOG_ERROR(L"ќшибка при открытии файла .v4f"); } return false; }
// return the current directory // always with forward slashes std::string get_cwd() { const size_t wd_len = 1024; #ifndef _WIN32 char wd[wd_len]; std::string cwd = getcwd(wd, wd_len); #else wchar_t wd[wd_len]; std::string cwd = wstring_to_string(_wgetcwd(wd, wd_len)); //convert backslashes to forward slashes replace(cwd.begin(), cwd.end(), '\\', '/'); #endif if (cwd[cwd.length() - 1] != '/') cwd += '/'; return cwd; }
void PasswdManager::write(std::wstring passwd_file_path) { std::wofstream out_passwd(TMP_PATH, std::wofstream::trunc); out_passwd.imbue(utf8_locale); for (auto i: this->users) { out_passwd << i.str(sys) << std::endl; } out_passwd.close(); FILE* fin = fopen(TMP_PATH, "rb"); FILE* fout = fopen(wstring_to_string(this->passwd_file_path).c_str(), "wb"); en_de_crypt_files(true, fin, fout, this->password_hash, IVEC); fclose(fin); fclose(fout); std::experimental::filesystem::remove(TMP_PATH); }
void ofxGLEditor::saveToFile(string _path) { string file = _path; ofstream myfile; myfile.open(file.c_str(), _S_out); string script; for (unsigned int i = 0; i < glEditor.size(); i++) { script += wstring_to_string(glEditor[i]->GetAllText()); script += "\n"; } myfile << script; myfile.close(); cout << "script saved" << endl; }
bool PasswdManager::read_from_file(std::wstring passwd_file_path) { this->passwd_file_path = passwd_file_path; FILE* fin = fopen(wstring_to_string(this->passwd_file_path).c_str(), "rb"); FILE* fout = fopen(TMP_PATH, "wb"); en_de_crypt_files(false, fin, fout, this->password_hash, IVEC); fclose(fin); fclose(fout); std::wfstream decrypted_passwd(TMP_PATH, std::fstream::in | std::wfstream::out); decrypted_passwd.imbue(utf8_locale); bool ret = this->read_from_stream(decrypted_passwd); decrypted_passwd.close(); std::experimental::filesystem::remove(TMP_PATH); return ret; }
void ofxGLEditor::saveToFile() { string curPath = ofToDataPath("", false); #ifdef TARGET_OSX ofSetDataPathRoot("../../../data/scripts/"); #endif string zero = "0"; string y = ofToString(ofGetYear()); string m = ofToString(ofGetMonth()); if (m.size() == 1) m = zero+m; string d = ofToString(ofGetDay()); if (d.size() == 1) d = zero+d; string hour = ofToString(ofGetHours()); if (hour.size() == 1) hour = zero+hour; string min = ofToString(ofGetMinutes()); if (min.size() == 1) min = zero+min; string sec = ofToString(ofGetSeconds()); if (sec.size() == 1) sec = zero+sec; string ymdhms = "gamuzaScript_"+y+m+d+hour+min+sec; string en = ".lua"; #ifndef __APPLE__ string fin = "scripts/"+ymdhms+en; #else string fin = ymdhms+en; #endif string scriptPath = fin; string file = ofToDataPath(scriptPath); ofstream myfile; myfile.open(file.c_str(), _S_out); string script; for (unsigned int i = 0; i < glEditor.size(); i++) { script += wstring_to_string(glEditor[i]->GetAllText()); script += "\n"; } myfile << script; myfile.close(); #ifdef TARGET_OSX ofSetDataPathRoot(curPath); #endif cout << "script saved" << endl; }
void ofxGLEditor::saveToFile(string _name,string _path) { string curPath = ofToDataPath("", false); ofSetDataPathRoot(_path+"/"); string fin = _name; string scriptPath = fin; string file = ofToDataPath(scriptPath); ofstream myfile; myfile.open(file.c_str(), _S_out); string script; for (int i = 0; i < glEditor.size(); i++) { script += wstring_to_string(glEditor[i]->GetAllText()); script += "\n"; } myfile << script; myfile.close(); ofSetDataPathRoot(curPath); cout << "script saved" << endl; }
std::ostream & operator << (std::ostream & os, const wchar_t * str) { os << wstring_to_string(str); return os; }
/** Запись широкой строки в узкий поток */ std::ostream & operator << (std::ostream & os, const std::wstring & str) { os << wstring_to_string(str); return os; }
bool VSQLGenerator::AddString(const std::string & name, const std::wstring & text) { return this->AddString(name, wstring_to_string(text)); }
std::string wstring_to_string(std::wstring const& str) { return wstring_to_string(str.c_str(), str.size()); }
std::string wstring_to_string(wchar_t const* str) { return wstring_to_string(str, std::wcslen(str)); }
JSONObjectWrapper::Checker::operator std::string() const { return wstring_to_string(this->operator std::wstring()); }