text: #include <boost/range/algorithm/replace_copy_if.hpp>

ext: hpp

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
/*=============================================================================
    Copyright (c) 2001-2010 Joel de Guzman
    Copyright (c) 2001-2010 Hartmut Kaiser

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

#if defined(_MSC_VER)
#pragma once
#endif

#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/bool.hpp>

#if !defined(BOOST_SPIRIT_MAX_LOCALS_SIZE)
# define BOOST_SPIRIT_MAX_LOCALS_SIZE 10
#else
# if BOOST_SPIRIT_MAX_LOCALS_SIZE < 3
#   undef BOOST_SPIRIT_MAX_LOCALS_SIZE
#   define BOOST_SPIRIT_MAX_LOCALS_SIZE 10
# endif
#endif

namespace boost { namespace spirit
{
    ///////////////////////////////////////////////////////////////////////////
    template <
        BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
            BOOST_SPIRIT_MAX_LOCALS_SIZE, typename T, mpl::na)
    >
    struct locals
      : mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_SPIRIT_MAX_LOCALS_SIZE, T)> {};

    ///////////////////////////////////////////////////////////////////////////
    namespace detail
    {
        template <typename T>
        struct is_locals
          : mpl::false_
        {};

        template <BOOST_PP_ENUM_PARAMS(BOOST_SPIRIT_MAX_LOCALS_SIZE, typename T)>
        struct is_locals<locals<BOOST_PP_ENUM_PARAMS(BOOST_SPIRIT_MAX_LOCALS_SIZE, T)> >
          : mpl::true_
        {};
    }
}}

#endif

max_issues_repo_name: benkaraban/anima-games-engine

max_forks_repo_name: benkaraban/anima-games-engine


text:
//
// Copyright 2017 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
//    names, trademarks, service marks, or product names of the Licensor
//    and its affiliates, except as required to comply with Section 4(c) of
//    the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//

#include "pxr/pxr.h"
#include "pxr/base/vt/value.h"

#include "pxr/usd/usd/stage.h"
#include "pxr/usd/usd/prim.h"
#include "pxr/usd/usd/attribute.h"

#include "pxr/base/tf/debug.h"

#ifdef PXR_PYTHON_SUPPORT_ENABLED
#include <boost/python/detail/wrap_python.hpp>
#endif // PXR_PYTHON_SUPPORT_ENABLED

#include <iostream>

PXR_NAMESPACE_USING_DIRECTIVE

void
TestTemplates()
{
    // --------------------------------------------------------------------- //
    // This test operates on /RootPrim.foo
    // and /RootPrim.foo:hidden
    // --------------------------------------------------------------------- //
    SdfPath primPath("/RootPrim");
    TfToken prop("foo");
    TfToken metaField("hidden");
    std::string propPath(primPath.GetString() + "." + prop.GetString());

    // --------------------------------------------------------------------- //
    // Author scene and compose the Stage
    // --------------------------------------------------------------------- //
    SdfLayerRefPtr layer = SdfLayer::CreateAnonymous();
    UsdStageRefPtr stage = UsdStage::Open(layer->GetIdentifier());

    TF_VERIFY(stage->OverridePrim(primPath),
              "Failed to create prim at %s",
              primPath.GetText());

    UsdPrim prim(stage->GetPrimAtPath(primPath));
    TF_VERIFY(prim, "Failed to get Prim from %s", primPath.GetText());

    // Grab the attribute we will be testing with.
    UsdAttribute attr =
        prim.CreateAttribute(prop, SdfValueTypeNames->Double3Array);
    TF_VERIFY(attr, "Failed to create property at %s", propPath.c_str());

    // --------------------------------------------------------------------- //
    // Setup some test data
    // --------------------------------------------------------------------- //
    VtVec3dArray vtVecOut(1);
    VtVec3dArray vtVecIn;
    std::string tmp;

    VtValue value;

    // ===================================================================== //
    // TEST READING METADATA
    // ===================================================================== //

    // --------------------------------------------------------------------- //
    // GetMetadata & SetMetadata the value as a VtValue
    // --------------------------------------------------------------------- //
    TF_VERIFY(attr.SetMetadata(metaField, VtValue(true)),
              "VtValue: Failed to set hidden metadata at %s",
              propPath.c_str());

    // Print the layer for debugging.
    layer->ExportToString(&tmp);
    std::cout << "-----------------------------------------" << std::endl;
    std::cout << "Metadata -- VtValue:" << std::endl;
    std::cout << tmp << std::endl;

    // Verify the result.
    TF_VERIFY(attr.GetMetadata(metaField, &value),
              "Metadata -- VtValue: Failed to get property value at %s",
              propPath.c_str());
    TF_VERIFY(value.IsHolding<bool>(),
              "Metadata -- VtValue: not holding bool%s",
              propPath.c_str());
   TF_VERIFY(value.Get<bool>(),
              "Metadata -- VtValue: value was not true %s",
              propPath.c_str());

    // --------------------------------------------------------------------- //
    // GetMetadata & SetMetadata the value as bool
    // --------------------------------------------------------------------- //
    bool valueIn = false;
    TF_VERIFY(attr.SetMetadata(metaField, true),
              "Metadata -- bool: Failed to set property at %s",
              propPath.c_str());

    // Print the layer for debugging.
    tmp = "";
    layer->ExportToString(&tmp);
    std::cout << "-----------------------------------------" << std::endl;
    std::cout << "Metadata -- bool:" << std::endl;
    std::cout << tmp << std::endl;

    // Verify Result.
    TF_VERIFY(attr.GetMetadata(metaField, &valueIn),
              "Metadata -- bool: Failed to get property value at %s",
              propPath.c_str());
    TF_VERIFY(valueIn,
              "Metadata -- bool: value was not true %s",
              propPath.c_str());

    // ===================================================================== //
    // TEST READING VALUES
    // ===================================================================== //

    // --------------------------------------------------------------------- //
    // Get & Set the value as a VtValue
    // --------------------------------------------------------------------- //
    vtVecOut[0] = GfVec3d(9,8,7);
    TF_VERIFY(attr.Set(VtValue(vtVecOut)),
              "VtValue: Failed to set property at %s",
              propPath.c_str());

    // Print the layer for debugging.
    layer->ExportToString(&tmp);
    std::cout << "-----------------------------------------" << std::endl;
    std::cout << "VtValue:" << std::endl;
    std::cout << tmp << std::endl;

    // Verify the result.
    TF_VERIFY(attr.Get(&value),
              "VtValue: Failed to get property value at %s",
              propPath.c_str());
    TF_VERIFY(value.IsHolding<VtVec3dArray>(),
              "VtValue: not holding VtVec3dArray %s",
              propPath.c_str());
   TF_VERIFY(value.Get<VtVec3dArray>()[0] == vtVecOut[0],
              "VtValue: VtVec3d[0] does not match %s",
              propPath.c_str());

    // --------------------------------------------------------------------- //
    // Get & Set the value as a VtArray
    // --------------------------------------------------------------------- //
    vtVecOut[0] = GfVec3d(6,5,4);
    TF_VERIFY(attr.Set(vtVecOut),
              "Failed to set property at %s",
              propPath.c_str());

    // Print the layer for debugging.
    tmp = "";
    layer->ExportToString(&tmp);
    std::cout << "-----------------------------------------" << std::endl;
    std::cout << "VtArray:" << std::endl;
    std::cout << tmp << std::endl;

    // Verify Result.
    TF_VERIFY(attr.Get(&vtVecIn),
              "VtArray: Failed to get property value at %s",
              propPath.c_str());
    TF_VERIFY(vtVecIn[0] == vtVecOut[0],
              "VtArray: VtVec3d[0] does not match %s",
              propPath.c_str());

    // --------------------------------------------------------------------- //
    // Get & Set the value as a VtDictionary (Dictionary composition semantics
    // are exercised in testUsdMetadata).
    // --------------------------------------------------------------------- //
    VtDictionary inDict;
    inDict["$Side"] = "R";
    TF_VERIFY(!prim.HasAuthoredMetadata(SdfFieldKeys->PrefixSubstitutions));
    TF_VERIFY(prim.SetMetadata(SdfFieldKeys->PrefixSubstitutions, inDict));
    VtDictionary outDict;
    TF_VERIFY(prim.HasAuthoredMetadata(SdfFieldKeys->PrefixSubstitutions));
    // Verify bug 97783 - GetMetadata should return true if Usd was able to
    // retrieve/compose a VtDictionary.
    TF_VERIFY(prim.GetMetadata(SdfFieldKeys->PrefixSubstitutions,&outDict));
    TF_VERIFY(inDict == outDict);
    std::cout << "-----------------------------------------" << std::endl;
    std::cout << "VtDictionary:" << std::endl;
    tmp = "";
    layer->ExportToString(&tmp);
    std::cout << tmp << std::endl;

}

int main()
{
    TestTemplates();

#ifdef PXR_PYTHON_SUPPORT_ENABLED
    TF_AXIOM(!Py_IsInitialized());
#endif // PXR_PYTHON_SUPPORT_ENABLED
}

ext: cpp

max_stars_repo_name: Tuftux/USD

max_issues_repo_name: Tuftux/USD

max_forks_repo_name: Tuftux/USD


text:
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.

// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.

// 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)

#ifndef BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP
#define BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP

#include <boost/mpl/assert.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/geometry/core/point_type.hpp>

namespace boost { namespace geometry
{

namespace traits
{

/*!
\brief Traits class defining the coordinate system of a point, important for strategy selection
\ingroup traits
\par Geometries:
    - point
\par Specializations should provide:
    - typedef CS type; (cs::cartesian, cs::spherical, etc)
*/
template <typename Point, typename Enable = void>
struct coordinate_system
{
    BOOST_MPL_ASSERT_MSG
        (
            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Point>)
        );
};

} // namespace traits

#ifndef DOXYGEN_NO_DISPATCH
namespace core_dispatch
{
    template <typename GeometryTag, typename G>
    struct coordinate_system
    {
        typedef typename point_type<GeometryTag, G>::type P;

        // Call its own specialization on point-tag
        typedef typename coordinate_system<point_tag, P>::type type;
    };

    template <typename P>
    struct coordinate_system<point_tag, P>
    {
        typedef typename traits::coordinate_system<P>::type type;
    };

} // namespace core_dispatch
#endif

/*!
\brief \brief_meta{type, coordinate system (cartesian\, spherical\, etc), \meta_point_type}
\tparam Geometry \tparam_geometry
\ingroup core

\qbk{[include reference/core/coordinate_system.qbk]}
*/
template <typename Geometry>
struct coordinate_system
{
    typedef typename boost::remove_const<Geometry>::type ncg;
    typedef typename core_dispatch::coordinate_system
        <
            typename tag<Geometry>::type,
            ncg
        >::type type;
};

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP

max_stars_repo_name: bobzabcik/OpenStudio

max_issues_repo_name: bobzabcik/OpenStudio

max_forks_repo_name: bobzabcik/OpenStudio


text:
/*
* Copyright (C) 2016 Turi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* 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/>.
*/
#include <cstdlib>
#include <vector>
#include <fstream>
#include <string>
#include <boost/algorithm/string.hpp>
#include <fault/query_object_server_manager.hpp>

int main(int argc, char** argv) {
  if (argc < 5) {
    std::cout << "Usage: " << argv[0] << " [zkhosts] [prefix] [object name list / file]\n"
              << "             [server program] [replicacount = 2] [object capacity = 32]\n"
              << "             [initial max masters = inf] \n";
    std::cout << "zkhosts is a comma seperated list of zookeeper servers\n";
    std::cout << "Object name list can be a comma separated list of names, or a filename\n";
    std::cout << "initial max masters is the maximum number of masters to create at the start\n";
    std::cout << "replicacount, object capacity, and max masters are optional\n";
    return 0;
  }

  // parse zkhosts
  std::vector<std::string> zkhosts;
  boost::split(zkhosts, argv[1],
               boost::is_any_of(", "), boost::token_compress_on);

  // parse prefix
  std::string prefix = argv[2];

  // parse object space
  std::vector<std::string> masterspace;
  std::ifstream fin(argv[3]);
  if (fin.good()) {
    std::cout << "Interpreting " << argv[3] << " as a file\n";
    while (!fin.eof()) {
      std::string s;
      fin >> s;
      boost::trim(s);
      if (!s.empty()) masterspace.push_back(s);
    }
  } else {
    std::cout << "Interpreting " << argv[3] << " as a comma seperated list\n";
    boost::split(masterspace, argv[3],
                 boost::is_any_of(", "), boost::token_compress_on);
  }

  // parse program
  std::string program = argv[4];

  size_t replicacount = 2;
  size_t objectcap = 32;
  size_t max_masters = (size_t)(-1);

  if (argc >= 6) replicacount = atoi(argv[5]);
  if (argc >= 7) objectcap = atoi(argv[6]);
  if (argc >= 8) max_masters = atoi(argv[7]);

  libfault::query_object_server_manager manager(program, replicacount, objectcap);
  manager.register_zookeeper(zkhosts, prefix);
  manager.set_all_object_keys(masterspace);
  std::cout << "\n\n\n";
  manager.start(max_masters);
  while(1) {
    std::cout << "l: list objects\n";
    std::cout << "s [object]: stop managing object\n";
    std::cout << "q: quit\n";
    char command;
    std::cin >> command;
    if (command == 'q') break;
    else if (command == 'l'){
      manager.print_all_object_names();
    } else if(command == 's') {
      std::string objectname;
      std::cin >> objectname;

      manager.stop_managing_object(objectname);
      std::cout << "\n";
    }
  }
  manager.stop();
}

max_stars_repo_name: venkattgg/venkey

max_issues_repo_name: venkattgg/venkey

max_forks_repo_name: venkattgg/venkey


text:
//  (C) Copyright Steve Cleary & John Maddock 2000.
//  Use, modification and distribution are 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)

//  See http://www.boost.org for most recent version including documentation.

#include <boost/static_assert.hpp>

//
// all these tests should fail:
//

// Template class scope
template <class Int, class Char>
struct Bill
{
  private:  // can be in private, to avoid namespace pollution
    BOOST_STATIC_ASSERT(sizeof(Int) == 4);
    //BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Char)); // should not compile when instantiated
  public:

  // Template member function scope: provides access to member variables
  Int x;
  Char c;
  template <class Int2, class Char2>
  void f(Int2 , Char2 )
  {
    BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Int2));
    BOOST_STATIC_ASSERT(sizeof(Char) == sizeof(Char2));
    BOOST_STATIC_ASSERT(sizeof(Int) == sizeof(Char)); // should not compile when instantiated
  }
};

void foo()
{
   int i = 0;
   char c = 0;
   Bill<int, char> b;
   // this should fail:
   b.f(i, c);
}

max_stars_repo_name: randolphwong/mcsema

max_issues_repo_name: randolphwong/mcsema

max_forks_repo_name: randolphwong/mcsema


text:
// Copyright Louis Dionne 2013-2016
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)

#include <boost/hana/bool.hpp>
#include <boost/hana/core/make.hpp>
#include <boost/hana/tuple.hpp>

#include <support/seq.hpp>

#include <laws/base.hpp>
#include <laws/searchable.hpp>
namespace hana = boost::hana;
using hana::test::ct_eq;

int main() {
    //////////////////////////////////////////////////////////////////////////
    // Laws with a minimal Searchable
    //////////////////////////////////////////////////////////////////////////
    {
        auto eqs = hana::make_tuple(
              ::seq()
            , ::seq(ct_eq<0>{})
            , ::seq(ct_eq<0>{}, ct_eq<1>{})
            , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
            , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})
        );

        auto eq_keys = hana::make_tuple(ct_eq<0>{}, ct_eq<3>{}, ct_eq<10>{});

        hana::test::TestSearchable<::Seq>{eqs, eq_keys};

        auto bools = hana::make_tuple(
              ::seq(hana::true_c)
            , ::seq(hana::false_c)
            , ::seq(hana::true_c, hana::true_c)
            , ::seq(hana::true_c, hana::false_c)
            , ::seq(hana::false_c, hana::true_c)
            , ::seq(hana::false_c, hana::false_c)
        );
        hana::test::TestSearchable<::Seq>{bools, hana::make_tuple(hana::true_c, hana::false_c)};
    }
}

max_stars_repo_name: metux/boost

max_issues_repo_name: metux/boost

max_forks_repo_name: metux/boost


text:
#include <url_utils.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <regex>
#include <message_types.hpp>

vector<string_t> UrlUtils::splitUri(const http_request& message)
{
	return uri::split_path(uri::decode(message.relative_uri().path()));
}

/// <summary>
/// Gets the name of the table.
/// Validates the table name using regular expression
/// Returns true if maches otherwise returns false
/// </summary>
/// <param name="paths">vector of paths.</param>
/// <param name="table">referece to table name.</param>
/// <returns></returns>
bool UrlUtils::getTableName(const vector<string_t> paths, string_t &table)
{
	//Expression will check for Table('name')
	//Table name must be 2 to 62 long and  can have alphanumaric characters
	const wregex expression(U("^(?:Tables\\(')([A-Za-z][A-Za-z0-9]{2,62})(?:'\\))$"));
	wsmatch what;
	//Path[1] is the Table('name')
	if (regex_match(paths[0], what, expression))
	{
		table = what[1]; //There are three sets in the expression, 2nd is the table name
		return true;
	}
	return false;
}

bool UrlUtils::getTableNamespace(const vector<string_t> paths, string_t &tablenamespace)
{
	if (paths.size() > 0)
	{
		tablenamespace = paths[0];
		return true;
	}
	return false;
}

map<string_t, string_t> UrlUtils::splitQueryString(const http_request& message)
{
	return uri::split_query(uri::decode(message.relative_uri().query()));
}

vector<string_t> UrlUtils::getColumnNames(string_t str)
{
	vector<string_t> columns;
	boost::split(columns, str, boost::is_any_of(","));
	return columns;
}

bool UrlUtils::hasTables(vector<string_t> const paths)
{
	if (paths.size() >= 0 && paths[0] == U("Tables"))
	{
		return true;
	}
	return false;
}

bool UrlUtils::hasQuery(vector<string_t> const paths)
{
	if (paths.size() >= 0 && paths[0] == U("Query"))
	{
		return true;
	}
	return false;
}

bool UrlUtils::hasAdministration(vector<string_t> const paths)
{
	if (paths.size() >= 0 && paths[0] == U("Administration"))
	{
		return true;
	}
	return false;
}

bool UrlUtils::getTableNameWithKeys(vector<string_t> const paths, string_t& table, string_t& rowkey, string_t& paritionkey)
{
	//Expression will check for tablename(RowKey='<rowkey>',PartitionKey='<partitionkey>')
	//Table name must be 2 to 62 long and  can have alphanumaric characters
	const wregex expression(U("^([A-Za-z][A-Za-z0-9]{2,62})(?:\\()(?:(?:PartitionKey=')(\\w+)(?:',RowKey=')(\\w+)(?:'))?(?:\\))$"));
	wsmatch what;
	//Path[1] is the Table('name')
	if (regex_match(paths[0], what, expression))
	{
		table = what[1]; //There are three sets in the expression, 2nd is the table name
		paritionkey = what[2];
		rowkey = what[3];
		return true;
	}
	return false;
}

bool UrlUtils::getTableNameWithoutKeys(vector<string_t> const paths, string_t& table)
{
	//Expression will check for tablename(RowKey='<rowkey>',PartitionKey='<partitionkey>')
	//Table name must be 2 to 62 long and  can have alphanumaric characters
	const wregex expression(U("^([A-Za-z][A-Za-z0-9]{2,62})(?:\\()?(?:\\))?$"));
	wsmatch what;
	//Path[1] is the Table('name')
	if (regex_match(paths[0], what, expression))
	{
		table = what[1]; //There are three sets in the expression, 2nd is the table name
		return true;
	}
	return false;
}

bool UrlUtils::getAnalyze(vector<string_t> const paths, string_t& tablename)
{
	if (paths.size() >= 2 && paths[1] == U("Analyze") && !paths[2].empty())
	{
		tablename = paths[2];
		return true;
	}
	return false;
}

bool UrlUtils::getCheck(vector<string_t> const paths, string_t& tablename)
{
	if (paths.size() >= 2 && paths[1] == U("Check") && !paths[2].empty())
	{
		tablename = paths[2];
		return true;
	}
	return false;
}

bool UrlUtils::getRepair(vector<string_t> const paths, string_t& tablename)
{
	if (paths.size() >= 2 && paths[1] == U("Repair") && !paths[2].empty())
	{
		tablename = paths[2];
		return true;
	}
	return false;
}

bool UrlUtils::getIndexes(vector<string_t> const paths, string_t& tablename)
{
	if (paths.size() >= 2 && paths[1] == U("Indexes") && !paths[2].empty())
	{
		tablename = paths[2];
		return true;
	}
	return false;
}

bool UrlUtils::getKeys(vector<string_t> const paths, string_t& tablename)
{
	if (paths.size() >= 2 && paths[1] == U("Keys") && !paths[2].empty())
	{
		tablename = paths[2];
		return true;
	}
	return false;
}

bool UrlUtils::getOptimize(vector<string_t> const paths, string_t& tablename)
{
	if (paths.size() >= 2 && paths[1] == U("Optimize") && !paths[2].empty())
	{
		tablename = paths[2];
		return true;
	}
	return false;
}

bool UrlUtils::hasEngines(vector<string_t> const paths)
{
	if (paths.size() >= 2 && paths[1] == U("Engines"))
	{
		return true;
	}
	return false;
}

bool UrlUtils::hasStatus(vector<string_t> const paths)
{
	if (paths.size() >= 2 && paths[1] == U("Status"))
	{
		return true;
	}
	return false;
}

bool UrlUtils::hasPlugins(vector<string_t> const paths)
{
	if (paths.size() >= 2 && paths[1] == U("Plugins"))
	{
		return true;
	}
	return false;
}

bool UrlUtils::hasOpenTables(vector<string_t> const paths)
{
	if (paths.size() >= 2 && paths[1] == U("OpenTables"))
	{
		return true;
	}
	return false;
}

bool UrlUtils::getFilter(map<string_t, string_t> const query, map<string_t, string_t> &filter)
{
	map<string_t, string_t> parsed_query;

	//Expression will check for tablename(RowKey='<rowkey>',PartitionKey='<partitionkey>')
	//Table name must be 2 to 62 long and  can have alphanumaric characters
	string_t expression_string = U("^(?:(?:\\()(\\w+)(?:\\s)(le|lt|ge|gt|ne|eq)(?:\\s)(\\w+)(?:\\)))(?:(?:\\s)(and|or)(?:\\s)(?:(?:\\()(\\w+)(?:\\s)(le|lt|ge|gt|ne|eq)(?:\\s)(\\w+)(?:\\))))?$");
	auto lfilter = query.find(FILTER);
	if (lfilter != query.end())
	{
		const wregex expression(expression_string);
		wsmatch what;
		//Path[1] is the Table('name')
		string_t filter_value = lfilter->second;
		if (regex_match(filter_value, what, expression))
		{
			if (what.size() >= 3)
			{
				parsed_query.insert(make_pair(U("first_attr"), what[1]));
				parsed_query.insert(make_pair(U("first_con"), what[2]));
				parsed_query.insert(make_pair(U("first_val"), what[3]));
				if (what.size() == 8)
				{
					parsed_query.insert(make_pair(U("join"), what[4]));
					parsed_query.insert(make_pair(U("second_attr"), what[5]));
					parsed_query.insert(make_pair(U("second_con"), what[6]));
					parsed_query.insert(make_pair(U("second_val"), what[7]));
				}
				filter = parsed_query;
				return true;
			}
		}
	}
	return false;
}

bool UrlUtils::getSelect(map<string_t, string_t> const query, vector<string_t>& select)
{
	if (query.find(SELECT) != query.cend())
	{
		auto lselect = getColumnNames(query.find(SELECT)->second);
		if (lselect.size() > 0)
		{
			select = lselect;
			return true;
		}
	}

	return false;
}

max_stars_repo_name: gamunu/bolt

max_issues_repo_name: gamunu/bolt

max_forks_repo_name: gamunu/bolt


text:
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*

    This example program shows how to find frontal human faces in an image and
    estimate their pose.  The pose takes the form of 68 landmarks.  These are
    points on the face such as the corners of the mouth, along the eyebrows, on
    the eyes, and so forth.

    This example is essentially just a version of the face_landmark_detection_ex.cpp
    example modified to use OpenCV's VideoCapture object to read from a camera instead
    of files.

    Finally, note that the face detector is fastest when compiled with at least
    SSE2 instructions enabled.  So if you are using a PC with an Intel or AMD
    chip then you should enable at least SSE2 instructions.  If you are using
    cmake to compile this program you can enable them by using one of the
    following commands when you create the build project:
        cmake path_to_dlib_root/examples -DUSE_SSE2_INSTRUCTIONS=ON
        cmake path_to_dlib_root/examples -DUSE_SSE4_INSTRUCTIONS=ON
        cmake path_to_dlib_root/examples -DUSE_AVX_INSTRUCTIONS=ON
    This will set the appropriate compiler options for GCC, clang, Visual
    Studio, or the Intel compiler.  If you are using another compiler then you
    need to consult your compiler's manual to determine how to enable these
    instructions.  Note that AVX is the fastest but requires a CPU from at least
    2011.  SSE4 is the next fastest and is supported by most current machines.
*/

#include <dlib/opencv.h>
#include <opencv2/highgui/highgui.hpp>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
#include <iostream>
#include <opencv2/opencv.hpp>

using namespace dlib;
using namespace std;

int main()
{

    // 3D model points.
    std::vector<cv::Point3d> model_points;
    model_points.push_back(cv::Point3d(0.0f, 0.0f, 0.0f));               // Nose tip
    model_points.push_back(cv::Point3d(0.0f, -330.0f, -65.0f));          // Chin
    model_points.push_back(cv::Point3d(-225.0f, 170.0f, -135.0f));       // Left eye left corner
    model_points.push_back(cv::Point3d(225.0f, 170.0f, -135.0f));        // Right eye right corner
    model_points.push_back(cv::Point3d(-150.0f, -150.0f, -125.0f));      // Left Mouth corner
    model_points.push_back(cv::Point3d(150.0f, -150.0f, -125.0f));       // Right mouth corner

    try
    {
        cv::VideoCapture cap(0);
        cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280);
        cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720);
        if (!cap.isOpened())
        {
            cerr << "Unable to connect to camera" << endl;
            return 1;
        }

        image_window win;

        // Load face detection and pose estimation models.
        frontal_face_detector detector = get_frontal_face_detector();
        shape_predictor pose_model;
        deserialize("shape_predictor_68_face_landmarks.dat") >> pose_model;

        // Grab and process frames until the main window is closed by the user.
        while(!win.is_closed())
        {
            // Grab a frame
            cv::Mat temp;
            if (!cap.read(temp))
            {
                break;
            }
            double focal_length = temp.cols; // Approximate focal length.
            int iIC = temp.cols;
            int iIR = temp.rows;
            //std::cout<<iIC<< " " <<iIR << std::endl;
            cv::Point2d center = cv::Point2d(iIC/2,iIR/2);
            cv::Mat camera_matrix = (cv::Mat_<double>(3,3) << focal_length, 0, center.x, 0 , focal_length, center.y, 0, 0, 1);
            cv::Mat dist_coeffs = cv::Mat::zeros(4,1,cv::DataType<double>::type); // Assuming no lens distortion

            // Turn OpenCV's Mat into something dlib can deal with.  Note that this just
            // wraps the Mat object, it doesn't copy anything.  So cimg is only valid as
            // long as temp is valid.  Also don't do anything to temp that would cause it
            // to reallocate the memory which stores the image as that will make cimg
            // contain dangling pointers.  This basically means you shouldn't modify temp
            // while using cimg.
            cv_image<bgr_pixel> cimg(temp);

            // Detect faces
            std::vector<rectangle> faces = detector(cimg);
            // Find the pose of each face.
            std::vector<full_object_detection> shapes;
            for (unsigned long i = 0; i < faces.size(); ++i)
            {
            	full_object_detection shape = pose_model(cimg, faces[i]);
            	//cout << "number of parts: "<< shape.num_parts() << endl;
            	//cout << "pixel position of first part:  " << shape.part(0)(1) << endl;
            	//cout << "pixel position of second part: " << shape.part(1) << endl;
                shapes.push_back(shape);

                std::vector<cv::Point2d> image_points;
                image_points.push_back( cv::Point2d(shape.part(30)(0), shape.part(30)(1)) );    // Nose tip
                image_points.push_back( cv::Point2d(shape.part(8)(0), shape.part(8)(1)) );    // Chin
                image_points.push_back( cv::Point2d(shape.part(36)(0), shape.part(36)(1)) );     // Left eye left corner
                image_points.push_back( cv::Point2d(shape.part(45)(0), shape.part(45)(1)) );    // Right eye right corner
                image_points.push_back( cv::Point2d(shape.part(48)(0), shape.part(48)(1)) );    // Left Mouth corner
                image_points.push_back( cv::Point2d(shape.part(54)(0), shape.part(54)(1)) );    // Right mouth corner
                //cout << "++++++++" <<endl;
                //cout << image_points[0] << endl;

                //cout << "Camera Matrix " << endl << camera_matrix << endl ;
                // Output rotation and translation
                cv::Mat rotation_vector; // Rotation in axis-angle form
                cv::Mat translation_vector;

                // Solve for pose
                cv::solvePnP(model_points, image_points, camera_matrix, dist_coeffs, rotation_vector, translation_vector);

                // Project a 3D point (0, 0, 1000.0) onto the image plane.
                // We use this to draw a line sticking out of the nose

                std::vector<cv::Point3d> nose_end_point3D;
                std::vector<cv::Point2d> nose_end_point2D;
                nose_end_point3D.push_back(cv::Point3d(0,0,1000.0));

                projectPoints(nose_end_point3D, rotation_vector, translation_vector, camera_matrix, dist_coeffs, nose_end_point2D);

                for(int i=0; i < image_points.size(); i++)
                    {
                	 circle(temp, image_points[i], 3, cv::Scalar(0,0,255), -1);
                    }

                cv::line(temp,image_points[0], nose_end_point2D[0], cv::Scalar(255,0,0), 2);

                //cout << "Rotation Vector " << endl << rotation_vector << endl;
                //cout << "Translation Vector" << endl << translation_vector << endl;
                //cout <<  nose_end_point2D << endl;

            }
            cv_image<bgr_pixel> ncimg(temp);
            // Display it all on the screen
            win.clear_overlay();
            win.set_image(ncimg);
            win.add_overlay(render_face_detections(shapes));
        }
    }
    catch(serialization_error& e)
    {
        cout << "You need dlib's default face landmarking model file to run this example." << endl;
        cout << "You can get it from the following URL: " << endl;
        cout << "   http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2" << endl;
        cout << endl << e.what() << endl;
    }
    catch(exception& e)
    {
        cout << e.what() << endl;
    }
}

max_stars_repo_name: WynMew/FacePoseEstimation

max_issues_repo_name: WynMew/FacePoseEstimation

max_forks_repo_name: WynMew/FacePoseEstimation