lin後綴的爲cad的線型文件.code
if(!PathFileExists(strFilePath.c_str())) { return false; } std::vector<LineStyle> vecLineStyle; MdIfStream ifs; ifs.open(strFilePath); if (!ifs.is_open()) { AfxMessageBox(MD_T("文件打開失敗!")); return vecLineStyle; } MdChar buf[1024]; while (ifs.getline(buf, sizeof(buf))) { MdString strRow = buf; while (strRow.size() > 0 && *strRow.begin() == MD_T(' ')) { strRow.erase(strRow.begin()); } if (strRow.size() > 0 && strRow[0] == MD_T('*')) { strRow.erase(strRow.begin()); int nSplit = (int)strRow.find(MD_T(",")); LineStyle lineStyle; lineStyle.strName = strRow.substr(0, nSplit); lineStyle.strDescription = strRow.substr(nSplit + 1, strRow.size() - nSplit); vecLineStyle.push_back(lineStyle); } } ifs.close(); return vecLineStyle;