Commit 4872dcad authored by Paul Asmuth's avatar Paul Asmuth
Browse files

switch back from std::optional to our own Option<T>

std::optional is part of C++17, which is not supported on macOS 10.13
parent 63e4fa21
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
 */
#pragma once
#include <unordered_map>
#include <optional>


#include "graphics/color.h"
#include "graphics/draw.h"
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ ReturnCode color_read_string(
ReturnCode color_read_opt(
    const Context* ctx,
    const Expr* expr,
    std::optional<Color>* color) {
    Option<Color>* color) {
  Color c;
  if (auto rc = color_read(ctx, expr, &c); !rc) {
    return rc;
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ ReturnCode color_read_string(
ReturnCode color_read_opt(
    const Context* ctx,
    const Expr* expr,
    std::optional<Color>* color);
    Option<Color>* color);

ReturnCode color_map_read(
    const Context* ctx,
+8 −8
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ struct LegendConfig {
  std::array<Measure, 4> margins;
  std::array<Measure, 4> padding;
  std::array<StrokeStyle, 4> borders;
  std::optional<Color> background;
  Option<Color> background;
  std::vector<LegendItem> items;
};

@@ -69,8 +69,8 @@ void legend_normalize(
ReturnCode legend_layout_item_rows(
    Context* ctx,
    LegendConfig* config,
    const std::optional<double> max_width,
    const std::optional<double> max_height,
    const Option<double> max_width,
    const Option<double> max_height,
    double* min_width,
    double* min_height,
    std::vector<Rectangle>* item_boxes) {
@@ -117,8 +117,8 @@ ReturnCode legend_layout_item_rows(
ReturnCode legend_layout_item_flow(
    Context* ctx,
    LegendConfig* config,
    const std::optional<double> max_width,
    const std::optional<double> max_height,
    const Option<double> max_width,
    const Option<double> max_height,
    double* min_width,
    double* min_height,
    std::vector<Rectangle>* item_boxes) {
@@ -140,7 +140,7 @@ ReturnCode legend_layout_item_flow(
      r_width += config->item_column_padding;
    }

    if (max_width && r_width + e_width > max_width) {
    if (max_width && r_width + e_width > *max_width) {
      m_height += r_height + config->item_row_padding;
      r_width = 0;
      r_height = 0;
@@ -175,8 +175,8 @@ ReturnCode legend_layout_item_flow(
ReturnCode legend_layout(
    Context* ctx,
    LegendConfig* config,
    std::optional<double> max_width,
    std::optional<double> max_height,
    Option<double> max_width,
    Option<double> max_height,
    double* min_width,
    double* min_height,
    std::vector<Rectangle>* item_boxes) {
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
 */
#pragma once
#include <unordered_map>
#include <optional>

#include <sexpr.h>
#include "return_code.h"

Loading