text:
//#include <boost/config.hpp>
#include <iostream>
#include <fstream>
#include <string>

#include <boost/graph/graphviz.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>

using boost::GraphvizDigraph;

template <typename Vertex_Descriptor, typename Vertex_Name_Map>
::std::string const & vertex_label(Vertex_Descriptor v, Vertex_Name_Map & name_map)
{
  return (*(name_map[v].find("label"))).second;
}

// Accepting state?
template <typename Vertex_Descriptor, typename Vertex_Name_Map>
bool accepting(Vertex_Descriptor v, Vertex_Name_Map & name_map)
{
  return (*(name_map[v].find("peripheries"))).second == "2" ? true : false;
}

template <typename Edge_Descriptor, typename Edge_Name_Map>
::std::string const & edge_label(Edge_Descriptor e, Edge_Name_Map & name_map)
{
  return(*(name_map[e].find("label"))).second;
}

void print_all_vertices(GraphvizDigraph const & g)
{
  char c;
  ::std::cout << "VERTICES:\n";

  typedef boost::graph_traits<GraphvizDigraph>::vertex_iterator Vertex_Iter_t;

  boost::property_map<GraphvizDigraph, boost::vertex_attribute_t>::const_type
    name_map = boost::get(boost::vertex_attribute, g);

  for(::std::pair<Vertex_Iter_t, Vertex_Iter_t> p = boost::vertices(g); p.first != p.second; ++p.first){

    if(accepting(*p.first, name_map))
      c = 'a';
    else
      c = '-';

    ::std::cout << vertex_label(*p.first, name_map)
                << "[" << c << "]" << ::std::endl;

  }
}

void print_all_edges(GraphvizDigraph const & g)
{
  ::std::cout << "EDGES:\n";

  typedef boost::graph_traits<GraphvizDigraph>::edge_iterator Edge_Iter_t;

  boost::property_map<GraphvizDigraph, boost::edge_attribute_t>::const_type
    name_map;
  name_map = boost::get(boost::edge_attribute, g);

  for(::std::pair<Edge_Iter_t, Edge_Iter_t> p = boost::edges(g); p.first != p.second; ++p.first){
    ::std::cout << edge_label(*p.first, name_map) << ::std::endl;
  }
}

void scc(GraphvizDigraph const & g)
{
  ::std::cout <<"SCC\n";
  typedef ::boost::graph_traits<GraphvizDigraph>::vertex_descriptor vertex_t;
  ::std::map<vertex_t, int> component;

  int num = strong_components(g, ::boost::make_assoc_property_map(component));

  ::boost::graph_traits<GraphvizDigraph>::vertex_iterator vi, vi_end;
  for(::boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi){
    ::std::cout << component[*vi] << ::std::endl;
  }

//   std::vector<int> c(num_vertices(g));
//   int num = strong_components
//     (g, ::boost::make_iterator_property_map(c.begin(), get(::boost::vertex_index, g)));

//   ::std::cout << "Total comps " << num << ::std::endl;
//   ::std::vector<int>::iterator i;
//   for(i = c.begin(); i != c.end(); ++i)
//     ::std::cout << "Vertex " << i - c.begin() << " is in comp " << *i
//		<< ::std::endl;
}

int main(int argc, char* argv[]) {

  std::string filename = "graphviz_test.dot";

  if ( argc > 1 )
    filename = argv[1];
  else{
    std::cout << "Usage: " << argv[0] << "  <input>.dot  <output>.dot " << std::endl;
    return 0;
  }

  ::boost::GraphvizDigraph g;

  boost::read_graphviz(filename, g);

  print_all_vertices(g);
  print_all_edges(g);
  scc(g);

  const char* dot = "graphviz_test_new.dot";
  if ( argc > 2 )
    dot = argv[2];

  boost::write_graphviz(dot, g);

  return 0;
}


text:
//  Copyright (c) 2015 Hartmut Kaiser
//  Copyright (c) 2011 Thomas Heller
//  Copyright (c) 2013 Agustin Berge
//
//  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)

#ifndef HPX_UTIL_BIND_ACTION_HPP
#define HPX_UTIL_BIND_ACTION_HPP

#include <hpx/hpx_fwd.hpp>
#include <hpx/lcos/future.hpp>
#include <hpx/traits/is_action.hpp>
#include <hpx/traits/is_bind_expression.hpp>
#include <hpx/traits/is_placeholder.hpp>
#include <hpx/traits/serialize_as_future.hpp>
#include <hpx/util/bind.hpp>
#include <hpx/util/decay.hpp>
#include <hpx/util/move.hpp>
#include <hpx/util/tuple.hpp>

#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/ref.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/utility/enable_if.hpp>

namespace hpx { namespace util
{
    ///////////////////////////////////////////////////////////////////////////
    namespace detail
    {
        ///////////////////////////////////////////////////////////////////////
        template <typename Action, typename BoundArgs, typename UnboundArgs>
        struct bind_action_apply_impl
        {
            typedef bool type;

            template <std::size_t ...Is>
            static BOOST_FORCEINLINE
            type call(
                detail::pack_c<std::size_t, Is...>
              , BoundArgs& bound_args, UnboundArgs&& unbound_args
            )
            {
                return hpx::apply<Action>(bind_eval<Action>(
                    util::get<Is>(bound_args),
                    std::forward<UnboundArgs>(unbound_args))...);
            }
        };

        template <typename Action, typename BoundArgs, typename UnboundArgs>
        BOOST_FORCEINLINE
        bool
        bind_action_apply(BoundArgs& bound_args, UnboundArgs&& unbound_args)
        {
            return bind_action_apply_impl<Action, BoundArgs, UnboundArgs>::call(
                typename detail::make_index_pack<
                    util::tuple_size<BoundArgs>::value
                >::type(),
                bound_args, std::forward<UnboundArgs>(unbound_args));
        }

        ///////////////////////////////////////////////////////////////////////
        template <typename Action, typename BoundArgs, typename UnboundArgs>
        struct bind_action_apply_cont_impl
        {
            typedef bool type;

            template <std::size_t ...Is>
            static BOOST_FORCEINLINE
            type call(
                detail::pack_c<std::size_t, Is...>
              , naming::id_type const& cont
              , BoundArgs& bound_args, UnboundArgs&& unbound_args
            )
            {
                return hpx::apply_c<Action>(cont, bind_eval<Action>(
                    util::get<Is>(bound_args),
                    std::forward<UnboundArgs>(unbound_args))...);
            }
        };

        template <typename Action, typename BoundArgs, typename UnboundArgs>
        BOOST_FORCEINLINE
        bool
        bind_action_apply_cont(naming::id_type const& cont,
            BoundArgs& bound_args, UnboundArgs&& unbound_args
        )
        {
            return bind_action_apply_cont_impl<
                    Action, BoundArgs, UnboundArgs
                >::call(
                    typename detail::make_index_pack<
                        util::tuple_size<BoundArgs>::value
                    >::type(), cont,
                    bound_args, std::forward<UnboundArgs>(unbound_args));
        }

        ///////////////////////////////////////////////////////////////////////
        template <typename Action, typename BoundArgs, typename UnboundArgs>
        struct bind_action_apply_cont_impl2
        {
            typedef bool type;

            template <std::size_t ...Is>
            static BOOST_FORCEINLINE
            type call(
                detail::pack_c<std::size_t, Is...>
              , hpx::actions::continuation_type const& cont
              , BoundArgs& bound_args, UnboundArgs&& unbound_args
            )
            {
                return hpx::apply<Action>(cont, bind_eval<Action>(
                    util::get<Is>(bound_args),
                    std::forward<UnboundArgs>(unbound_args))...);
            }
        };

        template <typename Action, typename BoundArgs, typename UnboundArgs>
        BOOST_FORCEINLINE
        bool
        bind_action_apply_cont2(hpx::actions::continuation_type const& cont,
            BoundArgs& bound_args, UnboundArgs&& unbound_args)
        {
            return bind_action_apply_cont_impl2<
                    Action, BoundArgs, UnboundArgs
                >::call(
                    typename detail::make_index_pack<
                        util::tuple_size<BoundArgs>::value
                    >::type(), cont,
                    bound_args, std::forward<UnboundArgs>(unbound_args));
        }

        ///////////////////////////////////////////////////////////////////////
        template <typename Action, typename BoundArgs, typename UnboundArgs>
        struct bind_action_async_impl
        {
            typedef lcos::future<typename traits::promise_local_result<
                typename hpx::actions::extract_action<Action>::remote_result_type
            >::type> type;

            template <std::size_t ...Is>
            static BOOST_FORCEINLINE
            type call(
                detail::pack_c<std::size_t, Is...>
              , BoundArgs& bound_args, UnboundArgs&& unbound_args
            )
            {
                return hpx::async<Action>(bind_eval<Action>(
                    util::get<Is>(bound_args),
                    std::forward<UnboundArgs>(unbound_args))...);
            }
        };

        template <typename Action, typename BoundArgs, typename UnboundArgs>
        BOOST_FORCEINLINE
        lcos::future<typename traits::promise_local_result<
            typename hpx::actions::extract_action<Action>::remote_result_type
        >::type>
        bind_action_async(BoundArgs& bound_args, UnboundArgs&& unbound_args)
        {
            return bind_action_async_impl<Action, BoundArgs, UnboundArgs>::call(
                typename detail::make_index_pack<
                    util::tuple_size<BoundArgs>::value
                >::type(),
                bound_args, std::forward<UnboundArgs>(unbound_args));
        }

        ///////////////////////////////////////////////////////////////////////
        template <typename Action, typename BoundArgs, typename UnboundArgs>
        BOOST_FORCEINLINE
        typename traits::promise_local_result<
            typename hpx::actions::extract_action<Action>::remote_result_type
        >::type
        bind_action_invoke(
            BoundArgs& bound_args
          , UnboundArgs&& unbound_args
        )
        {
            return bind_action_async_impl<Action, BoundArgs, UnboundArgs>::call(
                typename detail::make_index_pack<
                    util::tuple_size<BoundArgs>::value
                >::type(),
                bound_args, std::forward<UnboundArgs>(unbound_args)).get();
        }

        ///////////////////////////////////////////////////////////////////////
        template <typename Action, typename BoundArgs>
        class bound_action //-V690
        {
        public:
            typedef typename traits::promise_local_result<
                typename hpx::actions::extract_action<Action>::remote_result_type
            >::type result_type;

        public:
            // default constructor is needed for serialization
            bound_action()
            {}

            template <typename BoundArgs_>
            explicit bound_action(Action /*action*/, BoundArgs_&& bound_args)
              : _bound_args(std::forward<BoundArgs_>(bound_args))
            {}

            bound_action(bound_action const& other)
              : _bound_args(other._bound_args)
            {}
            bound_action(bound_action&& other)
              : _bound_args(std::move(other._bound_args))
            {}

            template <typename ...Us>
            BOOST_FORCEINLINE
            bool
            apply(Us&&... us) const
            {
                return detail::bind_action_apply<Action>(
                    _bound_args, util::forward_as_tuple(std::forward<Us>(us)...));
            }

            template <typename ...Us>
            BOOST_FORCEINLINE
            bool
            apply_c(naming::id_type const& contgid, Us&&... us) const
            {
                return detail::bind_action_apply_cont<Action>(contgid,
                    _bound_args, util::forward_as_tuple(std::forward<Us>(us)...));
            }

            template <typename ...Us>
            BOOST_FORCEINLINE
            bool
            apply_c(actions::continuation_type const& cont, Us&&... us) const
            {
                return detail::bind_action_apply_cont2<Action>(cont,
                    _bound_args, util::forward_as_tuple(std::forward<Us>(us)...));
            }

            template <typename ...Us>
            BOOST_FORCEINLINE
            hpx::lcos::future<result_type>
            async(Us&&... us) const
            {
                return detail::bind_action_async<Action>(
                    _bound_args, util::forward_as_tuple(std::forward<Us>(us)...));
            }

            template <typename ...Us>
            BOOST_FORCEINLINE
            result_type
            operator()(Us&&... us) const
            {
                return detail::bind_action_invoke<Action>(
                    _bound_args, util::forward_as_tuple(std::forward<Us>(us)...));
            }

        public: // exposition-only
            BoundArgs _bound_args;
        };
    }

    ///////////////////////////////////////////////////////////////////////////
    template <typename Action, typename ...Ts>
    typename boost::enable_if_c<
        traits::is_action<typename util::decay<Action>::type>::value
      , detail::bound_action<
            typename util::decay<Action>::type
          , util::tuple<typename util::decay<Ts>::type...>
        >
    >::type
    bind(Ts&&... vs)
    {
        typedef detail::bound_action<
            typename util::decay<Action>::type,
            util::tuple<typename util::decay<Ts>::type...>
        > result_type;

        return result_type(Action(),
            util::forward_as_tuple(std::forward<Ts>(vs)...));
    }

    template <
        typename Component, typename Signature, typename Derived
      , typename ...Ts>
    detail::bound_action<
        Derived
      , util::tuple<typename util::decay<Ts>::type...>
    >
    bind(
        hpx::actions::basic_action<Component, Signature, Derived> action,
        Ts&&... vs)
    {
        typedef detail::bound_action<
            Derived,
            util::tuple<typename util::decay<Ts>::type...>
        > result_type;

        return result_type(static_cast<Derived const&>(action),
            util::forward_as_tuple(std::forward<Ts>(vs)...));
    }
}}

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace traits
{
    ///////////////////////////////////////////////////////////////////////////
    template <typename Action, typename BoundArgs>
    struct is_bind_expression<util::detail::bound_action<Action, BoundArgs> >
      : boost::mpl::true_
    {};

    template <typename Action, typename BoundArgs>
    struct is_bound_action<util::detail::bound_action<Action, BoundArgs> >
      : boost::mpl::true_
    {};

    ///////////////////////////////////////////////////////////////////////////
    template <typename Action, typename BoundArgs>
    struct serialize_as_future<util::detail::bound_action<Action, BoundArgs> >
      : serialize_as_future<BoundArgs>
    {
        static bool
        call_if(util::detail::bound_action<Action, BoundArgs>& b)
        {
            return serialize_as_future<BoundArgs>::call_if(b._bound_args);
        }

        static void call(util::detail::bound_action<Action, BoundArgs>& b)
        {
            traits::serialize_as_future<BoundArgs>::call(b._bound_args);
        }
    };
}}

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace serialization
{
    // serialization of the bound action object
    template <typename Action, typename BoundArgs>
    void serialize(
        ::hpx::serialization::input_archive& ar
      , ::hpx::util::detail::bound_action<Action, BoundArgs>& bound
      , unsigned int const /*version*/)
    {
        ar >> bound._bound_args;
    }

    template <typename Action, typename BoundArgs>
    void serialize(
        ::hpx::serialization::output_archive& ar
      , ::hpx::util::detail::bound_action<Action, BoundArgs>& bound
      , unsigned int const /*version*/)
    {
        ar << bound._bound_args;
    }
}}

#endif

ext: hpp

max_stars_repo_name: kempj/hpx

max_issues_repo_name: kempj/hpx

max_forks_repo_name: kempj/hpx


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 _CEPHMESOS_SCHEDULER_EVENTLOOP_HPP_
#define _CEPHMESOS_SCHEDULER_EVENTLOOP_HPP_

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <exception>
#include <thread>
#include <glog/logging.h>
#include "common/JsonUtil.hpp"
#include <boost/interprocess/ipc/message_queue.hpp>

using std::string;
using std::vector;
using std::thread;
using std::cout;
using std::endl;
using std::istringstream;
using std::exception;
using namespace boost::interprocess;

class EventLoop
{
public:
  EventLoop();
  ~EventLoop();
  vector<int>* getPendingOSD() { return &pendingOSD; }

private:
  void processData(string data);

  bool loopTag;
  vector<int> pendingOSD;
  void recvData();
  thread *recvThread;
};
#endif

max_stars_repo_name: vivint-smarthome/ceph-mesos

max_issues_repo_name: vivint-smarthome/ceph-mesos

max_forks_repo_name: vivint-smarthome/ceph-mesos


text:
#include "problemes.h"
#include "arithmetique.h"

#include <fstream>
#include <boost/algorithm/string.hpp>

typedef unsigned long long nombre;
typedef std::vector<nombre> vecteur;

namespace {
    typedef std::vector<std::pair<std::string, nombre>> S;
    typedef std::map<nombre, std::set<S>> C;

    C construire(const S &score, const C &combinaisons) {
        auto suivant = combinaisons;
        for (const auto &s: score) {
            for (const auto &r: combinaisons) {
                auto c = r.second;
                for (auto f: c) {
                    f.push_back(s);
                    std::sort(f.begin(), f.end());
                    suivant[s.second + r.first].insert(f);
                }
            }
        }
        return suivant;
    };
}

ENREGISTRER_PROBLEME(109, "Darts") {
    // In the game of darts a player throws three darts at a target board which is split into twenty equal sized
    // sections numbered one to twenty.
    //
    // The score of a dart is determined by the number of the region that the dart lands in. A dart landing outside the
    // red/green outer ring scores zero. The black and cream regions inside this
    // ring represent single scores. However, the red/green outer ring and middle ring score double and treble scores
    // respectively.
    //
    // At the centre of the board are two concentric circles called the bull region, or bulls-eye.
    // The outer bull is worth 25 points and the inner bull is a double, worth 50 points.
    //
    // There are many variations of rules but in the most popular game the players will begin with a score 301 or 501
    // and the first player to reduce their running total to zero is a winner.
    // However, it is normal to play a "doubles out" system, which means that the player must land a double (including
    // the double bulls-eye at the centre of the board) on their final dart to win;
    // any other dart that would reduce their running total to one or lower means the score for that set of three darts
    // is "bust".
    //
    // When a player is able to finish on their current score it is called a "checkout" and the highest checkout is 170:
    // T20 T20 D25 (two treble 20s and double bull).
    //
    // There are exactly eleven distinct ways to checkout on a score of 6:
    //
    //      D3
    //      D1	D2
    //      S2	D2
    //      D2	D1
    //      S4	D1
    //      S1	S1	D2
    //      S1	T1	D1
    //      S1	S3	D1
    //      D1	D1	D1
    //      D1	S2	D1
    //      S2	S2	D1
    //
    // Note that D1 D2 is considered different to D2 D1 as they finish on different doubles. However, the combination
    // S1 T1 D1 is considered the same as T1 S1 D1.
    //
    // In addition we shall not include misses in considering combinations; for example, D3 is the same as 0 D3 and
    // 0 0 D3.
    //
    // Incredibly there are 42336 distinct ways of checking out in total.
    //
    // How many distinct ways can a player checkout with a score less than 100?
    S score;
    S score_double;

    for (nombre n = 1; n < 21; ++n) {
        score.emplace_back(utilitaires::concatener("S", n), n);
        score.emplace_back(utilitaires::concatener("D", n), 2 * n);
        score.emplace_back(utilitaires::concatener("T", n), 3 * n);
        score_double.emplace_back(utilitaires::concatener("D", n), 2 * n);
    }

    score.emplace_back(utilitaires::concatener("S", 25), 25);
    score.emplace_back(utilitaires::concatener("D", 25), 2 * 25);
    score_double.emplace_back(utilitaires::concatener("D", 25), 2 * 25);

    const S zero{std::make_pair("0", 0)};
    C combinaisons;
    combinaisons[0].insert(zero);

    combinaisons = construire(score, combinaisons);
    combinaisons = construire(score, combinaisons);

    C solution;
    for (const auto &s: score_double) {
        for (const auto &r: combinaisons) {
            auto c = r.second;
            for (auto f: c) {
                f.push_back(s);
                solution[s.second + r.first].insert(f);
            }
        }
    }

    nombre resultat = 0;
    for (const auto &r: solution) {
        if (r.first < 100)
            resultat += r.second.size();
    }

    return std::to_string(resultat);
}

ext: cpp

max_stars_repo_name: ZongoForSpeed/ProjectEuler

max_issues_repo_name: ZongoForSpeed/ProjectEuler

max_forks_repo_name: ZongoForSpeed/ProjectEuler


text:
// Copyright 2005 The Trustees of Indiana University.

// Use, modification and distribution is subject to 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)

//  Authors: Douglas Gregor
//           Andrew Lumsdaine
#ifndef BOOST_GRAPH_PYTHON_POINT3D_HPP
#define BOOST_GRAPH_PYTHON_POINT3D_HPP

#include <iostream>
#include <boost/graph/point_traits.hpp>

namespace boost { namespace graph { namespace python {
  class point3d
  {
  public:
    point3d() { coordinates[0] = coordinates[1] = coordinates[2] = 0.0f; }

    point3d(float x, float y, float z)
    {
      coordinates[0] = x;
      coordinates[1] = y;
      coordinates[2] = z;
    }

    float&       operator[](std::size_t i)       { return coordinates[i]; }
    const float& operator[](std::size_t i) const { return coordinates[i]; }

  private:
    float coordinates[3];
  };

  inline std::ostream& operator<<(std::ostream& out, point3d p)
  {
    return out << p[0] << ' ' << p[1] << ' ' << p[2];
  }

  inline std::istream& operator>>(std::istream& in, point3d& p)
  {
    return in >> p[0] >> p[1] >> p[2];
  }

  inline bool operator==(const point3d& p1, const point3d& p2)
  {
    return p1[0] == p2[0] && p1[1] == p2[1] && p1[2] == p2[2];
  }

  inline bool operator!=(const point3d& p1, const point3d& p2)
  {
    return p1[0] != p2[0] || p1[1] != p2[1] || p1[2];
  }
} // end namespace python

template<>
struct point_traits<boost::graph::python::point3d>
{
  typedef float component_type;

  static std::size_t dimensions(const boost::graph::python::point3d&)
  { return 3; }
};

} } // end namespace boost::graph

#endif // BOOST_GRAPH_PYTHON_POINT3D_HPP

max_stars_repo_name: erwinvaneijk/bgl-python

max_issues_repo_name: erwinvaneijk/bgl-python

max_forks_repo_name: erwinvaneijk/bgl-python


text:
#include "Attributes.h"
#include "Attribute.h"
//#include "json.h"
#include <boost/foreach.hpp>

namespace Limitless
{

void Attributes::addAttribute(SharedAttribute attribute)
{
    m_attributes[attribute->name()]=attribute;
}

std::vector<std::string> Attributes::keys() const
{
    std::vector<std::string> localKeys;

    for(SharedAttributeMap::const_iterator iter=m_attributes.begin(); iter!=m_attributes.end(); ++iter)
        localKeys.push_back(iter->first);
    return localKeys;
}

void merge(Attributes &dst, const Attributes &src)
{
    for(const Attributes::value_type &value:src)
    {
        dst[value.first]=value.second;
    }
}

SharedAttribute Attributes::find(const char *key) const
{
    const std::string stringKey(key);

    return find(stringKey);
}

SharedAttribute Attributes::find(const std::string &key) const
{
    SharedAttributeMap::const_iterator iter=m_attributes.find(key);

    if(iter!=m_attributes.end())
        return iter->second;
    return SharedAttribute();
}

void Attributes::serialize(Serializer *serializer)
{
    serializer->addKey("attributes");
    serializer->startObject();

    for(value_type &attribute:m_attributes)
        attribute.second->serialize(serializer);

    serializer->endObject();
}

void Attributes::unserialize(Unserializer *unserializer)
{
    if(unserializer->key("attributes"))
    {
        if(unserializer->type()==Type::OBJECT)
        {
            unserializer->openObject();

            for(value_type &attribute:m_attributes)
                attribute.second->unserialize(unserializer);

            unserializer->closeObject();
        }
    }
}

}//namespace Limitless

max_stars_repo_name: InfiniteInteractive/LimitlessSDK

max_issues_repo_name: InfiniteInteractive/LimitlessSDK

max_forks_repo_name: InfiniteInteractive/LimitlessSDK


text:
#ifndef GIFS_CONVERSION_H
#define GIFS_CONVERSION_H

#include <algorithm>
#include <armadillo>

/* Direct conversion! */
class Conversion
{
public:
    //
    explicit Conversion(double mass, double length, double time);
    Conversion(const Conversion& rhs) = default;
    Conversion(Conversion&& rhs) = default;
    Conversion& operator=(const Conversion& rhs) = default;
    Conversion& operator=(Conversion&& rhs) = default;

    //
    template<typename itr1, typename itr2>
    inline
    void
    transform_crd_md2au(itr1 in_begin, itr1 in_end, itr2 result_begin) {
        std::transform(in_begin, in_end, result_begin, [this](double value){ return this->crd_md2au(value); });
    };
    //
    template<typename itr1, typename itr2>
    inline
    void
    transform_veloc_md2au(itr1 in_begin, itr1 in_end, itr2 result_begin) {
        std::transform(in_begin, in_end, result_begin, [this](double value){ return this->veloc_md2au(value); });
    }
    //
    template<typename itr1, typename itr2>
    inline
    void
    transform_veloc_au2md(itr1 in_begin, itr1 in_end, itr2 result_begin) {
        std::transform(in_begin, in_end, result_begin, [this](double value){ return this->veloc_au2md(value); });
    }
    //
    template<typename itr1, typename itr2>
    inline
    void
    transform_gradient_au2md(itr1 in_begin, itr1 in_end, itr2 result_begin) {
        std::transform(in_begin, in_end, result_begin, [this](double value){ return this->grd_au2md(value); });
    }
    //
    template<typename itr1, typename itr2>
    inline
    void
    transform_gradient_md2au(itr1 in_begin, itr1 in_end, itr2 result_begin) {
        std::transform(in_begin, in_end, result_begin, [this](double value){ return this->grd_md2au(value); });
    }
    //
    template<typename itr1, typename itr2>
    inline
    void
    transform_masses_md2au(itr1 in_begin, itr1 in_end, itr2 result_begin) {
        std::transform(in_begin, in_end, result_begin, [this](double value){ return this->mass_md2au(value); });
    }
    //
    inline double energy_au2md(double value) const noexcept {return _energy_au2md*value;}
    inline double energy_md2au(double value) const noexcept {return _energy_md2au*value;}
    //
    inline double crd_au2md(double value) const noexcept {return _crd_au2md*value;}
    inline double crd_md2au(double value) const noexcept {return _crd_md2au*value;}
    //
    inline double veloc_au2md(double value) const noexcept {return _veloc_au2md*value;}
    inline double veloc_md2au(double value) const noexcept {return _veloc_md2au*value;}
    //
    inline double grd_au2md(double value) const noexcept {return _grd_au2md*value;}
    inline double grd_md2au(double value) const noexcept {return _grd_md2au*value;}
    //
    inline double mass_au2md(double value) const noexcept {return _mass_au2md*value;}
    inline double mass_md2au(double value) const noexcept {return _mass_md2au*value;}

private:
    // energies
    double _energy_au2md;
    double _energy_md2au;
    // coordinates
    double _crd_au2md;
    double _crd_md2au;
    // velocities
    double _veloc_au2md;
    double _veloc_md2au;
    // gradient
    double _grd_au2md;
    double _grd_md2au;
    // mass
    double _mass_au2md;
    double _mass_md2au;
    //
};

#endif


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

#include <alibabacloud/dplus_20201216.hpp>
#include <alibabacloud/endpoint_util.hpp>
#include <alibabacloud/open_api.hpp>
#include <alibabacloud/open_api_util.hpp>
#include <alibabacloud/open_platform_20191219.hpp>
#include <alibabacloud/oss.hpp>
#include <alibabacloud/ossutil.hpp>
#include <alibabacloud/rpc.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_Dplus20201216;

Alibabacloud_Dplus20201216::Client::Client(const shared_ptr<Alibabacloud_OpenApi::Config>& config) : Alibabacloud_OpenApi::Client(config) {
  _endpointRule = make_shared<string>("");
  checkConfig(config);
  _endpoint = make_shared<string>(getEndpoint(make_shared<string>("dplus"), _regionId, _endpointRule, _network, _suffix, _endpointMap, _endpoint));
};

string Alibabacloud_Dplus20201216::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);
}

AePredictCategoryResponse Alibabacloud_Dplus20201216::Client::aePredictCategoryWithOptions(shared_ptr<AePredictCategoryRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> body = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<string>(request->picUrl)) {
    body->insert(pair<string, string>("PicUrl", *request->picUrl));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"body", boost::any(Alibabacloud_OpenApiUtil::Client::parseToMap(body))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("AePredictCategory"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return AePredictCategoryResponse(callApi(params, req, runtime));
}

AePredictCategoryResponse Alibabacloud_Dplus20201216::Client::aePredictCategory(shared_ptr<AePredictCategoryRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return aePredictCategoryWithOptions(request, runtime);
}

AePredictCategoryResponse Alibabacloud_Dplus20201216::Client::aePredictCategoryAdvance(shared_ptr<AePredictCategoryAdvanceRequest> 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> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  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("dplus"))},
    {"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_OpenApiUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<AePredictCategoryRequest> aePredictCategoryReq = make_shared<AePredictCategoryRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(request, aePredictCategoryReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->picUrlObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_OpenApiUtil::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->picUrlObject ? boost::any() : boost::any(*request->picUrlObject)},
      {"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);
    aePredictCategoryReq->picUrl = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<AePredictCategoryResponse> aePredictCategoryResp = make_shared<AePredictCategoryResponse>(aePredictCategoryWithOptions(aePredictCategoryReq, runtime));
  return *aePredictCategoryResp;
}

AePropRecResponse Alibabacloud_Dplus20201216::Client::aePropRecWithOptions(shared_ptr<AePropRecRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> body = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<string>(request->picUrl)) {
    body->insert(pair<string, string>("PicUrl", *request->picUrl));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"body", boost::any(Alibabacloud_OpenApiUtil::Client::parseToMap(body))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("AePropRec"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return AePropRecResponse(callApi(params, req, runtime));
}

AePropRecResponse Alibabacloud_Dplus20201216::Client::aePropRec(shared_ptr<AePropRecRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return aePropRecWithOptions(request, runtime);
}

AePropRecResponse Alibabacloud_Dplus20201216::Client::aePropRecAdvance(shared_ptr<AePropRecAdvanceRequest> 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> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  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("dplus"))},
    {"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_OpenApiUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<AePropRecRequest> aePropRecReq = make_shared<AePropRecRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(request, aePropRecReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->picUrlObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_OpenApiUtil::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->picUrlObject ? boost::any() : boost::any(*request->picUrlObject)},
      {"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);
    aePropRecReq->picUrl = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<AePropRecResponse> aePropRecResp = make_shared<AePropRecResponse>(aePropRecWithOptions(aePropRecReq, runtime));
  return *aePropRecResp;
}

AlivisionImgdupResponse Alibabacloud_Dplus20201216::Client::alivisionImgdupWithOptions(shared_ptr<AlivisionImgdupRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> body = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<long>(request->imageHeight)) {
    body->insert(pair<string, long>("ImageHeight", *request->imageHeight));
  }
  if (!Darabonba_Util::Client::isUnset<long>(request->imageWidth)) {
    body->insert(pair<string, long>("ImageWidth", *request->imageWidth));
  }
  if (!Darabonba_Util::Client::isUnset<long>(request->outputImageNum)) {
    body->insert(pair<string, long>("OutputImageNum", *request->outputImageNum));
  }
  if (!Darabonba_Util::Client::isUnset<long>(request->picNum)) {
    body->insert(pair<string, long>("PicNum", *request->picNum));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->picUrl)) {
    body->insert(pair<string, string>("PicUrl", *request->picUrl));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"body", boost::any(Alibabacloud_OpenApiUtil::Client::parseToMap(body))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("AlivisionImgdup"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return AlivisionImgdupResponse(callApi(params, req, runtime));
}

AlivisionImgdupResponse Alibabacloud_Dplus20201216::Client::alivisionImgdup(shared_ptr<AlivisionImgdupRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return alivisionImgdupWithOptions(request, runtime);
}

AlivisionImgdupResponse Alibabacloud_Dplus20201216::Client::alivisionImgdupAdvance(shared_ptr<AlivisionImgdupAdvanceRequest> 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> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  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("dplus"))},
    {"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_OpenApiUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<AlivisionImgdupRequest> alivisionImgdupReq = make_shared<AlivisionImgdupRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(request, alivisionImgdupReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->picUrlObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_OpenApiUtil::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->picUrlObject ? boost::any() : boost::any(*request->picUrlObject)},
      {"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);
    alivisionImgdupReq->picUrl = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<AlivisionImgdupResponse> alivisionImgdupResp = make_shared<AlivisionImgdupResponse>(alivisionImgdupWithOptions(alivisionImgdupReq, runtime));
  return *alivisionImgdupResp;
}

CreateImageAmazonTaskResponse Alibabacloud_Dplus20201216::Client::createImageAmazonTaskWithOptions(shared_ptr<CreateImageAmazonTaskRequest> tmpReq, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(tmpReq);
  shared_ptr<CreateImageAmazonTaskShrinkRequest> request = make_shared<CreateImageAmazonTaskShrinkRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(tmpReq, request);
  if (!Darabonba_Util::Client::isUnset<vector<string>>(tmpReq->imgUrlList)) {
    request->imgUrlListShrink = make_shared<string>(Alibabacloud_OpenApiUtil::Client::arrayToStringWithSpecifiedStyle(tmpReq->imgUrlList, make_shared<string>("ImgUrlList"), make_shared<string>("json")));
  }
  if (!Darabonba_Util::Client::isUnset<vector<string>>(tmpReq->textList)) {
    request->textListShrink = make_shared<string>(Alibabacloud_OpenApiUtil::Client::arrayToStringWithSpecifiedStyle(tmpReq->textList, make_shared<string>("TextList"), make_shared<string>("json")));
  }
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<bool>(request->gif)) {
    query->insert(pair<string, bool>("Gif", *request->gif));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->imgUrlListShrink)) {
    query->insert(pair<string, string>("ImgUrlList", *request->imgUrlListShrink));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->templateMode)) {
    query->insert(pair<string, string>("TemplateMode", *request->templateMode));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->textListShrink)) {
    query->insert(pair<string, string>("TextList", *request->textListShrink));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("CreateImageAmazonTask"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return CreateImageAmazonTaskResponse(callApi(params, req, runtime));
}

CreateImageAmazonTaskResponse Alibabacloud_Dplus20201216::Client::createImageAmazonTask(shared_ptr<CreateImageAmazonTaskRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createImageAmazonTaskWithOptions(request, runtime);
}

FaceshifterTResponse Alibabacloud_Dplus20201216::Client::faceshifterTWithOptions(shared_ptr<FaceshifterTRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> body = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<long>(request->age)) {
    body->insert(pair<string, long>("Age", *request->age));
  }
  if (!Darabonba_Util::Client::isUnset<long>(request->gender)) {
    body->insert(pair<string, long>("Gender", *request->gender));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->picUrl)) {
    body->insert(pair<string, string>("PicUrl", *request->picUrl));
  }
  if (!Darabonba_Util::Client::isUnset<long>(request->race)) {
    body->insert(pair<string, long>("Race", *request->race));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"body", boost::any(Alibabacloud_OpenApiUtil::Client::parseToMap(body))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("FaceshifterT"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return FaceshifterTResponse(callApi(params, req, runtime));
}

FaceshifterTResponse Alibabacloud_Dplus20201216::Client::faceshifterT(shared_ptr<FaceshifterTRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return faceshifterTWithOptions(request, runtime);
}

FaceshifterTResponse Alibabacloud_Dplus20201216::Client::faceshifterTAdvance(shared_ptr<FaceshifterTAdvanceRequest> 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> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  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("dplus"))},
    {"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_OpenApiUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<FaceshifterTRequest> faceshifterTReq = make_shared<FaceshifterTRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(request, faceshifterTReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->picUrlObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_OpenApiUtil::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->picUrlObject ? boost::any() : boost::any(*request->picUrlObject)},
      {"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);
    faceshifterTReq->picUrl = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<FaceshifterTResponse> faceshifterTResp = make_shared<FaceshifterTResponse>(faceshifterTWithOptions(faceshifterTReq, runtime));
  return *faceshifterTResp;
}

GetTaskResultResponse Alibabacloud_Dplus20201216::Client::getTaskResultWithOptions(shared_ptr<GetTaskResultRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<long>(request->taskId)) {
    query->insert(pair<string, long>("TaskId", *request->taskId));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("GetTaskResult"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return GetTaskResultResponse(callApi(params, req, runtime));
}

GetTaskResultResponse Alibabacloud_Dplus20201216::Client::getTaskResult(shared_ptr<GetTaskResultRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return getTaskResultWithOptions(request, runtime);
}

GetTaskStatusResponse Alibabacloud_Dplus20201216::Client::getTaskStatusWithOptions(shared_ptr<GetTaskStatusRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<long>(request->taskId)) {
    query->insert(pair<string, long>("TaskId", *request->taskId));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("GetTaskStatus"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return GetTaskStatusResponse(callApi(params, req, runtime));
}

GetTaskStatusResponse Alibabacloud_Dplus20201216::Client::getTaskStatus(shared_ptr<GetTaskStatusRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return getTaskStatusWithOptions(request, runtime);
}

KuajingSegResponse Alibabacloud_Dplus20201216::Client::kuajingSegWithOptions(shared_ptr<KuajingSegRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> body = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<string>(request->picUrl)) {
    body->insert(pair<string, string>("PicUrl", *request->picUrl));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->returnPicFormat)) {
    body->insert(pair<string, string>("ReturnPicFormat", *request->returnPicFormat));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->returnPicType)) {
    body->insert(pair<string, string>("ReturnPicType", *request->returnPicType));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"body", boost::any(Alibabacloud_OpenApiUtil::Client::parseToMap(body))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("KuajingSeg"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return KuajingSegResponse(callApi(params, req, runtime));
}

KuajingSegResponse Alibabacloud_Dplus20201216::Client::kuajingSeg(shared_ptr<KuajingSegRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return kuajingSegWithOptions(request, runtime);
}

KuajingSegResponse Alibabacloud_Dplus20201216::Client::kuajingSegAdvance(shared_ptr<KuajingSegAdvanceRequest> 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> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  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("dplus"))},
    {"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_OpenApiUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<KuajingSegRequest> kuajingSegReq = make_shared<KuajingSegRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(request, kuajingSegReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->picUrlObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_OpenApiUtil::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->picUrlObject ? boost::any() : boost::any(*request->picUrlObject)},
      {"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);
    kuajingSegReq->picUrl = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<KuajingSegResponse> kuajingSegResp = make_shared<KuajingSegResponse>(kuajingSegWithOptions(kuajingSegReq, runtime));
  return *kuajingSegResp;
}

RemoveWordsResponse Alibabacloud_Dplus20201216::Client::removeWordsWithOptions(shared_ptr<RemoveWordsRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<string>(request->picUrl)) {
    query->insert(pair<string, string>("PicUrl", *request->picUrl));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("RemoveWords"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return RemoveWordsResponse(callApi(params, req, runtime));
}

RemoveWordsResponse Alibabacloud_Dplus20201216::Client::removeWords(shared_ptr<RemoveWordsRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return removeWordsWithOptions(request, runtime);
}

RemoveWordsResponse Alibabacloud_Dplus20201216::Client::removeWordsAdvance(shared_ptr<RemoveWordsAdvanceRequest> 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> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  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("dplus"))},
    {"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_OpenApiUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<RemoveWordsRequest> removeWordsReq = make_shared<RemoveWordsRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(request, removeWordsReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->picUrlObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_OpenApiUtil::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->picUrlObject ? boost::any() : boost::any(*request->picUrlObject)},
      {"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);
    removeWordsReq->picUrl = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<RemoveWordsResponse> removeWordsResp = make_shared<RemoveWordsResponse>(removeWordsWithOptions(removeWordsReq, runtime));
  return *removeWordsResp;
}

ReplaceBackgroundResponse Alibabacloud_Dplus20201216::Client::replaceBackgroundWithOptions(shared_ptr<ReplaceBackgroundRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  if (!Darabonba_Util::Client::isUnset<string>(request->backgroundId)) {
    query->insert(pair<string, string>("BackgroundId", *request->backgroundId));
  }
  if (!Darabonba_Util::Client::isUnset<long>(request->num)) {
    query->insert(pair<string, long>("Num", *request->num));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->picBackgroundUrl)) {
    query->insert(pair<string, string>("PicBackgroundUrl", *request->picBackgroundUrl));
  }
  if (!Darabonba_Util::Client::isUnset<string>(request->picUrl)) {
    query->insert(pair<string, string>("PicUrl", *request->picUrl));
  }
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("ReplaceBackground"))},
    {"version", boost::any(string("2020-12-16"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("formData"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return ReplaceBackgroundResponse(callApi(params, req, runtime));
}

ReplaceBackgroundResponse Alibabacloud_Dplus20201216::Client::replaceBackground(shared_ptr<ReplaceBackgroundRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return replaceBackgroundWithOptions(request, runtime);
}

ReplaceBackgroundResponse Alibabacloud_Dplus20201216::Client::replaceBackgroundAdvance(shared_ptr<ReplaceBackgroundAdvanceRequest> 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> securityToken = make_shared<string>(_credential->getSecurityToken());
  shared_ptr<string> credentialType = make_shared<string>(_credential->getType());
  shared_ptr<string> openPlatformEndpoint = _openPlatformEndpoint;
  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("dplus"))},
    {"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_OpenApiUtil::Client::convert(runtime, ossRuntime);
  shared_ptr<ReplaceBackgroundRequest> replaceBackgroundReq = make_shared<ReplaceBackgroundRequest>();
  Alibabacloud_OpenApiUtil::Client::convert(request, replaceBackgroundReq);
  if (!Darabonba_Util::Client::isUnset<Darabonba::Stream>(request->picUrlObject)) {
    authResponse = make_shared<Alibabacloud_OpenPlatform20191219::AuthorizeFileUploadResponse>(authClient->authorizeFileUploadWithOptions(authRequest, runtime));
    ossConfig->accessKeyId = authResponse->accessKeyId;
    ossConfig->endpoint = make_shared<string>(Alibabacloud_OpenApiUtil::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->picUrlObject ? boost::any() : boost::any(*request->picUrlObject)},
      {"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);
    replaceBackgroundReq->picUrl = make_shared<string>(string("http://") + string(*authResponse->bucket) + string(".") + string(*authResponse->endpoint) + string("/") + string(*authResponse->objectKey));
  }
  shared_ptr<ReplaceBackgroundResponse> replaceBackgroundResp = make_shared<ReplaceBackgroundResponse>(replaceBackgroundWithOptions(replaceBackgroundReq, runtime));
  return *replaceBackgroundResp;
}

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:
/**
 *    Copyright (C) 2015 MongoDB Inc.
 *
 *    This program is free software: you can redistribute it and/or  modify
 *    it under the terms of the GNU Affero General Public License, version 3,
 *    as published by the Free Software Foundation.
 *
 *    This program 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 Affero General Public License for more details.
 *
 *    You should have received a copy of the GNU Affero General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *    As a special exception, the copyright holders give permission to link the
 *    code of portions of this program with the OpenSSL library under certain
 *    conditions as described in each individual source file and distribute
 *    linked combinations including the program with the OpenSSL library. You
 *    must comply with the GNU Affero General Public License in all respects for
 *    all of the code used other than as permitted herein. If you modify file(s)
 *    with this exception, you may extend this exception to your version of the
 *    file(s), but you are not obligated to do so. If you do not wish to do so,
 *    delete this exception statement from your version. If you delete this
 *    exception statement from all source files in the program, then also delete
 *    it in the license file.
 */

#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery

#include "mongo/platform/basic.h"

#include "mongo/db/query/getmore_request.h"
#include "mongo/db/namespace_string.h"

#include <boost/optional.hpp>

#include "mongo/util/assert_util.h"
#include "mongo/util/stringutils.h"

namespace mongo {

namespace {

const char kCollectionField[] = "collection";
const char kBatchSizeField[] = "batchSize";
const char kMaxTimeMSField[] = "maxTimeMS";
const char kTermField[] = "term";

}  // namespace

const char GetMoreRequest::kGetMoreCommandName[] = "getMore";

GetMoreRequest::GetMoreRequest() : cursorid(0), batchSize(0) {}

GetMoreRequest::GetMoreRequest(NamespaceString namespaceString,
                               CursorId id,
                               boost::optional<long long> sizeOfBatch,
                               boost::optional<long long> term)
    : nss(std::move(namespaceString)), cursorid(id), batchSize(sizeOfBatch), term(term) {}

Status GetMoreRequest::isValid() const {
    if (!nss.isValid()) {
        return Status(ErrorCodes::BadValue,
                      str::stream() << "Invalid namespace for getMore: " << nss.ns());
    }

    if (cursorid == 0) {
        return Status(ErrorCodes::BadValue, "Cursor id for getMore must be non-zero");
    }

    if (batchSize && *batchSize <= 0) {
        return Status(ErrorCodes::BadValue,
                      str::stream() << "Batch size for getMore must be positive, "
                                    << "but received: " << *batchSize);
    }

    return Status::OK();
}

// static
std::string GetMoreRequest::parseNs(const std::string& dbname, const BSONObj& cmdObj) {
    BSONElement collElt = cmdObj["collection"];
    const std::string coll = (collElt.type() == BSONType::String) ? collElt.String() : "";

    return str::stream() << dbname << "." << coll;
}

// static
StatusWith<GetMoreRequest> GetMoreRequest::parseFromBSON(const std::string& dbname,
                                                         const BSONObj& cmdObj) {
    invariant(!dbname.empty());

    // Required fields.
    boost::optional<CursorId> cursorid;
    boost::optional<std::string> fullns;

    // Optional fields.
    boost::optional<long long> batchSize;
    boost::optional<long long> term;

    for (BSONElement el : cmdObj) {
        const char* fieldName = el.fieldName();
        if (str::equals(fieldName, kGetMoreCommandName)) {
            if (el.type() != BSONType::NumberLong) {
                return {ErrorCodes::TypeMismatch,
                        str::stream() << "Field 'getMore' must be of type long in: " << cmdObj};
            }

            cursorid = el.Long();
        } else if (str::equals(fieldName, kCollectionField)) {
            if (el.type() != BSONType::String) {
                return {ErrorCodes::TypeMismatch,
                        str::stream()
                            << "Field 'collection' must be of type string in: " << cmdObj};
            }

            fullns = parseNs(dbname, cmdObj);
        } else if (str::equals(fieldName, kBatchSizeField)) {
            if (!el.isNumber()) {
                return {ErrorCodes::TypeMismatch,
                        str::stream() << "Field 'batchSize' must be a number in: " << cmdObj};
            }

            batchSize = el.numberLong();
        } else if (str::equals(fieldName, kMaxTimeMSField)) {
            // maxTimeMS is parsed by the command handling code, so we don't repeat the parsing
            // here.
            continue;
        } else if (str::equals(fieldName, kTermField)) {
            if (el.type() != BSONType::NumberLong) {
                return {ErrorCodes::TypeMismatch,
                        str::stream() << "Field 'term' must be of type NumberLong in: " << cmdObj};
            }
            term = el.Long();
        } else if (!str::startsWith(fieldName, "$")) {
            return {ErrorCodes::FailedToParse,
                    str::stream() << "Failed to parse: " << cmdObj << ". "
                                  << "Unrecognized field '" << fieldName << "'."};
        }
    }

    if (!cursorid) {
        return {ErrorCodes::FailedToParse,
                str::stream() << "Field 'getMore' missing in: " << cmdObj};
    }

    if (!fullns) {
        return {ErrorCodes::FailedToParse,
                str::stream() << "Field 'collection' missing in: " << cmdObj};
    }

    GetMoreRequest request(NamespaceString(*fullns), *cursorid, batchSize, term);
    Status validStatus = request.isValid();
    if (!validStatus.isOK()) {
        return validStatus;
    }

    return request;
}

BSONObj GetMoreRequest::toBSON() const {
    BSONObjBuilder builder;

    builder.append(kGetMoreCommandName, cursorid);
    builder.append(kCollectionField, nss.coll());

    if (batchSize) {
        builder.append(kBatchSizeField, *batchSize);
    }

    if (term) {
        builder.append(kTermField, *term);
    }

    return builder.obj();
}

}  // namespace mongo

max_stars_repo_name: stbrody/mongo

max_issues_repo_name: stbrody/mongo

max_forks_repo_name: stbrody/mongo


text:
#ifndef BANK_HPP
#define BANK_HPP

#include <list>
#include <map>
#include <iostream>
#include <numeric>

#include "helper.hpp"
#include "ops.hpp"

#include <boost/serialization/utility.hpp>
#include <boost/serialization/map.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>

using namespace std;

class Tile;

class Bank{
    public:
        int id;
        data_type type;
        map<Tile*, int> allocated_tiles;
        int capacity; //in terms of bytes
        int capacity_used;

        list<pair<int, Tile*>>* evict_queue;
        list<pair<int, Tile*>>* spawn_queue;
        list<Tile*>* write_back_queue;

        Bank(){};
        Bank(int id, data_type type, int capacity);
        ~Bank();

        void spawn(int r);
        bool alloc_tile(int r, Tile* tile);
        bool evict(int r);
        void push_evict_queue(int r, Tile* tile);
        void garbage_collect(int r);
        void free_tile(Tile* tile);
        int evict_queue_size();

        friend class boost::serialization::access;

        template<class Archive>
        void serialize(Archive & ar, const unsigned int version){
            ar & this->id;
            ar & this->type;
            ar & this->allocated_tiles;
            ar & this->capacity;
            ar & this->capacity_used;
        }

    private:

};

class Banks{
    public:
        int no_banks;

        Banks(){};
        Banks(int no_banks, int bank_size);
        ~Banks();

        Bank* get_bank_by_id(int id, data_type type);
        list<Bank*>* get_x_banks();
        list<Bank*>* get_w_banks();
        list<Bank*>* get_p_banks();

        void garbage_collect(int r);
        void spawn(int r);

        bool is_write_back_empty();

        void print_usage();

        friend class boost::serialization::access;

        template<class Archive>
        void serialize(Archive & ar, const unsigned int version){
            ar & this->no_banks;
            ar & this->x_banks;
            ar & this->w_banks;
            ar & this->p_banks;
        }
    private:
        list<Bank*>* x_banks;
        list<Bank*>* w_banks;
        list<Bank*>* p_banks;

};

#endif /* BANK_HPP */

max_stars_repo_name: yuezuegu/sosa-compiler

max_issues_repo_name: yuezuegu/sosa-compiler

max_forks_repo_name: yuezuegu/sosa-compiler