Commit dce8adf2 authored by damien's avatar damien
Browse files

Making it compile with newer compilers…

parent 9bef727d
......@@ -62,121 +62,44 @@ namespace excel {
typedef std::function<void(stream&)> manipulator;
inline
xlnt::range_reference
find_cell_range(xlnt::worksheet sheet, xlnt::cell_reference pos)
{
if (sheet[pos].is_merged()) {
for (const auto& mrange: sheet.merged_ranges()) {
xlnt::range r(sheet, mrange, xlnt::major_order::column, false);
if (r.contains(pos)) {
return mrange;
}
}
}
return pos, pos;
}
find_cell_range(xlnt::worksheet sheet, xlnt::cell_reference pos);
inline
manipulator
new_worksheet(std::string name)
{
return [=] (stream& s) {
s.bookptr->create_sheet().title(name);
s.sheet = s.bookptr->sheet_by_title(name);
s.origin = s.cursor = xlnt::cell_reference("A1"); };
}
new_worksheet(std::string name);
inline
manipulator
select_worksheet(std::string name)
{
return [=] (stream& s) {
if (s.bookptr->contains(name)) {
s.sheet = s.bookptr->sheet_by_title(name);
} else {
new_worksheet(name)(s);
}
};
}
select_worksheet(std::string name);
inline
manipulator
rename_worksheet(std::string name)
{
return [=] (stream& s) { s.sheet.title(name); };
}
rename_worksheet(std::string name);
inline
manipulator
move(std::string ref)
{
return [=] (stream& s) { s.origin = s.cursor = xlnt::cell_reference(ref); };
}
move(std::string ref);
inline
manipulator
move(int row, int col)
{
return [=] (stream& s) { s.cursor = s.origin = xlnt::cell_reference("A1").make_offset(col - 1, row - 1); };
}
move(int row, int col);
inline
manipulator
moveby(int row_delta, int col_delta)
{
return [=] (stream& s) { s.cursor = s.origin = s.cursor.make_offset(col_delta, row_delta); };
}
moveby(int row_delta, int col_delta);
inline
manipulator
move(xlnt::cell_reference ref)
{
return [=] (stream& s) { s.origin = ref; s.cursor = s.origin; };
}
move(xlnt::cell_reference ref);
extern
manipulator next_col, next_row, prev_col, prev_row, set_origin, push, pop, to_origin, to_topright, to_bottomleft;
inline
manipulator
merge(int width, int height)
{
return [=] (stream& s) { s.sheet.merge_cells((s.cursor, s.cursor.make_offset(width - 1, height - 1))); };
}
merge(int width, int height);
inline
manipulator
apply_style(std::string name)
{
return [=] (stream& s) { s.sheet[s.cursor].style(name); };
}
apply_style(std::string name);
inline
manipulator
create_style(std::string name, std::function<void(xlnt::style&)> init)
{
return [=] (stream& s)
{
auto style = s.bookptr->create_style(name);
init(style);
};
}
create_style(std::string name, std::function<void(xlnt::style&)> init);
inline
manipulator
cell_format(std::function<void(xlnt::format&)> init)
{
return [=] (stream& s) {
auto cell = s.current_cell();
xlnt::format fmt = s.bookptr->create_format();
if (cell.has_format()) {
fmt = cell.format();
}
init(fmt);
cell.format(fmt);
};
}
cell_format(std::function<void(xlnt::format&)> init);
inline
void
......@@ -268,142 +191,35 @@ namespace excel {
}
inline
manipulator
border_bottom(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::bottom, c, sty);
};
}
border_bottom(xlnt::color c, xlnt::border_style sty);
inline
manipulator
border_right(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::end, c, sty);
};
}
border_right(xlnt::color c, xlnt::border_style sty);
inline
manipulator
border_top(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::top, c, sty);
};
}
border_top(xlnt::color c, xlnt::border_style sty);
inline
manipulator
border_left(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::start, c, sty);
};
}
border_left(xlnt::color c, xlnt::border_style sty);
inline
manipulator
border_box(int x1, int y1, int x2, int y2, const std::vector<std::pair<xlnt::color, xlnt::border_style>>& style)
{
return [=] (stream& s) {
xlnt::border top_, left_, right_, bottom_, tl_, tr_, bl_, br_;
xlnt::cell_reference topleft = xlnt::cell_reference("A1").make_offset(x1 - 1, y1 - 1);
xlnt::cell_reference topright = xlnt::cell_reference("A1").make_offset(x2 - 1, y1 - 1);
xlnt::cell_reference bottomleft = xlnt::cell_reference("A1").make_offset(x1 - 1, y2 - 1);
xlnt::cell_reference bottomright = xlnt::cell_reference("A1").make_offset(x2 - 1, y2 - 1);
xlnt::range_reference top_side((topleft.make_offset(1, 0), topright.make_offset(-1, 0)));
xlnt::range_reference bottom_side((bottomleft.make_offset(1, 0), bottomright.make_offset(-1, 0)));
xlnt::range_reference left_side((topleft.make_offset(0, 1), bottomleft.make_offset(0, -1)));
xlnt::range_reference right_side((topright.make_offset(0, 1), bottomright.make_offset(0, -1)));
int T, L, R, B;
switch (style.size()) {
case 1:
T = L = R = B = 0;
break;
case 2:
T = B = 0;
L = R = 1;
break;
case 4:
T = 0;
R = 1;
B = 2;
L = 3;
break;
case 0:
default:
return;
};
if (style[T].second != xlnt::border_style::none) {
top_.side(xlnt::border_side::top, xlnt::border::border_property().color(style[T].first).style(style[T].second));
tl_.side(xlnt::border_side::top, xlnt::border::border_property().color(style[T].first).style(style[T].second));
tr_.side(xlnt::border_side::top, xlnt::border::border_property().color(style[T].first).style(style[T].second));
}
if (style[R].second != xlnt::border_style::none) {
right_.side(xlnt::border_side::end, xlnt::border::border_property().color(style[R].first).style(style[R].second));
tr_.side(xlnt::border_side::end, xlnt::border::border_property().color(style[R].first).style(style[R].second));
br_.side(xlnt::border_side::end, xlnt::border::border_property().color(style[R].first).style(style[R].second));
}
if (style[B].second != xlnt::border_style::none) {
bottom_.side(xlnt::border_side::bottom, xlnt::border::border_property().color(style[B].first).style(style[B].second));
br_.side(xlnt::border_side::bottom, xlnt::border::border_property().color(style[B].first).style(style[B].second));
bl_.side(xlnt::border_side::bottom, xlnt::border::border_property().color(style[B].first).style(style[B].second));
}
if (style[L].second != xlnt::border_style::none) {
left_.side(xlnt::border_side::start, xlnt::border::border_property().color(style[L].first).style(style[L].second));
tl_.side(xlnt::border_side::start, xlnt::border::border_property().color(style[L].first).style(style[L].second));
bl_.side(xlnt::border_side::start, xlnt::border::border_property().color(style[L].first).style(style[L].second));
}
xlnt::range(s.sheet, top_side).border(top_);
xlnt::range(s.sheet, bottom_side).border(bottom_);
xlnt::range(s.sheet, left_side).border(left_);
xlnt::range(s.sheet, right_side).border(right_);
s.sheet[topleft].border(tl_);
s.sheet[topright].border(tr_);
s.sheet[bottomleft].border(bl_);
s.sheet[bottomright].border(br_);
};
}
border_box(int x1, int y1, int x2, int y2, const std::vector<std::pair<xlnt::color, xlnt::border_style>>& style);
inline
manipulator
border_box(xlnt::cell_reference c0, xlnt::cell_reference c1, const std::vector<std::pair<xlnt::color, xlnt::border_style>>& style)
{
return border_box(c0.column().index, c0.row(), c1.column().index, c1.row(), style);
}
border_box(xlnt::cell_reference c0, xlnt::cell_reference c1, const std::vector<std::pair<xlnt::color, xlnt::border_style>>& style);
inline
manipulator
style(const std::string& name, std::function<void(xlnt::style&)> init)
{
return [=](stream& s) { xlnt::style sty = s.bookptr->create_style(name); init(sty); };
}
style(const std::string& name, std::function<void(xlnt::style&)> init);
inline
manipulator
style(const std::string& name)
{
return [=](stream& s) { s.sheet[s.cursor].style(name); };
}
style(const std::string& name);
inline
manipulator
align(std::function<void(xlnt::alignment&)> init)
{
return [=](stream& s) { xlnt::alignment al; init(al); s.sheet[s.cursor].alignment(al); };
}
align(std::function<void(xlnt::alignment&)> init);
inline
manipulator
formula(const std::string& fmla)
{
return [&](stream& s) { s.sheet[s.cursor].formula(fmla); };
}
formula(const std::string& fmla);
}
......
......@@ -108,6 +108,8 @@ inline void ws_nl(file& is)
case '\r':
case '\n':
nl_ok = true;
(void)is.get();
break;
case ' ':
case '\t':
(void)is.get();
......
......@@ -409,9 +409,10 @@ struct model_block_key_struc {
}
switch (type) {
case mbk_Interaction:
if (!((*right) == (*other.right))) {
if (!((*right) == (*other.right) && (*left) == (*other.left))) {
return false;
}
break;
case mbk_Dominance:
if (!((*left) == (*other.left))) {
return false;
......@@ -507,6 +508,8 @@ private:
switch (type) {
case mbk_Interaction:
right->flatten(ret);
left->flatten(ret);
break;
case mbk_Dominance:
left->flatten(ret);
break;
......@@ -2223,6 +2226,8 @@ inline bool arg_match(std::istream& is, const model_block_key& mbk)
break;
case mbk_Interaction:
if (!arg_match(is, mbk->right)) { return false; }
if (!arg_match(is, mbk->left)) { return false; }
break;
case mbk_Dominance:
if (!arg_match(is, mbk->left)) { return false; }
break;
......@@ -2265,8 +2270,11 @@ inline void arg_write(std::ostream& os, const model_block_key& mbk)
break;
case mbk_Interaction:
arg_write(os, mbk->right);
arg_write(os, mbk->left);
break;
case mbk_Dominance:
arg_write(os, mbk->left);
break;
case mbk_CI:;
break;
case mbk_Covar:
......
......@@ -59,12 +59,12 @@ hangs_in_python(model_manager& mm)
// e.data().select(mm)
// mm.challenge_qtl("ch1", 114.96)
chromosome_value chr = NULL;
double locus;
// double locus;
for (const auto& kv: mm.search_new_best_per_chromosome(false, NULL)) {
if (kv.second.over_threshold) {
kv.second.select(mm);
chr = kv.second.chrom;
locus = kv.second.locus;
// locus = kv.second.locus;
}
}
if (chr) {
......
......@@ -30,6 +30,238 @@
#include "excel.h"
namespace excel {
xlnt::range_reference
find_cell_range(xlnt::worksheet sheet, xlnt::cell_reference pos)
{
if (sheet[pos].is_merged()) {
for (const auto& mrange: sheet.merged_ranges()) {
xlnt::range r(sheet, mrange, xlnt::major_order::column, false);
if (r.contains(pos)) {
return mrange;
}
}
}
return pos, pos;
}
manipulator
new_worksheet(std::string name)
{
return [=] (stream& s) {
s.bookptr->create_sheet().title(name);
s.sheet = s.bookptr->sheet_by_title(name);
s.origin = s.cursor = xlnt::cell_reference("A1"); };
}
manipulator
select_worksheet(std::string name)
{
return [=] (stream& s) {
if (s.bookptr->contains(name)) {
s.sheet = s.bookptr->sheet_by_title(name);
} else {
new_worksheet(name)(s);
}
};
}
manipulator
rename_worksheet(std::string name)
{
return [=] (stream& s) { s.sheet.title(name); };
}
manipulator
move(std::string ref)
{
return [=] (stream& s) { s.origin = s.cursor = xlnt::cell_reference(ref); };
}
manipulator
move(int row, int col)
{
return [=] (stream& s) { s.cursor = s.origin = xlnt::cell_reference("A1").make_offset(col - 1, row - 1); };
}
manipulator
moveby(int row_delta, int col_delta)
{
return [=] (stream& s) { s.cursor = s.origin = s.cursor.make_offset(col_delta, row_delta); };
}
manipulator
move(xlnt::cell_reference ref)
{
return [=] (stream& s) { s.origin = ref; s.cursor = s.origin; };
}
manipulator
merge(int width, int height)
{
return [=] (stream& s) { s.sheet.merge_cells((s.cursor, s.cursor.make_offset(width - 1, height - 1))); };
}
manipulator
apply_style(std::string name)
{
return [=] (stream& s) { s.sheet[s.cursor].style(name); };
}
manipulator
create_style(std::string name, std::function<void(xlnt::style&)> init)
{
return [=] (stream& s)
{
auto style = s.bookptr->create_style(name);
init(style);
};
}
manipulator
cell_format(std::function<void(xlnt::format&)> init)
{
return [=] (stream& s) {
auto cell = s.current_cell();
xlnt::format fmt = s.bookptr->create_format();
if (cell.has_format()) {
fmt = cell.format();
}
init(fmt);
cell.format(fmt);
};
}
manipulator
border_bottom(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::bottom, c, sty);
};
}
manipulator
border_right(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::end, c, sty);
};
}
manipulator
border_top(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::top, c, sty);
};
}
manipulator
border_left(xlnt::color c, xlnt::border_style sty)
{
return [=] (stream& s) {
apply_border(s, xlnt::border_side::start, c, sty);
};
}
manipulator
border_box(int x1, int y1, int x2, int y2, const std::vector<std::pair<xlnt::color, xlnt::border_style>>& style)
{
return [=] (stream& s) {
xlnt::border top_, left_, right_, bottom_, tl_, tr_, bl_, br_;
xlnt::cell_reference topleft = xlnt::cell_reference("A1").make_offset(x1 - 1, y1 - 1);
xlnt::cell_reference topright = xlnt::cell_reference("A1").make_offset(x2 - 1, y1 - 1);
xlnt::cell_reference bottomleft = xlnt::cell_reference("A1").make_offset(x1 - 1, y2 - 1);
xlnt::cell_reference bottomright = xlnt::cell_reference("A1").make_offset(x2 - 1, y2 - 1);
xlnt::range_reference top_side((topleft.make_offset(1, 0), topright.make_offset(-1, 0)));
xlnt::range_reference bottom_side((bottomleft.make_offset(1, 0), bottomright.make_offset(-1, 0)));
xlnt::range_reference left_side((topleft.make_offset(0, 1), bottomleft.make_offset(0, -1)));
xlnt::range_reference right_side((topright.make_offset(0, 1), bottomright.make_offset(0, -1)));
int T, L, R, B;
switch (style.size()) {
case 1:
T = L = R = B = 0;
break;
case 2:
T = B = 0;
L = R = 1;
break;
case 4:
T = 0;
R = 1;
B = 2;
L = 3;
break;
case 0:
default:
return;
};
if (style[T].second != xlnt::border_style::none) {
top_.side(xlnt::border_side::top, xlnt::border::border_property().color(style[T].first).style(style[T].second));
tl_.side(xlnt::border_side::top, xlnt::border::border_property().color(style[T].first).style(style[T].second));
tr_.side(xlnt::border_side::top, xlnt::border::border_property().color(style[T].first).style(style[T].second));
}
if (style[R].second != xlnt::border_style::none) {
right_.side(xlnt::border_side::end, xlnt::border::border_property().color(style[R].first).style(style[R].second));
tr_.side(xlnt::border_side::end, xlnt::border::border_property().color(style[R].first).style(style[R].second));
br_.side(xlnt::border_side::end, xlnt::border::border_property().color(style[R].first).style(style[R].second));
}
if (style[B].second != xlnt::border_style::none) {
bottom_.side(xlnt::border_side::bottom, xlnt::border::border_property().color(style[B].first).style(style[B].second));
br_.side(xlnt::border_side::bottom, xlnt::border::border_property().color(style[B].first).style(style[B].second));
bl_.side(xlnt::border_side::bottom, xlnt::border::border_property().color(style[B].first).style(style[B].second));
}
if (style[L].second != xlnt::border_style::none) {
left_.side(xlnt::border_side::start, xlnt::border::border_property().color(style[L].first).style(style[L].second));
tl_.side(xlnt::border_side::start, xlnt::border::border_property().color(style[L].first).style(style[L].second));
bl_.side(xlnt::border_side::start, xlnt::border::border_property().color(style[L].first).style(style[L].second));
}
xlnt::range(s.sheet, top_side).border(top_);
xlnt::range(s.sheet, bottom_side).border(bottom_);
xlnt::range(s.sheet, left_side).border(left_);
xlnt::range(s.sheet, right_side).border(right_);
s.sheet[topleft].border(tl_);
s.sheet[topright].border(tr_);
s.sheet[bottomleft].border(bl_);
s.sheet[bottomright].border(br_);
};
}
manipulator
border_box(xlnt::cell_reference c0, xlnt::cell_reference c1, const std::vector<std::pair<xlnt::color, xlnt::border_style>>& style)
{
return border_box(c0.column().index, c0.row(), c1.column().index, c1.row(), style);
}
manipulator
style(const std::string& name, std::function<void(xlnt::style&)> init)
{
return [=](stream& s) { xlnt::style sty = s.bookptr->create_style(name); init(sty); };
}
manipulator
style(const std::string& name)
{
return [=](stream& s) { s.sheet[s.cursor].style(name); };
}
manipulator
align(std::function<void(xlnt::alignment&)> init)
{
return [=](stream& s) { xlnt::alignment al; init(al); s.sheet[s.cursor].alignment(al); };
}
manipulator
formula(const std::string& fmla)
{
return [&](stream& s) { s.sheet[s.cursor].formula(fmla); };
}
} /* namespace excel */
excel::manipulator
excel::to_origin = [] (excel::stream& s) {
s.cursor = s.origin;
......