<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.20" xml:lang="en-US">
  <compounddef id="MetricManagerIncrementTodayCAPI_8c-example" kind="example">
    <compoundname>MetricManagerIncrementTodayCAPI.c</compoundname>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
<para>A simple example of a metric that doesn&apos;t worry about updating history, and just increments a single value in response to an action. This is for apps that do not already have a way of knowing the current value. <programlisting filename="MetricManagerIncrementTodayCAPI.c"><codeline><highlight class="preprocessor">#include<sp/>&lt;<ref refid="usermetricsinput_8h" kindref="compound">libusermetricsinput/usermetricsinput.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>main(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>argc,<sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*argv[])<sp/>{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>We<sp/>start<sp/>with<sp/>a<sp/>manager<sp/>object</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1a7352ed8164cb4dfee8f0ef9d27d3ebe1" kindref="member">UserMetricsInputMetricManager</ref><sp/>metricManager<sp/>=</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1af59e1f9c50dcc73755a7b4b07b1aba37" kindref="member">usermetricsinput_metricmanager_new</ref>();</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Create<sp/>a<sp/>parameters<sp/>object</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1a34ed483df591648eb3f3118609eae6df" kindref="member">UserMetricsInputMetricParameters</ref><sp/>parameters<sp/>=</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1af0f8d6a63b4dee377a84f47f21be7bd3" kindref="member">usermetricsinput_metricparameters_new</ref>(</highlight><highlight class="stringliteral">&quot;photo-app-photos&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Set<sp/>its<sp/>attributes</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1a07374ef2eef88fddd5bb1f5d6dcec28e" kindref="member">usermetricsinput_metricparameters_set_format_string</ref>(parameters,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;&lt;b&gt;%1&lt;/b&gt;<sp/>photos<sp/>taken<sp/>today&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1aedf61b9f47b1de80db718059ffe86319" kindref="member">usermetricsinput_metricparameters_set_empty_data_string</ref>(parameters,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;No<sp/>photos<sp/>today&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1ae7fdf9c5fe35a32f58d81876d020c052" kindref="member">usermetricsinput_metricparameters_set_text_domain</ref>(parameters,<sp/>APP_ID);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>You<sp/>can<sp/>hold<sp/>onto<sp/>this<sp/>shared<sp/>object<sp/>for<sp/>as<sp/>long<sp/>as<sp/>you<sp/>want</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1a1abb7e3afa51177792d0672b4e9769b9" kindref="member">UserMetricsInputMetric</ref><sp/>metric<sp/>=<sp/><ref refid="usermetricsinput_8h_1a1634de4e0e5490b465e8c544074cb0e8" kindref="member">usermetricsinput_metricmanager_add</ref>(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>metricManager,<sp/>parameters);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Remember<sp/>to<sp/>free<sp/>the<sp/>parameters<sp/>object<sp/>after<sp/>use</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1a1642acbf716986af38a30afbb0dbfb1a" kindref="member">usermetricsinput_metricparameters_delete</ref>(parameters);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Providing<sp/>a<sp/>blank<sp/>username<sp/>string<sp/>will<sp/>use<sp/>the<sp/>current</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>user<sp/>according<sp/>to<sp/>the<sp/>USER<sp/>environment<sp/>variable.</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1a5551501a7c1d28aa878cac0da47b7a79" kindref="member">usermetricsinput_metric_increment</ref>(metric,<sp/>1,<sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Now<sp/>we&apos;re<sp/>done<sp/>with<sp/>the<sp/>manager</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="usermetricsinput_8h_1a72fdb8f86e2b0f69b17b68309d733642" kindref="member">usermetricsinput_metricmanager_delete</ref>(metricManager);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline><highlight class="normal">}</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
</programlisting> </para>
    </detaileddescription>
  </compounddef>
</doxygen>
