text:
// Copyright (c) 2018 oneiric (oneiric at i2pmail dot org)
//
// 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)
//
// Official repository: https://github.com/boostorg/beast
//

#ifndef BOOST_BEAST_URI_PARTS_HPP
#define BOOST_BEAST_URI_PARTS_HPP

#include <boost/beast/core/string.hpp>

namespace boost {
namespace beast {
namespace uri   {

class parts {
protected:
  std::string scheme_;
  std::string username_;
  std::string password_;
  std::string host_;
  std::string port_;
  std::string path_;
  std::string query_;
  std::string fragment_;

  void reset()
  {
    scheme_.clear();
    username_.clear();
    password_.clear();
    host_.clear();
    port_.clear();
    path_.clear();
    query_.clear();
    fragment_.clear();
  }

public:
  void scheme(std::string part) { scheme_ = part; }
  boost::string_view scheme() const noexcept { return scheme_; }

  void username(std::string part) { username_ = part; }
  boost::string_view username() const noexcept { return username_; }

  void password(std::string part) { password_ = part; }
  boost::string_view password() const noexcept { return password_; }

  boost::string_view user_info() const noexcept {
    return username_ + (password_.empty() ? "" : ":" + password_);
  }

  void host(std::string part) { host_ = part; }
  boost::string_view host() const noexcept { return host_; }

  void port(std::string part) { port_ = part; }
  boost::string_view port() const noexcept { return port_; }

  void path(std::string part) { path_ = part; }
  boost::string_view path() const noexcept { return path_; }

  void query(std::string part) { query_ = part; }
  boost::string_view query() const noexcept { return query_; }

  void fragment(std::string part) { fragment_ = part; }
  boost::string_view fragment() const noexcept { return fragment_; }
};

} // namespace uri
} // namespace beast
} // namespace boost

#endif

max_stars_repo_name: coneiric/beast

max_issues_repo_name: coneiric/beast

max_forks_repo_name: coneiric/beast


text: #include <boost/range.hpp>

ext: hpp

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <fstream>
#include <iostream>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include "box.hpp"

using namespace std;

Box::Box() {}
Box::Box(long frame, double xtl, double ytl, double xbr,
            double ybr, int outside, int occluded,
            int keyframe) {

    this->frame = frame;
    this->xtl = xtl;
    this->ytl = ytl;
    this->xbr = xbr;
    this->ybr = ybr;
    this->outside = outside;
    this->occluded = occluded;
    this->keyframe = keyframe;
}

ext: cpp


text:
//
// Copyright Thomas Witt 2003.
// 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)
//
#include <boost/iterator/iterator_archetypes.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_concepts.hpp>
#include <boost/concept_check.hpp>
#include <boost/cstdlib.hpp>

int main()
{
  {
    typedef boost::iterator_archetype<
        int
      , boost::iterator_archetypes::readable_iterator_t
      , boost::random_access_traversal_tag
    > iter;

    boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
    boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
  }
  {
    typedef boost::iterator_archetype<
        int
      , boost::iterator_archetypes::readable_writable_iterator_t
      , boost::random_access_traversal_tag
    > iter;

    boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
    boost::function_requires< boost_concepts::WritableIteratorConcept<iter> >();
    boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
  }
  {
    typedef boost::iterator_archetype<
        const int // I don't like adding const to Value. It is redundant. -JGS
      , boost::iterator_archetypes::readable_lvalue_iterator_t
      , boost::random_access_traversal_tag
    > iter;

    boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
    boost::function_requires< boost_concepts::LvalueIteratorConcept<iter> >();
    boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
  }
  {
    typedef boost::iterator_archetype<
        int
      , boost::iterator_archetypes::writable_lvalue_iterator_t
      , boost::random_access_traversal_tag
    > iter;

    boost::function_requires< boost_concepts::WritableIteratorConcept<iter> >();
    boost::function_requires< boost_concepts::LvalueIteratorConcept<iter> >();
    boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
  }

  return boost::exit_success;
}

max_issues_repo_name: qingkouwei/mediaones


text:
//  boost/filesystem/operations.hpp  ---------------------------------------------------//

//  Copyright Beman Dawes 2002-2009
//  Copyright Jan Langer 2002
//  Copyright Dietmar Kuehl 2001
//  Copyright Vladimir Prus 2002
//  Copyright Andrey Semashev 2020

//  Distributed under the Boost Software License, Version 1.0.
//  See http://www.boost.org/LICENSE_1_0.txt

//  Library home page: http://www.boost.org/libs/filesystem

//--------------------------------------------------------------------------------------//

#ifndef BOOST_FILESYSTEM3_OPERATIONS_HPP
#define BOOST_FILESYSTEM3_OPERATIONS_HPP

#include <boost/config.hpp>

# if defined( BOOST_NO_STD_WSTRING )
#   error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
# endif

#include <boost/filesystem/config.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/file_status.hpp>

#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
// These includes are left for backward compatibility and should be included directly by users, as needed
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/directory.hpp>
#endif

#include <boost/detail/bitmask.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/system/error_code.hpp>
#include <boost/cstdint.hpp>
#include <string>
#include <ctime>

#include <boost/config/abi_prefix.hpp> // must be the last #include

//--------------------------------------------------------------------------------------//

namespace boost {
namespace filesystem {

struct space_info
{
  // all values are byte counts
  boost::uintmax_t capacity;
  boost::uintmax_t free;      // <= capacity
  boost::uintmax_t available; // <= free
};

BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(copy_options, unsigned int)
{
  none = 0u,                    // Default. For copy_file: error if the target file exists. For copy: do not recurse, follow symlinks, copy file contents.

  // copy_file options:
  skip_existing = 1u,           // Don't overwrite the existing target file, don't report an error
  overwrite_existing = 1u << 1, // Overwrite existing file
  update_existing = 1u << 2,    // Overwrite existing file if its last write time is older than the replacement file

  // copy options:
  recursive = 1u << 8,          // Recurse into sub-directories
  copy_symlinks = 1u << 9,      // Copy symlinks as symlinks instead of copying the referenced file
  skip_symlinks = 1u << 10,     // Don't copy symlinks
  directories_only = 1u << 11,  // Only copy directory structure, do not copy non-directory files
  create_symlinks = 1u << 12,   // Create symlinks instead of copying files
  create_hard_links = 1u << 13, // Create hard links instead of copying files
  _detail_recursing = 1u << 14  // Internal use only, do not use
}
BOOST_SCOPED_ENUM_DECLARE_END(copy_options)

BOOST_BITMASK(BOOST_SCOPED_ENUM_NATIVE(copy_options))

#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_SCOPED_ENUM_DECLARE_BEGIN(copy_option)
{
  none = static_cast< unsigned int >(copy_options::none),
  fail_if_exists = none,
  overwrite_if_exists = static_cast< unsigned int >(copy_options::overwrite_existing)
}
BOOST_SCOPED_ENUM_DECLARE_END(copy_option)
#endif

//--------------------------------------------------------------------------------------//
//                             implementation details                                   //
//--------------------------------------------------------------------------------------//

namespace detail {

BOOST_FILESYSTEM_DECL
path absolute(const path& p, const path& base, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
file_status status(const path&p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
file_status symlink_status(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
bool is_empty(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path initial_path(system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path canonical(const path& p, const path& base, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void copy(const path& from, const path& to, unsigned int options, system::error_code* ec=0);
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_FILESYSTEM_DECL
void copy_directory(const path& from, const path& to, system::error_code* ec=0);
#endif
BOOST_FILESYSTEM_DECL
bool copy_file(const path& from, const path& to,  // See ticket #2925
               unsigned int options, system::error_code* ec=0); // see copy_options for options
BOOST_FILESYSTEM_DECL
void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
bool create_directories(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
bool create_directory(const path& p, const path* existing, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void create_directory_symlink(const path& to, const path& from,
                              system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void create_hard_link(const path& to, const path& from, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void create_symlink(const path& to, const path& from, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path current_path(system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void current_path(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
bool equivalent(const path& p1, const path& p2, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
boost::uintmax_t file_size(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
boost::uintmax_t hard_link_count(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
std::time_t last_write_time(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void last_write_time(const path& p, const std::time_t new_time,
                     system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void permissions(const path& p, perms prms, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path read_symlink(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path relative(const path& p, const path& base, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
bool remove(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
boost::uintmax_t remove_all(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void rename(const path& old_p, const path& new_p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
void resize_file(const path& p, uintmax_t size, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
space_info space(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path system_complete(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path temp_directory_path(system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path unique_path(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path weakly_canonical(const path& p, system::error_code* ec = 0);

} // namespace detail

//--------------------------------------------------------------------------------------//
//                                                                                //
//                             status query functions                                   //
//                                                                                //
//--------------------------------------------------------------------------------------//

inline
file_status status(const path& p)    {return detail::status(p);}
inline
file_status status(const path& p, system::error_code& ec)
                                     {return detail::status(p, &ec);}
inline
file_status symlink_status(const path& p) {return detail::symlink_status(p);}
inline
file_status symlink_status(const path& p, system::error_code& ec)
                                     {return detail::symlink_status(p, &ec);}
inline
bool exists(const path& p)           {return exists(detail::status(p));}
inline
bool exists(const path& p, system::error_code& ec)
                                     {return exists(detail::status(p, &ec));}
inline
bool is_directory(const path& p)     {return is_directory(detail::status(p));}
inline
bool is_directory(const path& p, system::error_code& ec)
                                     {return is_directory(detail::status(p, &ec));}
inline
bool is_regular_file(const path& p)  {return is_regular_file(detail::status(p));}
inline
bool is_regular_file(const path& p, system::error_code& ec)
                                     {return is_regular_file(detail::status(p, &ec));}
inline
bool is_other(const path& p)         {return is_other(detail::status(p));}
inline
bool is_other(const path& p, system::error_code& ec)
                                     {return is_other(detail::status(p, &ec));}
inline
bool is_symlink(const path& p)       {return is_symlink(detail::symlink_status(p));}
inline
bool is_symlink(const path& p, system::error_code& ec)
                                     {return is_symlink(detail::symlink_status(p, &ec));}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline
bool is_regular(const path& p)       {return is_regular(detail::status(p));}
inline
bool is_regular(const path& p, system::error_code& ec)
                                     {return is_regular(detail::status(p, &ec));}
#endif

inline
bool is_empty(const path& p)         {return detail::is_empty(p);}
inline
bool is_empty(const path& p, system::error_code& ec)
                                     {return detail::is_empty(p, &ec);}

//--------------------------------------------------------------------------------------//
//                                                                                //
//                             operational functions                                    //
//                                                                                //
//--------------------------------------------------------------------------------------//

inline
path initial_path()                  {return detail::initial_path();}

inline
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}

template <class Path>
path initial_path() {return initial_path();}
template <class Path>
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}

inline
path current_path()                  {return detail::current_path();}

inline
path current_path(system::error_code& ec) {return detail::current_path(&ec);}

inline
void current_path(const path& p)     {detail::current_path(p);}

inline
void current_path(const path& p, system::error_code& ec) BOOST_NOEXCEPT {detail::current_path(p, &ec);}

inline
path absolute(const path& p, const path& base=current_path()) {return detail::absolute(p, base);}
inline
path absolute(const path& p, system::error_code& ec)
{
  path base = current_path(ec);
  if (ec)
    return path();
  return detail::absolute(p, base, &ec);
}
inline
path absolute(const path& p, const path& base, system::error_code& ec) {return detail::absolute(p, base, &ec);}

inline
path canonical(const path& p, const path& base=current_path())
                                     {return detail::canonical(p, base);}
inline
path canonical(const path& p, system::error_code& ec)
{
  path base = current_path(ec);
  if (ec)
    return path();
  return detail::canonical(p, base, &ec);
}
inline
path canonical(const path& p, const path& base, system::error_code& ec)
                                     {return detail::canonical(p, base, &ec);}

#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline
path complete(const path& p)
{
  return absolute(p, initial_path());
}

inline
path complete(const path& p, const path& base)
{
  return absolute(p, base);
}
#endif

inline
void copy(const path& from, const path& to)
{
  detail::copy(from, to, static_cast< unsigned int >(copy_options::none));
}
inline
void copy(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
{
  detail::copy(from, to, static_cast< unsigned int >(copy_options::none), &ec);
}
inline
void copy(const path& from, const path& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
{
  detail::copy(from, to, static_cast< unsigned int >(options));
}
inline
void copy(const path& from, const path& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
{
  detail::copy(from, to, static_cast< unsigned int >(options), &ec);
}

#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
inline
void copy_directory(const path& from, const path& to)
                                     {detail::copy_directory(from, to);}
inline
void copy_directory(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::copy_directory(from, to, &ec);}
#endif
inline
bool copy_file(const path& from, const path& to)
{
  return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none));
}
inline
bool copy_file(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
{
  return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none), &ec);
}
inline
bool copy_file(const path& from, const path& to,   // See ticket #2925
               BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
{
  return detail::copy_file(from, to, static_cast< unsigned int >(options));
}
inline
bool copy_file(const path& from, const path& to,   // See ticket #2925
               BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
{
  return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
}
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
inline
bool copy_file(const path& from, const path& to,   // See ticket #2925
               BOOST_SCOPED_ENUM_NATIVE(copy_option) options)
{
  return detail::copy_file(from, to, static_cast< unsigned int >(options));
}
inline
bool copy_file(const path& from, const path& to,   // See ticket #2925
               BOOST_SCOPED_ENUM_NATIVE(copy_option) options, system::error_code& ec) BOOST_NOEXCEPT
{
  return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
}
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
inline
void copy_symlink(const path& existing_symlink,
                  const path& new_symlink) {detail::copy_symlink(existing_symlink, new_symlink);}

inline
void copy_symlink(const path& existing_symlink, const path& new_symlink,
                  system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::copy_symlink(existing_symlink, new_symlink, &ec);}
inline
bool create_directories(const path& p) {return detail::create_directories(p);}

inline
bool create_directories(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::create_directories(p, &ec);}
inline
bool create_directory(const path& p) {return detail::create_directory(p, 0);}

inline
bool create_directory(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::create_directory(p, 0, &ec);}
inline
bool create_directory(const path& p, const path& existing)
                                     {return detail::create_directory(p, &existing);}
inline
bool create_directory(const path& p, const path& existing, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::create_directory(p, &existing, &ec);}
inline
void create_directory_symlink(const path& to, const path& from)
                                     {detail::create_directory_symlink(to, from);}
inline
void create_directory_symlink(const path& to, const path& from, system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::create_directory_symlink(to, from, &ec);}
inline
void create_hard_link(const path& to, const path& new_hard_link) {detail::create_hard_link(to, new_hard_link);}

inline
void create_hard_link(const path& to, const path& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::create_hard_link(to, new_hard_link, &ec);}
inline
void create_symlink(const path& to, const path& new_symlink) {detail::create_symlink(to, new_symlink);}

inline
void create_symlink(const path& to, const path& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::create_symlink(to, new_symlink, &ec);}
inline
bool equivalent(const path& p1, const path& p2) {return detail::equivalent(p1, p2);}

inline
bool equivalent(const path& p1, const path& p2, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::equivalent(p1, p2, &ec);}
inline
boost::uintmax_t file_size(const path& p) {return detail::file_size(p);}

inline
boost::uintmax_t file_size(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::file_size(p, &ec);}
inline
boost::uintmax_t hard_link_count(const path& p) {return detail::hard_link_count(p);}

inline
boost::uintmax_t hard_link_count(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::hard_link_count(p, &ec);}
inline
std::time_t last_write_time(const path& p) {return detail::last_write_time(p);}

inline
std::time_t last_write_time(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::last_write_time(p, &ec);}
inline
void last_write_time(const path& p, const std::time_t new_time)
                                     {detail::last_write_time(p, new_time);}
inline
void last_write_time(const path& p, const std::time_t new_time,
                     system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::last_write_time(p, new_time, &ec);}
inline
void permissions(const path& p, perms prms)
                                     {detail::permissions(p, prms);}
inline
void permissions(const path& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::permissions(p, prms, &ec);}

inline
path read_symlink(const path& p)     {return detail::read_symlink(p);}

inline
path read_symlink(const path& p, system::error_code& ec)
                                     {return detail::read_symlink(p, &ec);}

inline
bool remove(const path& p)           {return detail::remove(p);}

inline
bool remove(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::remove(p, &ec);}

inline
boost::uintmax_t remove_all(const path& p) {return detail::remove_all(p);}

inline
boost::uintmax_t remove_all(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::remove_all(p, &ec);}
inline
void rename(const path& old_p, const path& new_p) {detail::rename(old_p, new_p);}

inline
void rename(const path& old_p, const path& new_p, system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::rename(old_p, new_p, &ec);}
inline  // name suggested by Scott McMurray
void resize_file(const path& p, uintmax_t size) {detail::resize_file(p, size);}

inline
void resize_file(const path& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
                                     {detail::resize_file(p, size, &ec);}
inline
path relative(const path& p, const path& base=current_path())
                                     {return detail::relative(p, base);}
inline
path relative(const path& p, system::error_code& ec)
{
  path base = current_path(ec);
  if (ec)
    return path();
  return detail::relative(p, base, &ec);
}
inline
path relative(const path& p, const path& base, system::error_code& ec)
                                     {return detail::relative(p, base, &ec);}
inline
space_info space(const path& p)      {return detail::space(p);}

inline
space_info space(const path& p, system::error_code& ec) BOOST_NOEXCEPT
                                     {return detail::space(p, &ec);}

#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline bool symbolic_link_exists(const path& p)
                                     { return is_symlink(filesystem::symlink_status(p)); }
#endif

inline
path system_complete(const path& p)  {return detail::system_complete(p);}

inline
path system_complete(const path& p, system::error_code& ec)
                                     {return detail::system_complete(p, &ec);}
inline
path temp_directory_path()           {return detail::temp_directory_path();}

inline
path temp_directory_path(system::error_code& ec)
                                     {return detail::temp_directory_path(&ec);}
inline
path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%")
                                     {return detail::unique_path(p);}
inline
path unique_path(const path& p, system::error_code& ec)
                                     {return detail::unique_path(p, &ec);}
inline
path weakly_canonical(const path& p)   {return detail::weakly_canonical(p);}

inline
path weakly_canonical(const path& p, system::error_code& ec)
                                     {return detail::weakly_canonical(p, &ec);}

//  test helper  -----------------------------------------------------------------------//

//  Not part of the documented interface since false positives are possible;
//  there is no law that says that an OS that has large stat.st_size
//  actually supports large file sizes.

namespace detail {

BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();

} // namespace detail

} // namespace filesystem
} // namespace boost

#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM3_OPERATIONS_HPP

max_stars_repo_name: kindlychung/mediasoup-sfu-cpp

max_issues_repo_name: kindlychung/mediasoup-sfu-cpp

max_forks_repo_name: kindlychung/mediasoup-sfu-cpp


text:
/***********************************************************************************************************************
 *  OpenStudio(R), Copyright (c) 2008-2017, Alliance for Sustainable Energy, LLC. All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 *  following conditions are met:
 *
 *  (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
 *  disclaimer.
 *
 *  (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
 *  following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote
 *  products derived from this software without specific prior written permission from the respective party.
 *
 *  (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative
 *  works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without
 *  specific prior written permission from Alliance for Sustainable Energy, LLC.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR
 *  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **********************************************************************************************************************/

#ifndef UTILITIES_CORE_STRINGHELPERS_HPP
#define UTILITIES_CORE_STRINGHELPERS_HPP

#include "../UtilitiesAPI.hpp"

#include "./Enum.hpp"

#include <boost/regex.hpp>

#include <string>

namespace openstudio {

  /** \class DocumentFormat
  * \brief Document output formats supported by OpenStudio.
  * \details See the OPENSTUDIO_ENUM documentation in utilities/core/Enum.hpp. The actual
  * macro call is:
  * \code
  OPENSTUDIO_ENUM(DocumentFormat,
  ((COUT))
  ((LaTeX))
  ((XHTML)) );
  * \endcode */
  OPENSTUDIO_ENUM(DocumentFormat,
    ((COUT))
    ((LaTeX))
    ((XHTML)));

  /** Replace all non-letters and digits with spaces, and then remove spaces by to make camel
   *  case. */
  UTILITIES_API std::string toCamelCase(const std::string& s);

  /** Make camel case then upcase the first letter. */
  UTILITIES_API std::string toUpperCamelCase(const std::string& s);

  /** Make camel case then downcase the first letter. */
  UTILITIES_API std::string toLowerCamelCase(const std::string& s);

  /** Make underscore case. */
  UTILITIES_API std::string toUnderscoreCase(const std::string& s);

  /** Convert IDD object and field names to something reasonable for computers. */
  UTILITIES_API std::string convertIddName(const std::string& s);

  /** Convert IDD object name to default name for IDF objects of this type. */
  UTILITIES_API std::string iddObjectNameToIdfObjectName(const std::string& s);

  /** Prints value with numFractionalDigits, inserting commas to separate into
   *  thousands, millions, etc. if desired. */
  UTILITIES_API std::string toNeatString(double value,
                                         unsigned numFractionalDigits = 0,
                                         bool applyCommas = true);

  /** Prints value in numSigFigs, inserting commas to separate into thousands,
  millions, etc. if desired. */
  UTILITIES_API std::string toNeatStringBySigFigs(double value,
                                                  unsigned numSigFigs = 3,
                                                  bool applyCommas = true);

  /** Returns the number of digits past the decimal point in str. */
  UTILITIES_API unsigned numFractionalDigits(const std::string& str);

  /** Returns the number of significant digits past the decimal point in value, given numSigFigs.
   *  Throws if numSigFigs == 0. */
  UTILITIES_API unsigned numFractionalDigits(double value,unsigned numSigFigs);

  /** Returns the minimum and maximum number of significant digits past the decimal
   *  point in values, given numSigFigs. Throws if numSigFigs == 0. */
  UTILITIES_API std::pair<unsigned,unsigned> numFractionalDigits(const std::vector<double>& values,
                                                                 unsigned numSigFigs);

  /** Rounds value to a number of significant figures (rather than to a particular
   *  decimal place). Throws if numSigFigs == 0. */
  UTILITIES_API double toNumSigFigs(double value, unsigned numSigFigs);

  UTILITIES_API boost::regex superscript();

  UTILITIES_API boost::regex subscript();

  UTILITIES_API std::string formatText(const std::string& str, DocumentFormat fmt);

  /** Ensures that underscores will remain as underscores (not changed to subscripts). */
  UTILITIES_API std::string formatUnderscore(const std::string& str);

  UTILITIES_API std::string formatSuperAndSubscripts(const std::string& str, DocumentFormat fmt);

  /** Applies formatSuperAndSubscripts, and replaces '*' with small dot. Does nothing for fmt ==
  * DocumentFormat::COUT. */
  UTILITIES_API std::string formatUnitString(const std::string& str, DocumentFormat fmt);

  /** Split a string into a vector of strings given a delimiter character. An empty string results
   *  in an empty vector, strings that begin or end with the delimiter will result in a vector
   *  beginning or ending with an empty string, and non-empty strings with no delimiters returns
   *  a vector with the input string as the only element. */
  UTILITIES_API std::vector <std::string> splitString(const std::string & string, char delimiter);

}

#endif // UTILITIES_CORE_STRINGHELPERS_HPP

max_stars_repo_name: OpenStudioThailand/OpenStudio

max_issues_repo_name: OpenStudioThailand/OpenStudio

max_forks_repo_name: OpenStudioThailand/OpenStudio


text:
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include <boost/algorithm/string/replace.hpp>
#include <json/value.h>
#include <re2/re2.h>

#include <mariana-trench/Assert.h>
#include <mariana-trench/CanonicalName.h>
#include <mariana-trench/JsonValidation.h>
#include <mariana-trench/Log.h>

namespace marianatrench {

namespace {

static const re2::RE2 add_underscore_regex("([a-z])([A-Z])");

void convert_to_lower_underscore(std::string& input) {
  RE2::GlobalReplace(&input, add_underscore_regex, "\\1_\\2");
  std::transform(
      input.begin(), input.end(), input.begin(), [](unsigned char c) {
        return std::tolower(c);
      });
}

} // namespace

bool CanonicalName::is_via_type_of_template() const {
  auto value = template_value();
  if (!value) {
    return false;
  }

  return value->find(k_via_type_of_marker) != std::string::npos;
}

std::optional<CanonicalName> CanonicalName::instantiate(
    const Method* method,
    const std::vector<const Feature*>& via_type_ofs) const {
  auto value = template_value();
  mt_assert(value);
  auto canonical_name = *value;

  if (canonical_name.find(k_leaf_name_marker) != std::string::npos) {
    auto callee_name = method->signature();
    boost::algorithm::replace_all(
        canonical_name, k_leaf_name_marker, callee_name);
  }

  // Converts Lcom/SomeMutationData;.setPhoneField:.* to
  // some_mutation:phone_field which follows the graphql notation
  if (canonical_name.find(k_graphql_root_marker) != std::string::npos) {
    auto class_signature = method->get_class()->get_name()->str();
    auto pos = class_signature.find_last_of("/");
    if (pos != std::string::npos && class_signature.size() > (pos + 2)) {
      std::string class_name =
          class_signature.substr(pos + 1, class_signature.size() - pos - 2);
      boost::replace_last(class_name, "Data", "");
      convert_to_lower_underscore(class_name);
      std::string method_name = method->get_name();
      boost::replace_first(method_name, "set", "");
      convert_to_lower_underscore(method_name);
      boost::algorithm::replace_all(
          canonical_name,
          k_graphql_root_marker,
          class_name + ":" + method_name);
    }
  }

  if (canonical_name.find(k_via_type_of_marker) != std::string::npos) {
    if (via_type_ofs.size() == 0) {
      WARNING(
          2,
          "Could not instantiate canonical name template '{}'. Via-type-of feature not available.",
          *value);
      return std::nullopt;
    } else if (via_type_ofs.size() > 1) {
      ERROR(
          1,
          "Could not instantiate canonical name template '{}'. Unable to disambiguate between {} via-type-of features.",
          *value,
          via_type_ofs.size());
      // Should have been verified when parsing models during model-generation.
      mt_assert(false);
      return std::nullopt;
    }

    auto via_type_of = *via_type_ofs.begin();
    boost::algorithm::replace_all(
        canonical_name, k_via_type_of_marker, via_type_of->name());
  }

  return CanonicalName(CanonicalName::InstantiatedValue{canonical_name});
}

CanonicalName CanonicalName::from_json(const Json::Value& value) {
  JsonValidation::validate_object(value);

  if (value.isMember("template")) {
    auto template_value = JsonValidation::string(value["template"]);
    if (value.isMember("instantiated")) {
      throw JsonValidationError(
          value,
          /* field */ std::nullopt,
          "either 'template' or 'instantiated' value but not both.");
    }

    return CanonicalName(CanonicalName::TemplateValue{template_value});
  }

  if (value.isMember("instantiated")) {
    auto instantiated_value = JsonValidation::string(value["instantiated"]);
    return CanonicalName(CanonicalName::InstantiatedValue{instantiated_value});
  }

  throw JsonValidationError(
      value,
      /* field */ std::nullopt,
      "either 'template' or 'instantiated' value.");
}

Json::Value CanonicalName::to_json() const {
  auto result = Json::Value(Json::objectValue);
  auto value = template_value();
  if (value) {
    result["template"] = *value;
    return result;
  }

  value = instantiated_value();
  if (value) {
    result["instantiated"] = *value;
    return result;
  }

  mt_unreachable();
  return result;
}

std::ostream& operator<<(std::ostream& out, const CanonicalName& root) {
  auto value = root.template_value();
  if (value) {
    return out << "template=" << *value;
  }

  value = root.instantiated_value();
  if (value) {
    return out << "instantiated=" << *value;
  }

  mt_unreachable();
  return out;
}

} // namespace marianatrench


text:
#pragma once

#include <boost/intrusive_ptr.hpp>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>

#include "formula_callable.hpp"
#include "formula_callable_definition.hpp"
#include "frustum.hpp"
#include "variant.hpp"

class camera_callable : public game_logic::formula_callable
{
public:
	enum CAMERA_TYPE { PERSPECTIVE_CAMERA, ORTHOGONAL_CAMERA };
	camera_callable();
	explicit camera_callable(CAMERA_TYPE type, int left, int right, int top, int bottom);
	explicit camera_callable(CAMERA_TYPE type, float fov, float aspect, float near_clip, float far_clip);
	explicit camera_callable(const variant& node);
	virtual ~camera_callable();
	//virtual variant get_value(const std::string&) const;
	//virtual void set_value(const std::string& key, const variant& value);

	void compute_view();
	void compute_projection();

	void set_mousespeed(float ms) { mouse_speed_ = ms; }
	void set_speed(float spd) { speed_ = spd; }
	void set_hangle(float ha) { horizontal_angle_ = ha; }
	void set_vangle(float va) { vertical_angle_ = va; }
	void set_fov(float fov);
	void set_aspect(float aspect);
	void set_clip_planes(float z_near, float z_far);
	void set_type(CAMERA_TYPE type);
	void set_ortho_window(int left, int right, int top, int bottom);
	float mousespeed() const { return mouse_speed_; }
	float speed() const { return speed_; }
	float hangle() const { return horizontal_angle_; }
	float vangle() const { return vertical_angle_; }
	float fov() const { return fov_; }
	float aspect() const { return aspect_; }
	float near_clip() const { return near_clip_; }
	float far_clip() const { return far_clip_; }
	CAMERA_TYPE type() const { return type_; }
	int ortho_left() const { return ortho_left_; }
	int ortho_right() const { return ortho_right_; }
	int ortho_top() const { return ortho_top_; }
	int ortho_bottom() const { return ortho_bottom_; }
	const glm::vec3& position() const { return position_; }
	const glm::vec3& right() const { return right_; }
	const glm::vec3& direction() const { return direction_; }
	const glm::vec3& target() const { return target_; }
	const glm::vec3& up() const { return up_; }
	void set_position(const glm::vec3& position) { position_ = position; }

	void look_at(glm::vec3 position, glm::vec3 target, glm::vec3 up);

	const float* projection() const { return glm::value_ptr(projection_); }
	const float* view() const { return glm::value_ptr(view_); }
	const glm::mat4& view_mat() const { return view_; }
	const glm::mat4& projection_mat() const { return projection_; }

	const graphics::frustum& frustum() { return frustum_; }

	glm::vec3 screen_to_world(int x, int y, int wx, int wy) const;
	glm::ivec3 get_facing(const glm::vec3& coords) const;

	variant write();
protected:
private:
	DECLARE_CALLABLE(camera_callable);

	enum {MODE_AUTO, MODE_MANUAL} mode_;

	float fov_;
	float horizontal_angle_;
	float vertical_angle_;
	glm::vec3 position_;
	glm::vec3 target_;
	glm::vec3 up_;
	glm::vec3 right_;
	glm::vec3 direction_;
	float speed_;
	float mouse_speed_;

	float near_clip_;
	float far_clip_;
	bool clip_planes_set_;

	float aspect_;

	graphics::frustum frustum_;

	CAMERA_TYPE type_;
	int ortho_left_;
	int ortho_right_;
	int ortho_top_;
	int ortho_bottom_;

	glm::mat4 projection_;
	glm::mat4 view_;

	camera_callable(const camera_callable&);
};

typedef boost::intrusive_ptr<camera_callable> camera_callable_ptr;
typedef boost::intrusive_ptr<const camera_callable> const_camera_callable_ptr;

max_stars_repo_name: sweetkristas/anura

max_issues_repo_name: sweetkristas/anura

max_forks_repo_name: sweetkristas/anura


text:
/*
 * Copyright (c) 2018 Lucas Walter
 * October 2018
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the Willow Garage, Inc. nor the names of its
 *       contributors may be used to endorse or promote products derived from
 *       this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

// #define IMGUI_DEFINE_MATH_OPERATORS

#include <SDL2/SDL_scancode.h>
// #include <boost/date_time/posix_time/posix_time.hpp>
// #include <chrono>
#include <imgui.h>
#include <imgui_internal.h>
#include <imgui_ros/bag_console.h>
#include <string>
#include <unordered_map>

namespace imgui_ros
{

void BagConsole::draw()
{
  const int min = 0;
  const int max = msgs_.size();
  // TEMP before using built-in imgui console (if it actually works here)
  {
    int pos = position_;
    ImGui::SliderInt("scroll", &pos, min, max, "%d");
    position_ = pos;
  }

  const auto old_selected = selected_;
  if (ImGui::IsWindowFocused()) {
    if (ImGui::IsKeyPressed(SDL_SCANCODE_UP)) {
      if (selected_ > 0) {
        selected_--;
      }
    }
    if (ImGui::IsKeyPressed(SDL_SCANCODE_DOWN)) {
      if (selected_ < static_cast<size_t>(max)) {
        selected_++;
      }
    }
  }

  ImGui::Checkbox("pause", &pause_);  // this causes messages to get lost
  ImGui::SameLine();
  ImGui::Checkbox("hhmmss", &columns_[0].hhmmss_);  // this causes messages to get lost
  ImGui::SameLine();
  size_t num_columns = 0;
  bool changed_columns = false;
  for (auto& column : columns_) {
    if (column.name_ != "time") {
      if (ImGui::Checkbox(column.name_.c_str(), &column.enable_)) {  // this causes messages to get lost
        changed_columns = true;
      }
      ImGui::SameLine();
    }
    if (column.enable_) {
      ++num_columns;
    }
  }

  const auto win_width = ImGui::GetWindowContentRegionMax().x - ImGui::GetWindowContentRegionMin().x;
  // TODO(lucasw) typeToString()
  // const std::string text = topic_;
  // ImGui::Text("%.*s", static_cast<int>(text.size()), text.data());
  std::lock_guard<std::mutex> lock(mutex_);

  const size_t start_ind = position_;

  // TODO(lucasw) have stamp optionally in unix time, or HH MM SS,
  // or seconds since some other timestamp
  //
  // Optionally have name, file, function, line, and topics in columns
  // Color code according to level: green, white, yellow, red, dark red (or black on red background)
  ImGui::Text("%zu / %zu log messages", start_ind, msgs_.size());

  ImGui::Columns(num_columns);
  size_t ind = 0;
  for (const auto& column : columns_) {
    if (column.enable_) {
      ImGui::Text("%s", column.name_.c_str());  // this causes messages to get lost
      ImGui::NextColumn();
      if (changed_columns || (count_ == 0)) {
        // TODO(lucasw) need to store live width and restore that
        // on changed_columns instead of going back to default.
        ImGui::SetColumnWidth(ind, win_width * column.width_);
      }
      ++ind;
    }
  }

  for (size_t i = start_ind; (i < start_ind + view_num) && (i < msgs_.size()); ++i) {
    const auto& msg = msgs_[i];
    for (const auto& column : columns_) {
      column.draw(msg, selected_, i);
    }
  }
  ImGui::Columns(1);

  if ((old_selected != selected_) && (selected_ < msgs_.size())) {
    std::cout << "selection " << selected_ << ":\n" << *msgs_[selected_] << "\n";
  }
  ++count_;
}

// https://answers.ros.org/question/340701/convert-ros-time-to-hours-minutes-seconds-string-in-system-timezone-in-c
std::string stampToString(const ros::Time& stamp, const std::string format = "%Y-%m-%d %H:%M:%S")
{
#if 0
  // Capital S needs to be lower case here?
  const auto current_time = stamp.toBoost();
  // https://stackoverflow.com/questions/17779660/who-is-responsible-for-deleting-the-facet
  std::stringstream ss;
  auto facet = new boost::posix_time::time_facet(format.c_str());
  ss.imbue(std::locale(std::cout.getloc(), facet));
  ss << current_time;
  return ss.str();
#endif

  // any advantage to using std chrono?
  // std::chrono::duration dur = std::chrono::seconds{stamp.sec} + std::chrono::nanoseconds{stamp.nsec};
  const int kOutputSize = 100;
  char output[kOutputSize];
  std::time_t raw_time = static_cast<time_t>(stamp.sec);
  struct tm* timeinfo = localtime(&raw_time);
  // TODO(lucasw) -1 for terminating 0?
  std::strftime(output, kOutputSize, format.c_str(), timeinfo);
  std::stringstream ss;
  ss << std::setw(9) << std::setfill('0') << stamp.nsec;
  const size_t fractional_second_digits = 4;
  return std::string(output) + "." + ss.str().substr(0, fractional_second_digits);
}

void BagConsole::Column::draw(const rosgraph_msgs::Log::ConstPtr& msg,
    size_t& selected, size_t& i) const
{
  if (!enable_) {
    return;
  }
  const std::unordered_map<std::string, std::function<void()>> draw_ops{
    {"time", [&]() {
      // const auto sel_flags = ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_PressedOnClick;
      const auto sel_flags = ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_SelectOnClick;
      const auto stamp = msg->header.stamp;
      std::string text;
      if (hhmmss_) {
        text = stampToString(stamp);
      } else {
        text = std::to_string(stamp.toSec());
      }

      // TODO(lucasw) how to make any column selectable if time is disabled
      if (ImGui::Selectable((text + "##unique").c_str(), i == selected, sel_flags)) {
        // Don't add to rosout here
        selected = i;
      }
      ImGui::NextColumn();
    }},
    {"msg", [&]() {
      ImGui::Text("%s", msg->msg.c_str());
      ImGui::NextColumn();
    }},
    {"name", [&]() {
      ImGui::Text("%s", msg->name.c_str());
      ImGui::NextColumn();
    }},
    {"file", [&](){
      ImGui::Text("%s", msg->file.c_str());
      ImGui::NextColumn();
    }},
    {"function", [&](){
      ImGui::Text("%s", msg->function.c_str());
      ImGui::NextColumn();
    }},
    {"line", [&](){
      ImGui::Text("%u", msg->line);
      ImGui::NextColumn();
    }}
  };

  draw_ops.find(name_)->second();
}

void BagConsole::callback(const typename rosgraph_msgs::LogConstPtr msg)
{
  // have mode where pause still pauses the screen but still records
  // new messages, but have to watch buffer fill levels.
  if (pause_) {
    return;
  }
  std::lock_guard<std::mutex> lock(mutex_);
  msgs_.push_back(msg);
  if (msgs_.size() >= max_num_) {
    msgs_.pop_front();
    if (selected_ < max_num_) {
      selected_--;
      // if the user has selected a message, keep it on screen instead
      // of scrolling past
      if ((position_ > 0) && (position_ < max_num_)) {
        position_ -= 1;
      }
    }
  }
}

}  // namespace imgui_ros


text:
// Copyright (C) 2011, 2012  Google Inc.
//
// This file is part of YouCompleteMe.
//
// YouCompleteMe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// YouCompleteMe 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with YouCompleteMe.  If not, see <http://www.gnu.org/licenses/>.

#include "IdentifierCompleter.h"
#include "PythonSupport.h"
#include "versioning.h"

#ifdef USE_CLANG_COMPLETER
#  include "ClangCompleter.h"
#  include "ClangUtils.h"
#  include "CompletionData.h"
#  include "Diagnostic.h"
#  include "Location.h"
#  include "Range.h"
#  include "UnsavedFile.h"
#  include "CompilationDatabase.h"
#  include "Documentation.h"
#endif // USE_CLANG_COMPLETER

#include <boost/python.hpp>
#include <boost/utility.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>

bool HasClangSupport() {
#ifdef USE_CLANG_COMPLETER
  return true;
#else
  return false;
#endif // USE_CLANG_COMPLETER
}

BOOST_PYTHON_MODULE(ycm_core)
{
  using namespace boost::python;
  using namespace YouCompleteMe;

  // Necessary because of usage of the ReleaseGil class
  PyEval_InitThreads();

  def( "HasClangSupport", HasClangSupport );
  def( "FilterAndSortCandidates", FilterAndSortCandidates );
  def( "YcmCoreVersion", YcmCoreVersion );

  class_< IdentifierCompleter, boost::noncopyable >( "IdentifierCompleter" )
    .def( "AddIdentifiersToDatabase",
          &IdentifierCompleter::AddIdentifiersToDatabase )
    .def( "ClearForFileAndAddIdentifiersToDatabase",
          &IdentifierCompleter::ClearForFileAndAddIdentifiersToDatabase )
    .def( "AddIdentifiersToDatabaseFromTagFiles",
          &IdentifierCompleter::AddIdentifiersToDatabaseFromTagFiles )
    .def( "CandidatesForQueryAndType",
          &IdentifierCompleter::CandidatesForQueryAndType );

  class_< std::vector< std::string >,
      boost::shared_ptr< std::vector< std::string > > >( "StringVector" )
    .def( vector_indexing_suite< std::vector< std::string > >() );

#ifdef USE_CLANG_COMPLETER
  def( "ClangVersion", ClangVersion );

  // CAREFUL HERE! For filename and contents we are referring directly to
  // Python-allocated and -managed memory since we are accepting pointers to
  // data members of python objects. We need to ensure that those objects
  // outlive our UnsavedFile objects.
  class_< UnsavedFile >( "UnsavedFile" )
    .add_property( "filename_",
      make_getter( &UnsavedFile::filename_ ),
      make_setter( &UnsavedFile::filename_,
                   return_value_policy< reference_existing_object >() ) )
    .add_property( "contents_",
      make_getter( &UnsavedFile::contents_ ),
      make_setter( &UnsavedFile::contents_,
                   return_value_policy< reference_existing_object >() ) )
    .def_readwrite( "length_", &UnsavedFile::length_ );

  class_< std::vector< UnsavedFile > >( "UnsavedFileVector" )
    .def( vector_indexing_suite< std::vector< UnsavedFile > >() );

  class_< ClangCompleter, boost::noncopyable >( "ClangCompleter" )
    .def( "GetDeclarationLocation", &ClangCompleter::GetDeclarationLocation )
    .def( "GetDefinitionLocation", &ClangCompleter::GetDefinitionLocation )
    .def( "DeleteCachesForFile", &ClangCompleter::DeleteCachesForFile )
    .def( "UpdatingTranslationUnit", &ClangCompleter::UpdatingTranslationUnit )
    .def( "UpdateTranslationUnit", &ClangCompleter::UpdateTranslationUnit )
    .def( "CandidatesForLocationInFile",
          &ClangCompleter::CandidatesForLocationInFile )
    .def( "GetTypeAtLocation", &ClangCompleter::GetTypeAtLocation )
    .def( "GetEnclosingFunctionAtLocation",
          &ClangCompleter::GetEnclosingFunctionAtLocation )
    .def( "GetFixItsForLocationInFile",
          &ClangCompleter::GetFixItsForLocationInFile )
    .def( "GetDocsForLocationInFile",
          &ClangCompleter::GetDocsForLocationInFile );

  enum_< CompletionKind >( "CompletionKind" )
    .value( "STRUCT", STRUCT )
    .value( "CLASS", CLASS )
    .value( "ENUM", ENUM )
    .value( "TYPE", TYPE )
    .value( "MEMBER", MEMBER )
    .value( "FUNCTION", FUNCTION )
    .value( "VARIABLE", VARIABLE )
    .value( "MACRO", MACRO )
    .value( "PARAMETER", PARAMETER )
    .value( "NAMESPACE", NAMESPACE )
    .value( "UNKNOWN", UNKNOWN )
    .export_values();

  class_< CompletionData >( "CompletionData" )
    .def( "TextToInsertInBuffer", &CompletionData::TextToInsertInBuffer )
    .def( "MainCompletionText", &CompletionData::MainCompletionText )
    .def( "ExtraMenuInfo", &CompletionData::ExtraMenuInfo )
    .def( "DetailedInfoForPreviewWindow",
          &CompletionData::DetailedInfoForPreviewWindow )
    .def( "DocString", &CompletionData::DocString )
    .def_readonly( "kind_", &CompletionData::kind_ );

  class_< std::vector< CompletionData >,
      boost::shared_ptr< std::vector< CompletionData > > >( "CompletionVector" )
    .def( vector_indexing_suite< std::vector< CompletionData > >() );

  class_< Location >( "Location" )
    .def_readonly( "line_number_", &Location::line_number_ )
    .def_readonly( "column_number_", &Location::column_number_ )
    .def_readonly( "filename_", &Location::filename_ )
    .def( "IsValid", &Location::IsValid );

  class_< Range >( "Range" )
    .def_readonly( "start_", &Range::start_ )
    .def_readonly( "end_", &Range::end_ );

  class_< std::vector< Range > >( "RangeVector" )
    .def( vector_indexing_suite< std::vector< Range > >() );

  class_< FixItChunk >( "FixItChunk" )
    .def_readonly( "replacement_text", &FixItChunk::replacement_text )
    .def_readonly( "range", &FixItChunk::range );

  class_< std::vector< FixItChunk > >( "FixItChunkVector" )
    .def( vector_indexing_suite< std::vector< FixItChunk > >() );

  class_< FixIt >( "FixIt" )
    .def_readonly( "chunks", &FixIt::chunks )
    .def_readonly( "location", &FixIt::location );

  class_< std::vector< FixIt > >( "FixItVector" )
    .def( vector_indexing_suite< std::vector< FixIt > >() );

  enum_< DiagnosticKind >( "DiagnosticKind" )
    .value( "ERROR", ERROR )
    .value( "WARNING", WARNING )
    .value( "INFORMATION", INFORMATION )
    .export_values();

  class_< Diagnostic >( "Diagnostic" )
    .def_readonly( "ranges_", &Diagnostic::ranges_ )
    .def_readonly( "location_", &Diagnostic::location_ )
    .def_readonly( "location_extent_", &Diagnostic::location_extent_ )
    .def_readonly( "kind_", &Diagnostic::kind_ )
    .def_readonly( "text_", &Diagnostic::text_ )
    .def_readonly( "long_formatted_text_", &Diagnostic::long_formatted_text_ )
    .def_readonly( "fixits_", &Diagnostic::fixits_ );

  class_< std::vector< Diagnostic > >( "DiagnosticVector" )
    .def( vector_indexing_suite< std::vector< Diagnostic > >() );

  class_< DocumentationData >( "DocumentationData" )
    .def_readonly( "comment_xml", &DocumentationData::comment_xml )
    .def_readonly( "raw_comment", &DocumentationData::raw_comment )
    .def_readonly( "brief_comment", &DocumentationData::brief_comment )
    .def_readonly( "canonical_type", &DocumentationData::canonical_type )
    .def_readonly( "display_name", &DocumentationData::display_name );

  class_< CompilationDatabase, boost::noncopyable >(
      "CompilationDatabase", init< std::string >() )
    .def( "DatabaseSuccessfullyLoaded",
          &CompilationDatabase::DatabaseSuccessfullyLoaded )
    .def( "AlreadyGettingFlags",
          &CompilationDatabase::AlreadyGettingFlags )
    .def( "GetCompilationInfoForFile",
          &CompilationDatabase::GetCompilationInfoForFile );

  class_< CompilationInfoForFile,
      boost::shared_ptr< CompilationInfoForFile > >(
          "CompilationInfoForFile", no_init )
    .def_readonly( "compiler_working_dir_",
                   &CompilationInfoForFile::compiler_working_dir_ )
    .def_readonly( "compiler_flags_",
                   &CompilationInfoForFile::compiler_flags_ );

#endif // USE_CLANG_COMPLETER
}

// Boost.Thread forces us to implement this.
// We don't use any thread-specific (local) storage so it's fine to implement
// this as an empty function.
namespace boost {
void tss_cleanup_implemented() {}
};

max_stars_repo_name: akrehl/dotfiles

max_issues_repo_name: akrehl/dotfiles

max_forks_repo_name: akrehl/dotfiles


text:
/*=============================================================================
    Boost.Wave: A Standard compliant C++ preprocessor library
    http://www.boost.org/

    Copyright (c) 2001-2012 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_WAVE_CUSTOM_DIRECTIVES_HOOKS_INCLUDED)
#define BOOST_WAVE_CUSTOM_DIRECTIVES_HOOKS_INCLUDED
//#define MY_USE_TEMPLATES 1
#include <cstdio>
#include <ostream>
#include <string>
#include <algorithm>

#include <boost/assert.hpp>
#include <boost/config.hpp>

#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/macro_helpers.hpp>
#include <boost/wave/preprocessing_hooks.hpp>

#include <boost/wave/util/cpp_iterator.hpp>
//#include <boost/wave/token_ids.hpp>
//#include <boost/wave/util/macro_helpers.hpp>
//
//#include "boost/wave/cpp_iteration_context.hpp"
//#include <boost/wave/cpplexer/cpp_lex_token.hpp>  // token type
//#include "idllexer/idl_lex_iterator.hpp"          // lexer type
static bool isImportDirective  ;

			///////////////////////////////////////////////////////////////////////////////
			//
			//  The custom_directives_hooks policy class is used to register some
			//  of the more advanced (and probably more rarely used hooks with the Wave
			//  library.
			//
			//  This policy type is used as a template parameter to the boost::wave::context<>
			//  object.
			//
			///////////////////////////////////////////////////////////////////////////////
			class custom_directives_hooks
				: public boost::wave::context_policies::default_preprocessing_hooks
			{
			//ContextT	ctx
			public:

					///////////////////////////////////////////////////////////////////////////
					//
					//  The function 'locate_include_file' is called, whenever a #include
					//  directive was encountered. It is supposed to locate the given file and
					//  should return the full file name of the located file. This file name
					//  is expected to uniquely identify the referenced file.
					//
					//  The parameter 'ctx' is a reference to the context object used for
					//  instantiating the preprocessing iterators by the user.
					//
					//  The parameter 'file_path' contains the (expanded) file name found after
					//  the #include directive. This parameter holds the string as it is
					//  specified in the #include directive, i.e. <file> or "file" will result
					//  in a parameter value 'file'.
					//
					//  The parameter 'is_system' is set to 'true' if this call happens as a
					//  result of a #include '<file>' directive, it is 'false' otherwise, i.e.
					//  for #include "file" directives.
					//
					//  The parameter 'current_name' is only used if a #include_next directive
					//  was encountered (and BOOST_WAVE_SUPPORT_INCLUDE_NEXT was defined to be
					//  non-zero). In this case it points to unique full name of the current
					//  include file (if any). Otherwise this parameter is set to NULL.
					//
					//  The parameter 'dir_path' on return is expected to hold the directory
					//  part of the located file.
					//
					//  The parameter 'native_name' on return is expected to hold the unique
					//  full file name of the located file.
					//
					//  The return value defines whether the file was located successfully.
					//
					///////////////////////////////////////////////////////////////////////////
					template <typename ContextT>
					bool
					locate_include_file(ContextT& ctx, std::string &file_path,
						bool is_system, char const *current_name, std::string &dir_path,
						std::string &native_name)
					{
						boost::filesystem::path  pa(file_path);
						bool isExtension = pa.has_extension(); //ok fonctionne  file_path.find(".") != std::string::npos; /// problem pour les path relative ../ TODO FIXME
						if (isExtension)
						{
										 if (!ctx.find_include_file(file_path, dir_path, is_system, current_name))
										 {
												if(file_path.substr(file_path.find_last_of(".") + 1) == "h")
												{
													file_path = file_path.substr(0, file_path.find_last_of(".")) + ".oxh";
												}
												else
												{
													if(file_path.substr(file_path.find_last_of(".") + 1) == "oxh")
													{
													file_path = file_path.substr(0, file_path.find_last_of(".")) + ".h";
													}
													else
														return false;   // could not locate file
												}
											if (!ctx.find_include_file(file_path, dir_path, is_system, current_name))
													return false;   // could not locate file
										 }
						}
						else
						{
							bool found = false;
							std::list<std::string> listofExtension = { ".h",".oxh" };
							for (auto it = listofExtension.begin(); it != listofExtension.end(); it++)
							{
								// Access the object through iterator
								std::string ext = *it;
								std::string temp = file_path + ext;
								if (ctx.find_include_file(temp, dir_path, is_system, current_name))
								{
									found = true;
									file_path = temp;
									break;
								}
							}
							if(!found)
									return false;
						}

						namespace fs = boost::filesystem;

						fs::path native_path(boost::wave::util::create_path(file_path));
						if (!fs::exists(native_path)) {
							BOOST_WAVE_THROW_CTX(ctx, boost::wave::preprocess_exception, bad_include_file,
								file_path.c_str(), ctx.get_main_pos());
							return false;
						}

						// return the unique full file system path of the located file
						native_name = boost::wave::util::native_file_string(native_path);
						return true;      // include file has been located successfully
					}

					   //  recent essaie de changer les emit lines directive en fonction de import ou non

						//  The function 'emit_line_directive' is called whenever a #line directive
						//  has to be emitted into the generated output.
						//
						//  The parameter 'ctx' is a reference to the context object used for
						//  instantiating the preprocessing iterators by the user.
						//
						//  The parameter 'pending' may be used to push tokens back into the input
						//  stream, which are to be used instead of the default output generated
						//  for the #line directive.
						//
						//  The parameter 'act_token' contains the actual #pragma token, which may
						//  be used for error output. The line number stored in this token can be
						//  used as the line number emitted as part of the #line directive.
						//
						//  If the return value is 'false', a default #line directive is emitted
						//  by the library. A return value of 'true' will inhibit any further
						//  actions, the tokens contained in 'pending' will be copied verbatim
						//  to the output.
						//
						///////////////////////////////////////////////////////////////////////////
				/*	#if MY_USE_TEMPLATES
				    template <typename ContextT, typename ContainerT>
					#else */

					/*
	 			 */
			//#ifdef MY_USE_TEMPLATESm
			//		typedef boost::wave::idllexer::lex_iterator<boost::wave::cpplexer::lex_token<>> lex_iterator_type;
			//		typedef boost::wave::context<std::string::iterator, lex_iterator_type, boost::wave::iteration_context_policies::load_file_to_string, custom_directives_hooks>  ContextT;
			//		// typedef boost::wave::idllexer::lex_iterator<boost::wave::cpplexer::lex_token<>> ContainerT;
			//		//typedef	 boost::wave::context<std::_String_iterator<std::_String_val<std::_Simple_types<char> > >, boost::wave::idllexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::char_traits<char>, std::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::allocator<char> >, char *> > > > >, boost::wave::iteration_context_policies::load_file_to_string, custom_directives_hooks, boost::wave::this_type> ContextT;
			//		template < typename ContainerT>
			//	 #else
					 template <typename ContextT, typename ContainerT>
				 //#endif
						/*template <typename ContextT, typename ContainerT>*/

						bool
						emit_line_directive(ContextT & ctx, ContainerT &pending,
							typename ContextT::token_type const& act_token)
						{
							using namespace boost::wave;
							unsigned int column = 6;
							typedef typename ContextT::token_type result_type;
						    typename ContextT::position_type pos = act_token.get_position();

							// REAL QUESTION HOW TO ACESS THE ctx.pop_iteration_context() in custome_directives ?
						 //   typedef idllexer::lex_iterator<cpplexer::lex_token<>> lex_iterator_type;
							//// typedef boost::wave::context<std::string::iterator, lex_iterator_type,boost::wave::iteration_context_policies::load_file_to_string , custom_directives_hooks>  context;
							//  boost::shared_ptr <base_iteration_context<ContextT, lex_iterator_type> >   iter_ctx  = ctx.pop_iteration_context();;
					  //    typedef BOOST_WAVE_STRINGTYPE   string_type;
						 //   lex_iterator_type it = iter_ctx->first;
							//string_type m=   it->get_value();
							//std::string tex = m.c_str(); //"\n"
							// the hook did not generate anything, emit default #line
							pos.set_column(1);

							 if(isImportDirective)
								 pending.push_back(result_type(boost::wave::T_PP_LINE, "#impo", pos));
							else
								pending.push_back(result_type(T_PP_LINE, "#line", pos));
							 //isImportDirective = false;

							pos.set_column(column);      // account for '#line'
							pending.push_back(result_type(T_SPACE, " ", pos));

							// 21 is the max required size for a 64 bit integer represented as a
							// string
							char buffer[22];

								using namespace std;    // for some systems sprintf is in namespace std
								sprintf (buffer, "%ld", pos.get_line());

								pos.set_column(++column);                 // account for ' '
								pending.push_back(result_type(T_INTLIT, buffer, pos));
								pos.set_column(column += (unsigned int)strlen(buffer)); // account for <number>
								pending.push_back(result_type(T_SPACE, " ", pos));
								pos.set_column(++column);                 // account for ' '

							std::string file("\"");
							boost::filesystem::path filename(
								 //boost::wave::util::create_path(act_pos.get_file().c_str()));
						       util::create_path(ctx.get_current_filename().c_str()));

							    using  util::impl::escape_lit;
								file += escape_lit(util::native_file_string(filename)) + "\"";

								pending.push_back(result_type(T_STRINGLIT, file.c_str(), pos));
								pos.set_column(column += (unsigned int)file.size());    // account for filename
								pending.push_back(result_type(T_GENERATEDNEWLINE, "\n", pos));

							return true;
						}

						    ///////////////////////////////////////////////////////////////////////////
    //
    //  The function 'returning_from_include_file' is called, whenever an
    //  included file is about to be closed after it's processing is complete.
    //
    //  The parameter 'ctx' is a reference to the context object used for
    //  instantiating the preprocessing iterators by the user.
    //
    ///////////////////////////////////////////////////////////////////////////

    // new signature
    template <typename ContextT>
    void
    returning_from_include_file(ContextT const& ctx)
    {
		isImportDirective = false;
    }

						custom_directives_hooks() : need_comment(true) { isImportDirective = false; }

						  ///////////////////////////////////////////////////////////////////////////
    //
    //  The function 'found_include_directive' is called, whenever a #include
    //  directive was located.
    //
    //  The parameter 'ctx' is a reference to the context object used for
    //  instantiating the preprocessing iterators by the user.
    //
    //  The parameter 'filename' contains the (expanded) file name found after
    //  the #include directive. This has the format '<file>', '"file"' or
    //  'file'.
    //  The formats '<file>' or '"file"' are used for #include directives found
    //  in the preprocessed token stream, the format 'file' is used for files
    //  specified through the --force_include command line argument.
    //
    //  The parameter 'include_next' is set to true if the found directive was
    //  a #include_next directive and the BOOST_WAVE_SUPPORT_INCLUDE_NEXT
    //  preprocessing constant was defined to something != 0.
    //
    //  The return value defines whether the found file will be included
    //  (return false) or will be skipped (return true).
    //
    ///////////////////////////////////////////////////////////////////////////
//
//#ifdef MY_USE_TEMPLATESm
//		typedef boost::wave::idllexer::lex_iterator<boost::wave::cpplexer::lex_token<>> lex_iterator_type;
//		typedef boost::wave::context<std::string::iterator, lex_iterator_type, boost::wave::iteration_context_policies::load_file_to_string, custom_directives_hooks>  ContextT;
//
// #else
	    template <typename ContextT>
//#endif

    bool
    found_include_directive(ContextT & ctx, std::string const& filename,
        bool include_next)
    {

		 /*  using namespace boost::wave;
		   typedef idllexer::lex_iterator<cpplexer::lex_token<>> lex_iterator_type;
		   typedef BOOST_WAVE_STRINGTYPE   string_type;
		   auto  m=   ctx.last;
		   auto  iter_ctx  = ctx.iter_ctxs;;
		   ctx.pop_iteration_context();*/

		   //l'id�e est ici de recuperer si c'est un import ou 1 include  !

        return false;    // ok to include this file
    }

    ///////////////////////////////////////////////////////////////////////////
    //
    //  The function 'found_directive' is called, whenever a preprocessor
    //  directive was encountered, but before the corresponding action is
    //  executed.
    //
    //  The parameter 'ctx' is a reference to the context object used for
    //  instantiating the preprocessing iterators by the user.
    //
    //  The parameter 'directive' is a reference to the token holding the
    //  preprocessing directive.
    //
    ///////////////////////////////////////////////////////////////////////////
//#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
//    template <typename TokenT>
//    void
//    found_directive(TokenT const& directive)
//#else
    template <typename ContextT, typename TokenT>
    bool
    found_directive(ContextT const& ctx, TokenT const& directive)
//#endif
    {

		const boost::wave::token_id OX_IMPORT = boost::wave::T_PP_HHEADER;

        // print the commented conditional directives
        using namespace boost::wave;
        token_id id = token_id(directive);
        switch (id) {
        case T_PP_IFDEF:
        case T_PP_IFNDEF:
        case T_PP_IF:
        case T_PP_ELIF:
            std::cout << "//" + directive.get_value() << " ";
            need_comment = false;
			isinbloc = true;
            break;

        case T_PP_ELSE:
			   need_comment = true;
            break;
        case T_PP_ENDIF:
        //    std::cout << "b// " << directive.get_value() << std::endl;
            need_comment = true;
			isinbloc = false;

            break;

		case T_PP_IMPORT:
			isImportDirective = true;
		/*	std::cout << "FOUND ----- >T_PP_QHEADER" << endl;
			std::cout << "----- > IMPORT YES" << endl;*/
		break;

		case T_PP_QHEADER:
		case T_PP_HHEADER :
			/*std::cout << "FOUND ----- >T_PP_QHEADER/T_PP_HHEADER" << endl;*/
			isImportDirective = false;
			//std::cout << "------> IMPORT NO" << endl;
			 break;

        default:
					//isImportDirective = false;
            break;
        }

        return false;

    }

    ///////////////////////////////////////////////////////////////////////////
    //
    //  The function 'evaluated_conditional_expression' is called, whenever a
    //  conditional preprocessing expression was evaluated (the expression
    //  given to a #if, #elif, #ifdef or #ifndef directive)
    //
    //  The parameter 'ctx' is a reference to the context object used for
    //  instantiating the preprocessing iterators by the user.
    //
    //  The parameter 'expression' holds the non-expanded token sequence
    //  comprising the evaluated expression.
    //
    //  The parameter expression_value contains the result of the evaluation of
    //  the expression in the current preprocessing context.
    //
    //  The return value defines, whether the given expression has to be
    //  evaluated again, allowing to decide which of the conditional branches
    //  should be expanded. You need to return 'true' from this hook function
    //  to force the expression to be re-evaluated.
    //
    ///////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
    template <typename ContainerT>
    bool
    evaluated_conditional_expression(
        ContainerT const& expression, bool expression_value)
#else
    template <typename ContextT, typename TokenT, typename ContainerT>
    bool
    evaluated_conditional_expression(ContextT const &ctx,
        TokenT const& directive, ContainerT const& expression,
        bool expression_value)
#endif
    {
        // print the conditional expressions
	//	std::cout << boost::wave::util::impl::as_string(expression);// << std::endl;
        need_comment = false;
        return false;          // ok to continue, do not re-evaluate expression
    }

    ///////////////////////////////////////////////////////////////////////////
    //
    //  The function 'skipped_token' is called, whenever a token is about to be
    //  skipped due to a false preprocessor condition (code fragments to be
    //  skipped inside the not evaluated conditional #if/#else/#endif branches).
    //
    //  The parameter 'ctx' is a reference to the context object used for
    //  instantiating the preprocessing iterators by the user.
    //
    //  The parameter 'token' refers to the token to be skipped.
    //
    ///////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
    template <typename TokenT>
    void
    skipped_token(TokenT const& token)
#else
    template <typename ContextT, typename TokenT>
    void
    skipped_token(ContextT const& ctx, TokenT const& token)
#endif
    {
        // prepend a comment at the beginning of all skipped lines
        using namespace boost::wave;
        if (isinbloc && need_comment && token_id(token) != T_SPACE) {
            std::cout << "//";
            need_comment = false;
        }

		token_id id = token_id(token);
		 if (id == T_PP_IFDEF |
			 id == T_PP_IFNDEF |
			 id == T_PP_IF|
			 id == T_PP_ELIF|
			 id == T_PP_ELSE|
			 id == T_PP_ENDIF

			 )
		 {
			 std::cout << token.get_value();

		 }
		/* else
		    std::cout << "e-" << token.get_value();*/

		  //if(isinbloc)
				 if (token_id(token) == T_NEWLINE || token_id(token) == T_CPPCOMMENT)
				 {
					 need_comment = true;

					 if (token_id(token) == T_NEWLINE)
					 std::cout << std::endl;
				 }

    }

private:
    bool need_comment;
	bool isinbloc = false;
			};

#endif // !defined(BOOST_WAVE_ADVANCED_PREPROCESSING_HOOKS_INCLUDED)

max_stars_repo_name: prolept/OxLinter

max_issues_repo_name: prolept/OxLinter

max_forks_repo_name: prolept/OxLinter


text:
//
// GTestBrcm.cpp - GTESTs
//
// GTESTs
//
// Created by Sudheendra Gopinath, March 2018
// Copyright (c) [2017] Juniper Networks, Inc. All rights reserved.
//
// All rights reserved.
//
// Notice and Disclaimer: This code is licensed to you under the Apache
// License 2.0 (the "License"). You may not use this code except in compliance
// with the License. This code is not an official Juniper product. You can
// obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Third-Party Code: This code may depend on other components under separate
// copyright notice and license terms. Your use of the source code for those
// components is subject to the terms and conditions of the respective license
// as noted in the Third-Party source code file.
//

#include <limits.h>
#include "gtest/gtest.h"
#include "TestPacket.h"
#include "TestUtils.h"
#include "Controller.h"
#include <boost/filesystem.hpp>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <future>
#include <fstream>

using namespace std;

using namespace std::chrono_literals;

//
// Test setup
//
//        +---------------------+
//        |        QFX          |                Controller/GTEST
//        |                     |                    ^
//        |                     |         P4 Runtime |
//        |                     |                    |
//        |                     |                    V
//        |   BCM RPC server <------BCM RPC-----> JP4Agent
//        |                     |
//        |                     |
//        |                     |
//        |                     |
//        |   p1            p2  |
//        +--|-|-----------|-|--+
//           |_|           |_|
//
//

// Test fixture class for common setup.
// We setup the forwarding pipeline config here.
class P4BRCM : public ::testing::Test
{
protected:
    static void SetUpTestCase()
    {
        ControllerSetConfig();
        sleep_thread_log(5s);
    }
};

// Test1: Inject and Punt Test.
TEST_F(P4BRCM, BrcmInjectPuntL2Pkt)
{
    uint16_t port = 13;

    TestPacket *testPkt = testPacketLibrary.getTestPacket(
        TestPacketLibrary::TEST_PKT_ID_BRCM_TEST_INJECT);
    char pktbuf[ETHER_PAYLOAD_BUF_SIZE];
    size_t pktlen = testPkt->getEtherPacket(pktbuf, ETHER_PAYLOAD_BUF_SIZE);
    std::string inject_l2_pkt{pktbuf, pktlen};

    // Print injected pkt
    std::cout << "Injected pkt on port: " << port << std::hex << std::uppercase;
    for (size_t i = 0; i < pktlen; i++) {
        if (i % 16 == 0) std::cout << "\n";
        std::cout << " " << std::setfill('0') << std::setw(2)
                  << +(uint8_t)inject_l2_pkt[i];
    }
    std::cout << std::endl << std::dec << std::nouppercase;

    std::string recvd_pkt;
    ControllerInjectPuntL2Pkt(inject_l2_pkt, recvd_pkt, port, port, 15s);
    ASSERT_FALSE(recvd_pkt.empty()) << "Failed to read packet";

    // Verify packets.
    EXPECT_EQ(0, memcmp(pktbuf, recvd_pkt.data(), pktlen))
        << "Sent and received pkts differ";
}

// Test2: Transit Packet Test.
TEST_F(P4BRCM, BrcmIpv4Router)
{
    uint16_t iport = 9;
    uint16_t eport = 13;

    // Launch controller to add route entries.
    // First, the default route.
    ControllerAddRouteEntry(0, 0, 0x0b000001, 0x88a25e91a2a8, 9);

    // Next, the actual route
    ControllerAddRouteEntry(0x37373702, 24, 0x0a000001, 0x88a25e9175ff, 13);
    sleep_thread_log(5s);

    TestPacket *injectPkt = testPacketLibrary.getTestPacket(
        TestPacketLibrary::TEST_PKT_ID_BRCM_TEST_TRANSIT_INJECT);
    char pktbuf[ETHER_PAYLOAD_BUF_SIZE];
    size_t pktlen = injectPkt->getEtherPacket(pktbuf, ETHER_PAYLOAD_BUF_SIZE);
    std::string inject_l2_pkt{pktbuf, pktlen};

    // Print injected pkt
    std::cout << "Injected pkt on port: " << iport << std::hex << std::uppercase;
    for (size_t i = 0; i < pktlen; i++) {
        if (i % 16 == 0) std::cout << "\n";
        std::cout << " " << std::setfill('0') << std::setw(2)
                  << +(uint8_t)inject_l2_pkt[i];
    }
    std::cout << std::endl << std::dec << std::nouppercase;

    std::string recvd_pkt;
    ControllerInjectPuntL2Pkt(inject_l2_pkt, recvd_pkt, eport, iport, 30s);
    ASSERT_FALSE(recvd_pkt.empty()) << "Failed to read packet";

    TestPacket *puntPkt = testPacketLibrary.getTestPacket(
        TestPacketLibrary::TEST_PKT_ID_BRCM_TEST_TRANSIT_PUNT);
    pktlen = puntPkt->getEtherPacket(pktbuf, ETHER_PAYLOAD_BUF_SIZE);

    // Verify packets. Ignore checksum difference.
    EXPECT_EQ(0, (memcmp(pktbuf, recvd_pkt.data(), 22) &&
                  memcmp(pktbuf + 25, recvd_pkt.data() + 25, pktlen - 26)))
        << "Sent and received pkts differ";
}