void ImportLanguageReference() { m_lang.clear(); boost::filesystem::path binFolder; GetProgramFolder(binFolder); boost::filesystem::path path = binFolder / stringToPath(LANGREFFILE_CSV); boost::filesystem::path xml_path = binFolder / stringToPath(ReferenceFileName().GetString()); CUnicodeFile file; if (file.Open(pathToString(path).c_str())) { std::_tstring data; file.Read(data); typedef std::vector<std::_tstring> split_vector_type; split_vector_type SplitVec; boost::algorithm::split(SplitVec, data, boost::algorithm::is_any_of("\r\n"), boost::algorithm::token_compress_on); for (split_vector_type::const_iterator itr = SplitVec.begin(); itr != SplitVec.end(); ++itr) { std::_tstring line = *itr; if (line.length()) { std::vector<std::_tstring> fields; DecodeCSV(line, fields); m_lang.push_back(fields); } } } save(m_lang, xml_path.string().c_str()); }
CModFileRepository(const TCHAR* url, const TCHAR* label) : m_label(label), m_url(url) { m_path = stringToPath(url); CUnicodeFile file; if (file.Open(pathToWString(m_path).c_str())) { file.Read(m_modFile); file.Close(); } boost::algorithm::replace_all(m_modFile, _T("\r\n\r\n"), _T("\r\n \r\n")); //Hack to stop blank lines being eaten by the tokenizer. }
const TCHAR *GetText(bool refresh, bool noBroadcast = false) const { clib::recursive_mutex::scoped_lock proc(m_mutex); if (!m_eclFetched || refresh) { CUnicodeFile file; file.Open(m_path); std::_tstring ecl; file.Read(ecl); file.Close(); m_ecl = ecl.c_str(); m_eclFetched = true; } return m_ecl; }
void CBookmarksView::OnLoadFile(bool mergeFlag) { if (m_list.GetItemCount() > 0) { if (mergeFlag) { if (MessageBox(LOAD_MERGE_BOOKMARKS_MSG, _T("Warning"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) != IDYES) { return; } } else if (MessageBox(LOAD_BOOKMARKS_MSG, _T("Warning"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) != IDYES) { return; } } CUnicodeFile file; std::_tstring xmlStr; file.Open(BookmarksFilePath()); if (file.IsOpen()) { file.Read(xmlStr); file.Close(); BOOL bResult = FALSE; std::_tstring bookmarks; int index = 0; bookmarks = FindTag(xmlStr, _T("bookmarks"), index); if (index >= 0) { index = 0; int col = 0; if (!mergeFlag) { m_listMaster.DeleteAllItems(); } std::_tstring bookmark, line, type, user, lineNum, column, module, attribute, attributeType, description; while (index >= 0) { bookmark = FindTag(bookmarks, _T("bookmark"), index); if (index >= 0) { int bookmarkIndex = 0; lineNum = FindTag(bookmark, _T("line"), bookmarkIndex); type = FindTag(bookmark, _T("type"), bookmarkIndex); column = FindTag(bookmark, _T("column"), bookmarkIndex); user = FindTag(bookmark, _T("user"), bookmarkIndex); module = FindTag(bookmark, _T("module"), bookmarkIndex); attribute = FindTag(bookmark, _T("attribute"), bookmarkIndex); attributeType = FindTag(bookmark, _T("attrtype"), bookmarkIndex); description = FindTag(bookmark, _T("description"), bookmarkIndex); bool foundDupe = false; for (int i = 0; i < m_listMaster.GetItemCount(); ++i) { std::_tstring lineDupe = m_listMaster.GetItemText(i, 0); std::_tstring moduleDupe = m_listMaster.GetItemText(i, 3); std::_tstring attributeDupe = m_listMaster.GetItemText(i, 4); if (lineDupe == lineNum && moduleDupe == module && attributeDupe == attribute) { foundDupe = true; } } if (!foundDupe) { if (lineNum.length() > 0 && attribute.length() > 0 && description.length() > 0) { int row = 0; col = 0; row = m_listMaster.InsertItem(col++, lineNum.c_str()); m_listMaster.SetItemText(row, col++, type.c_str()); m_listMaster.SetItemText(row, col++, user.c_str()); m_listMaster.SetItemText(row, col++, module.c_str()); m_listMaster.SetItemText(row, col++, attribute.c_str()); m_listMaster.SetItemText(row, col++, attributeType.c_str()); m_listMaster.SetItemText(row, col++, description.c_str()); BookmarkItemData *data = new BookmarkItemData; data->marked = true; data->bookmarkType = m_listMaster.StringToType(type); data->column = boost::lexical_cast<int>(column); m_listMaster.SetItemData(row, (DWORD_PTR)data); } } } } for (int i = 0; i < col; ++i) { m_list.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER); } } DoRefresh(NULL, 0); } else { MessageBox(LOAD_UNFOUND_BOOKMARKS_MSG, _T("Warning")); } }