// -*- mode: C++ -*-

// AUTOGENERATED BY glean_parser.  DO NOT EDIT.

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_GleanMetrics_h
#define mozilla_GleanMetrics_h

#include "mozilla/JSONStringWriteFuncs.h"
#include "mozilla/glean/bindings/MetricTypes.h"

namespace mozilla::glean {

namespace test {
  /**
   * generated from test.boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::BooleanMetric boolean_metric(1);

  /**
   * generated from test.counter_metric
   * A multi-line
   * description
   */
  constexpr impl::CounterMetric<impl::CounterType::eBaseOrLabeled> counter_metric(2);

  /**
   * generated from test.custom_distribution_metric
   * A multi-line
   * description
   */
  constexpr impl::CustomDistributionMetric custom_distribution_metric(3);

  /**
   * generated from test.labeled_boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::BooleanMetric, DynamicLabel> labeled_boolean_metric(4);

  /**
   * generated from test.labeled_boolean_metric_labels
   */
  enum class LabeledBooleanMetricLabelsLabel: uint16_t {
    eOneLabel = 0,
    eTwoLabels = 1,
    eThreeLabels = 2,
    eFourLabels = 3,
    eFiveLabels = 4,
    eSixLabels = 5,
    eSevenLabels = 6,
    eEightLabels = 7,
    eNineLabels = 8,
    eTenLabels = 9,
    e__Other__,
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::BooleanMetric, LabeledBooleanMetricLabelsLabel> labeled_boolean_metric_labels(5);

  /**
   * generated from test.labeled_counter_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::CounterMetric<impl::CounterType::eBaseOrLabeled>, DynamicLabel> labeled_counter_metric(6);

  /**
   * generated from test.labeled_counter_metric_labels
   */
  enum class LabeledCounterMetricLabelsLabel: uint16_t {
    eOneLabel = 0,
    eTwoLabels = 1,
    e__Other__,
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::CounterMetric<impl::CounterType::eBaseOrLabeled>, LabeledCounterMetricLabelsLabel> labeled_counter_metric_labels(7);

  /**
   * generated from test.labeled_string_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::StringMetric, DynamicLabel> labeled_string_metric(8);

  /**
   * generated from test.labeled_string_metric_labels
   */
  enum class LabeledStringMetricLabelsLabel: uint16_t {
    eOneLabel = 0,
    eTwoLabels = 1,
    e__Other__,
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::StringMetric, LabeledStringMetricLabelsLabel> labeled_string_metric_labels(9);

  /**
   * generated from test.memory_distribution_metric
   * A multi-line
   * description
   */
  constexpr impl::MemoryDistributionMetric memory_distribution_metric(10);

  /**
   * generated from test.string_list_metric
   * A multi-line
   * description
   */
  constexpr impl::StringListMetric string_list_metric(11);

  /**
   * generated from test.string_metric
   * A multi-line
   * description
   */
  constexpr impl::StringMetric string_metric(12);

  /**
   * generated from test.text_metric
   * A multi-line
   * description
   */
  constexpr impl::TextMetric text_metric(13);

  /**
   * generated from test.timespan_metric
   * A multi-line
   * description
   */
  constexpr impl::TimespanMetric timespan_metric(14);

  /**
   * generated from test.timing_distribution_metric
   * A multi-line
   * description
   */
  constexpr impl::TimingDistributionMetric timing_distribution_metric(15);

  /**
   * generated from test.unordered_boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::BooleanMetric unordered_boolean_metric(16);

  /**
   * generated from test.unordered_labeled_boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::BooleanMetric, DynamicLabel> unordered_labeled_boolean_metric(17);
}

namespace test_nested {
  /**
   * generated from test.nested.a_dual_labeled_counter
   * An example DLC
   */
  constexpr impl::DualLabeledCounterMetric a_dual_labeled_counter(18);

  /**
   * generated from test.nested.an_object
   */

  struct AnObjectObjectItem {
    Maybe<nsCString> colour;
    Maybe<int64_t> diameter;
    Maybe<int64_t> CamelCasedParameter;
  };

  using AnObjectObject = nsTArray<AnObjectObjectItem>;
  /**
   * An example object
   */
  constexpr impl::ObjectMetric<AnObjectObject, struct AnObjectObjectTag> an_object(19);

  /**
   * generated from test.nested.datetime_metric
   * A multi-line
   * description
   */
  constexpr impl::DatetimeMetric datetime_metric(20);

  /**
   * generated from test.nested.event_metric
   */
  /**
   * A multi-line
   * description
   */
  constexpr impl::EventMetric<NoExtraKeys> event_metric(21);

  /**
   * generated from test.nested.event_metric_with_extra
   */
  struct EventMetricWithExtraExtra {
    mozilla::Maybe<nsCString> anExtraKey;
    mozilla::Maybe<nsCString> anotherExtraKey;
    mozilla::Maybe<bool> boolExtra;
    mozilla::Maybe<uint32_t> quantityExtra;

    std::tuple<nsTArray<nsCString>, nsTArray<nsCString>> ToFfiExtra() const {
      nsTArray<nsCString> extraKeys;
      nsTArray<nsCString> extraValues;
      if (anExtraKey) {
        extraKeys.AppendElement()->AssignASCII("an_extra_key");
        extraValues.EmplaceBack(anExtraKey.value());
      }
      if (anotherExtraKey) {
        extraKeys.AppendElement()->AssignASCII("another_extra_key");
        extraValues.EmplaceBack(anotherExtraKey.value());
      }
      if (boolExtra) {
        extraKeys.AppendElement()->AssignASCII("bool_extra");
        extraValues.AppendElement()->AssignASCII(boolExtra.value() ? "true" : "false");
      }
      if (quantityExtra) {
        extraKeys.AppendElement()->AssignASCII("quantity_extra");
        extraValues.AppendElement()->AppendInt(quantityExtra.value());
      }
      return std::make_tuple(std::move(extraKeys), std::move(extraValues));
    }
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::EventMetric<EventMetricWithExtraExtra> event_metric_with_extra(22);

  /**
   * generated from test.nested.external_denominator
   * A multi-line
   * description
   */
  constexpr impl::DenominatorMetric external_denominator(23);

  /**
   * generated from test.nested.optimizable_counter_metric
   * A multi-line
   * description
   */
  constexpr impl::CounterMetric<impl::CounterType::eBaseOrLabeled> optimizable_counter_metric(24);

  /**
   * generated from test.nested.optimizable_disabled_counter_metric
   * A multi-line
   * description
   */
  constexpr impl::CounterMetric<impl::CounterType::eBaseOrLabeled> optimizable_disabled_counter_metric(25);

  /**
   * generated from test.nested.quantity_metric
   * A multi-line
   * description
   */
  constexpr impl::QuantityMetric quantity_metric(26);

  /**
   * generated from test.nested.rate_metric
   * A multi-line
   * description
   */
  constexpr impl::RateMetric rate_metric(27);

  /**
   * generated from test.nested.rate_with_external_denominator
   * A multi-line
   * description
   */
  constexpr impl::NumeratorMetric rate_with_external_denominator(28);

  /**
   * generated from test.nested.uuid_metric
   * A multi-line
   * description
   */
  constexpr impl::UuidMetric uuid_metric(29);
}

template <>
inline void impl::ObjectMetric<test_nested::AnObjectObject, test_nested::AnObjectObjectTag>::Set(const test_nested::AnObjectObject& aObj) const {
  nsCString json;
  JSONStringRefWriteFunc writeFunc(json);
  JSONWriter writer(writeFunc, JSONWriter::CollectionStyle::SingleLineStyle);

  writer.StartArrayElement();
  {
    for (const auto& aobjItem: aObj) {
      writer.StartObjectElement();
      {
        if (aobjItem.colour.isSome()) {
          writer.StringProperty("colour", *(aobjItem.colour));
        }
        if (aobjItem.diameter.isSome()) {
          writer.IntProperty("diameter", *(aobjItem.diameter));
        }
        if (aobjItem.CamelCasedParameter.isSome()) {
          writer.IntProperty("CamelCasedParameter", *(aobjItem.CamelCasedParameter));
        }
      }
      writer.EndObject();

    }
  }
  writer.EndArray();


  SetStr(json);
}

namespace test2 {
  /**
   * generated from test2.boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::BooleanMetric boolean_metric(30);

  /**
   * generated from test2.counter_metric
   * A multi-line
   * description
   */
  constexpr impl::CounterMetric<impl::CounterType::eBaseOrLabeled> counter_metric(31);

  /**
   * generated from test2.custom_distribution_metric
   * A multi-line
   * description
   */
  constexpr impl::CustomDistributionMetric custom_distribution_metric(32);

  /**
   * generated from test2.labeled_boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::BooleanMetric, DynamicLabel> labeled_boolean_metric(33);

  /**
   * generated from test2.labeled_boolean_metric_labels
   */
  enum class LabeledBooleanMetricLabelsLabel: uint16_t {
    eOneLabel = 0,
    eTwoLabels = 1,
    eThreeLabels = 2,
    eFourLabels = 3,
    eFiveLabels = 4,
    eSixLabels = 5,
    eSevenLabels = 6,
    eEightLabels = 7,
    eNineLabels = 8,
    eTenLabels = 9,
    e__Other__,
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::BooleanMetric, LabeledBooleanMetricLabelsLabel> labeled_boolean_metric_labels(34);

  /**
   * generated from test2.labeled_counter_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::CounterMetric<impl::CounterType::eBaseOrLabeled>, DynamicLabel> labeled_counter_metric(35);

  /**
   * generated from test2.labeled_counter_metric_labels
   */
  enum class LabeledCounterMetricLabelsLabel: uint16_t {
    eOneLabel = 0,
    eTwoLabels = 1,
    e__Other__,
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::CounterMetric<impl::CounterType::eBaseOrLabeled>, LabeledCounterMetricLabelsLabel> labeled_counter_metric_labels(36);

  /**
   * generated from test2.labeled_string_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::StringMetric, DynamicLabel> labeled_string_metric(37);

  /**
   * generated from test2.labeled_string_metric_labels
   */
  enum class LabeledStringMetricLabelsLabel: uint16_t {
    eOneLabel = 0,
    eTwoLabels = 1,
    e__Other__,
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::StringMetric, LabeledStringMetricLabelsLabel> labeled_string_metric_labels(38);

  /**
   * generated from test2.memory_distribution_metric
   * A multi-line
   * description
   */
  constexpr impl::MemoryDistributionMetric memory_distribution_metric(39);

  /**
   * generated from test2.string_list_metric
   * A multi-line
   * description
   */
  constexpr impl::StringListMetric string_list_metric(40);

  /**
   * generated from test2.string_metric
   * A multi-line
   * description
   */
  constexpr impl::StringMetric string_metric(41);

  /**
   * generated from test2.text_metric
   * A multi-line
   * description
   */
  constexpr impl::TextMetric text_metric(42);

  /**
   * generated from test2.timespan_metric
   * A multi-line
   * description
   */
  constexpr impl::TimespanMetric timespan_metric(43);

  /**
   * generated from test2.timing_distribution_metric
   * A multi-line
   * description
   */
  constexpr impl::TimingDistributionMetric timing_distribution_metric(44);

  /**
   * generated from test2.unordered_boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::BooleanMetric unordered_boolean_metric(45);

  /**
   * generated from test2.unordered_labeled_boolean_metric
   * A multi-line
   * description
   */
  constexpr impl::Labeled<impl::BooleanMetric, DynamicLabel> unordered_labeled_boolean_metric(46);
}

namespace test2_nested {
  /**
   * generated from test2.nested.an_object
   */

  struct AnObjectObjectItem {
    Maybe<nsCString> colour;
    Maybe<int64_t> diameter;
    Maybe<int64_t> CamelCasedParameter;
  };

  using AnObjectObject = nsTArray<AnObjectObjectItem>;
  /**
   * An example object
   */
  constexpr impl::ObjectMetric<AnObjectObject, struct AnObjectObjectTag> an_object(47);

  /**
   * generated from test2.nested.datetime_metric
   * A multi-line
   * description
   */
  constexpr impl::DatetimeMetric datetime_metric(48);

  /**
   * generated from test2.nested.event_metric
   */
  /**
   * A multi-line
   * description
   */
  constexpr impl::EventMetric<NoExtraKeys> event_metric(49);

  /**
   * generated from test2.nested.event_metric_with_extra
   */
  struct EventMetricWithExtraExtra {
    mozilla::Maybe<nsCString> anExtraKey;
    mozilla::Maybe<nsCString> anotherExtraKey;

    std::tuple<nsTArray<nsCString>, nsTArray<nsCString>> ToFfiExtra() const {
      nsTArray<nsCString> extraKeys;
      nsTArray<nsCString> extraValues;
      if (anExtraKey) {
        extraKeys.AppendElement()->AssignASCII("an_extra_key");
        extraValues.EmplaceBack(anExtraKey.value());
      }
      if (anotherExtraKey) {
        extraKeys.AppendElement()->AssignASCII("another_extra_key");
        extraValues.EmplaceBack(anotherExtraKey.value());
      }
      return std::make_tuple(std::move(extraKeys), std::move(extraValues));
    }
  };
  /**
   * A multi-line
   * description
   */
  constexpr impl::EventMetric<EventMetricWithExtraExtra> event_metric_with_extra(50);

  /**
   * generated from test2.nested.external_denominator
   * A multi-line
   * description
   */
  constexpr impl::CounterMetric<impl::CounterType::eBaseOrLabeled> external_denominator(51);

  /**
   * generated from test2.nested.optimizable_counter_metric
   * A multi-line
   * description
   */
  constexpr impl::CounterMetric<impl::CounterType::eBaseOrLabeled> optimizable_counter_metric(52);

  /**
   * generated from test2.nested.optimizable_disabled_counter_metric
   * A multi-line
   * description
   */
  constexpr impl::CounterMetric<impl::CounterType::eBaseOrLabeled> optimizable_disabled_counter_metric(53);

  /**
   * generated from test2.nested.quantity_metric
   * A multi-line
   * description
   */
  constexpr impl::QuantityMetric quantity_metric(54);

  /**
   * generated from test2.nested.rate_metric
   * A multi-line
   * description
   */
  constexpr impl::RateMetric rate_metric(55);

  /**
   * generated from test2.nested.rate_with_external_denominator
   * A multi-line
   * description
   */
  constexpr impl::NumeratorMetric rate_with_external_denominator(56);

  /**
   * generated from test2.nested.uuid_metric
   * A multi-line
   * description
   */
  constexpr impl::UuidMetric uuid_metric(57);
}

template <>
inline void impl::ObjectMetric<test2_nested::AnObjectObject, test2_nested::AnObjectObjectTag>::Set(const test2_nested::AnObjectObject& aObj) const {
  nsCString json;
  JSONStringRefWriteFunc writeFunc(json);
  JSONWriter writer(writeFunc, JSONWriter::CollectionStyle::SingleLineStyle);

  writer.StartArrayElement();
  {
    for (const auto& aobjItem: aObj) {
      writer.StartObjectElement();
      {
        if (aobjItem.colour.isSome()) {
          writer.StringProperty("colour", *(aobjItem.colour));
        }
        if (aobjItem.diameter.isSome()) {
          writer.IntProperty("diameter", *(aobjItem.diameter));
        }
        if (aobjItem.CamelCasedParameter.isSome()) {
          writer.IntProperty("CamelCasedParameter", *(aobjItem.CamelCasedParameter));
        }
      }
      writer.EndObject();

    }
  }
  writer.EndArray();


  SetStr(json);
}

} // namespace mozilla::glean

#endif // mozilla_GleanMetrics_h
