Some codestyle changes

This commit is contained in:
2015-06-22 15:00:54 +03:00
parent 8ead60066e
commit c830057810
5 changed files with 29 additions and 28 deletions

View File

@@ -2,6 +2,9 @@
<CodeLite_Workspace Name="CrossGen" Database=""> <CodeLite_Workspace Name="CrossGen" Database="">
<Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="Yes"/> <Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="Yes"/>
<Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="No"/> <Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="No"/>
<Environment>
<![CDATA[]]>
</Environment>
<BuildMatrix> <BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="no"> <WorkspaceConfiguration Name="Debug" Selected="no">
<Project Name="wxCrossGen" ConfigName="Debug"/> <Project Name="wxCrossGen" ConfigName="Debug"/>

View File

@@ -1,8 +1,8 @@
.PHONY: clean All .PHONY: clean All
All: All:
@echo "----------Building project:[ CrossBench - Release ]----------" @echo "----------Building project:[ wxCrossGen - Release ]----------"
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk" @cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk"
clean: clean:
@echo "----------Cleaning project:[ CrossBench - Release ]----------" @echo "----------Cleaning project:[ wxCrossGen - Release ]----------"
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean @cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean

View File

@@ -11,10 +11,9 @@ void readDict(const wxString path, DictType &dict_out){
wxTextFile f; wxTextFile f;
f.Open(path); f.Open(path);
for (wxString str = f.GetFirstLine(); !f.Eof(); str = f.GetNextLine()) { for (wxString str = f.GetFirstLine(); !f.Eof(); str = f.GetNextLine()) {
wxString key,val;
int del_ind = str.Index('-'); int del_ind = str.Index('-');
key = str.Left(del_ind-1); wxString key = str.Left(del_ind-1);
val = str.Right(str.size() - del_ind - 2); wxString val = str.Right(str.size() - del_ind - 2);
dict_out[key] = val; dict_out[key] = val;
} }
f.Close(); f.Close();
@@ -36,6 +35,7 @@ void readGrid(const wxString path, GridType &grid){
grid.at(j).at(i) = str.at(j); grid.at(j).at(i) = str.at(j);
++i; ++i;
} }
wxLogDebug(wxT("Прочитана сетка размером %d x %d"), wxLogDebug(wxT("Прочитана сетка размером %d x %d"),
static_cast<int>(grid.size()), static_cast<int>(grid.at(0).size())); static_cast<int>(grid.size()), static_cast<int>(grid.at(0).size()));
f.Close(); f.Close();
@@ -58,7 +58,6 @@ BackedCharsTransType getFromCharsTransed(const CharsTransType &char_trans){
} }
void toWorkGridType(const GridType &grid, WorkGridType &grid_out){ void toWorkGridType(const GridType &grid, WorkGridType &grid_out){
grid_out.clear();
grid_out.resize(grid.size()); grid_out.resize(grid.size());
for (size_t i = 0; i < grid.size(); ++i){ for (size_t i = 0; i < grid.size(); ++i){
grid_out.at(i).resize(grid.at(0).size()); grid_out.at(i).resize(grid.at(0).size());
@@ -81,7 +80,7 @@ void generateAllWords(const DictType &dict, AllWordsType &words_out,
TransedChar st = TRANS_BORDER + 1; TransedChar st = TRANS_BORDER + 1;
for (auto it = dict.begin(); it != dict.end(); ++it){ for (auto it = dict.begin(); it != dict.end(); ++it){
if ( words_out.size() <= it->first.size() ) if ( words_out.size() <= it->first.size() )
words_out.resize(it->first.size() + 2); words_out.resize(it->first.size() + 1);
TransedWord t_tw(it->first.size()); TransedWord t_tw(it->first.size());
for (size_t i = 0; i < it->first.size(); ++i){ for (size_t i = 0; i < it->first.size(); ++i){
auto cur_ch = it->first.at(i); auto cur_ch = it->first.at(i);
@@ -183,16 +182,16 @@ bool procCross(
TransedWord cur_word = words.at(cur_len).at((icw + rand_add) % cur_words_size); TransedWord cur_word = words.at(cur_len).at((icw + rand_add) % cur_words_size);
// Показывает, можно ли записать это слово в сетку // Показывает, можно ли записать это слово в сетку
bool can_write = true; bool can_write = true;
if ( cur_wi.direct == false ){ if ( cur_wi.direct ){
for (size_t j = 0; j < cur_wi.len; ++j)
if ((grid.at(cur_wi.x).at(j + cur_wi.y) != TRANS_CLEAR) &&
(grid.at(cur_wi.x).at(j + cur_wi.y) != cur_word.at(j)))
can_write = false;
} else {
for (size_t j = 0; j < cur_wi.len; ++j) for (size_t j = 0; j < cur_wi.len; ++j)
if ( (grid.at(cur_wi.x + j).at(cur_wi.y) != TRANS_CLEAR) && if ( (grid.at(cur_wi.x + j).at(cur_wi.y) != TRANS_CLEAR) &&
(grid.at(cur_wi.x + j).at(cur_wi.y) != cur_word.at(j)) ) (grid.at(cur_wi.x + j).at(cur_wi.y) != cur_word.at(j)) )
can_write = false; can_write = false;
} else {
for (size_t j = 0; j < cur_wi.len; ++j)
if ( (grid.at(cur_wi.x).at(j + cur_wi.y) != TRANS_CLEAR) &&
(grid.at(cur_wi.x).at(j + cur_wi.y) != cur_word.at(j)) )
can_write = false;
} }
if ( can_write ) { if ( can_write ) {
@@ -234,7 +233,6 @@ void generateCross(const GridType &grid, const AllWordsType &words,
procCross(t_used, words, grid_work, winfos, 0, words_trans_out); procCross(t_used, words, grid_work, winfos, 0, words_trans_out);
std::reverse(words_trans_out.begin(), words_trans_out.end()); std::reverse(words_trans_out.begin(), words_trans_out.end());
BackedCharsTransType bctt = getFromCharsTransed(trans_type); BackedCharsTransType bctt = getFromCharsTransed(trans_type);
words_out.clear();
words_out.resize(words_trans_out.size()); words_out.resize(words_trans_out.size());
std::transform( std::transform(
words_trans_out.begin(), words_trans_out.begin(),

View File

@@ -152,7 +152,7 @@ void MainFrame::onGenerateClick(wxCommandEvent &event) {
} }
void MainFrame::onExportClick(wxCommandEvent& event) { void MainFrame::onExportClick(wxCommandEvent& event) {
if ( _grid.size() == 0 ) { if ( _grid.empty() ) {
wxMessageBox( _("Grid isn't loaded now"), _("Info"), wxICON_INFORMATION ); wxMessageBox( _("Grid isn't loaded now"), _("Info"), wxICON_INFORMATION );
return; return;
} }
@@ -166,7 +166,7 @@ void MainFrame::onExportClick(wxCommandEvent& event) {
t_cross.ques = _ques; t_cross.ques = _ques;
generateWordInfo(_grid, t_cross.words); generateWordInfo(_grid, t_cross.words);
if ( !exportToFile(t_cross, dlgSave.GetPath()) ){ if ( !exportToFile(t_cross, dlgSave.GetPath()) ){
wxLogError(wxT("Cannot save current contents in file '%s'."), dlgSave.GetPath().GetData()); wxLogError(_("Cannot save current contents to file '%s'."), dlgSave.GetPath().GetData());
return; return;
} }
wxLogDebug(wxT("Exporting to ") + dlgSave.GetPath() + wxT(" is complete")); wxLogDebug(wxT("Exporting to ") + dlgSave.GetPath() + wxT(" is complete"));

View File

@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath := CurrentFilePath :=
CurrentFileFullPath := CurrentFileFullPath :=
User :=Aleksey Lobanov User :=Aleksey Lobanov
Date :=20/06/15 Date :=22/06/15
CodeLitePath :="/home/alex/.codelite" CodeLitePath :="/home/alex/.codelite"
LinkerName :=/usr/bin/g++-4.8 LinkerName :=/usr/bin/g++-4.8
SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC