text:
// Author: Tassilo Kugelstadt
// License: MIT
// Source:
//   https://github.com/InteractiveComputerGraphics/Discregrid/blob/
//   6e7270eff242e87aa3f8d938da570c87e13e7761/discregrid/
//   include/Discregrid/acceleration/bounding_sphere.hpp

#ifndef MCL_BOUNDINGSPHERE_HPP
#define MCL_BOUNDINGSPHERE_HPP 1

#include <Eigen/Core>
#include <vector>

namespace mcl
{

class BoundingSphere
{
public:
    BoundingSphere() : m_x(Eigen::Vector3d::Zero()), m_r(0.0) {}

    BoundingSphere(Eigen::Vector3d const& x, double r) : m_x(x), m_r(r) {}

    BoundingSphere(const Eigen::Vector3d& a)
    {
        m_x = a;
        m_r = 0.0;
    }

    BoundingSphere(const Eigen::Vector3d& a, const Eigen::Vector3d& b)
    {
        const Eigen::Vector3d ba = b - a;
        m_x = (a + b) * 0.5;
        m_r = 0.5 * ba.norm();
    }

    BoundingSphere(const Eigen::Vector3d& a, const Eigen::Vector3d& b, const Eigen::Vector3d& c)
    {
        const Eigen::Vector3d ba = b - a;
        const Eigen::Vector3d ca = c - a;
        const Eigen::Vector3d baxca = ba.cross(ca);
        Eigen::Vector3d r;
        Eigen::Matrix3d T;
        T << ba[0], ba[1], ba[2],
        ca[0], ca[1], ca[2],
        baxca[0], baxca[1], baxca[2];
        r[0] = 0.5 * ba.squaredNorm();
        r[1] = 0.5 * ca.squaredNorm();
        r[2] = 0.0;
        m_x = T.inverse() * r;
        m_r = m_x.norm();
        m_x += a;
    }

    BoundingSphere(const Eigen::Vector3d& a, const Eigen::Vector3d& b, const Eigen::Vector3d& c, const Eigen::Vector3d& d)
    {
        const Eigen::Vector3d ba = b - a;
        const Eigen::Vector3d ca = c - a;
        const Eigen::Vector3d da = d - a;
        Eigen::Vector3d r;
        Eigen::Matrix3d T;
        T << ba[0], ba[1], ba[2],
        ca[0], ca[1], ca[2],
        da[0], da[1], da[2];
        r[0] = 0.5 * ba.squaredNorm();
        r[1] = 0.5 * ca.squaredNorm();
        r[2] = 0.5 * da.squaredNorm();
        m_x = T.inverse() * r;
        m_r = m_x.norm();
        m_x += a;
    }

    BoundingSphere(const std::vector<Eigen::Vector3d>& p)
    {
        m_r = 0;
        m_x.setZero();
        setPoints(p);
    }

    // Center
    Eigen::Vector3d const& x() const { return m_x; }
    Eigen::Vector3d& x() { return m_x; }

    // Radius
    double r() const { return m_r; }
    double& r() { return m_r; }

    void setPoints(const std::vector<Eigen::Vector3d>& p)
    {
        //remove duplicates
        std::vector<Eigen::Vector3d> v(p);
        std::sort(v.begin(), v.end(), [](const Eigen::Vector3d& a, const Eigen::Vector3d& b)
        {
            if (a[0] < b[0]) return true;
            if (a[0] > b[0]) return false;
            if (a[1] < b[1]) return true;
            if (a[1] > b[1]) return false;
            return (a[2] < b[2]);
        });
        v.erase(std::unique(v.begin(), v.end(), [](Eigen::Vector3d& a, Eigen::Vector3d& b) { return a.isApprox(b); }), v.end());

        Eigen::Vector3d d;
        const int n = int(v.size());

        //generate random permutation of the points and permute the points by epsilon to avoid corner cases
        const double epsilon = 1.0e-6;
        for (int i = n - 1; i > 0; i--)
        {
            const Eigen::Vector3d epsilon_vec = epsilon * Eigen::Vector3d::Random();
            const int j = static_cast<int>(floor(i * double(rand()) / RAND_MAX));
            d = v[i] + epsilon_vec;
            v[i] = v[j] - epsilon_vec;
            v[j] = d;
        }

        BoundingSphere S = BoundingSphere(v[0], v[1]);

        for (int i = 2; i < n; i++)
        {
            //SES0
            d = v[i] - S.x();
            if (d.squaredNorm() > S.r()* S.r())
            S = ses1(i, v, v[i]);
        }

        m_x = S.m_x;
        m_r = S.m_r + epsilon;	//add epsilon to make sure that all non-pertubated points are inside the sphere
    }

    bool overlaps(BoundingSphere const& other) const
    {
        const double rr = m_r + other.m_r;
        return (m_x - other.m_x).squaredNorm() < rr * rr;
    }

    bool contains(BoundingSphere const& other) const
    {
        const double rr = r() - other.r();
        return (x() - other.x()).squaredNorm() < rr * rr;
    }

    bool contains(Eigen::Vector3d const& other) const
    {
        return (x() - other).squaredNorm() < m_r * m_r;
    }

private:

    BoundingSphere ses3(int n, std::vector<Eigen::Vector3d>& p, Eigen::Vector3d& q1, Eigen::Vector3d& q2, Eigen::Vector3d& q3)
    {
        BoundingSphere S(q1, q2, q3);

        for (int i = 0; i < n; i++)
        {
            Eigen::Vector3d d = p[i] - S.x();
            if (d.squaredNorm() > S.r()* S.r())
            S = BoundingSphere(q1, q2, q3, p[i]);
        }
        return S;
    }

    BoundingSphere ses2(int n, std::vector<Eigen::Vector3d>& p, Eigen::Vector3d& q1, Eigen::Vector3d& q2)
    {
        BoundingSphere S(q1, q2);

        for (int i = 0; i < n; i++)
        {
            Eigen::Vector3d d = p[i] - S.x();
            if (d.squaredNorm() > S.r()* S.r())
            S = ses3(i, p, q1, q2, p[i]);
        }
        return S;
    }

    BoundingSphere ses1(int n, std::vector<Eigen::Vector3d>& p, Eigen::Vector3d& q1)
    {
        BoundingSphere S(p[0], q1);

        for (int i = 1; i < n; i++)
        {
            Eigen::Vector3d d = p[i] - S.x();
            if (d.squaredNorm() > S.r()* S.r())
            S = ses2(i, p, q1, p[i]);
        }
        return S;
    }

    Eigen::Vector3d m_x;
    double m_r;
};

} // ns mcl

#endif

max_stars_repo_name: mattoverby/mclgeom

max_issues_repo_name: mattoverby/mclgeom

max_forks_repo_name: mattoverby/mclgeom


text:
/**********************************************************************
*  Copyright (c) 2008-2014, Alliance for Sustainable Energy.
*  All rights reserved.
*
*  This library is free software; you can redistribute it and/or
*  modify it under the terms of the GNU Lesser General Public
*  License as published by the Free Software Foundation; either
*  version 2.1 of the License, or (at your option) any later version.
*
*  This library is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*  Lesser General Public License for more details.
*
*  You should have received a copy of the GNU Lesser General Public
*  License along with this library; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
**********************************************************************/

#ifndef OPENSTUDIO_RUNMANAGER_TOOLINFO_HPP__
#define OPENSTUDIO_RUNMANAGER_TOOLINFO_HPP__

#include "RunManagerAPI.hpp"

#include <string>
#include <utilities/core/Path.hpp>
#include <utilities/core/Logger.hpp>
#include <boost/regex.hpp>
#include <boost/function.hpp>
#include <algorithm>

namespace openstudio {
namespace runmanager {

  /// Utility for holding and comparing ToolVersion numbers
  class RUNMANAGER_API ToolVersion
  {
    public:
      ToolVersion();

      ToolVersion(int t_major);

      ToolVersion(int t_major, int t_minor);

      ToolVersion(int t_major, int t_minor, int t_build);

      ToolVersion(boost::optional<int> t_major, boost::optional<int> t_minor, boost::optional<int> t_build);

      /// \returns true if no part of the ToolVersion info is set
      bool empty() const;

      /// Compare for exact equality.
      /// \returns true if major, minor and build all match
      bool operator==(const ToolVersion &rhs) const;

      /// Compare less than.
      /// \returns true if any element is less than the corresponding element of rhs
      ///          or if the LHS element (major,minor,build) is not defined
      bool operator<(const ToolVersion &rhs) const;

      /// Compare the requirements to the current object
      /// For each element that "requirements" has set. If an element in requirements is not
      /// set, then any version number for that element will be accepted.
      /// \param[in] requirements requirements to check against
      /// \returns true if the object matches the requirements
      bool matches(const ToolVersion &requirements) const;

      /// Return a string reprentation of the version object
      std::string toString() const;

      static ToolVersion fromString(const std::string &);

      /// \returns the major version number
      boost::optional<int> getMajor() const;

      /// \returns the minor version number
      boost::optional<int> getMinor() const;

      /// \returns the build version number
      boost::optional<int> getBuild() const;

    private:
      /// Helper for comparing two optional values, checking to see if they are set or not
      /// \returns true if the values are equal, or if neither optional is set
      static bool optional_equal(const boost::optional<int> &lhs, const boost::optional<int> &rhs);

      /// Helper for comparing two optional values.
      /// \returns true if both are set and lhs < rhs. true if lhs is not set and rhs is set. False otherwise
      static bool optional_less_than(const boost::optional<int> &lhs, const boost::optional<int> &rhs);

      boost::optional<int> m_major;
      boost::optional<int> m_minor;
      boost::optional<int> m_build;
  };

  /// Operator overload for streaming ToolVersion to ostream
  RUNMANAGER_API std::ostream &operator<<(std::ostream &os, const ToolVersion &tv);

  /// Used for holding details about a tool binary location, including information for running the tool remotely.
  struct RUNMANAGER_API ToolInfo
  {
    /// Default constructor, not really a valid ToolInfo object
    ToolInfo()
    {
    }

    /** Create a ToolInfo object
     *  \param[in] t_name Name of tool
     *  \param[in] t_version Tool version identifier
     *  \param[in] t_localBinPath Binary location for running locally
     *  \param[in] t_remoteArchive Location of archive to upload for remote execution
     *  \param[in] t_remoteExe relative path for remote executable after tools have been extracted
     *  \param[in] t_outFileFilter Filter to use when determining which files were generated by
     *  this tool */
    ToolInfo(const std::string &t_name,
             const ToolVersion &t_version,
             const openstudio::path &t_localBinPath,
             const openstudio::path &t_remoteArchive,
             const openstudio::path &t_remoteExe,
             const boost::regex &t_outFileFilter)
      : name(t_name), version(t_version), localBinPath(t_localBinPath),
        remoteArchive(t_remoteArchive), remoteExe(t_remoteExe),
        outFileFilter(t_outFileFilter)
    {
    }

    /// Create a ToolInfo object. Useful only for locally executing jobs
    /// \param[in] t_name Name of tool
    /// \param[in] t_localBinPath Binary location for running locally
    ToolInfo(const std::string &t_name,
             const openstudio::path &t_localBinPath)
      : name(t_name), localBinPath(t_localBinPath)
    {
    }

    /// Create a ToolInfo object. Useful only for locally executing jobs
    /// \param[in] t_name Name of tool
    /// \param[in] t_version Version info
    /// \param[in] t_localBinPath Binary location for running locally
    ToolInfo(const std::string &t_name,
             const ToolVersion &t_version,
             const openstudio::path &t_localBinPath)
      : name(t_name), version(t_version), localBinPath(t_localBinPath)
    {
    }

    /// Simplist ToolInfo constructor, useful only for locally executing jobs
    /// \param[in] t_localBinPath Binary location for running locally
    ToolInfo(const openstudio::path &t_localBinPath)
      : localBinPath(t_localBinPath)
    {
    }

    /// \returns fleshed out path to remote tool extraction site
    openstudio::path remoteToolPath() const
    {
      if (remoteExe.empty() || name.empty())
      {
        throw std::runtime_error("Unable to construct remote path: remoteExe name or tool name not available");
      }

      return toPath("tools") / toPath(name) / toPath(version.toString());
    }

    /// \returns fleshed out path to remote tool executable
    openstudio::path remoteToolExePath() const
    {
      return remoteToolPath() / remoteExe;
    }

    /// \returns true if remoteExe is not empty
    bool remoteExecutable() const
    {
      return !remoteArchive.empty() && !remoteExe.empty();
    }

    bool operator<(const ToolInfo &ti) const
    {
      return name < ti.name
         || (name == ti.name && version < ti.version);
    }

    bool operator==(const ToolInfo &t_rhs) const
    {
      return name == t_rhs.name
        && version == t_rhs.version
        && localBinPath == t_rhs.localBinPath
        && remoteArchive == t_rhs.remoteArchive
        && remoteExe == t_rhs.remoteExe
        && outFileFilter == t_rhs.outFileFilter;
    }

    std::string name;
    ToolVersion version;
    openstudio::path localBinPath;
    openstudio::path remoteArchive;
    openstudio::path remoteExe;
    boost::regex outFileFilter;
  };

  /// Represents a collection of ToolInfo objects
  class RUNMANAGER_API Tools
  {
    public:
      Tools()
      {
      }

      /// Constructs a Tools object with the given vector of ToolInfo objects
      Tools(const std::vector<ToolInfo> &t_tools)
        : m_tools(t_tools)
      {}

      bool operator==(const Tools &t_rhs) const
      {
        return std::equal(m_tools.begin(), m_tools.end(), t_rhs.m_tools.begin());
      }

      /// Appends a ToolInfo object to this collection of ToolInfo objects
      void append(const ToolInfo &fi)
      {
        m_tools.push_back(fi);
      }

      /// Appends the collection of ToolInfo objects in the Tools parameters
      /// to this collection of ToolInfo objects
      void append(const Tools &f)
      {
        append(f.m_tools.begin(), f.m_tools.end());
      }

      /// Returns the collection of ToolInfo objects in this object as a vector
      std::vector<ToolInfo> tools() const
      {
        return m_tools;
      }

      /// Returns the last ToolInfo in the collection matching the given name
      ToolInfo getLastByName(const std::string &t_name) const;

      /// Returns all ToolInfo objects in the collection that match the given name
      Tools getAllByName(const std::string &t_name) const;

      /// Returns the last ToolInfo object in the collection that match the given name
      ///
      /// \sa openstudio::runmanager::ToolVersion for information on how ToolVersion
      ///                                         objects are compared
      ToolInfo getLastByVersion(const ToolVersion &t_version) const;

      /// Returns all ToolInfo objects in the collection that match the given name
      ///
      /// \sa openstudio::runmanager::ToolVersion for information on how ToolVersion
      ///                                         objects are compared
      Tools getAllByVersion(const ToolVersion &t_version) const;

      /**
       * Returns the tool with the given name and the highest version number
       */
      ToolInfo getTool(const std::string &t_name) const
      {
        Tools ts = getAllByName(t_name);
        std::sort(ts.m_tools.begin(), ts.m_tools.end(), &Tools::versionLessThan);

        if (!ts.m_tools.empty())
        {
          return *ts.m_tools.rbegin();
        } else {
          throw std::runtime_error("No tool matching: " + t_name);
        }
      }

      /**
       * Returns the tool with the given name and the highest version number
       * that matches the passed in requirements.
       */
      ToolInfo getTool(const std::string &t_name, const ToolVersion &t_requirements) const
      {
        LOG(Debug, "getTool called: " << t_name << " " << t_requirements.toString());
        LOG(Debug, "total tools: " << m_tools.size());
        Tools ts = getAllByName(t_name);
        LOG(Debug, "getAllByName returns " << ts.tools().size());

        Tools byversion = ts.getAllByVersion(t_requirements);
        LOG(Debug, "getAllByVersion returns " << byversion.tools().size());

        std::sort(byversion.m_tools.begin(), byversion.m_tools.end(), &Tools::versionLessThan);

        if (!byversion.m_tools.empty())
        {
          return *byversion.m_tools.rbegin();
        } else {
          throw std::runtime_error("No tool matching: " + t_name + " " + t_requirements.toString());
        }
      }

    private:
      REGISTER_LOGGER("openstudio.runmanager.Tools");

      static bool nameCompare(const std::string &t_name, const ToolInfo &ti)
      {
        return ti.name == t_name;
      }

      static bool versionLessThan(const ToolInfo &lhs, const ToolInfo &rhs)
      {
        return lhs.version < rhs.version;
      }

      static bool versionCompare(const ToolVersion &t_requirements, const ToolInfo &ti)
      {
        return ti.version.matches(t_requirements);
      }

      template<typename InItr>
        void append(const InItr &begin, const InItr &end)
        {
          m_tools.insert(m_tools.end(), begin, end);
        }

      ToolInfo getLast(const boost::function<bool (const ToolInfo &)> &f) const
      {
        std::vector<openstudio::runmanager::ToolInfo>::const_reverse_iterator itr
          = std::find_if(m_tools.rbegin(), m_tools.rend(), f);

        if (itr != m_tools.rend())
        {
          return *itr;
        }

        throw std::out_of_range("ToolInfo not found");
      }

      Tools getAll(const boost::function<bool (const ToolInfo &)> &f) const
      {
        std::vector<openstudio::runmanager::ToolInfo>::const_iterator itr = m_tools.begin();
        const std::vector<openstudio::runmanager::ToolInfo>::const_iterator end = m_tools.end();

        Tools ret;

        while (itr != end)
        {
          if (f(*itr))
          {
            ret.append(*itr);
          }
          ++itr;
        }

        return ret;
      }

      std::vector<ToolInfo> m_tools;
  };

} // runmanager
} // openstudio

#endif

ext: hpp

max_stars_repo_name: ORNL-BTRIC/OpenStudio

max_issues_repo_name: ORNL-BTRIC/OpenStudio

max_forks_repo_name: ORNL-BTRIC/OpenStudio


text:
/*=============================================================================
    Copyright (c) 2006 Tobias Schwinger
    http://spirit.sourceforge.net/

  Distributed under the Boost Software License, Version 1.0. (See accompanying
  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_SPIRIT_LISTS_FWD_HPP)
#define BOOST_SPIRIT_LISTS_FWD_HPP

#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/parser.hpp>

namespace boost { namespace spirit {

BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN

    struct no_list_endtoken;

    template <
        typename ItemT, typename DelimT, typename EndT = no_list_endtoken,
        typename CategoryT = plain_parser_category
    >
    struct list_parser;

BOOST_SPIRIT_CLASSIC_NAMESPACE_END

}} // namespace BOOST_SPIRIT_CLASSIC_NS

#endif

max_stars_repo_name: randolphwong/mcsema

max_issues_repo_name: randolphwong/mcsema

max_forks_repo_name: randolphwong/mcsema


text:
/*
 * OXT - OS eXtensions for boosT
 * Provides important functionality necessary for writing robust server software.
 *
 * Copyright (c) 2012 Phusion
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#ifndef _OXT_DETAIL_CONTEXT_HPP_
#define _OXT_DETAIL_CONTEXT_HPP_

#include <boost/thread/mutex.hpp>
#include <boost/shared_ptr.hpp>
#include <list>
#include <vector>
#include <string>
#include <pthread.h>
#ifdef __linux__
	#include <sys/types.h>
#endif
#include "../spin_lock.hpp"

namespace oxt {

struct thread_local_context;

typedef boost::shared_ptr<thread_local_context> thread_local_context_ptr;

struct global_context_t {
	boost::mutex next_thread_number_mutex;
	/** Thread numbering begins at 2. The main thread has number 1.
	 * A thread number of 0 is invalid. */
	unsigned int next_thread_number;

	boost::mutex thread_registration_mutex;
	std::list<thread_local_context_ptr> registered_threads;

	global_context_t();
};

struct thread_local_context {
	std::list<thread_local_context_ptr>::iterator iterator;

	pthread_t thread;
	#ifdef __linux__
		pid_t tid;
	#endif
	unsigned int thread_number;
	std::string thread_name;

	/** This lock is normally locked, but only unlocked during an oxt::sycall function,
	 * and is relocked when that function returns. One can use try_lock to find out
	 * whether the code is inside an oxt::syscall function.
	 */
	spin_lock syscall_interruption_lock;

	#ifdef OXT_BACKTRACE_IS_ENABLED
		std::vector<trace_point *> backtrace_list;
		spin_lock backtrace_lock;
	#endif

	static thread_local_context_ptr make_shared_ptr();

	thread_local_context();
};

void set_thread_local_context(const thread_local_context_ptr &ctx);
thread_local_context *get_thread_local_context();

} // namespace oxt

#endif /* _OXT_DETAIL_CONTEXT_HPP_ */

max_stars_repo_name: tqrg-bot/passenger

max_issues_repo_name: gnoling/passenger

max_forks_repo_name: gnoling/passenger


text:
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
#define EPSILON 0.0000001
#include <typeindex>
#include <typeinfo>
#include <vector>

#include "gen-cpp/DoubleConstantsTest_constants.h"
using namespace thrift::test;

#define BOOST_TEST_MODULE RenderedDoubleConstantsTest
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(RenderedDoubleConstantsTest)

BOOST_AUTO_TEST_CASE(test_rendered_double_constants) {
    const double EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT = 1.0;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT = -100.0;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT = 9223372036854775807.0;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT = -9223372036854775807.0;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS = 3.14159265359;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE = 1000000.1;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE = -1000000.1;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE = 1.7e+308;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE = 9223372036854775816.43;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE = -1.7e+308;
    const double EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE = -9223372036854775816.43;
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE, EPSILON);
    BOOST_CHECK_CLOSE(
        g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST,
        EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE, EPSILON);
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_INT_CONSTANT_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_INT_CONSTANT).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_INT_CONSTANT).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_LARGEST_INT_CONSTANT).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_SMALLEST_INT_CONSTANT).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_DOUBLE_WITH_MANY_DECIMALS).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_FRACTIONAL_DOUBLE).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_FRACTIONAL_DOUBLE).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_LARGE_DOUBLE_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_DOUBLE).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_LARGE_FRACTIONAL_DOUBLE).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_SMALL_DOUBLE_TEST).hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_SMALL_DOUBLE).hash_code());
    BOOST_CHECK(
        typeid(g_DoubleConstantsTest_constants.DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE_TEST)
            .hash_code() ==
        typeid(EXPECTED_DOUBLE_ASSIGNED_TO_NEGATIVE_BUT_LARGE_FRACTIONAL_DOUBLE).hash_code());
}

BOOST_AUTO_TEST_CASE(test_rendered_double_list) {
    const std::vector<double> EXPECTED_DOUBLE_LIST{1.0,-100.0,100.0,9223372036854775807.0,-9223372036854775807.0,
        3.14159265359,1000000.1,-1000000.1,1.7e+308,-1.7e+308,9223372036854775816.43,-9223372036854775816.43};
    BOOST_CHECK_EQUAL(g_DoubleConstantsTest_constants.DOUBLE_LIST_TEST.size(), EXPECTED_DOUBLE_LIST.size());
    for (unsigned int i = 0; i < EXPECTED_DOUBLE_LIST.size(); ++i) {
        BOOST_CHECK_CLOSE(g_DoubleConstantsTest_constants.DOUBLE_LIST_TEST[i], EXPECTED_DOUBLE_LIST[i], EPSILON);
    }
}

BOOST_AUTO_TEST_SUITE_END()

ext: cpp


text:
#include "Segmentation.hpp"
#include "Neighbourhood.hpp"
#include "Plots.hpp"
#include <Slimage/Convert.hpp>
#include <boost/graph/property_iter_range.hpp>

namespace dasp
{

slimage::Image1ub CreateBoundaryImageFromLabels(const Superpixels& clustering, const graphseg::GraphLabeling& labeling)
{
	// create segment labeling
	slimage::Image1i labels(clustering.width(), clustering.height(), slimage::Pixel1i{-1});
	clustering.ForPixelClusters([&labeling,&labels](unsigned int cid, const dasp::Cluster& c, unsigned int pid, const dasp::Point& p) {
		labels[pid] = labeling.labels[cid];
	});
	// plot segment boundaries
	slimage::Image1ub boundaries_wt = slimage::Image1ub(clustering.width(), clustering.height(), slimage::Pixel1ub{0});
	dasp::plots::PlotEdges(boundaries_wt, labels, slimage::Pixel1ub{255}, 1);
	return boundaries_wt;
}

std::vector<slimage::Pixel3ub> ComputeSegmentColors(const Superpixels& clusters, const graphseg::GraphLabeling& labeling)
{
//	return plots::CreateRandomColors(segment_count);
	struct Pair { Eigen::Vector3f val; unsigned int cnt; };
	std::vector<Pair> segment_center_sum(labeling.num_labels);
	for(unsigned int i=0; i<labeling.labels.size(); i++) {
		Pair& p = segment_center_sum[labeling.labels[i]];
		p.val += clusters.cluster[i].center.color;
		p.cnt ++;
	}
	std::vector<slimage::Pixel3ub> colors(labeling.num_labels);
	for(unsigned int i=0; i<colors.size(); i++) {
		Eigen::Vector3f c = segment_center_sum[i].val / static_cast<float>(segment_center_sum[i].cnt);
		c = clusters.ColorToRGB(c);
		slimage::conversion::Convert(slimage::Pixel3f{{c[0],c[1],c[2]}}, colors[i]);
	}
	return colors;
}

slimage::Image3ub CreateLabelImage(const Superpixels& clusters, const graphseg::GraphLabeling& labeling, const std::vector<slimage::Pixel3ub>& colors)
{
	slimage::Image3ub vis_img(clusters.width(), clusters.height(), slimage::Pixel3ub{{0,0,0}});
	clusters.ForPixelClusters([&labeling,&vis_img,&colors](unsigned int cid, const dasp::Cluster& c, unsigned int pid, const dasp::Point& p) {
		vis_img[pid] = colors[labeling.labels[cid]];
	});
	return vis_img;
}

}

max_stars_repo_name: jbellis/superpixel-benchmark

max_issues_repo_name: jbellis/superpixel-benchmark

max_forks_repo_name: jbellis/superpixel-benchmark


text:
#include <iostream>
#include <complex>
#include <cmath>
#include <Eigen/Dense>
#include "mex.h"

const std::complex<double> i1(0.0, 1.0);
typedef Eigen::Matrix<double, 2, 3> Matrix2x3d;

Eigen::Matrix3cd T;
Eigen::Vector3cd aux_states(0, 0, 0);
Eigen::Matrix3d F;
Eigen::Matrix3d V;
Matrix2x3d J;
std::complex<double> dmdT1;
std::complex<double> dmdT2;
std::complex<double> dmdM0;

void update_T(double a, double p)
{
    T(0,0) = pow(cos(a/2),2);
    T(0,1) = pow(sin(a/2),2)*(cos(2*p)+1.0*i1*sin(2*p));
    T(0,2) = sin(a)*(sin(p)-1.0*i1*cos(p));
    T(1,0) = std::conj(T(0,1));
    T(1,1) = T(0,0);
    T(1,2) = std::conj(T(0,2));
    T(2,0) = -0.5*sin(a)*(sin(p)+1.0*i1*cos(p));
    T(2,1) = std::conj(T(2,0));
    T(2,2) = cos(a);
}

void add2FIM()
{
    J(0,0) = dmdT1.real();
    J(1,0) = dmdT1.imag();
    J(0,1) = dmdT2.real();
    J(1,1) = dmdT2.imag();
    J(0,2) = dmdM0.real();
    J(1,2) = dmdM0.imag();
    F     += J.transpose() * J;
}

void EPG_GRE_efficiency(double *f, double *N, double *FA, double *RF, double *TR, double *TE, double *T1, double *T2)
{
    int n = (int) N[0];

    //max order of EPG simulation
    int KMAX = n;
    if(n>25){KMAX = 25;}

    ///// MEMORY ALLOCATION
    double E1;
    double E2;
    double E2_TE;
    double dEdT1;
    double dEdT2;
    double dEdT2_TE;
    double Tacq = 0.0;

    // fisher information matrix
    F.setZero();

    // signal vectors
    Eigen::VectorXcd Fplus(KMAX);
    Fplus.setZero();
    Eigen::VectorXcd Fminus(KMAX);
    Fminus.setZero();
    Eigen::VectorXcd Z(KMAX);
    Z.setZero();
    Eigen::VectorXcd prev_Fplus(KMAX);
    prev_Fplus.setZero();
    Eigen::VectorXcd prev_Fminus(KMAX);
    prev_Fminus.setZero();
    Eigen::VectorXcd prev_Z(KMAX);
    prev_Z.setZero();

    // for CRLB calculation
    Eigen::VectorXcd Fplus_dOdT1(KMAX);
    Fplus_dOdT1.setZero();
    Eigen::VectorXcd Fminus_dOdT1(KMAX);
    Fminus_dOdT1.setZero();
    Eigen::VectorXcd Z_dOdT1(KMAX);
    Z_dOdT1.setZero();
    Eigen::VectorXcd prev_Fplus_dOdT1(KMAX);
    prev_Fplus_dOdT1.setZero();
    Eigen::VectorXcd prev_Fminus_dOdT1(KMAX);
    prev_Fminus_dOdT1.setZero();
    Eigen::VectorXcd prev_Z_dOdT1(KMAX);
    prev_Z_dOdT1.setZero();

    Eigen::VectorXcd Fplus_dOdT2(KMAX);
    Fplus_dOdT2.setZero();
    Eigen::VectorXcd Fminus_dOdT2(KMAX);
    Fminus_dOdT2.setZero();
    Eigen::VectorXcd Z_dOdT2(KMAX);
    Z_dOdT2.setZero();
    Eigen::VectorXcd prev_Fplus_dOdT2(KMAX);
    prev_Fplus_dOdT2.setZero();
    Eigen::VectorXcd prev_Fminus_dOdT2(KMAX);
    prev_Fminus_dOdT2.setZero();
    Eigen::VectorXcd prev_Z_dOdT2(KMAX);
    prev_Z_dOdT2.setZero();

    Eigen::VectorXcd Fplus_dOdM0(KMAX);
    Fplus_dOdM0.setZero();
    Eigen::VectorXcd Fminus_dOdM0(KMAX);
    Fminus_dOdM0.setZero();
    Eigen::VectorXcd Z_dOdM0(KMAX);
    Z_dOdM0.setZero();
    Eigen::VectorXcd prev_Fplus_dOdM0(KMAX);
    prev_Fplus_dOdM0.setZero();
    Eigen::VectorXcd prev_Fminus_dOdM0(KMAX);
    prev_Fminus_dOdM0.setZero();
    Eigen::VectorXcd prev_Z_dOdM0(KMAX);
    prev_Z_dOdM0.setZero();

    /////CRLB SIMULATION
    Z(0)       = 1.0 + 0.0*i1;
    Z_dOdM0(0) = 1.0 + 0.0*i1;

    //simulate the sequence
    for (int j=0; j<n; j++){

        E1       = exp(-TR[j] / T1[0]);
        E2       = exp(-TR[j] / T2[0]);
        E2_TE    = exp(-TE[j] / T2[0]);
        dEdT1    = TR[j] * E1 / pow(T1[0],2);
        dEdT2    = TR[j] * E2 / pow(T2[0],2);
        dEdT2_TE = TE[j] * E2_TE / pow(T2[0],2);
        Tacq    += TR[j]*1e-3;

        //apply T
        update_T(FA[j], RF[j]);
    	for (int k=0; k<(std::min(KMAX,j+1)); k++)
    	{
    		aux_states(0) = Fplus(k);
    		aux_states(1) = Fminus(k);
    		aux_states(2) = Z(k);
    		aux_states    = T * aux_states;

    		prev_Fplus(k)  = aux_states(0);
    		prev_Fminus(k) = aux_states(1);
    		prev_Z(k)      = aux_states(2);

            //T1
            aux_states(0) = Fplus_dOdT1(k);
  		    aux_states(1) = Fminus_dOdT1(k);
   		    aux_states(2) = Z_dOdT1(k);
   		    aux_states    = T * aux_states;

   		    prev_Fplus_dOdT1(k)  = aux_states(0);
   		    prev_Fminus_dOdT1(k) = aux_states(1);
   		    prev_Z_dOdT1(k)      = aux_states(2);

            //T2
            aux_states(0) = Fplus_dOdT2(k);
  		    aux_states(1) = Fminus_dOdT2(k);
   		    aux_states(2) = Z_dOdT2(k);
   		    aux_states    = T * aux_states;

   		    prev_Fplus_dOdT2(k)  = aux_states(0);
   		    prev_Fminus_dOdT2(k) = aux_states(1);
   		    prev_Z_dOdT2(k)      = aux_states(2);

            //M0
            aux_states(0) = Fplus_dOdM0(k);
  		    aux_states(1) = Fminus_dOdM0(k);
   		    aux_states(2) = Z_dOdM0(k);
   		    aux_states    = T * aux_states;

   		    prev_Fplus_dOdM0(k)  = aux_states(0);
   		    prev_Fminus_dOdM0(k) = aux_states(1);
   		    prev_Z_dOdM0(k)      = aux_states(2);
    	}

        //CRLB calculation
        dmdT1 = E2_TE * prev_Fminus_dOdT1(0);
        dmdT2 = dEdT2_TE * prev_Fminus(0) + E2_TE * prev_Fminus_dOdT2(0);
        dmdM0 = E2_TE * prev_Fminus_dOdM0(0);
        add2FIM();

	    //apply E
    	for (int k=0; k<(std::min(j+1,KMAX)); k++)
    	{
    		Fplus(k)  = prev_Fplus(k) * E2;
    		Fminus(k) = prev_Fminus(k) * E2;
    		Z(k)      = prev_Z(k) * E1;

            Fplus_dOdT1(k)  = prev_Fplus_dOdT1(k) * E2;
            Fminus_dOdT1(k) = prev_Fminus_dOdT1(k) * E2;
            Z_dOdT1(k)      = prev_Z(k) * dEdT1 + prev_Z_dOdT1(k) * E1;

            Fplus_dOdT2(k)  = prev_Fplus_dOdT2(k) * E2 + prev_Fplus(k) * dEdT2;
            Fminus_dOdT2(k) = prev_Fminus_dOdT2(k) * E2 + prev_Fminus(k) * dEdT2;
            Z_dOdT2(k)      = prev_Z_dOdT2(k) * E1;

            Fplus_dOdM0(k)  = prev_Fplus_dOdM0(k) * E2;
            Fminus_dOdM0(k) = prev_Fminus_dOdM0(k) * E2;
            Z_dOdM0(k)      = prev_Z_dOdM0(k) * E1;
       	}
    	Z(0)       += 1.0 - E1;
        Z_dOdT1(0) -= dEdT1;
        Z_dOdM0(0) += 1.0 - E1;

    	//apply S
    	for (int k=(std::min(KMAX-1,j+1)); k>0; k--)
        {
            Fplus(k)       = Fplus(k-1);
            Fplus_dOdT1(k) = Fplus_dOdT1(k-1);
            Fplus_dOdT2(k) = Fplus_dOdT2(k-1);
            Fplus_dOdM0(k) = Fplus_dOdM0(k-1);
        }
    	Fplus(0)       = std::conj(Fminus(1));
        Fplus_dOdT1(0) = std::conj(Fminus_dOdT1(1));
        Fplus_dOdT2(0) = std::conj(Fminus_dOdT2(1));
        Fplus_dOdM0(0) = std::conj(Fminus_dOdM0(1));
    	for (int k=0; k<(std::min(KMAX-1,j)); k++)
        {
            Fminus(k)       = Fminus(k+1);
            Fminus_dOdT1(k) = Fminus_dOdT1(k+1);
            Fminus_dOdT2(k) = Fminus_dOdT2(k+1);
            Fminus_dOdM0(k) = Fminus_dOdM0(k+1);

        }
    	Fminus(std::min(KMAX-1,j))       = 0.0 + 0.0*i1;
		Fminus_dOdT1(std::min(KMAX-1,j)) = 0.0 + 0.0*i1;
        Fminus_dOdT2(std::min(KMAX-1,j)) = 0.0 + 0.0*i1;
		Fminus_dOdM0(std::min(KMAX-1,j)) = 0.0 + 0.0*i1;
    }

    V = F.inverse();

    double sq_eta_T1 = pow(T1[0],2.0) / (V(0,0) * Tacq);
    double sq_eta_T2 = pow(T2[0],2.0) / (V(1,1) * Tacq);

    if(sq_eta_T1>1e6 || sq_eta_T2>1e6 || sq_eta_T1<0 || sq_eta_T2<0){
        f[0] = 1e6;
    }
    else{
        f[0] = 1.0/sq_eta_T1 + 1.0/sq_eta_T2;
    }

}

void mexFunction(int nlhs, mxArray *plhs[], int rhs, const mxArray *prhs[])
{
    /* Declare arrays necessary to compute signals */
    double *N;
    double *FA;
    double *RF;
    double *TR;
    double *TE;
    double *T1;
    double *T2;

    double *f;

    /* Check for proper number of arguments */

    /* Create pointers to the inputs */
    N  = mxGetPr(prhs[0]);
    FA = mxGetPr(prhs[1]);
    RF = mxGetPr(prhs[2]);
    TR = mxGetPr(prhs[3]);
    TE = mxGetPr(prhs[4]);
    T1 = mxGetPr(prhs[5]);
    T2 = mxGetPr(prhs[6]);

    /* Create pointers to the outputs */
    plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);

    // Check this link to see how to return complex arrays:
    // http://matlab.izmiran.ru/help/techdoc/matlab_external/ch04cre9.html
    f = mxGetPr(plhs[0]);

    /* Call the computational routine */
    EPG_GRE_efficiency(f, N, FA, RF, TR, TE, T1, T2);

}


text:
// This file is auto-generated, don't edit it. Thanks.

#include <alibabacloud/cloudauth_20190307.hpp>
#include <alibabacloud/endpoint_util.hpp>
#include <alibabacloud/open_platform_20191219.hpp>
#include <alibabacloud/oss.hpp>
#include <alibabacloud/ossutil.hpp>
#include <alibabacloud/rpc.hpp>
#include <alibabacloud/rpcutil.hpp>
#include <boost/any.hpp>
#include <boost/throw_exception.hpp>
#include <darabonba/core.hpp>
#include <darabonba/file_form.hpp>
#include <darabonba/util.hpp>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

using namespace Alibabacloud_Cloudauth20190307;

Alibabacloud_Cloudauth20190307::Client::Client(const shared_ptr<Alibabacloud_RPC::Config>& config) : Alibabacloud_RPC::Client(config) {
  _endpointRule = make_shared<string>("central");
  checkConfig(config);
  _endpoint = make_shared<string>(getEndpoint(make_shared<string>("cloudauth"), _regionId, _endpointRule, _network, _suffix, _endpointMap, _endpoint));
};

DescribeWhitelistSettingResponse Alibabacloud_Cloudauth20190307::Client::describeWhitelistSetting(shared_ptr<DescribeWhitelistSettingRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeWhitelistSettingResponse(doRequest(make_shared<string>("DescribeWhitelistSetting"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeWhitelistSettingResponse Alibabacloud_Cloudauth20190307::Client::describeWhitelistSettingSimply(shared_ptr<DescribeWhitelistSettingRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeWhitelistSetting(request, runtime);
}

DeleteWhitelistSettingResponse Alibabacloud_Cloudauth20190307::Client::deleteWhitelistSetting(shared_ptr<DeleteWhitelistSettingRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DeleteWhitelistSettingResponse(doRequest(make_shared<string>("DeleteWhitelistSetting"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DeleteWhitelistSettingResponse Alibabacloud_Cloudauth20190307::Client::deleteWhitelistSettingSimply(shared_ptr<DeleteWhitelistSettingRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return deleteWhitelistSetting(request, runtime);
}

CreateWhitelistSettingResponse Alibabacloud_Cloudauth20190307::Client::createWhitelistSetting(shared_ptr<CreateWhitelistSettingRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CreateWhitelistSettingResponse(doRequest(make_shared<string>("CreateWhitelistSetting"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CreateWhitelistSettingResponse Alibabacloud_Cloudauth20190307::Client::createWhitelistSettingSimply(shared_ptr<CreateWhitelistSettingRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createWhitelistSetting(request, runtime);
}

DescribeWhitelistResponse Alibabacloud_Cloudauth20190307::Client::describeWhitelist(shared_ptr<DescribeWhitelistRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeWhitelistResponse(doRequest(make_shared<string>("DescribeWhitelist"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeWhitelistResponse Alibabacloud_Cloudauth20190307::Client::describeWhitelistSimply(shared_ptr<DescribeWhitelistRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeWhitelist(request, runtime);
}

DeleteWhitelistResponse Alibabacloud_Cloudauth20190307::Client::deleteWhitelist(shared_ptr<DeleteWhitelistRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DeleteWhitelistResponse(doRequest(make_shared<string>("DeleteWhitelist"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DeleteWhitelistResponse Alibabacloud_Cloudauth20190307::Client::deleteWhitelistSimply(shared_ptr<DeleteWhitelistRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return deleteWhitelist(request, runtime);
}

CreateWhitelistResponse Alibabacloud_Cloudauth20190307::Client::createWhitelist(shared_ptr<CreateWhitelistRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CreateWhitelistResponse(doRequest(make_shared<string>("CreateWhitelist"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CreateWhitelistResponse Alibabacloud_Cloudauth20190307::Client::createWhitelistSimply(shared_ptr<CreateWhitelistRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createWhitelist(request, runtime);
}

DescribeFaceConfigResponse Alibabacloud_Cloudauth20190307::Client::describeFaceConfig(shared_ptr<DescribeFaceConfigRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeFaceConfigResponse(doRequest(make_shared<string>("DescribeFaceConfig"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeFaceConfigResponse Alibabacloud_Cloudauth20190307::Client::describeFaceConfigSimply(shared_ptr<DescribeFaceConfigRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeFaceConfig(request, runtime);
}

UpdateFaceConfigResponse Alibabacloud_Cloudauth20190307::Client::updateFaceConfig(shared_ptr<UpdateFaceConfigRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return UpdateFaceConfigResponse(doRequest(make_shared<string>("UpdateFaceConfig"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

UpdateFaceConfigResponse Alibabacloud_Cloudauth20190307::Client::updateFaceConfigSimply(shared_ptr<UpdateFaceConfigRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return updateFaceConfig(request, runtime);
}

CreateFaceConfigResponse Alibabacloud_Cloudauth20190307::Client::createFaceConfig(shared_ptr<CreateFaceConfigRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CreateFaceConfigResponse(doRequest(make_shared<string>("CreateFaceConfig"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CreateFaceConfigResponse Alibabacloud_Cloudauth20190307::Client::createFaceConfigSimply(shared_ptr<CreateFaceConfigRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createFaceConfig(request, runtime);
}

LivenessFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::livenessFaceVerify(shared_ptr<LivenessFaceVerifyRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return LivenessFaceVerifyResponse(doRequest(make_shared<string>("LivenessFaceVerify"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

LivenessFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::livenessFaceVerifySimply(shared_ptr<LivenessFaceVerifyRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return livenessFaceVerify(request, runtime);
}

CompareFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::compareFaceVerify(shared_ptr<CompareFaceVerifyRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CompareFaceVerifyResponse(doRequest(make_shared<string>("CompareFaceVerify"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CompareFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::compareFaceVerifySimply(shared_ptr<CompareFaceVerifyRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return compareFaceVerify(request, runtime);
}

DescribeSdkUrlResponse Alibabacloud_Cloudauth20190307::Client::describeSdkUrl(shared_ptr<DescribeSdkUrlRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeSdkUrlResponse(doRequest(make_shared<string>("DescribeSdkUrl"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeSdkUrlResponse Alibabacloud_Cloudauth20190307::Client::describeSdkUrlSimply(shared_ptr<DescribeSdkUrlRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeSdkUrl(request, runtime);
}

DescribeUpdatePackageResultResponse Alibabacloud_Cloudauth20190307::Client::describeUpdatePackageResult(shared_ptr<DescribeUpdatePackageResultRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeUpdatePackageResultResponse(doRequest(make_shared<string>("DescribeUpdatePackageResult"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeUpdatePackageResultResponse Alibabacloud_Cloudauth20190307::Client::describeUpdatePackageResultSimply(shared_ptr<DescribeUpdatePackageResultRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeUpdatePackageResult(request, runtime);
}

UpdateAppPackageResponse Alibabacloud_Cloudauth20190307::Client::updateAppPackage(shared_ptr<UpdateAppPackageRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return UpdateAppPackageResponse(doRequest(make_shared<string>("UpdateAppPackage"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

UpdateAppPackageResponse Alibabacloud_Cloudauth20190307::Client::updateAppPackageSimply(shared_ptr<UpdateAppPackageRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return updateAppPackage(request, runtime);
}

DescribeAppInfoResponse Alibabacloud_Cloudauth20190307::Client::describeAppInfo(shared_ptr<DescribeAppInfoRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeAppInfoResponse(doRequest(make_shared<string>("DescribeAppInfo"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeAppInfoResponse Alibabacloud_Cloudauth20190307::Client::describeAppInfoSimply(shared_ptr<DescribeAppInfoRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeAppInfo(request, runtime);
}

ContrastFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::contrastFaceVerify(shared_ptr<ContrastFaceVerifyRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return ContrastFaceVerifyResponse(doRequest(make_shared<string>("ContrastFaceVerify"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

ContrastFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::contrastFaceVerifySimply(shared_ptr<ContrastFaceVerifyRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return contrastFaceVerify(request, runtime);
}

ContrastFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::contrastFaceVerifyAdvance(shared_ptr<ContrastFaceVerifyAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  // Step 0: init client
  shared_ptr<string> accessKeyId = make_shared<string>(_credential->getAccessKeyId());
  shared_ptr<string> accessKeySecret = make_shared<string>(_credential->getAccessKeySecret());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  shared_ptr<string> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  if (Darabonba_Util::Client::isUnset<string>(openPlatformEndpoint)) {
    openPlatformEndpoint = make_shared<string>("openplatform.aliyuncs.com");
  }
  if (Darabonba_Util::Client::isUnset<string>(credentialType)) {
    credentialType = make_shared<string>("access_key");
  }
  shared_ptr<Alibabacloud_RPC::Config> authConfig = make_shared<Alibabacloud_RPC::Config>(map<string, boost::any>({
    {"accessKeyId", !accessKeyId ? boost::any() : boost::any(*accessKeyId)},
    {"accessKeySecret", !accessKeySecret ? boost::any() : boost::any(*accessKeySecret)},
    {"securityToken", !securityToken ? boost::any() : boost::any(*securityToken)},
    {"type", !credentialType ? boost::any() : boost::any(*credentialType)},
    {"endpoint", !openPlatformEndpoint ? boost::any() : boost::any(*openPlatformEndpoint)},
    {"protocol", !_protocol ? boost::any() : boost::any(*_protocol)},
    {"regionId", !_regionId ? boost::any() : boost::any(*_regionId)}
  }));
  shared_ptr<Alibabacloud_OpenPlatform20191219::Client> authClient = make_shared<Alibabacloud_OpenPlatform20191219::Client>(authConfig);
  shared_ptr<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadRequest> authRequest = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadRequest>(map<string, boost::any>({
    {"product", boost::any(string("Cloudauth"))},
    {"regionId", !_regionId ? boost::any() : boost::any(*_regionId)}
  }));
  shared_ptr<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse> authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>();
  shared_ptr<Alibabacloud_OSS::Config> ossConfig = make_shared<Alibabacloud_OSS::Config>(map<string, boost::any>({
    {"accessKeySecret", !accessKeySecret ? boost::any() : boost::any(*accessKeySecret)},
    {"type", boost::any(string("access_key"))},
    {"protocol", !_protocol ? boost::any() : boost::any(*_protocol)},
    {"regionId", !_regionId ? boost::any() : boost::any(*_regionId)}
  }));
  shared_ptr<Alibabacloud_OSS::Client> ossClient;
  shared_ptr<Darabonba_FileForm::FileField> fileObj = make_shared<Darabonba_FileForm::FileField>();
  shared_ptr<Alibabacloud_OSS::PostObjectRequestHeader> ossHeader = make_shared<Alibabacloud_OSS::PostObjectRequestHeader>();
  shared_ptr<Alibabacloud_OSS::PostObjectRequest> uploadRequest = make_shared<Alibabacloud_OSS::PostObjectRequest>();
  shared_ptr<Alibabacloud_OSSUtil::RuntimeOptions> ossRuntime = make_shared<Alibabacloud_OSSUtil::RuntimeOptions>();
  Alibabacloud_RPCUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<ContrastFaceVerifyRequest> contrastFaceVerifyReq = make_shared<ContrastFaceVerifyRequest>();
  Alibabacloud_RPCUtil::Client::convert(request, contrastFaceVerifyReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->faceContrastFileObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_RPCUtil::Client::getEndpoint(authResponse->endpoint, authResponse->useAccelerate, _endpointType));
    ossClient = make_shared<Alibabacloud_OSS::Client>(ossConfig);
    fileObj = make_shared<Darabonba_FileForm::FileField>(map<string, boost::any>({
      {"filename", !authResponse->objectKey ? boost::any() : boost::any(*authResponse->objectKey)},
      {"content", !request->faceContrastFileObject ? boost::any() : boost::any(*request->faceContrastFileObject)},
      {"contentType", boost::any(string(""))}
    }));
    ossHeader = make_shared<Alibabacloud_OSS::PostObjectRequestHeader>(map<string, boost::any>({
      {"accessKeyId", !authResponse->accessKeyId ? boost::any() : boost::any(*authResponse->accessKeyId)},
      {"policy", !authResponse->encodedPolicy ? boost::any() : boost::any(*authResponse->encodedPolicy)},
      {"signature", !authResponse->signature ? boost::any() : boost::any(*authResponse->signature)},
      {"key", !authResponse->objectKey ? boost::any() : boost::any(*authResponse->objectKey)},
      {"file", !fileObj ? boost::any() : boost::any(*fileObj)},
      {"successActionStatus", boost::any(string("201"))}
    }));
    uploadRequest = make_shared<Alibabacloud_OSS::PostObjectRequest>(map<string, boost::any>({
      {"bucketName", !authResponse->bucket ? boost::any() : boost::any(*authResponse->bucket)},
      {"header", !ossHeader ? boost::any() : boost::any(*ossHeader)}
    }));
    ossClient->postObject(uploadRequest, ossRuntime);
    contrastFaceVerifyReq->faceContrastFile = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<ContrastFaceVerifyResponse> contrastFaceVerifyResp = make_shared<ContrastFaceVerifyResponse>(contrastFaceVerify(contrastFaceVerifyReq, runtime));
  return *contrastFaceVerifyResp;
}

InitDeviceResponse Alibabacloud_Cloudauth20190307::Client::initDevice(shared_ptr<InitDeviceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return InitDeviceResponse(doRequest(make_shared<string>("InitDevice"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

InitDeviceResponse Alibabacloud_Cloudauth20190307::Client::initDeviceSimply(shared_ptr<InitDeviceRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return initDevice(request, runtime);
}

InitFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::initFaceVerify(shared_ptr<InitFaceVerifyRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return InitFaceVerifyResponse(doRequest(make_shared<string>("InitFaceVerify"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

InitFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::initFaceVerifySimply(shared_ptr<InitFaceVerifyRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return initFaceVerify(request, runtime);
}

DescribeFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::describeFaceVerify(shared_ptr<DescribeFaceVerifyRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeFaceVerifyResponse(doRequest(make_shared<string>("DescribeFaceVerify"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeFaceVerifyResponse Alibabacloud_Cloudauth20190307::Client::describeFaceVerifySimply(shared_ptr<DescribeFaceVerifyRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeFaceVerify(request, runtime);
}

VerifyDeviceResponse Alibabacloud_Cloudauth20190307::Client::verifyDevice(shared_ptr<VerifyDeviceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return VerifyDeviceResponse(doRequest(make_shared<string>("VerifyDevice"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

VerifyDeviceResponse Alibabacloud_Cloudauth20190307::Client::verifyDeviceSimply(shared_ptr<VerifyDeviceRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return verifyDevice(request, runtime);
}

ModifyDeviceInfoResponse Alibabacloud_Cloudauth20190307::Client::modifyDeviceInfo(shared_ptr<ModifyDeviceInfoRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return ModifyDeviceInfoResponse(doRequest(make_shared<string>("ModifyDeviceInfo"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

ModifyDeviceInfoResponse Alibabacloud_Cloudauth20190307::Client::modifyDeviceInfoSimply(shared_ptr<ModifyDeviceInfoRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return modifyDeviceInfo(request, runtime);
}

DescribeVerifySDKResponse Alibabacloud_Cloudauth20190307::Client::describeVerifySDK(shared_ptr<DescribeVerifySDKRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeVerifySDKResponse(doRequest(make_shared<string>("DescribeVerifySDK"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeVerifySDKResponse Alibabacloud_Cloudauth20190307::Client::describeVerifySDKSimply(shared_ptr<DescribeVerifySDKRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeVerifySDK(request, runtime);
}

DescribeDeviceInfoResponse Alibabacloud_Cloudauth20190307::Client::describeDeviceInfo(shared_ptr<DescribeDeviceInfoRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeDeviceInfoResponse(doRequest(make_shared<string>("DescribeDeviceInfo"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeDeviceInfoResponse Alibabacloud_Cloudauth20190307::Client::describeDeviceInfoSimply(shared_ptr<DescribeDeviceInfoRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeDeviceInfo(request, runtime);
}

CreateVerifySDKResponse Alibabacloud_Cloudauth20190307::Client::createVerifySDK(shared_ptr<CreateVerifySDKRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CreateVerifySDKResponse(doRequest(make_shared<string>("CreateVerifySDK"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CreateVerifySDKResponse Alibabacloud_Cloudauth20190307::Client::createVerifySDKSimply(shared_ptr<CreateVerifySDKRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createVerifySDK(request, runtime);
}

CreateAuthKeyResponse Alibabacloud_Cloudauth20190307::Client::createAuthKey(shared_ptr<CreateAuthKeyRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CreateAuthKeyResponse(doRequest(make_shared<string>("CreateAuthKey"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CreateAuthKeyResponse Alibabacloud_Cloudauth20190307::Client::createAuthKeySimply(shared_ptr<CreateAuthKeyRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createAuthKey(request, runtime);
}

DetectFaceAttributesResponse Alibabacloud_Cloudauth20190307::Client::detectFaceAttributes(shared_ptr<DetectFaceAttributesRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DetectFaceAttributesResponse(doRequest(make_shared<string>("DetectFaceAttributes"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DetectFaceAttributesResponse Alibabacloud_Cloudauth20190307::Client::detectFaceAttributesSimply(shared_ptr<DetectFaceAttributesRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return detectFaceAttributes(request, runtime);
}

CompareFacesResponse Alibabacloud_Cloudauth20190307::Client::compareFaces(shared_ptr<CompareFacesRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CompareFacesResponse(doRequest(make_shared<string>("CompareFaces"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CompareFacesResponse Alibabacloud_Cloudauth20190307::Client::compareFacesSimply(shared_ptr<CompareFacesRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return compareFaces(request, runtime);
}

DescribeFaceUsageResponse Alibabacloud_Cloudauth20190307::Client::describeFaceUsage(shared_ptr<DescribeFaceUsageRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeFaceUsageResponse(doRequest(make_shared<string>("DescribeFaceUsage"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeFaceUsageResponse Alibabacloud_Cloudauth20190307::Client::describeFaceUsageSimply(shared_ptr<DescribeFaceUsageRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeFaceUsage(request, runtime);
}

DescribeVerifyRecordsResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyRecords(shared_ptr<DescribeVerifyRecordsRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeVerifyRecordsResponse(doRequest(make_shared<string>("DescribeVerifyRecords"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeVerifyRecordsResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyRecordsSimply(shared_ptr<DescribeVerifyRecordsRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeVerifyRecords(request, runtime);
}

UpdateVerifySettingResponse Alibabacloud_Cloudauth20190307::Client::updateVerifySetting(shared_ptr<UpdateVerifySettingRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return UpdateVerifySettingResponse(doRequest(make_shared<string>("UpdateVerifySetting"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

UpdateVerifySettingResponse Alibabacloud_Cloudauth20190307::Client::updateVerifySettingSimply(shared_ptr<UpdateVerifySettingRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return updateVerifySetting(request, runtime);
}

CreateVerifySettingResponse Alibabacloud_Cloudauth20190307::Client::createVerifySetting(shared_ptr<CreateVerifySettingRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CreateVerifySettingResponse(doRequest(make_shared<string>("CreateVerifySetting"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CreateVerifySettingResponse Alibabacloud_Cloudauth20190307::Client::createVerifySettingSimply(shared_ptr<CreateVerifySettingRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createVerifySetting(request, runtime);
}

DescribeVerifySettingResponse Alibabacloud_Cloudauth20190307::Client::describeVerifySetting(shared_ptr<DescribeVerifySettingRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeVerifySettingResponse(doRequest(make_shared<string>("DescribeVerifySetting"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeVerifySettingResponse Alibabacloud_Cloudauth20190307::Client::describeVerifySettingSimply(shared_ptr<DescribeVerifySettingRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeVerifySetting(request, runtime);
}

DescribeVerifyUsageResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyUsage(shared_ptr<DescribeVerifyUsageRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeVerifyUsageResponse(doRequest(make_shared<string>("DescribeVerifyUsage"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeVerifyUsageResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyUsageSimply(shared_ptr<DescribeVerifyUsageRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeVerifyUsage(request, runtime);
}

DescribeUserStatusResponse Alibabacloud_Cloudauth20190307::Client::describeUserStatus(shared_ptr<DescribeUserStatusRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeUserStatusResponse(doRequest(make_shared<string>("DescribeUserStatus"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeUserStatusResponse Alibabacloud_Cloudauth20190307::Client::describeUserStatusSimply(shared_ptr<DescribeUserStatusRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeUserStatus(request, runtime);
}

DescribeUploadInfoResponse Alibabacloud_Cloudauth20190307::Client::describeUploadInfo(shared_ptr<DescribeUploadInfoRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeUploadInfoResponse(doRequest(make_shared<string>("DescribeUploadInfo"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeUploadInfoResponse Alibabacloud_Cloudauth20190307::Client::describeUploadInfoSimply(shared_ptr<DescribeUploadInfoRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeUploadInfo(request, runtime);
}

DescribeRPSDKResponse Alibabacloud_Cloudauth20190307::Client::describeRPSDK(shared_ptr<DescribeRPSDKRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeRPSDKResponse(doRequest(make_shared<string>("DescribeRPSDK"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeRPSDKResponse Alibabacloud_Cloudauth20190307::Client::describeRPSDKSimply(shared_ptr<DescribeRPSDKRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeRPSDK(request, runtime);
}

CreateRPSDKResponse Alibabacloud_Cloudauth20190307::Client::createRPSDK(shared_ptr<CreateRPSDKRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return CreateRPSDKResponse(doRequest(make_shared<string>("CreateRPSDK"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

CreateRPSDKResponse Alibabacloud_Cloudauth20190307::Client::createRPSDKSimply(shared_ptr<CreateRPSDKRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createRPSDK(request, runtime);
}

VerifyMaterialResponse Alibabacloud_Cloudauth20190307::Client::verifyMaterial(shared_ptr<VerifyMaterialRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return VerifyMaterialResponse(doRequest(make_shared<string>("VerifyMaterial"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

VerifyMaterialResponse Alibabacloud_Cloudauth20190307::Client::verifyMaterialSimply(shared_ptr<VerifyMaterialRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return verifyMaterial(request, runtime);
}

DescribeVerifyResultResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyResult(shared_ptr<DescribeVerifyResultRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeVerifyResultResponse(doRequest(make_shared<string>("DescribeVerifyResult"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeVerifyResultResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyResultSimply(shared_ptr<DescribeVerifyResultRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeVerifyResult(request, runtime);
}

DescribeOssUploadTokenResponse Alibabacloud_Cloudauth20190307::Client::describeOssUploadToken(shared_ptr<DescribeOssUploadTokenRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeOssUploadTokenResponse(doRequest(make_shared<string>("DescribeOssUploadToken"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeOssUploadTokenResponse Alibabacloud_Cloudauth20190307::Client::describeOssUploadTokenSimply(shared_ptr<DescribeOssUploadTokenRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeOssUploadToken(request, runtime);
}

DescribeVerifyTokenResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyToken(shared_ptr<DescribeVerifyTokenRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  return DescribeVerifyTokenResponse(doRequest(make_shared<string>("DescribeVerifyToken"), make_shared<string>("HTTPS"), make_shared<string>("POST"), make_shared<string>("2019-03-07"), make_shared<string>("AK"), nullptr, make_shared<map<string, boost::any>>(request->toMap()), runtime));
}

DescribeVerifyTokenResponse Alibabacloud_Cloudauth20190307::Client::describeVerifyTokenSimply(shared_ptr<DescribeVerifyTokenRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeVerifyToken(request, runtime);
}

string Alibabacloud_Cloudauth20190307::Client::getEndpoint(shared_ptr<string> productId,
                                                           shared_ptr<string> regionId,
                                                           shared_ptr<string> endpointRule,
                                                           shared_ptr<string> network,
                                                           shared_ptr<string> suffix,
                                                           shared_ptr<map<string, string>> endpointMap,
                                                           shared_ptr<string> endpoint) {
  if (!Darabonba_Util::Client::empty(endpoint)) {
    return *endpoint;
  }
  if (!Darabonba_Util::Client::isUnset<map<string, string>>(endpointMap) && !Darabonba_Util::Client::empty(make_shared<string>((*endpointMap)[regionId]))) {
    return (*endpointMap)[regionId];
  }
  return Alibabacloud_EndpointUtil::Client::getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

max_stars_repo_name: aliyun/alibabacloud-cpp-sdk

max_issues_repo_name: aliyun/alibabacloud-cpp-sdk

max_forks_repo_name: aliyun/alibabacloud-cpp-sdk


text:
/*
 * xml_parser.cpp
 *
 *  Created on: 05.11.2014
 *      Author: Marius
 */

#include "header_file_scope.hpp"
#include <fixp/xml_parser.hpp>

// #include <boost/property_tree/info_parser.hpp>
// #include <boost/property_tree/xml_parser.hpp>
#include <boost/algorithm/string.hpp>

namespace fixp
{
void xml_parser::load_specs(const xml_parser::tree_type& fixTree, const xml_parser::tree_type& userTree)
{
	const boost::property_tree::ptree& fields = fixTree.get_child("fix").get_child("fields");
	load_fields(fields);
	boost::optional<const boost::property_tree::ptree&> userTypes = userTree.get_child_optional("types");
	if(userTypes)
		load_user_types(*userTypes);
}

void xml_parser::load_user_types(const xml_parser::tree_type& fields)
{
	for(const boost::property_tree::ptree::value_type& vt : fields)
	{
		const tree_type& info = vt.second.get_child("<xmlattr>");
		const tree_type& fixtype = info.get_child("fixtype");
		const tree_type& alias =  info.get_child("alias");
		const tree_type& apptype = info.get_child("apptype");
		data_dict.update_type(fixtype.data(), &alias.data(), &apptype.data());
	}
}

void xml_parser::load_fields(const xml_parser::tree_type& fields)
{
	for(const boost::property_tree::ptree::value_type& vt : fields)
	{
		const tree_type& info = vt.second.get_child("<xmlattr>");
		const tree_type& tag = info.get_child("number");
		const tree_type& name =  info.get_child("name");
		const tree_type& type = info.get_child("type");

		// TODO - use emplace
		field_attributes.insert(FieldAttributes::value_type
		{
			name.data(),
			FieldAttribute{tag.data(), *types.insert(type.data()).first}
		});

		data_dict.add_type(type.data());
	}
}

void xml_parser::write_traits(std::ostream& out)
{
	header_file_scope scope {"tags", {"fixp/traits.hpp"}, {"fixp", "tags"}, out};
	out << "\tusing tag_type=traits::tag_type;\n\n";
	for(const FieldAttributes::value_type& vt : field_attributes)
	{
		out << "\tconstexpr tag_type " << vt.first << "=" << *vt.second.tag << ";\n";
	}
}

void xml_parser::write_tags(std::ostream& out)
{
	header_file_scope scope {"tags", {}, {"fixp"}, out};
	out << "class traits\n{\npublic:\n";
	for(const std::string& type : types)
	{
		out << "\tusing " << type << "=" << type << ";\n";
	}
}

void xml_parser::write_message(std::ostream& out, const xml_parser::tree_type& message)
{
	const tree_type& xmlattr = message.get_child("<xmlattr>");

	std::set<std::string> fields; // todo - use const references to std::string, use vector instead
	std::set<std::string> types;

	for(const tree_type::value_type& vt : message)
	{
		if(vt.first == "field")
		{
			const tree_type& field = vt.second.get_child("<xmlattr>");
			const tree_type& name = field.get_child("name");
			fields.insert(name.data()); // todo - use emplace, check if it already exists in the collection

			FieldAttributes::const_iterator it = field_attributes.find(name.data());
			if(field_attributes.end() != it)
				types.insert(*it->second.type);
		}
	}

	const std::string& name = xmlattr.get_child("name").data();
	header_file_scope scope {name, { "fixp/tags.hpp", "fixp/traits.hpp", }, {"fixp"}, out};

	std::string tmp;

	out << "\nclass " << xmlattr.get_child("name").data() <<
			" : public fixp::component\n"
			"{\n"
			"public:\n";

	// generate typedefs
	out << "\tusing Base = fixp::component;\n";
	out << "\tusing tag_type = traits::tag_type;\n";
	for(const std::string& type : types)
	{
		const data_dictionary::type_info* typeInfo = data_dict.find_type(type);
		if(typeInfo)
		{
			if(typeInfo->get_alias())
			{
				out << "\tusing " << *typeInfo->get_alias() << " = traits::" << *typeInfo->get_alias() << ";\n";
			}
			else if(typeInfo->get_user_type_name())
			{
				out << "\tusing " << *typeInfo->get_user_type_name() << " = traits::" << *typeInfo->get_user_type_name() << ";\n";
			}
		}
	}

	out << "\n\t// observers\n\n";

	for(const std::string& field : fields)
	{
		FieldAttributes::const_iterator it = field_attributes.find(field);
		out << "\t";
		if(field_attributes.end() == it)
		{
			out << "UnknownType"  << " get" << field << "() { return Base::getField(tags::" << field << "); }\n";		}
		else
		{
			const data_dictionary::type_info* typeInfo = data_dict.find_type(*it->second.type);
			const std::string* type {};
			if(typeInfo && typeInfo->get_alias())
			{
				type = typeInfo->get_alias();
			}
			else if(typeInfo && typeInfo->get_user_type_name())
			{
				type = typeInfo->get_user_type_name();
			}
			else
			{
				type = it->second.type;
			}
			out << *type << " get" << field << "() { return Base::getField" << "<" << *type << ">(tags::" << field << "); }\n";
		}

	}

	out << "\n\t// modifiers \n\n";

	for(const std::string& field : fields)
	{
		FieldAttributes::const_iterator it = field_attributes.find(field);
		out << "\t";
		if(field_attributes.end() == it)
			out << "UnknownType";
		else
		{
			tmp = *it->second.type;
			tmp += "_type";
		}

		out << "void set" << field <<
			"("<< tmp << " " << field << ") { Base::setField(tags::" << field << ", " << field << "); }\n";
	}

	out << "};\n";
}

void xml_parser::write_types(std::ostream& out)
{
	const std::set<data_dictionary::type_info>& types = data_dict.get_types();
	for(const data_dictionary::type_info& info : types)
	{
		out << info.get_name();
		if(info.get_alias())
		{
			out << ' ' << *info.get_alias();
		}

		if(info.get_user_type_name())
		{
			out << ' ' << *info.get_user_type_name();
		}

		out << '\n';
	}

}

}

max_stars_repo_name: mdobrea/effective-fix

max_issues_repo_name: mdobrea/effective-fix

max_forks_repo_name: mdobrea/effective-fix


text:
/**************************************************************
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 *************************************************************/

#ifndef INCLUDED_SLIDESHOW_INTRINSICANIMATIONEVENTHANDLER_HXX
#define INCLUDED_SLIDESHOW_INTRINSICANIMATIONEVENTHANDLER_HXX

#include <boost/shared_ptr.hpp>

/* Definition of IntrinsicAnimationEventHandler interface */

namespace slideshow
{
    namespace internal
    {

        /** Interface for handling intrinsic animation display modes.

        	Classes implementing this interface can be added to an
        	EventMultiplexer object, and are called from there to
        	handle intrinsic animation events.
         */
        class IntrinsicAnimationEventHandler
        {
        public:
            virtual ~IntrinsicAnimationEventHandler() {}

            virtual bool enableAnimations() = 0;
            virtual bool disableAnimations() = 0;
        };

        typedef ::boost::shared_ptr< IntrinsicAnimationEventHandler > IntrinsicAnimationEventHandlerSharedPtr;

    }
}

#endif /* INCLUDED_SLIDESHOW_INTRINSICANIMATIONEVENTHANDLER_HXX */

ext: hxx

max_stars_repo_name: Grosskopf/openoffice

max_issues_repo_name: Grosskopf/openoffice

max_forks_repo_name: Grosskopf/openoffice


text:
/*

Copyright (c) 2008, 2010-2019, Arvid Norberg
Copyright (c) 2016, 2018, Alden Torres
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in
      the documentation and/or other materials provided with the distribution.
    * Neither the name of the author nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

*/

#ifndef TORRENT_SSL_STREAM_HPP_INCLUDED
#define TORRENT_SSL_STREAM_HPP_INCLUDED

#ifdef TORRENT_USE_OPENSSL

#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/io_context.hpp"
#include "libtorrent/aux_/openssl.hpp"

#include <functional>

#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/asio/ssl.hpp>
#if defined TORRENT_BUILD_SIMULATOR
#include "simulator/simulator.hpp"
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"

namespace libtorrent {
namespace ssl {

#if defined TORRENT_BUILD_SIMULATOR
	using sim::asio::ssl::context;
	using sim::asio::ssl::stream_base;
	using sim::asio::ssl::stream;
#else
	using boost::asio::ssl::context;
	using boost::asio::ssl::stream_base;
	using boost::asio::ssl::stream;
#endif
}

template <class Stream>
struct ssl_stream
{
	ssl_stream(io_context& io_context, ssl::context& ctx)
		: m_sock(new ssl::stream<Stream>(io_context, ctx))
	{}

	template <typename S>
	ssl_stream(S&& s, ssl::context& ctx)
		: m_sock(new ssl::stream<Stream>(std::forward<S>(s), ctx))
	{}

	ssl_stream(ssl_stream&&) = default;

	using sock_type = typename boost::asio::ssl::stream<Stream>;
	using next_layer_type = typename sock_type::next_layer_type;
	using lowest_layer_type = typename Stream::lowest_layer_type;
	using endpoint_type = typename Stream::endpoint_type;
	using protocol_type = typename Stream::protocol_type;
	using executor_type = typename sock_type::executor_type;
	executor_type get_executor() { return m_sock->get_executor(); }

	void set_host_name(std::string const& name)
	{
		aux::openssl_set_tlsext_hostname(m_sock->native_handle(), name.c_str());
	}

	template <class T>
	void set_verify_callback(T const& fun, error_code& ec)
	{ m_sock->set_verify_callback(fun, ec); }

	SSL* native_handle() { return m_sock->native_handle(); }

	template <class Handler>
	void async_connect(endpoint_type const& endpoint, Handler const& h)
	{
		// the connect is split up in the following steps:
		// 1. connect to peer
		// 2. perform SSL client handshake

		m_sock->next_layer().async_connect(endpoint, wrap_allocator(
			[this](error_code const& ec, Handler hn) {
				connected(ec, std::move(hn));
			}, std::move(h)));
	}

	template <class Handler>
	void async_accept_handshake(Handler const& h)
	{
		// this is used for accepting SSL connections
		using std::placeholders::_1;
		m_sock->async_handshake(ssl::stream_base::server, wrap_allocator(
			[this](error_code const& ec, Handler hn) {
				handshake(ec, std::move(hn));
			}, std::move(h)));
	}

	void accept_handshake(error_code& ec)
	{
		// this is used for accepting SSL connections
		m_sock->handshake(ssl::stream_base::server, ec);
	}

	template <class Handler>
	void async_shutdown(Handler const& handler)
	{
		error_code ec;
		m_sock->next_layer().cancel(ec);
		m_sock->async_shutdown(handler);
	}

	void shutdown(error_code& ec)
	{
		m_sock->shutdown(ec);
	}

	template <class Mutable_Buffers, class Handler>
	void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
	{
		m_sock->async_read_some(buffers, handler);
	}

	template <class Mutable_Buffers>
	std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
	{
		return m_sock->read_some(buffers, ec);
	}

#ifndef BOOST_NO_EXCEPTIONS
	template <class SettableSocketOption>
	void set_option(SettableSocketOption const& opt)
	{
		m_sock->next_layer().set_option(opt);
	}
#endif

	template <class SettableSocketOption>
	void set_option(SettableSocketOption const& opt, error_code& ec)
	{
		m_sock->next_layer().set_option(opt, ec);
	}

#ifndef BOOST_NO_EXCEPTIONS
	template <class GettableSocketOption>
	void get_option(GettableSocketOption& opt)
	{
		m_sock->next_layer().get_option(opt);
	}
#endif

	template <class GettableSocketOption>
	void get_option(GettableSocketOption& opt, error_code& ec)
	{
		m_sock->next_layer().get_option(opt, ec);
	}

#ifndef BOOST_NO_EXCEPTIONS
	template <class Mutable_Buffers>
	std::size_t read_some(Mutable_Buffers const& buffers)
	{
		return m_sock->read_some(buffers);
	}

	template <class IO_Control_Command>
	void io_control(IO_Control_Command& ioc)
	{
		m_sock->next_layer().io_control(ioc);
	}
#endif

	template <class IO_Control_Command>
	void io_control(IO_Control_Command& ioc, error_code& ec)
	{
		m_sock->next_layer().io_control(ioc, ec);
	}

#ifndef BOOST_NO_EXCEPTIONS
	void non_blocking(bool b) { m_sock->next_layer().non_blocking(b); }
#endif

	void non_blocking(bool b, error_code& ec)
	{ m_sock->next_layer().non_blocking(b, ec); }

	template <class Const_Buffers, class Handler>
	void async_write_some(Const_Buffers const& buffers, Handler const& handler)
	{
		m_sock->async_write_some(buffers, handler);
	}

	template <class Const_Buffers>
	std::size_t write_some(Const_Buffers const& buffers, error_code& ec)
	{
		return m_sock->write_some(buffers, ec);
	}

	// the SSL stream may cache 17 kiB internally, and there's no way of
	// asking how large its buffer is. 17 kiB isn't very much though, so it
	// seems fine to potentially over-estimate the number of bytes available.
#ifndef BOOST_NO_EXCEPTIONS
	std::size_t available() const
	{ return 17 * 1024 + const_cast<sock_type&>(*m_sock).next_layer().available(); }
#endif

	std::size_t available(error_code& ec) const
	{ return 17 * 1024 + const_cast<sock_type&>(*m_sock).next_layer().available(ec); }

#ifndef BOOST_NO_EXCEPTIONS
	void bind(endpoint_type const& endpoint)
	{
		m_sock->next_layer().bind(endpoint);
	}
#endif

	void bind(endpoint_type const& endpoint, error_code& ec)
	{
		m_sock->next_layer().bind(endpoint, ec);
	}

#ifndef BOOST_NO_EXCEPTIONS
	void open(protocol_type const& p)
	{
		m_sock->next_layer().open(p);
	}
#endif

	void open(protocol_type const& p, error_code& ec)
	{
		m_sock->next_layer().open(p, ec);
	}

	bool is_open() const
	{
		return m_sock->next_layer().is_open();
	}

#ifndef BOOST_NO_EXCEPTIONS
	void close()
	{
		m_sock->next_layer().close();
	}
#endif

	void close(error_code& ec)
	{
		m_sock->next_layer().close(ec);
	}

#ifndef BOOST_NO_EXCEPTIONS
	endpoint_type remote_endpoint() const
	{
		return m_sock->next_layer().remote_endpoint();
	}
#endif

	endpoint_type remote_endpoint(error_code& ec) const
	{
		return m_sock->next_layer().remote_endpoint(ec);
	}

#ifndef BOOST_NO_EXCEPTIONS
	endpoint_type local_endpoint() const
	{
		return m_sock->next_layer().local_endpoint();
	}
#endif

	endpoint_type local_endpoint(error_code& ec) const
	{
		return m_sock->next_layer().local_endpoint(ec);
	}

	lowest_layer_type& lowest_layer()
	{
		return m_sock->lowest_layer();
	}

	lowest_layer_type const& lowest_layer() const
	{
		return m_sock->lowest_layer();
	}

	next_layer_type& next_layer()
	{
		return m_sock->next_layer();
	}

	next_layer_type const& next_layer() const
	{
		return m_sock->next_layer();
	}

private:

	template <typename Handler>
	void connected(error_code const& e, Handler h)
	{
		if (e)
		{
			h(e);
			return;
		}

		m_sock->async_handshake(ssl::stream_base::client, wrap_allocator(
			[this](error_code const& ec, Handler hn) {
				handshake(ec, std::move(hn));
			}, std::move(h)));
	}

	template <typename Handler>
	void handshake(error_code const& e, Handler h)
	{
		h(e);
	}

	// to make us movable
	std::unique_ptr<ssl::stream<Stream>> m_sock;
};

}

#endif // TORRENT_USE_OPENSSL

#endif

max_stars_repo_name: paulyc/libtorrent-arvid

max_issues_repo_name: paulyc/libtorrent-arvid

max_forks_repo_name: paulyc/libtorrent-arvid


text:
// The Expat License
//
// Copyright (c) 2017, Shlomi Fish
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include <boost/countertree/set.hpp>
#include <cstdio>
#include <iostream>

static inline int read_int(FILE *const f)
{
    int ret;
    fscanf(f, "%d", &ret);
    return ret;
}

int main(int argc, char * argv[])
{
    const int n = std::stoi(argv[1]);
    const int k = std::stoi(argv[2]);

    countertree::multiset<int> myset;
    FILE * in = fopen("S2.txt", "r");
    for (int i = 0; i < k; i++) {
        myset.insert(read_int(in));
    }
    FILE * remove = fopen("S2.txt", "r");
    long long sum = 0;
    for (int i = 1; i <= n-k+1; i++) {
        sum += myset.pos((k-1) >> 1) + myset.pos((k) >> 1);
#if 0
        std::cout << "Sum[" << i << "] = " << sum << std::endl;
#endif
        myset.insert(read_int(in));
        const auto it = myset.find(read_int(remove));
        myset.erase(it);
    }
    fclose(remove);
    fclose(in);
    std::cout << "Sum = " << (sum >> 1) << (((sum&0x1) == 0) ? ".0" : ".5") <<
        std::endl;
    return 0;
}

max_stars_repo_name: zoffixznet/project-euler

max_issues_repo_name: zoffixznet/project-euler

max_forks_repo_name: zoffixznet/project-euler