hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
fae2e8971649ef29d954ba9d7e0e184037343fcd
491
cpp
C++
math/tetration_mod/gen/random.cpp
tko919/library-checker-problems
007a3ef79d1a1824e68545ab326d1523d9c05262
[ "Apache-2.0" ]
290
2019-06-06T22:20:36.000Z
2022-03-27T12:45:04.000Z
math/tetration_mod/gen/random.cpp
tko919/library-checker-problems
007a3ef79d1a1824e68545ab326d1523d9c05262
[ "Apache-2.0" ]
536
2019-06-06T18:25:36.000Z
2022-03-29T11:46:36.000Z
math/tetration_mod/gen/random.cpp
tko919/library-checker-problems
007a3ef79d1a1824e68545ab326d1523d9c05262
[ "Apache-2.0" ]
82
2019-06-06T18:17:55.000Z
2022-03-21T07:40:31.000Z
#include "random.h" #include <iostream> using namespace std; using ll = long long; int main(int, char* argv[]) { long long seed = atoll(argv[1]); auto gen = Random(seed); int t = gen.uniform(1, 1000); printf("%d\n", t); for (int i = 0; i < t; i++) { ll a = gen.uniform(0LL, 1'000'000'000LL); ll b = gen.uniform(0LL, 1'000'000'000LL); ll m = gen.uniform(1LL, 1'000'000'000LL); printf("%lld %lld %lld\n", a, b, m); } return 0; }
22.318182
49
0.543788
tko919
fae9c211baf5dcb54095693d6360e0d565b1ebdf
3,205
cc
C++
DataStructuresAndAlgorithms/old_algo_code/DS/C++/Array/main.cc
DLonng/Go
a67ac6d6501f9fadadec6a6cf766d4b4a356d572
[ "MIT" ]
23
2020-04-10T01:53:46.000Z
2021-12-31T03:43:10.000Z
DataStructuresAndAlgorithms/old_algo_code/DS/C++/Array/main.cc
DLonng/Go
a67ac6d6501f9fadadec6a6cf766d4b4a356d572
[ "MIT" ]
1
2020-12-10T07:08:37.000Z
2021-04-14T07:47:01.000Z
DataStructuresAndAlgorithms/old_algo_code/DS/C++/Array/main.cc
DLonng/Go
a67ac6d6501f9fadadec6a6cf766d4b4a356d572
[ "MIT" ]
9
2020-04-05T11:49:22.000Z
2021-11-04T10:23:37.000Z
#include "cvector.h" #include <iostream> #include <cassert> void test_print() { cspace::CVector vec(10); vec.Push(1); vec.Push(2); vec.Push(3); vec.PrintVector(); } void test_size() { cspace::CVector vec(10); assert(vec.size() == 0); vec.Push(1); vec.Push(2); vec.Push(3); assert(vec.size() == 3); } void test_capacity() { cspace::CVector vec1(0); assert(vec1.capacity() == 1); cspace::CVector vec2(15); assert(vec2.capacity() == 16); cspace::CVector vec3(17); assert(vec3.capacity() == 32); } void test_is_empty() { cspace::CVector vec(10); assert(vec.IsEmpty() == 1); vec.Push(1); vec.Push(2); vec.Push(3); assert(vec.IsEmpty() == 0); } void test_at() { cspace::CVector vec(10); vec.Push(1); vec.Push(2); vec.Push(3); assert(vec.At(0) == 1); assert(vec.At(1) == 2); assert(vec.At(2) == 3); } void test_push() { cspace::CVector vec(10); assert(vec.capacity() == 16); for (int i = 0; i < 20; i++) vec.Push(i + 1); assert(vec.capacity() == 32); assert(vec.size() == 20); } void test_insert() { cspace::CVector vec(10); for (int i = 0; i < vec.capacity(); i++) vec.Push(i + 1); vec.Insert(1, 22); assert(vec.capacity() == 32); assert(vec.At(1) == 22); } void test_prepend() { cspace::CVector vec(10); assert(vec.size() == 0); vec.Push(1); vec.Push(2); vec.Push(3); vec.Prepend(22); assert(vec.size() == 4); assert(vec.At(0) == 22); assert(vec.At(1) == 1); } void test_pop() { cspace::CVector vec(10); vec.Push(1); vec.Push(2); vec.Push(3); assert(vec.size() == 3); vec.Pop(); vec.Pop(); vec.Pop(); assert(vec.size() == 0); } void test_delete() { cspace::CVector vec(10); vec.Push(1); vec.Push(2); vec.Push(3); assert(vec.size() == 3); vec.Delete(1); assert(vec.At(1) == 3); assert(vec.size() == 2); } void test_remove() { cspace::CVector vec(10); vec.Push(1); vec.Push(2); vec.Push(2); vec.Push(2); vec.Push(2); vec.Push(3); vec.Remove(2); assert(vec.size() == 2); assert(vec.Find(2) == -1); } void test_find() { cspace::CVector vec(10); vec.Push(1); vec.Push(2); vec.Push(3); assert(vec.Find(1) == 0); assert(vec.Find(4) == -1); } /* void test_resize_up() { cspace::CVector vec(10); for (int i = 0; i < vec.capacity(); i++) vec.Push(i + 1); assert(vec.size() == 16); vec.Resize(18); assert(vec.size() == 32); assert(vec.At(15) == 16); } void test_resize_down() { cspace::CVector vec(30); for (int i = 0; i < 5; i++) vec.Push(i + 1); assert(vec.size() == 5); assert(vec.capacity() == 32); vec.Resize(15); assert(vec.capacity() == 16); } */ void run_all_test() { //test_print(); //test_size(); //test_capacity(); //test_is_empty(); //test_at(); //test_push(); //test_insert(); //test_prepend(); //test_pop(); //test_delete(); test_remove(); //test_find(); //test_resize_up(); //test_resize_down(); } int main(void) { run_all_test(); return 0; }
17.139037
43
0.532605
DLonng
faea5af16d93a34b1c65f37d6648223a3ff22c70
9,788
hpp
C++
include/ironbeepp/connection.hpp
b1v1r/ironbee
97b453afd9c3dc70342c6183a875bde22c9c4a76
[ "Apache-2.0" ]
148
2015-01-10T01:53:39.000Z
2022-03-20T20:48:12.000Z
include/ironbeepp/connection.hpp
ErikHendriks/ironbee
97b453afd9c3dc70342c6183a875bde22c9c4a76
[ "Apache-2.0" ]
8
2015-03-09T15:50:36.000Z
2020-10-10T19:23:06.000Z
include/ironbeepp/connection.hpp
ErikHendriks/ironbee
97b453afd9c3dc70342c6183a875bde22c9c4a76
[ "Apache-2.0" ]
46
2015-03-08T22:45:42.000Z
2022-01-15T13:47:59.000Z
/***************************************************************************** * Licensed to Qualys, Inc. (QUALYS) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * QUALYS licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ****************************************************************************/ /** * @file * @brief IronBee++ --- Connection * * This file defines (Const)Connection, a wrapper for ib_conn_t. * * @remark Developers should be familiar with @ref ironbeepp to understand * aspects of this code, e.g., the public/non-virtual inheritance. * * @author Christopher Alfeld <calfeld@qualys.com> */ #ifndef __IBPP__CONNECTION__ #define __IBPP__CONNECTION__ #include <ironbeepp/abi_compatibility.hpp> #include <ironbeepp/common_semantics.hpp> #include <ironbeepp/module.hpp> #include <ironbee/engine.h> #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor" #endif #include <boost/date_time/posix_time/ptime.hpp> #ifdef __clang__ #pragma clang diagnostic pop #endif #include <ostream> // IronBee C Type typedef struct ib_conn_t ib_conn_t; namespace IronBee { class Engine; class MemoryManager; class Context; class Transaction; /** * Const Connection; equivalent to a const pointer to ib_conn_t. * * Provides operators ==, !=, <, >, <=, >= and evaluation as a boolean for * singularity via CommonSemantics. * * See Connection for discussion of Connection * * @sa Connection * @sa ironbeepp * @sa ib_conn_t * @nosubgrouping **/ class ConstConnection : public CommonSemantics<ConstConnection> { public: //! C Type. typedef const ib_conn_t* ib_type; /** * Construct singular ConstConnection. * * All behavior of a singular ConstConnection is undefined except for * assignment, copying, comparison, and evaluate-as-bool. **/ ConstConnection(); /** * @name C Interoperability * Methods to access underlying C types. **/ ///@{ //! const ib_conn_t accessor. // Intentionally inlined. ib_type ib() const { return m_ib; } //! Construct Connection from ib_conn_t. explicit ConstConnection(ib_type ib_connection); ///@} //! Associated Engine. Engine engine() const; //! Associated MemoryManager. MemoryManager memory_manager() const; //! Identifier. const char* id() const; //! Associated Context. Context context() const; //! When the connection started. boost::posix_time::ptime started_time() const; //! When the connection finished. boost::posix_time::ptime finished_time() const; //! Remote IP address as a dotted quad string. const char* remote_ip_string() const; //! Remote port. uint16_t remote_port() const; //! Local IP address as a dotted quad string. const char* local_ip_string() const; //! Local port. uint16_t local_port() const; //! Number of transactions. size_t transaction_count() const; /** * First transaction / beginning of transaction list. * * Later transaction can be accessed via Transaction::next(). **/ Transaction first_transaction() const; //! Last transaction / end of transaction list. Transaction last_transaction() const; //! Transaction most recently created/destroyed/modified. Transaction transaction() const; /** * @name Flags * Transaction Flags * * The masks for the flags are defined by the flags_e enum. All flags * as a set of bits can be accessed via flags(). Individual flags can be * checked either via flags() @c & @c flag_X or via @c is_X(). **/ ///@{ //! Possible flags. Treat as bit masks. enum flags_e { flag_none = IB_CONN_FNONE, flag_error = IB_CONN_FERROR, flag_transaction = IB_CONN_FTX, flag_data_in = IB_CONN_FDATAIN, flag_data_out = IB_CONN_FDATAOUT, flag_opened = IB_CONN_FOPENED, flag_closed = IB_CONN_FCLOSED }; //! All flags. ib_flags_t flags() const; //! flags() & flag_none bool is_none() const { return flags() & flag_none; } //! flags() & flag_error bool is_error() const { return flags() & flag_error; } //! flags() & flag_transaction bool is_transaction() const { return flags() & flag_transaction; } //! flags() & flag_data_in bool is_data_in() const { return flags() & flag_data_in; } //! flags() & flag_data_out bool is_data_out() const { return flags() & flag_data_out; } //! flags() & flag_opened bool is_opened() const { return flags() & flag_opened; } //! flags() & flag_closed bool is_closed() const { return flags() & flag_closed; } private: ib_type m_ib; }; /** * Connection; equivalent to a pointer to ib_conn_t. * * Connection can be treated as ConstConnection. See @ref ironbeepp for * details on IronBee++ object semantics. * * A connection is a sequence of transactions over a single stream between * a remote and a local entity. * * This class adds no functionality to ConstConnection beyond providing a * non-const @c ib_conn_t* via ib(). * * @sa ConstConnection * @sa ironbeepp * @sa ib_conn_t * @nosubgrouping **/ class Connection : public ConstConnection { public: //! C Type. typedef ib_conn_t* ib_type; /** * Remove the constness of a ConstConnection. * * @warning This is as dangerous as a @c const_cast, use carefully. * * @param[in] connection ConstConnection to remove const from. * @returns Connection pointing to same underlying connection as * @a connection. **/ static Connection remove_const(ConstConnection connection); /** * Construct singular Connection. * * All behavior of a singular Connection is undefined except for * assignment, copying, comparison, and evaluate-as-bool. **/ Connection(); /** * @name C Interoperability * Methods to access underlying C types. **/ ///@{ //! ib_conn_t accessor. ib_type ib() const { return m_ib; } //! Construct Connection from ib_conn_t. explicit Connection(ib_type ib_connection); ///@} /** * Create a new connection. * * The C API provides a plugin context @c void* parameter for connection * creation. This is currently unsupported. It is intended that C++ * server plugins not need that context. * * @param[in] engine Engine to associate connection with. * @returns Connection **/ static Connection create(Engine engine); /** * Set remote IP string. * * The memory pointed to by @a ip must have a lifetime that exceeds the * connection. * * @param[in] ip New remote IP string. **/ void set_remote_ip_string(const char* ip) const; /** * Set remote port number. * * @param[in] port New port number. **/ void set_remote_port(uint16_t port) const; /** * Set local IP string. * * The memory pointed to by @a ip must have a lifetime that exceeds the * connection. * * @param[in] ip New local IP string. **/ void set_local_ip_string(const char* ip) const; /** * Set local port number. * * @param[in] port New port number. **/ void set_local_port(uint16_t port) const; /** * Destroy connection. **/ void destroy() const; /** * Copy @a t into the T module data. * * ConstConnection::memory_manager() will be charged with * destroying the copy of @a t when the transaction is over. * * @param[in] m The module to store @a t for. * @param[in] t The module data. * @throws IronBee errors on C API failures. */ template<typename T> void set_module_data(ConstModule m, T t); /** * Return a reference to the stored module connection data. * * @param[in] m The module that the data is stored for. * @throws IronBee errors on C API failures. */ template<typename T> T get_module_data(ConstModule m); private: ib_type m_ib; }; /** * Output operator for Connection. * * Output IronBee::Connection[@e value] where @e value is remote ip and port * -> local ip ad port. * * @param[in] o Ostream to output to. * @param[in] connection Connection to output. * @return @a o **/ std::ostream& operator<<(std::ostream& o, const ConstConnection& connection); template<typename T> void Connection::set_module_data(ConstModule m, T t) { void *v = value_to_data(t, memory_manager().ib()); throw_if_error( ib_conn_set_module_data(ib(), m.ib(), v) ); } template<typename T> T Connection::get_module_data(ConstModule m) { void *v = NULL; throw_if_error( ib_conn_get_module_data(ib(), m.ib(), &v) ); return data_to_value<T>(v); } } // IronBee #endif
24.592965
78
0.631794
b1v1r
faeab71bf12d01b90741d85608c874526118d5fb
285
cpp
C++
src/dot.cpp
blauergrashalm/galaxy_server
762c7f939ed1675c1fdbde15c8d1dbada22cfbef
[ "MIT" ]
1
2020-04-07T17:35:31.000Z
2020-04-07T17:35:31.000Z
src/dot.cpp
blauergrashalm/galaxy_server
762c7f939ed1675c1fdbde15c8d1dbada22cfbef
[ "MIT" ]
12
2020-04-08T13:45:52.000Z
2020-06-02T09:45:42.000Z
src/dot.cpp
blauergrashalm/galaxy_server
762c7f939ed1675c1fdbde15c8d1dbada22cfbef
[ "MIT" ]
null
null
null
#include "dot.hpp" #include "field.hpp" json Dot::toJson() { json dot; dot["x"] = position.x; dot["y"] = position.y; for (auto it = fields.begin(); it != fields.end(); it++) { dot["fields"].push_back((*it)->id); } dot["id"] = id; return dot; }
17.8125
60
0.508772
blauergrashalm
faeb03cca28142b65668fd5cc48e90e6b35939c8
3,055
cpp
C++
tests/Engine/Math/Vector3.cpp
AntoineJT/NazaraEngine
e0b05a7e7a2779e20a593b4083b4a881cc57ce14
[ "BSD-3-Clause-Clear", "Apache-2.0", "MIT" ]
null
null
null
tests/Engine/Math/Vector3.cpp
AntoineJT/NazaraEngine
e0b05a7e7a2779e20a593b4083b4a881cc57ce14
[ "BSD-3-Clause-Clear", "Apache-2.0", "MIT" ]
null
null
null
tests/Engine/Math/Vector3.cpp
AntoineJT/NazaraEngine
e0b05a7e7a2779e20a593b4083b4a881cc57ce14
[ "BSD-3-Clause-Clear", "Apache-2.0", "MIT" ]
null
null
null
#include <Nazara/Math/Vector3.hpp> #include <Catch/catch.hpp> #include <Nazara/Math/Vector2.hpp> #include <Nazara/Math/Vector4.hpp> SCENARIO("Vector3", "[MATH][VECTOR3]") { GIVEN("Two same unit vector") { Nz::Vector3f firstUnit(1.f, 1.f, 1.f); Nz::Vector3f secondUnit(Nz::Vector3i(Nz::Vector4i(1, 1, 1, 5))); WHEN("We compare them") { THEN("They are the same") { REQUIRE(firstUnit == secondUnit); } } WHEN("We test the dot product") { Nz::Vector3f tmp(-1.f, 0.f, 1.f); THEN("These results are expected") { REQUIRE(firstUnit.AbsDotProduct(tmp) == Approx(2.f)); REQUIRE(firstUnit.DotProduct(tmp) == Approx(0.f)); REQUIRE(firstUnit.AngleBetween(tmp) == Approx(Nz::FromDegrees(90.f))); REQUIRE(firstUnit.AngleBetween(-firstUnit) == Approx(Nz::FromDegrees(180.f))); } } WHEN("We test the cross product") { THEN("These results are expected") { REQUIRE(Nz::Vector3f::CrossProduct(Nz::Vector3f::UnitX(), Nz::Vector3f::UnitY()) == Nz::Vector3f::UnitZ()); REQUIRE(Nz::Vector3f::CrossProduct(Nz::Vector3f(1.f, 2.f, 3.f), Nz::Vector3f(3.f, 2.f, 1.f)) == Nz::Vector3f(-4.f, 8.f, -4.f)); } } WHEN("We ask for distance") { Nz::Vector3f tmp(-1.f, -5.f, -8.f); THEN("These are expected") { REQUIRE(firstUnit.Distance(tmp) == Approx(11.f)); REQUIRE(firstUnit.SquaredDistance(tmp) == Approx(121.f)); REQUIRE(firstUnit.GetSquaredLength() == Approx(3.f)); REQUIRE(firstUnit.GetLength() == Approx(std::sqrt(3.f))); } } WHEN("We nomalize the vectors") { float ratio = 0.f; THEN("For normal cases should be normal") { Nz::Vector3f normalized = firstUnit.GetNormal(&ratio); REQUIRE(normalized == (Nz::Vector3f::Unit() / std::sqrt(3.f))); REQUIRE(ratio == Approx(std::sqrt(3.f))); } THEN("For null vector") { Nz::Vector3f zero = Nz::Vector3f::Zero(); REQUIRE(zero.GetNormal(&ratio) == Nz::Vector3f::Zero()); REQUIRE(ratio == Approx(0.f)); } } WHEN("We try to maximize and minimize") { Nz::Vector3f maximize(2.f, 1.f, 2.f); Nz::Vector3f minimize(1.f, 2.f, 1.f); THEN("The minimised and maximised should be (1, 1, 1) and (2, 2, 2)") { Nz::Vector3f maximized = maximize; Nz::Vector3f minimized = minimize; REQUIRE(minimized.Minimize(maximized) == Nz::Vector3f::Unit()); REQUIRE(maximize.Maximize(minimize) == (2.f * Nz::Vector3f::Unit())); } } WHEN("We try to lerp") { THEN("Compilation should be fine") { Nz::Vector3f zero = Nz::Vector3f::Zero(); Nz::Vector3f unit = Nz::Vector3f::Unit(); REQUIRE(Nz::Vector3f::Lerp(zero, unit, 0.5f) == (Nz::Vector3f::Unit() * 0.5f)); } } } GIVEN("Two vectors") { Nz::Vector2f unit = Nz::Vector2f::Unit(); Nz::Vector3f smaller(-1.f, unit); Nz::Vector3f bigger(1.f, unit.x, unit.y); WHEN("We combine divisions and multiplications") { Nz::Vector3f result = smaller / bigger; result *= bigger; THEN("We should get the identity") { REQUIRE(result == smaller); } } } }
25.247934
131
0.615712
AntoineJT
faebaad8eafe5c76d4ec89f4e2a333db0c5c8cec
3,942
cpp
C++
icarus/tcpclient.cpp
Jusot/icarus
1b908b0d7ff03d6ee088c94730acfef36101ef32
[ "MIT" ]
4
2019-04-01T10:49:54.000Z
2020-12-24T11:46:45.000Z
icarus/tcpclient.cpp
Jusot/Icarus
1b908b0d7ff03d6ee088c94730acfef36101ef32
[ "MIT" ]
null
null
null
icarus/tcpclient.cpp
Jusot/Icarus
1b908b0d7ff03d6ee088c94730acfef36101ef32
[ "MIT" ]
1
2019-04-04T02:36:29.000Z
2019-04-04T02:36:29.000Z
#include <cassert> #include "connector.hpp" #include "tcpclient.hpp" #include "eventloop.hpp" #include "inetaddress.hpp" #include "socketsfunc.hpp" namespace icarus { TcpClient::TcpClient(EventLoop *loop, const InetAddress &server_addr, std::string name) : loop_(loop) , connector_(std::make_unique<Connector>(loop, server_addr)) , name_(std::move(name)) , connection_callback_(TcpConnection::default_connection_callback) , message_callback_(TcpConnection::default_message_callback) , retry_(false) , connect_(true) , next_conn_id_(1) { connector_->set_new_connection_callback([this] (int sockfd) { this->new_connection(sockfd); }); } TcpClient::~TcpClient() { TcpConnectionPtr conn; bool unique = false; { /** * in fact, if we are inside different thread * connection_ may be assigned after we assign conn */ std::lock_guard lock(mutex_); unique = connection_.unique(); conn = connection_; } if (conn) { assert(loop_ == conn->get_loop()); /** * reset close callback because old method cannot be used after destructor */ loop_->run_in_loop([loop = loop_, conn] { conn->set_close_callback([loop] (const TcpConnectionPtr &conn) { loop->queue_in_loop([conn] { conn->connect_destroyed(); }); }); }); if (unique) { /** * when conn is unique, the close_callback * cannot be called if we do not force close it */ conn->force_close(); } } else { connector_->stop(); } } void TcpClient::connect() { connect_ = true; connector_->start(); } void TcpClient::disconnect() { connect_ = false; { std::lock_guard lock(mutex_); if (connection_) { connection_->shutdown(); } } } /** * after some time, we can call stop directly */ void TcpClient::stop() { connect_ = false; connector_->stop(); } bool TcpClient::retry() const { return retry_; } void TcpClient::enable_retry() { retry_ = true; } const std::string &TcpClient::name() const { return name_; } void TcpClient::set_connection_callback(ConnectionCallback cb) { connection_callback_ = std::move(cb); } void TcpClient::set_message_callback(MessageCallback cb) { message_callback_ = std::move(cb); } void TcpClient::set_write_complete_callback(WriteCompleteCallback cb) { write_complete_callback_ = std::move(cb); } void TcpClient::new_connection(int sockfd) { loop_->assert_in_loop_thread(); InetAddress peer_addr(sockets::get_peer_addr(sockfd)); InetAddress local_addr(sockets::get_local_addr(sockfd)); char buf[32]; snprintf(buf, sizeof buf, ":%s#%d", peer_addr.to_ip_port().c_str(), next_conn_id_); ++next_conn_id_; std::string conn_name = name_ + buf; auto conn = std::make_shared<TcpConnection>( loop_, conn_name, sockfd, local_addr, peer_addr ); conn->set_connection_callback(connection_callback_); conn->set_message_callback(message_callback_); conn->set_write_complete_callback(write_complete_callback_); conn->set_close_callback([this] (const TcpConnectionPtr &conn) { this->remove_connection(conn); }); { std::lock_guard lock(mutex_); connection_ = conn; } conn->connect_established(); } void TcpClient::remove_connection(const TcpConnectionPtr &conn) { loop_->assert_in_loop_thread(); assert(loop_ == conn->get_loop()); { std::lock_guard lock(mutex_); assert(connection_ == conn); connection_.reset(); } loop_->queue_in_loop([conn] { conn->connect_destroyed(); }); if (retry_ && connect_) { connector_->restart(); } } } // namespace icarus
21.9
87
0.625317
Jusot
faee715662cf26f2db0ab242376cf4af16425a18
1,165
cpp
C++
tests/RomanToIntegerTest.cpp
yanzhe-chen/LeetCode
d82f0b9721ea613ab216c78e7286671d0e9e4187
[ "MIT" ]
43
2015-10-10T12:59:52.000Z
2018-07-11T18:07:00.000Z
tests/RomanToIntegerTest.cpp
yanzhe-chen/LeetCode
d82f0b9721ea613ab216c78e7286671d0e9e4187
[ "MIT" ]
null
null
null
tests/RomanToIntegerTest.cpp
yanzhe-chen/LeetCode
d82f0b9721ea613ab216c78e7286671d0e9e4187
[ "MIT" ]
11
2015-10-10T14:41:11.000Z
2018-07-28T06:03:16.000Z
#include "catch.hpp" #include "RomanToInteger.hpp" TEST_CASE("Roman To Integer") { RomanToInteger s; SECTION("Base tests") { REQUIRE(s.romanToInt("I") == 1); REQUIRE(s.romanToInt("II") == 2); REQUIRE(s.romanToInt("III") == 3); REQUIRE(s.romanToInt("XL") == 40); REQUIRE(s.romanToInt("L") == 50); REQUIRE(s.romanToInt("LX") == 60); REQUIRE(s.romanToInt("DCC") == 700); REQUIRE(s.romanToInt("DCCC") == 800); REQUIRE(s.romanToInt("CM") == 900); REQUIRE(s.romanToInt("M") == 1000); REQUIRE(s.romanToInt("MM") == 2000); REQUIRE(s.romanToInt("MMM") == 3000); } SECTION("Combination tests") { REQUIRE(s.romanToInt("LXI") == 61); REQUIRE(s.romanToInt("CMLXI") == 961); REQUIRE(s.romanToInt("MMCMLXI") == 2961); } SECTION("Zero tests") { REQUIRE(s.romanToInt("CCCXX") == 320); REQUIRE(s.romanToInt("DVII") == 507); REQUIRE(s.romanToInt("MVI") == 1006); REQUIRE(s.romanToInt("MMXXX") == 2030); REQUIRE(s.romanToInt("MMXXX") == 2030); REQUIRE(s.romanToInt("MMMD") == 3500); } }
33.285714
49
0.547639
yanzhe-chen
faefcee01eb2ab2ef48a0675776cb5f58042a766
1,720
hpp
C++
android-31/android/inputmethodservice/InputMethodService_InputMethodSessionImpl.hpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
12
2020-03-26T02:38:56.000Z
2022-03-14T08:17:26.000Z
android-28/android/inputmethodservice/InputMethodService_InputMethodSessionImpl.hpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
1
2021-01-27T06:07:45.000Z
2021-11-13T19:19:43.000Z
android-30/android/inputmethodservice/InputMethodService_InputMethodSessionImpl.hpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
3
2021-02-02T12:34:55.000Z
2022-03-08T07:45:57.000Z
#pragma once #include "./AbstractInputMethodService_AbstractInputMethodSessionImpl.hpp" class JArray; namespace android::graphics { class Rect; } namespace android::inputmethodservice { class InputMethodService; } namespace android::os { class Bundle; } namespace android::view::inputmethod { class CursorAnchorInfo; } namespace android::view::inputmethod { class ExtractedText; } class JString; namespace android::inputmethodservice { class InputMethodService_InputMethodSessionImpl : public android::inputmethodservice::AbstractInputMethodService_AbstractInputMethodSessionImpl { public: // Fields // QJniObject forward template<typename ...Ts> explicit InputMethodService_InputMethodSessionImpl(const char *className, const char *sig, Ts...agv) : android::inputmethodservice::AbstractInputMethodService_AbstractInputMethodSessionImpl(className, sig, std::forward<Ts>(agv)...) {} InputMethodService_InputMethodSessionImpl(QJniObject obj); // Constructors InputMethodService_InputMethodSessionImpl(android::inputmethodservice::InputMethodService arg0); // Methods void appPrivateCommand(JString arg0, android::os::Bundle arg1) const; void displayCompletions(JArray arg0) const; void finishInput() const; void toggleSoftInput(jint arg0, jint arg1) const; void updateCursor(android::graphics::Rect arg0) const; void updateCursorAnchorInfo(android::view::inputmethod::CursorAnchorInfo arg0) const; void updateExtractedText(jint arg0, android::view::inputmethod::ExtractedText arg1) const; void updateSelection(jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5) const; void viewClicked(jboolean arg0) const; }; } // namespace android::inputmethodservice
31.272727
261
0.797674
YJBeetle
faf0792514d28bfaa3975ccbb47597ba0a93f48e
4,542
cpp
C++
src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.cpp
luoxiao/audacity
afdcded32d50ff1fd4ed6f736ab1824d540ae4d2
[ "CC-BY-3.0" ]
1
2019-08-05T09:19:46.000Z
2019-08-05T09:19:46.000Z
src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.cpp
luoxiao/audacity
afdcded32d50ff1fd4ed6f736ab1824d540ae4d2
[ "CC-BY-3.0" ]
null
null
null
src/tracks/playabletrack/notetrack/ui/NoteTrackVZoomHandle.cpp
luoxiao/audacity
afdcded32d50ff1fd4ed6f736ab1824d540ae4d2
[ "CC-BY-3.0" ]
null
null
null
/********************************************************************** Audacity: A Digital Audio Editor NoteTrackVZoomHandle.cpp Paul Licameli split from TrackPanel.cpp **********************************************************************/ #include "../../../../Audacity.h" #include "NoteTrackVZoomHandle.h" #include "../../../../Experimental.h" #include "NoteTrackVRulerControls.h" #include "../../../../HitTestResult.h" #include "../../../../NoteTrack.h" #include "../../../../Project.h" #include "../../../../RefreshCode.h" #include "../../../../TrackPanelMouseEvent.h" #include "../../../../../images/Cursors.h" #include <wx/event.h> namespace { bool IsDragZooming(int zoomStart, int zoomEnd) { const int DragThreshold = 3;// Anything over 3 pixels is a drag, else a click. return (abs(zoomEnd - zoomStart) > DragThreshold); } } /////////////////////////////////////////////////////////////////////////////// NoteTrackVZoomHandle::NoteTrackVZoomHandle (const std::shared_ptr<NoteTrack> &pTrack, const wxRect &rect, int y) : mZoomStart(y), mZoomEnd(y), mRect(rect) , mpTrack{ pTrack } { } void NoteTrackVZoomHandle::Enter(bool) { #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING mChangeHighlight = RefreshCode::RefreshCell; #endif } HitTestPreview NoteTrackVZoomHandle::HitPreview(const wxMouseState &state) { static auto zoomInCursor = ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomInCursorXpm, 19, 15); static auto zoomOutCursor = ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomOutCursorXpm, 19, 15); const auto message = _("Click to verticaly zoom in, Shift-click to zoom out, Drag to create a particular zoom region."); return { message, (state.ShiftDown() ? &*zoomOutCursor : &*zoomInCursor) // , message }; } UIHandlePtr NoteTrackVZoomHandle::HitTest (std::weak_ptr<NoteTrackVZoomHandle> &holder, const wxMouseState &state, const std::shared_ptr<NoteTrack> &pTrack, const wxRect &rect) { if (pTrack) { auto result = std::make_shared<NoteTrackVZoomHandle>( pTrack, rect, state.m_y); result = AssignUIHandlePtr(holder, result); return result; } return {}; } NoteTrackVZoomHandle::~NoteTrackVZoomHandle() { } UIHandle::Result NoteTrackVZoomHandle::Click (const TrackPanelMouseEvent &, AudacityProject *) { // change note track to zoom like audio track // mpTrack->StartVScroll(); return RefreshCode::RefreshNone; } UIHandle::Result NoteTrackVZoomHandle::Drag (const TrackPanelMouseEvent &evt, AudacityProject *pProject) { using namespace RefreshCode; auto pTrack = pProject->GetTracks()->Lock(mpTrack); if (!pTrack) return Cancelled; const wxMouseEvent &event = evt.event; mZoomEnd = event.m_y; if (IsDragZooming(mZoomStart, mZoomEnd)) { // changed Note track to work like audio track // pTrack->VScroll(mZoomStart, mZoomEnd); return RefreshAll; } return RefreshNone; } HitTestPreview NoteTrackVZoomHandle::Preview (const TrackPanelMouseState &st, const AudacityProject *) { return HitPreview(st.state); } UIHandle::Result NoteTrackVZoomHandle::Release (const TrackPanelMouseEvent &evt, AudacityProject *pProject, wxWindow *pParent) { using namespace RefreshCode; auto pTrack = pProject->GetTracks()->Lock(mpTrack); if (!pTrack) return RefreshNone; const wxMouseEvent &event = evt.event; if (IsDragZooming(mZoomStart, mZoomEnd)) { pTrack->ZoomTo(evt.rect, mZoomStart, mZoomEnd); } else if (event.ShiftDown() || event.RightUp()) { if (event.ShiftDown() && event.RightUp()) { // Zoom out completely pTrack->SetBottomNote(0); pTrack->SetPitchHeight(evt.rect.height, 1); } else { // Zoom out pTrack->ZoomOut(evt.rect, mZoomEnd); } } else { pTrack->ZoomIn(evt.rect, mZoomEnd); } mZoomEnd = mZoomStart = 0; pProject->ModifyState(true); return RefreshAll; } UIHandle::Result NoteTrackVZoomHandle::Cancel(AudacityProject *pProject) { // Cancel is implemented! And there is no initial state to restore, // so just return a code. return RefreshCode::RefreshAll; } void NoteTrackVZoomHandle::DrawExtras (DrawingPass pass, wxDC * dc, const wxRegion &, const wxRect &panelRect) { if (!mpTrack.lock()) //? TrackList::Lock() return; if ( pass == UIHandle::Cells && IsDragZooming( mZoomStart, mZoomEnd ) ) TrackVRulerControls::DrawZooming ( dc, mRect, panelRect, mZoomStart, mZoomEnd ); }
26.87574
99
0.649053
luoxiao
faf4f5193a1d42e7a3cb5250faf0843d2d05d2f1
6,736
cc
C++
examples/Cassie/osc_jump/convert_traj_for_sim.cc
hanliumaozhi/dairlib
a74ae5b24efe708b6723e778bea6f4bb038e2951
[ "BSD-3-Clause" ]
1
2021-04-20T11:29:23.000Z
2021-04-20T11:29:23.000Z
examples/Cassie/osc_jump/convert_traj_for_sim.cc
hanliumaozhi/dairlib
a74ae5b24efe708b6723e778bea6f4bb038e2951
[ "BSD-3-Clause" ]
null
null
null
examples/Cassie/osc_jump/convert_traj_for_sim.cc
hanliumaozhi/dairlib
a74ae5b24efe708b6723e778bea6f4bb038e2951
[ "BSD-3-Clause" ]
null
null
null
#include <drake/geometry/scene_graph.h> #include <drake/multibody/parsing/parser.h> #include <gflags/gflags.h> #include "examples/Cassie/cassie_utils.h" #include "multibody/multibody_utils.h" #include "lcm/lcm_trajectory.h" #include "drake/multibody/plant/multibody_plant.h" using drake::geometry::SceneGraph; using drake::multibody::JacobianWrtVariable; using drake::multibody::MultibodyPlant; using drake::multibody::Parser; using drake::systems::Context; using Eigen::Matrix3Xd; using Eigen::MatrixXd; using Eigen::Vector3d; using Eigen::VectorXd; using std::string; DEFINE_string(trajectory_name, "", "File name where the optimal trajectory is stored."); DEFINE_string(folder_path, "/home/yangwill/Documents/research/projects/cassie" "/jumping/saved_trajs/", "Folder path for where the trajectory names are stored"); namespace dairlib { /// This program converts the trajectory computed using the fixed spring /// cassie model to the cassie model with springs. This is necessary to /// initialize the simulator at a particular state along the trajectory int DoMain() { // Drake system initialization stuff drake::systems::DiagramBuilder<double> builder; SceneGraph<double>& scene_graph = *builder.AddSystem<SceneGraph>(); scene_graph.set_name("scene_graph"); MultibodyPlant<double> plant_wo_spr( 1e-5); // non-zero timestep to avoid continuous MultibodyPlant<double> plant_w_spr(1e-5); // non-zero timestep to avoid Parser parser_wo_spr(&plant_wo_spr, &scene_graph); Parser parser_w_spr(&plant_w_spr, &scene_graph); parser_wo_spr.AddModelFromFile( FindResourceOrThrow("examples/Cassie/urdf/cassie_fixed_springs.urdf")); parser_w_spr.AddModelFromFile( FindResourceOrThrow("examples/Cassie/urdf/cassie_v2.urdf")); plant_wo_spr.mutable_gravity_field().set_gravity_vector( -9.81 * Eigen::Vector3d::UnitZ()); plant_w_spr.mutable_gravity_field().set_gravity_vector( -9.81 * Eigen::Vector3d::UnitZ()); plant_wo_spr.Finalize(); plant_w_spr.Finalize(); int nq_wo_spr = plant_wo_spr.num_positions(); int nv_wo_spr = plant_wo_spr.num_velocities(); int nq_w_spr = plant_w_spr.num_positions(); int nv_w_spr = plant_w_spr.num_velocities(); int nx_wo_spr = nq_wo_spr + nv_wo_spr; int nx_w_spr = nq_w_spr + nv_w_spr; int nu = plant_w_spr.num_actuators(); const std::map<string, int>& pos_map_w_spr = multibody::makeNameToPositionsMap(plant_w_spr); const std::map<string, int>& vel_map_w_spr = multibody::makeNameToVelocitiesMap(plant_w_spr); const std::map<string, int>& pos_map_wo_spr = multibody::makeNameToPositionsMap(plant_wo_spr); const std::map<string, int>& vel_map_wo_spr = multibody::makeNameToVelocitiesMap(plant_wo_spr); // Initialize the mapping from states for the plant without springs to the // plant with springs. Note: this is a tall matrix MatrixXd map_position_from_no_spring_to_spring = MatrixXd::Zero(nq_w_spr, nq_wo_spr); MatrixXd map_velocity_from_no_spring_to_spring = MatrixXd::Zero(nv_w_spr, nv_wo_spr); MatrixXd map_state_from_no_spring_to_spring = MatrixXd::Zero(nx_w_spr, nx_wo_spr); for (const auto& pos_pair_wo_spr : pos_map_wo_spr) { bool successfully_added = false; for (const auto& pos_pair_w_spr : pos_map_w_spr) { if (pos_pair_wo_spr.first == pos_pair_w_spr.first) { map_position_from_no_spring_to_spring(pos_pair_w_spr.second, pos_pair_wo_spr.second) = 1; successfully_added = true; } } DRAKE_DEMAND(successfully_added); } for (const auto& vel_pair_wo_spr : vel_map_wo_spr) { bool successfully_added = false; for (const auto& vel_pair_w_spr : vel_map_w_spr) { if (vel_pair_wo_spr.first == vel_pair_w_spr.first) { map_velocity_from_no_spring_to_spring(vel_pair_w_spr.second, vel_pair_wo_spr.second) = 1; successfully_added = true; } } DRAKE_DEMAND(successfully_added); } map_state_from_no_spring_to_spring.block(0, 0, nq_w_spr, nq_wo_spr) = map_position_from_no_spring_to_spring; map_state_from_no_spring_to_spring.block(nq_w_spr, nq_wo_spr, nv_w_spr, nv_wo_spr) = map_velocity_from_no_spring_to_spring; const LcmTrajectory& loadedTrajs = LcmTrajectory(FLAGS_folder_path + FLAGS_trajectory_name); auto traj_mode0 = loadedTrajs.getTrajectory("cassie_jumping_trajectory_x_u0"); auto traj_mode1 = loadedTrajs.getTrajectory("cassie_jumping_trajectory_x_u1"); auto traj_mode2 = loadedTrajs.getTrajectory("cassie_jumping_trajectory_x_u2"); int n_points = traj_mode0.datapoints.cols() + traj_mode1.datapoints.cols() + traj_mode2.datapoints.cols(); MatrixXd xu(2*nx_wo_spr + nu, n_points); VectorXd times(n_points); xu << traj_mode0.datapoints, traj_mode1.datapoints, traj_mode2.datapoints; times << traj_mode0.time_vector, traj_mode1.time_vector, traj_mode2.time_vector; MatrixXd x_w_spr(2*nx_w_spr, n_points); x_w_spr.topRows(nx_w_spr) = map_state_from_no_spring_to_spring * xu.topRows(nx_wo_spr); x_w_spr.bottomRows(nx_w_spr) = map_state_from_no_spring_to_spring * xu.topRows(2*nx_wo_spr).bottomRows (nx_wo_spr); auto state_traj_w_spr = LcmTrajectory::Trajectory(); state_traj_w_spr.traj_name = "cassie_jumping_trajectory_x"; state_traj_w_spr.datapoints = x_w_spr; state_traj_w_spr.time_vector = times; const std::vector<string> state_names = multibody::createStateNameVectorFromMap( plant_w_spr); const std::vector<string> state_dot_names = multibody::createStateNameVectorFromMap( plant_w_spr); state_traj_w_spr.datatypes.reserve(2 * nx_w_spr); state_traj_w_spr.datatypes.insert(state_traj_w_spr.datatypes.end(), state_names.begin(), state_names.end()); state_traj_w_spr.datatypes.insert(state_traj_w_spr.datatypes.end(), state_dot_names.begin(), state_dot_names.end()); std::vector<LcmTrajectory::Trajectory> trajectories = {state_traj_w_spr}; std::vector<std::string> trajectory_names = {state_traj_w_spr.traj_name}; auto processed_traj = LcmTrajectory(trajectories, trajectory_names, "jumping_trajectory", "State trajectory for cassie jumping adjusted to include " "states of the plant with springs"); processed_traj.writeToFile(FLAGS_folder_path + FLAGS_trajectory_name + "_for_sim"); return 0; } } // namespace dairlib int main(int argc, char* argv[]) { gflags::ParseCommandLineFlags(&argc, &argv, true); dairlib::DoMain(); }
39.857988
80
0.729513
hanliumaozhi
faf515fa1845530f9b2d92b143d9a9b03bfa1a17
13,329
cpp
C++
winston/external/asio/src/tests/unit/compose.cpp
danie1kr/winston
18fe865dc59e8315cb1d85c6fa60c4ddeaf83202
[ "MIT" ]
172
2018-10-31T13:47:10.000Z
2022-02-21T12:08:20.000Z
winston/external/asio/src/tests/unit/compose.cpp
danie1kr/winston
18fe865dc59e8315cb1d85c6fa60c4ddeaf83202
[ "MIT" ]
51
2018-11-01T12:46:25.000Z
2021-12-14T15:16:15.000Z
winston/external/asio/src/tests/unit/compose.cpp
danie1kr/winston
18fe865dc59e8315cb1d85c6fa60c4ddeaf83202
[ "MIT" ]
72
2018-10-31T13:50:02.000Z
2022-03-14T09:10:35.000Z
// // compose.cpp // ~~~~~~~~~~~ // // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) // // Disable autolinking for unit tests. #if !defined(BOOST_ALL_NO_LIB) #define BOOST_ALL_NO_LIB 1 #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. #include "asio/compose.hpp" #include "unit_test.hpp" #include "asio/bind_cancellation_slot.hpp" #include "asio/cancellation_signal.hpp" #include "asio/io_context.hpp" #include "asio/post.hpp" #include "asio/system_timer.hpp" #if defined(ASIO_HAS_BOOST_BIND) # include <boost/bind/bind.hpp> #else // defined(ASIO_HAS_BOOST_BIND) # include <functional> #endif // defined(ASIO_HAS_BOOST_BIND) //------------------------------------------------------------------------------ class impl_0_completion_args { public: explicit impl_0_completion_args(asio::io_context& ioc) : ioc_(ioc), state_(starting) { } template <typename Self> void operator()(Self& self) { switch (state_) { case starting: state_ = posting; asio::post(ioc_, ASIO_MOVE_CAST(Self)(self)); break; case posting: self.complete(); break; default: break; } } private: asio::io_context& ioc_; enum { starting, posting } state_; }; template <typename CompletionToken> ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) async_0_completion_args(asio::io_context& ioc, ASIO_MOVE_ARG(CompletionToken) token) { return asio::async_compose<CompletionToken, void()>( impl_0_completion_args(ioc), token); } void compose_0_args_handler(int* count) { ++(*count); } struct compose_0_args_lvalue_handler { int* count_; void operator()() { ++(*count_); } }; void compose_0_completion_args_test() { #if defined(ASIO_HAS_BOOST_BIND) namespace bindns = boost; #else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; #endif // defined(ASIO_HAS_BOOST_BIND) asio::io_context ioc; int count = 0; async_0_completion_args(ioc, bindns::bind(&compose_0_args_handler, &count)); // No handlers can be called until run() is called. ASIO_CHECK(!ioc.stopped()); ASIO_CHECK(count == 0); ioc.run(); // The run() call will not return until all work has finished. ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ioc.restart(); count = 0; compose_0_args_lvalue_handler lvalue_handler = { &count }; async_0_completion_args(ioc, lvalue_handler); // No handlers can be called until run() is called. ASIO_CHECK(!ioc.stopped()); ASIO_CHECK(count == 0); ioc.run(); // The run() call will not return until all work has finished. ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); } //------------------------------------------------------------------------------ class impl_1_completion_arg { public: explicit impl_1_completion_arg(asio::io_context& ioc) : ioc_(ioc), state_(starting) { } template <typename Self> void operator()(Self& self) { switch (state_) { case starting: state_ = posting; asio::post(ioc_, ASIO_MOVE_CAST(Self)(self)); break; case posting: self.complete(42); break; default: break; } } private: asio::io_context& ioc_; enum { starting, posting } state_; }; template <typename CompletionToken> ASIO_INITFN_RESULT_TYPE(CompletionToken, void(int)) async_1_completion_arg(asio::io_context& ioc, ASIO_MOVE_ARG(CompletionToken) token) { return asio::async_compose<CompletionToken, void(int)>( impl_1_completion_arg(ioc), token); } void compose_1_arg_handler(int* count, int* result_out, int result) { ++(*count); *result_out = result; } struct compose_1_arg_lvalue_handler { int* count_; int* result_out_; void operator()(int result) { ++(*count_); *result_out_ = result; } }; void compose_1_completion_arg_test() { #if defined(ASIO_HAS_BOOST_BIND) namespace bindns = boost; #else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; #endif // defined(ASIO_HAS_BOOST_BIND) using bindns::placeholders::_1; asio::io_context ioc; int count = 0; int result = 0; async_1_completion_arg(ioc, bindns::bind(&compose_1_arg_handler, &count, &result, _1)); // No handlers can be called until run() is called. ASIO_CHECK(!ioc.stopped()); ASIO_CHECK(count == 0); ASIO_CHECK(result == 0); ioc.run(); // The run() call will not return until all work has finished. ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == 42); ioc.restart(); count = 0; result = 0; compose_1_arg_lvalue_handler lvalue_handler = { &count, &result }; async_1_completion_arg(ioc, lvalue_handler); // No handlers can be called until run() is called. ASIO_CHECK(!ioc.stopped()); ASIO_CHECK(count == 0); ASIO_CHECK(result == 0); ioc.run(); // The run() call will not return until all work has finished. ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == 42); } //------------------------------------------------------------------------------ typedef asio::enable_terminal_cancellation default_filter; template <typename CancellationFilter> class impl_cancellable { public: explicit impl_cancellable(CancellationFilter cancellation_filter, asio::system_timer& timer) : cancellation_filter_(cancellation_filter), timer_(timer), state_(starting) { } template <typename Self> void operator()(Self& self, const asio::error_code& ec = asio::error_code()) { switch (state_) { case starting: if (!asio::is_same<CancellationFilter, default_filter>::value) self.reset_cancellation_state(cancellation_filter_); state_ = waiting; timer_.expires_after(asio::chrono::milliseconds(100)); timer_.async_wait(ASIO_MOVE_CAST(Self)(self)); break; case waiting: self.complete(!ec); break; default: break; } } private: CancellationFilter cancellation_filter_; asio::system_timer& timer_; enum { starting, waiting } state_; }; template <typename CancellationFilter, typename CompletionToken> ASIO_INITFN_RESULT_TYPE(CompletionToken, void(bool)) async_cancellable(CancellationFilter cancellation_filter, asio::system_timer& timer, ASIO_MOVE_ARG(CompletionToken) token) { return asio::async_compose<CompletionToken, void(bool)>( impl_cancellable<CancellationFilter>(cancellation_filter, timer), token); } void compose_partial_cancellation_handler( int* count, bool* result_out, bool result) { ++(*count); *result_out = result; } void compose_default_cancellation_test() { #if defined(ASIO_HAS_BOOST_BIND) namespace bindns = boost; #else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; #endif // defined(ASIO_HAS_BOOST_BIND) using bindns::placeholders::_1; asio::io_context ioc; asio::system_timer timer(ioc); asio::cancellation_signal signal; int count = 0; bool result = false; async_cancellable(default_filter(), timer, bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1)); ioc.run(); // No cancellation, operation completes successfully. ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == true); ioc.restart(); count = 0; result = 0; async_cancellable(default_filter(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Total cancellation unsupported. Operation completes successfully. signal.emit(asio::cancellation_type::total); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == true); ioc.restart(); count = 0; result = 0; async_cancellable(default_filter(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Partial cancellation unsupported. Operation completes successfully. signal.emit(asio::cancellation_type::partial); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == true); ioc.restart(); count = 0; result = 0; async_cancellable(default_filter(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Terminal cancellation works. Operation completes with failure. signal.emit(asio::cancellation_type::terminal); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == false); } void compose_partial_cancellation_test() { #if defined(ASIO_HAS_BOOST_BIND) namespace bindns = boost; #else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; #endif // defined(ASIO_HAS_BOOST_BIND) using bindns::placeholders::_1; asio::io_context ioc; asio::system_timer timer(ioc); asio::cancellation_signal signal; int count = 0; bool result = false; async_cancellable(asio::enable_partial_cancellation(), timer, bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1)); ioc.run(); // No cancellation, operation completes successfully. ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == true); ioc.restart(); count = 0; result = 0; async_cancellable(asio::enable_partial_cancellation(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Total cancellation unsupported. Operation completes successfully. signal.emit(asio::cancellation_type::total); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == true); ioc.restart(); count = 0; result = 0; async_cancellable(asio::enable_partial_cancellation(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Partial cancellation works. Operation completes with failure. signal.emit(asio::cancellation_type::partial); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == false); ioc.restart(); count = 0; result = 0; async_cancellable(asio::enable_partial_cancellation(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Terminal cancellation works. Operation completes with failure. signal.emit(asio::cancellation_type::terminal); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == false); } void compose_total_cancellation_test() { #if defined(ASIO_HAS_BOOST_BIND) namespace bindns = boost; #else // defined(ASIO_HAS_BOOST_BIND) namespace bindns = std; #endif // defined(ASIO_HAS_BOOST_BIND) using bindns::placeholders::_1; asio::io_context ioc; asio::system_timer timer(ioc); asio::cancellation_signal signal; int count = 0; bool result = false; async_cancellable(asio::enable_total_cancellation(), timer, bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1)); ioc.run(); // No cancellation, operation completes successfully. ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == true); ioc.restart(); count = 0; result = 0; async_cancellable(asio::enable_total_cancellation(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Total cancellation works. Operation completes with failure. signal.emit(asio::cancellation_type::total); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == false); ioc.restart(); count = 0; result = 0; async_cancellable(asio::enable_total_cancellation(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Partial cancellation works. Operation completes with failure. signal.emit(asio::cancellation_type::partial); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == false); ioc.restart(); count = 0; result = 0; async_cancellable(asio::enable_total_cancellation(), timer, asio::bind_cancellation_slot(signal.slot(), bindns::bind(&compose_partial_cancellation_handler, &count, &result, _1))); // Terminal cancellation works. Operation completes with failure. signal.emit(asio::cancellation_type::terminal); ioc.run(); ASIO_CHECK(ioc.stopped()); ASIO_CHECK(count == 1); ASIO_CHECK(result == false); } //------------------------------------------------------------------------------ ASIO_TEST_SUITE ( "compose", ASIO_TEST_CASE(compose_0_completion_args_test) ASIO_TEST_CASE(compose_1_completion_arg_test) ASIO_TEST_CASE(compose_default_cancellation_test) ASIO_TEST_CASE(compose_partial_cancellation_test) ASIO_TEST_CASE(compose_total_cancellation_test) )
24.016216
80
0.686548
danie1kr
faf5803b8c46550304e8e61d5d2c95dc41dcddb0
9,032
cpp
C++
tools/pe_bliss/pe_rebuilder.cpp
shackra/godot
685384f4eb0a29f3415d44e4d284e368e2688673
[ "CC-BY-3.0", "MIT" ]
1
2020-06-13T05:57:51.000Z
2020-06-13T05:57:51.000Z
tools/pe_bliss/pe_rebuilder.cpp
shackra/godot
685384f4eb0a29f3415d44e4d284e368e2688673
[ "CC-BY-3.0", "MIT" ]
null
null
null
tools/pe_bliss/pe_rebuilder.cpp
shackra/godot
685384f4eb0a29f3415d44e4d284e368e2688673
[ "CC-BY-3.0", "MIT" ]
1
2021-07-05T13:40:51.000Z
2021-07-05T13:40:51.000Z
/*************************************************************************/ /* Copyright (c) 2015 dx, http://kaimi.ru */ /* */ /* Permission is hereby granted, free of charge, to any person */ /* obtaining a copy of this software and associated documentation */ /* files (the "Software"), to deal in the Software without */ /* restriction, including without limitation the rights to use, */ /* copy, modify, merge, publish, distribute, sublicense, and/or */ /* sell copies of the Software, and to permit persons to whom the */ /* Software is furnished to do so, subject to the following conditions: */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "pe_rebuilder.h" #include "pe_base.h" #include "pe_structures.h" #include "pe_exception.h" namespace pe_bliss { using namespace pe_win; //Rebuilds PE image headers //If strip_dos_header is true, DOS headers partially will be used for PE headers //If change_size_of_headers == true, SizeOfHeaders will be recalculated automatically //If save_bound_import == true, existing bound import directory will be saved correctly (because some compilers and bind.exe put it to PE headers) void rebuild_pe(pe_base& pe, image_dos_header& dos_header, bool strip_dos_header, bool change_size_of_headers, bool save_bound_import) { dos_header = pe.get_dos_header(); if(strip_dos_header) { //Strip stub overlay pe.strip_stub_overlay(); //BaseOfCode NT Headers field now overlaps //e_lfanew field, so we're acrually setting //e_lfanew with this call pe.set_base_of_code(8 * sizeof(uint16_t)); } else { //Set start of PE headers dos_header.e_lfanew = sizeof(image_dos_header) + pe_utils::align_up(static_cast<uint32_t>(pe.get_stub_overlay().size()), sizeof(uint32_t)); } section_list& sections = pe.get_image_sections(); //Calculate pointer to section data size_t ptr_to_section_data = (strip_dos_header ? 8 * sizeof(uint16_t) : sizeof(image_dos_header)) + pe.get_sizeof_nt_header() + pe_utils::align_up(pe.get_stub_overlay().size(), sizeof(uint32_t)) - sizeof(image_data_directory) * (image_numberof_directory_entries - pe.get_number_of_rvas_and_sizes()) + sections.size() * sizeof(image_section_header); if(save_bound_import && pe.has_bound_import()) { //It will be aligned to DWORD, because we're aligning to DWORD everything above it pe.set_directory_rva(image_directory_entry_bound_import, static_cast<uint32_t>(ptr_to_section_data)); ptr_to_section_data += pe.get_directory_size(image_directory_entry_bound_import); } ptr_to_section_data = pe_utils::align_up(ptr_to_section_data, pe.get_file_alignment()); //Set size of headers and size of optional header if(change_size_of_headers) { if(!pe.get_image_sections().empty()) { if(static_cast<uint32_t>(ptr_to_section_data) > (*sections.begin()).get_virtual_address()) throw pe_exception("Headers of PE file are too long. Try to strip STUB or don't build bound import", pe_exception::cannot_rebuild_image); } pe.set_size_of_headers(static_cast<uint32_t>(ptr_to_section_data)); } //Set number of sections in PE header pe.update_number_of_sections(); pe.update_image_size(); pe.set_size_of_optional_header(static_cast<uint16_t>(pe.get_sizeof_opt_headers() - sizeof(image_data_directory) * (image_numberof_directory_entries - pe.get_number_of_rvas_and_sizes()))); //Recalculate pointer to raw data according to section list for(section_list::iterator it = sections.begin(); it != sections.end(); ++it) { //Save section headers PointerToRawData (*it).set_pointer_to_raw_data(static_cast<uint32_t>(ptr_to_section_data)); ptr_to_section_data += (*it).get_aligned_raw_size(pe.get_file_alignment()); } } //Rebuild PE image and write it to "out" ostream //If strip_dos_header is true, DOS headers partially will be used for PE headers //If change_size_of_headers == true, SizeOfHeaders will be recalculated automatically //If save_bound_import == true, existing bound import directory will be saved correctly (because some compilers and bind.exe put it to PE headers) void rebuild_pe(pe_base& pe, std::ostream& out, bool strip_dos_header, bool change_size_of_headers, bool save_bound_import) { if(out.bad()) throw pe_exception("Stream is bad", pe_exception::stream_is_bad); if(save_bound_import && pe.has_bound_import()) { if(pe.section_data_length_from_rva(pe.get_directory_rva(image_directory_entry_bound_import), pe.get_directory_rva(image_directory_entry_bound_import), section_data_raw, true) < pe.get_directory_size(image_directory_entry_bound_import)) throw pe_exception("Incorrect bound import directory", pe_exception::incorrect_bound_import_directory); } //Change ostream state out.exceptions(std::ios::goodbit); out.clear(); uint32_t original_bound_import_rva = pe.has_bound_import() ? pe.get_directory_rva(image_directory_entry_bound_import) : 0; if(original_bound_import_rva && original_bound_import_rva > pe.get_size_of_headers()) { //No need to do anything with bound import directory //if it is placed inside of any section, not headers original_bound_import_rva = 0; save_bound_import = false; } { image_dos_header dos_header; //Rebuild PE image headers rebuild_pe(pe, dos_header, strip_dos_header, change_size_of_headers, save_bound_import); //Write DOS header out.write(reinterpret_cast<const char*>(&dos_header), strip_dos_header ? 8 * sizeof(uint16_t) : sizeof(image_dos_header)); } //If we have stub overlay, write it too { const std::string& stub = pe.get_stub_overlay(); if(stub.size()) { out.write(stub.data(), stub.size()); size_t aligned_size = pe_utils::align_up(stub.size(), sizeof(uint32_t)); //Align PE header, which is right after rich overlay while(aligned_size > stub.size()) { out.put('\0'); --aligned_size; } } } //Write NT headers out.write(static_cast<const pe_base&>(pe).get_nt_headers_ptr(), pe.get_sizeof_nt_header() - sizeof(image_data_directory) * (image_numberof_directory_entries - pe.get_number_of_rvas_and_sizes())); //Write section headers const section_list& sections = pe.get_image_sections(); for(section_list::const_iterator it = sections.begin(); it != sections.end(); ++it) { if(it == sections.end() - 1) //If last section encountered { image_section_header header((*it).get_raw_header()); header.SizeOfRawData = static_cast<uint32_t>((*it).get_raw_data().length()); //Set non-aligned actual data length for it out.write(reinterpret_cast<const char*>(&header), sizeof(image_section_header)); } else { out.write(reinterpret_cast<const char*>(&(*it).get_raw_header()), sizeof(image_section_header)); } } //Write bound import data if requested if(save_bound_import && pe.has_bound_import()) { out.write(pe.section_data_from_rva(original_bound_import_rva, section_data_raw, true), pe.get_directory_size(image_directory_entry_bound_import)); } //Write section data finally for(section_list::const_iterator it = sections.begin(); it != sections.end(); ++it) { const section& s = *it; std::streamoff wpos = out.tellp(); //Fill unused overlay data between sections with null bytes for(unsigned int i = 0; i < s.get_pointer_to_raw_data() - wpos; i++) out.put(0); //Write raw section data out.write(s.get_raw_data().data(), s.get_raw_data().length()); } } //Rebuild PE image and write it to "out" file //If strip_dos_header is true, DOS headers partially will be used for PE headers //If change_size_of_headers == true, SizeOfHeaders will be recalculated automatically //If save_bound_import == true, existing bound import directory will be saved correctly (because some compilers and bind.exe put it to PE headers) void rebuild_pe(pe_base& pe, const char* out, bool strip_dos_header, bool change_size_of_headers, bool save_bound_import) { std::ofstream pe_file(out, std::ios::out | std::ios::binary | std::ios::trunc); if(!pe_file) { throw pe_exception("Error in open file.", pe_exception::stream_is_bad); } rebuild_pe(pe, pe_file, strip_dos_header, change_size_of_headers, save_bound_import); } }
42.009302
176
0.721435
shackra
faf64ee32f5532d4eb6884b56363b40dba6e19e8
6,033
cpp
C++
libc/utils/benchmarks/LibcBenchmarkTest.cpp
medismailben/llvm-project
e334a839032fe500c3bba22bf976ab7af13ce1c1
[ "Apache-2.0" ]
34
2020-01-31T17:50:00.000Z
2022-02-16T20:19:29.000Z
libc/utils/benchmarks/LibcBenchmarkTest.cpp
medismailben/llvm-project
e334a839032fe500c3bba22bf976ab7af13ce1c1
[ "Apache-2.0" ]
14
2020-02-03T23:39:51.000Z
2021-07-20T16:24:25.000Z
libc/utils/benchmarks/LibcBenchmarkTest.cpp
medismailben/llvm-project
e334a839032fe500c3bba22bf976ab7af13ce1c1
[ "Apache-2.0" ]
6
2021-02-08T16:57:07.000Z
2022-01-13T11:32:34.000Z
#include "LibcBenchmark.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include <chrono> #include <limits> #include <queue> #include <vector> using std::chrono::nanoseconds; using ::testing::ElementsAre; using ::testing::Field; using ::testing::IsEmpty; using ::testing::SizeIs; namespace llvm { namespace libc_benchmarks { namespace { // A simple parameter provider returning a zero initialized vector of size // `iterations`. struct DummyParameterProvider { std::vector<char> generateBatch(size_t iterations) { return std::vector<char>(iterations); } }; class LibcBenchmark : public ::testing::Test { public: // A Clock interface suitable for testing. // - Either it returns 0, // - Or a timepoint coming from the `setMeasurements` call. Duration now() { if (!MaybeTimepoints) return {}; assert(!MaybeTimepoints->empty()); const Duration timepoint = MaybeTimepoints->front(); MaybeTimepoints->pop(); return timepoint; } protected: void SetUp() override { Options.Log = BenchmarkLog::Full; } void TearDown() override { // We make sure all the expected measurements were performed. if (MaybeTimepoints) EXPECT_THAT(*MaybeTimepoints, IsEmpty()); } BenchmarkResult run() { return benchmark(Options, ParameterProvider, DummyFunction, *this); } void setMeasurements(llvm::ArrayRef<Duration> Durations) { MaybeTimepoints.emplace(); // Create the optional value. Duration CurrentTime = nanoseconds(1); for (const auto &Duration : Durations) { MaybeTimepoints->push(CurrentTime); CurrentTime += Duration; MaybeTimepoints->push(CurrentTime); CurrentTime += nanoseconds(1); } } BenchmarkOptions Options; private: DummyParameterProvider ParameterProvider; static char DummyFunction(char Payload) { return Payload; } llvm::Optional<std::queue<Duration>> MaybeTimepoints; }; TEST_F(LibcBenchmark, MaxSamplesReached) { Options.MaxSamples = 1; const auto Result = run(); EXPECT_THAT(Result.MaybeBenchmarkLog->size(), 1); EXPECT_THAT(Result.TerminationStatus, BenchmarkStatus::MaxSamplesReached); } TEST_F(LibcBenchmark, MaxDurationReached) { Options.MaxDuration = nanoseconds(10); setMeasurements({nanoseconds(11)}); const auto Result = run(); EXPECT_THAT(Result.MaybeBenchmarkLog->size(), 1); EXPECT_THAT(Result.TerminationStatus, BenchmarkStatus::MaxDurationReached); } TEST_F(LibcBenchmark, MaxIterationsReached) { Options.InitialIterations = 1; Options.MaxIterations = 20; Options.ScalingFactor = 2; Options.Epsilon = 0; // unreachable. const auto Result = run(); EXPECT_THAT(*Result.MaybeBenchmarkLog, ElementsAre(Field(&BenchmarkState::LastSampleIterations, 1), Field(&BenchmarkState::LastSampleIterations, 2), Field(&BenchmarkState::LastSampleIterations, 4), Field(&BenchmarkState::LastSampleIterations, 8), Field(&BenchmarkState::LastSampleIterations, 16), Field(&BenchmarkState::LastSampleIterations, 32))); EXPECT_THAT(Result.MaybeBenchmarkLog->size(), 6); EXPECT_THAT(Result.TerminationStatus, BenchmarkStatus::MaxIterationsReached); } TEST_F(LibcBenchmark, MinSamples) { Options.MinSamples = 4; Options.ScalingFactor = 2; Options.Epsilon = std::numeric_limits<double>::max(); // always reachable. setMeasurements( {nanoseconds(1), nanoseconds(2), nanoseconds(4), nanoseconds(8)}); const auto Result = run(); EXPECT_THAT(*Result.MaybeBenchmarkLog, ElementsAre(Field(&BenchmarkState::LastSampleIterations, 1), Field(&BenchmarkState::LastSampleIterations, 2), Field(&BenchmarkState::LastSampleIterations, 4), Field(&BenchmarkState::LastSampleIterations, 8))); EXPECT_THAT(Result.MaybeBenchmarkLog->size(), 4); EXPECT_THAT(Result.TerminationStatus, BenchmarkStatus::PrecisionReached); } TEST_F(LibcBenchmark, Epsilon) { Options.MinSamples = 4; Options.ScalingFactor = 2; Options.Epsilon = std::numeric_limits<double>::max(); // always reachable. setMeasurements( {nanoseconds(1), nanoseconds(2), nanoseconds(4), nanoseconds(8)}); const auto Result = run(); EXPECT_THAT(*Result.MaybeBenchmarkLog, ElementsAre(Field(&BenchmarkState::LastSampleIterations, 1), Field(&BenchmarkState::LastSampleIterations, 2), Field(&BenchmarkState::LastSampleIterations, 4), Field(&BenchmarkState::LastSampleIterations, 8))); EXPECT_THAT(Result.MaybeBenchmarkLog->size(), 4); EXPECT_THAT(Result.TerminationStatus, BenchmarkStatus::PrecisionReached); } TEST(ArrayRefLoop, Cycle) { std::array<int, 2> array = {1, 2}; EXPECT_THAT(cycle(array, 0), ElementsAre()); EXPECT_THAT(cycle(array, 1), ElementsAre(1)); EXPECT_THAT(cycle(array, 2), ElementsAre(1, 2)); EXPECT_THAT(cycle(array, 3), ElementsAre(1, 2, 1)); EXPECT_THAT(cycle(array, 4), ElementsAre(1, 2, 1, 2)); EXPECT_THAT(cycle(array, 5), ElementsAre(1, 2, 1, 2, 1)); } TEST(ByteConstrainedArray, Simple) { EXPECT_THAT((ByteConstrainedArray<char, 17>()), SizeIs(17)); EXPECT_THAT((ByteConstrainedArray<uint16_t, 17>()), SizeIs(8)); EXPECT_THAT((ByteConstrainedArray<uint32_t, 17>()), SizeIs(4)); EXPECT_THAT((ByteConstrainedArray<uint64_t, 17>()), SizeIs(2)); EXPECT_LE(sizeof(ByteConstrainedArray<char, 17>), 17U); EXPECT_LE(sizeof(ByteConstrainedArray<uint16_t, 17>), 17U); EXPECT_LE(sizeof(ByteConstrainedArray<uint32_t, 17>), 17U); EXPECT_LE(sizeof(ByteConstrainedArray<uint64_t, 17>), 17U); } TEST(ByteConstrainedArray, Cycle) { ByteConstrainedArray<uint64_t, 17> TwoValues{{1UL, 2UL}}; EXPECT_THAT(cycle(TwoValues, 5), ElementsAre(1, 2, 1, 2, 1)); } } // namespace } // namespace libc_benchmarks } // namespace llvm
35.698225
79
0.698326
medismailben
fafa0ffbdd0a31cae636e9f4716305433a5b1a41
4,135
cpp
C++
include/utility/test/algorithm/sort.test.cpp
SakuraLife/utility
b9bf26198917b6dc415520f74eb3eebf8aa8195e
[ "Unlicense" ]
2
2017-12-10T10:59:48.000Z
2017-12-13T04:11:14.000Z
include/utility/test/algorithm/sort.test.cpp
SakuraLife/utility
b9bf26198917b6dc415520f74eb3eebf8aa8195e
[ "Unlicense" ]
null
null
null
include/utility/test/algorithm/sort.test.cpp
SakuraLife/utility
b9bf26198917b6dc415520f74eb3eebf8aa8195e
[ "Unlicense" ]
null
null
null
#define UTILITY_DEBUG #include<cstdlib> #include<cstdio> #include<cassert> #include<ctime> #include<utility/container/vector.hpp> #include<utility/algorithm/is_sorted.hpp> #include<utility/algorithm/sort.hpp> template< typename _Tag = utility::algorithm::sort_tag::introspective_sort_tag > void sort_test(utility::size_t __size = 10000) { using std::rand; using std::clock; using std::clock_t; using utility::size_t; using utility::container::vector; using utility::algorithm::is_sorted; using utility::algorithm::sort; vector<int> rec; for(size_t __i = 0; __i < __size; ++__i) { rec.push_back((rand()&1?1:-1) * rand());} clock_t begin = clock(); sort<_Tag>(rec.begin(), rec.end()); clock_t end = clock(); double ti = end - begin; ti /= CLOCKS_PER_SEC; assert(is_sorted(rec.begin(), rec.end())); printf("Sort test %lu passes. Time: %lfs\n", __size, ti); return; } int main() { using std::time; using std::srand; using namespace utility::algorithm::sort_tag; srand(time(0)); printf("select_sort_tag\n"); sort_test<select_sort_tag>(10); sort_test<select_sort_tag>(100); sort_test<select_sort_tag>(1000); sort_test<select_sort_tag>(10000); sort_test<select_sort_tag>(100000); sort_test<select_sort_tag>(1000000); printf("bubble_sort_tag\n"); sort_test<bubble_sort_tag>(10); sort_test<bubble_sort_tag>(100); sort_test<bubble_sort_tag>(1000); sort_test<bubble_sort_tag>(10000); sort_test<bubble_sort_tag>(100000); sort_test<bubble_sort_tag>(1000000); printf("cocktail_shaker_sort_tag\n"); sort_test<cocktail_shaker_sort_tag>(10); sort_test<cocktail_shaker_sort_tag>(100); sort_test<cocktail_shaker_sort_tag>(1000); sort_test<cocktail_shaker_sort_tag>(10000); sort_test<cocktail_shaker_sort_tag>(100000); sort_test<cocktail_shaker_sort_tag>(1000000); printf("odd_even_sort_tag\n"); sort_test<odd_even_sort_tag>(10); sort_test<odd_even_sort_tag>(100); sort_test<odd_even_sort_tag>(1000); sort_test<odd_even_sort_tag>(10000); sort_test<odd_even_sort_tag>(100000); sort_test<odd_even_sort_tag>(1000000); printf("comb_sort_tag\n"); sort_test<comb_sort_tag>(10); sort_test<comb_sort_tag>(100); sort_test<comb_sort_tag>(1000); sort_test<comb_sort_tag>(10000); sort_test<comb_sort_tag>(100000); sort_test<comb_sort_tag>(1000000); printf("gnome_sort_tag\n"); sort_test<gnome_sort_tag>(10); sort_test<gnome_sort_tag>(100); sort_test<gnome_sort_tag>(1000); sort_test<gnome_sort_tag>(10000); sort_test<gnome_sort_tag>(100000); sort_test<gnome_sort_tag>(1000000); printf("insertion_sort_tag\n"); sort_test<insertion_sort_tag>(10); sort_test<insertion_sort_tag>(100); sort_test<insertion_sort_tag>(1000); sort_test<insertion_sort_tag>(10000); sort_test<insertion_sort_tag>(100000); sort_test<insertion_sort_tag>(1000000); printf("shell_sort_tag\n"); sort_test<shell_sort_tag>(10); sort_test<shell_sort_tag>(100); sort_test<shell_sort_tag>(1000); sort_test<shell_sort_tag>(10000); sort_test<shell_sort_tag>(100000); sort_test<shell_sort_tag>(1000000); printf("cycle_sort_tag\n"); sort_test<cycle_sort_tag>(10); sort_test<cycle_sort_tag>(100); sort_test<cycle_sort_tag>(1000); sort_test<cycle_sort_tag>(10000); sort_test<cycle_sort_tag>(100000); sort_test<cycle_sort_tag>(1000000); printf("heap_sort_tag\n"); sort_test<heap_sort_tag>(10); sort_test<heap_sort_tag>(100); sort_test<heap_sort_tag>(1000); sort_test<heap_sort_tag>(10000); sort_test<heap_sort_tag>(100000); sort_test<heap_sort_tag>(1000000); printf("quick_sort_tag\n"); sort_test<quick_sort_tag>(10); sort_test<quick_sort_tag>(100); sort_test<quick_sort_tag>(1000); sort_test<quick_sort_tag>(10000); sort_test<quick_sort_tag>(100000); sort_test<quick_sort_tag>(1000000); printf("introspective_sort_tag\n"); sort_test<introspective_sort_tag>(10); sort_test<introspective_sort_tag>(100); sort_test<introspective_sort_tag>(1000); sort_test<introspective_sort_tag>(10000); sort_test<introspective_sort_tag>(100000); sort_test<introspective_sort_tag>(1000000); }
28.321918
70
0.754051
SakuraLife
fafd3e422704ff61398329bf92a26a22e3d33fae
37,450
cpp
C++
src/Components.cpp
pilif0/open-sea
b5d28c82d43547894f10f02b206a607f541ce864
[ "MIT" ]
4
2018-03-13T16:41:02.000Z
2021-12-23T12:42:24.000Z
src/Components.cpp
pilif0/open-sea
b5d28c82d43547894f10f02b206a607f541ce864
[ "MIT" ]
21
2018-02-24T13:55:01.000Z
2021-06-02T09:35:54.000Z
src/Components.cpp
pilif0/open-sea
b5d28c82d43547894f10f02b206a607f541ce864
[ "MIT" ]
null
null
null
/** \file Components.cpp * Component implementations * * \author Filip Smola */ #include <open-sea/Components.h> #include <open-sea/Debug.h> #include <open-sea/Model.h> #include <open-sea/GL.h> #include <imgui.h> #include <glm/glm.hpp> #include <stdexcept> #include <random> #include <algorithm> namespace open_sea::ecs { //! Number of live entities that need to be seen in row before garbage collection gives up constexpr size_t live_in_row = 4; //--- Start ModelTable implementation /** * \brief Construct a model component manager * * Construct a model component manager and pre-allocate space for the given number of components. * * \param size Number of components */ ModelTable::ModelTable(unsigned size) { this->table = std::make_unique<data::TableSoA<Entity, Data>>(size); } /** * \brief Get index to a model * * Get index to a model, adding the model to the manager's storage if necessary. * * \param model Pointer to model * \return Index into the \c models storage of this manager */ size_t ModelTable::model_to_index(const std::shared_ptr<model::Model> &model) { size_t model_idx; // Try to find the model in storage auto model_pos = std::find(models.begin(), models.end(), model); if (model_pos == models.end()) { // Not found -> add the pointer model_idx = static_cast<int>(models.size()); models.emplace_back(model); } else { // Found -> use found index model_idx = static_cast<int>(model_pos - models.begin()); } return model_idx; } /** * \brief Get the model at the provided index * * Get the model at the provided index from the model store * * \param i Index * \return Model pointer */ std::shared_ptr<model::Model> ModelTable::get_model(size_t i) const { return std::shared_ptr<model::Model>(models[i]); } /** * \brief Get the model associated with the entity * * \param e Entity * \return Model pointer */ std::shared_ptr<model::Model> ModelTable::get_model(Entity e) const { return get_model(table->get_copy(e).model); } /** * \brief Remove model from storage * * Remove the model at the provided index from the store. * If the model is used by any entities, the relevant records are removed. * * \param i Index * \return \c true if the any records were removed */ bool ModelTable::remove_model(size_t i) { // Remove from store if (i < models.size()) { // In range -> remove models.erase(models.begin()+i); } else { // Otherwise -> not in store, there should be no records so skip the rest return false; } // Iterate through the table, removing records with that model Data::Ptr ref = table->get_reference(); size_t n = 0; bool result = false; while (n < table->size()) { if (*ref.model == i) { // Matches -> remove table->remove(data::opt_index(n)); result = true; // No incrementing, because current got swapped with last and size decremented by removal } else { // Otherwise -> go to next table->increment_reference(ref); n++; } } return result; } /** * \brief Collect garbage * * Destroy records for dead entities. * This is done by checking random records until a certain number of live entities in a row are found. * Therefore with few dead entities not much time is wasted iterating through the array, and with many dead entities * they are destroyed within couple calls. * * \param manager Entity manager to check entities against */ void ModelTable::gc(const EntityManager &manager) { unsigned seen_live_in_row = 0; static std::random_device device; static std::mt19937_64 generator(table->size()); std::vector<Entity> entities = table->keys(); std::uniform_int_distribution<int> distribution(0, entities.size()); // Keep trying while there are entities and haven't seen too many living while (!entities.empty() && seen_live_in_row < live_in_row) { // Note: modulo required because number of entities can change and this keeps indices in valid range size_t i = distribution(generator) % entities.size(); if (manager.alive(entities[i])) { // Increment live counter seen_live_in_row++; } else { // Reset live counter and remove record from table and entity list seen_live_in_row = 0; table->remove(entities[i]); entities.erase(entities.begin() + i); } } } /** * \brief Destroy the component manager, freeing up the used memory */ ModelTable::~ModelTable() = default; /** * \brief Show ImGui debug information */ void ModelTable::show_debug() { ImGui::Text("Table type: %s", table->type_name()); ImGui::Text("Record size: %lu bytes", sizeof(Data)); ImGui::Text("Records: %lu (%lu bytes)", table->size(), sizeof(Data) * table->size()); ImGui::Text("Allocated: %lu (%lu bytes)", table->allocated(), sizeof(Data) * table->allocated()); ImGui::Text("Pages allocated: %lu", table->pages()); ImGui::Text("Stored models: %i", static_cast<int>(models.size())); if (ImGui::Button("Query")) { ImGui::OpenPopup("Component Manager Query"); } if (ImGui::BeginPopupModal("Component Manager Query", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { show_query(); ImGui::Separator(); if (ImGui::Button("Close")) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } /** * \brief Show ImGui form for querying data from a manager of this component */ void ModelTable::show_query() { ImGui::TextUnformatted("Entity:"); ImGui::InputInt2("index - generation", query_idx_gen); if (ImGui::Button("Refresh")) { if (query_idx_gen[0] >= 0 && query_idx_gen[1] >= 0) { try { Entity entity(static_cast<unsigned>(query_idx_gen[0]), static_cast<unsigned>(query_idx_gen[1])); query_ref = table->get_reference(entity); } catch (std::out_of_range&) { query_ref = {nullptr}; } } else { query_ref = {nullptr}; } } ImGui::Separator(); if (query_ref.model) { size_t model_id = *(query_ref.model); ImGui::Text("Model index: %zu", model_id); ImGui::TextUnformatted("Model information:"); ImGui::Indent(); get_model(model_id)->show_debug(); ImGui::Unindent(); } else { ImGui::TextUnformatted("No record found"); } } //--- End ModelTable implementation /** * \brief Compute transformation matrix * * \param position Position * \param orientation Orientation * \param scale Scale * \return Transformation */ glm::mat4 transformation(glm::vec3 position, glm::quat orientation, glm::vec3 scale) { glm::mat4 s = glm::scale(glm::mat4(1.0f), scale); glm::mat4 r = glm::mat4_cast(orientation); glm::mat4 t = glm::translate(glm::mat4(1.0f), position); return t * r * s; } //--- Start TransformationTable implementation /** * \brief Construct a transformation component manager * * Construct a transformation component manager and pre-allocate space for the given number of components. * * \param size Number of components */ TransformationTable::TransformationTable(unsigned size) { this->table = std::make_unique<data::TableSoA<Entity, Data>>(size); } /** * \brief Collect garbage * * Destroy records for dead entities. * This is done by checking random records until a certain number of live entities in a row are found. * Therefore with few dead entities not much time is wasted iterating through the array, and with many dead entities * they are destroyed within couple calls. * * \param manager Entity manager to check entities against */ void TransformationTable::gc(const EntityManager &manager) { unsigned seen_live_in_row = 0; static std::random_device device; static std::mt19937_64 generator(table->size()); std::vector<Entity> entities = table->keys(); std::uniform_int_distribution<int> distribution(0, entities.size()); // Keep trying while there are entities and haven't seen too many living while (!entities.empty() && seen_live_in_row < live_in_row) { // Note: modulo required because number of entities can change and this keeps indices in valid range size_t i = distribution(generator) % entities.size(); if (manager.alive(entities[i])) { // Increment live counter seen_live_in_row++; } else { // Reset live counter and remove record from table and entity list seen_live_in_row = 0; remove(entities[i]); entities.erase(entities.begin() + i); } } } /** * \brief Add the component to the entity * * Each records is added to the start of the parent's children list. * * \param key Entity * \param position Position * \param orientation Orientation * \param scale Scale * \param parent Parent (-1 if root) * \return `true` iff the structure was modified */ bool TransformationTable::add(const Entity &key, const glm::vec3 &position, const glm::quat &orientation, const glm::vec3 &scale, const data::opt_index parent) { // Get parent reference Data::Ptr par_ref{}; if (parent.is_set()) { try { par_ref = table->get_reference(parent); } catch (std::out_of_range &e) { // Not found -> Invalid parent provided throw std::invalid_argument("Adding record to parent that can't be found."); } } // Construct data Data data = { position, orientation, scale, transformation(position, orientation, scale), parent, {}, (parent.is_set()) ? *par_ref.first_child : data::opt_index(), {} }; // Add it auto idx = table->add(key, data); // Check for failure if (!idx.is_set()) { return false; } // Link with sibling and parent if (parent.is_set()) { // Set as previous first child's sibling auto sibling = *par_ref.first_child; if (sibling.is_set()) { // Get reference Data::Ptr sib_ref{}; try { sib_ref = table->get_reference(sibling); } catch (std::out_of_range &e) { // Not found -> Invalid sibling provided throw std::invalid_argument("Parent references first child that can't be found."); } // Set previous sibling sib_ref.prev_sibling->set(idx); } // Set as parent's first child par_ref.first_child->set(idx); } // Update parent's matrix to propagate it to new children if (parent.is_set()) { update_matrix(parent); } return idx.is_set(); } /** * \brief Add the component to the entities * * Each records is added to the start of the parent's children list. * Any record that fails to be added is skipped. * * \param key Entities * \param position Positions * \param orientation Orientations * \param scale Scales * \param parent Parent (-1 if root) * \return `true` iff the structure was modified */ // Note: This can't be done in SOA style, because each inserted record needs to know where the previous was inserted // (for prev_sibling, and to set its next_sibling). bool TransformationTable::add(const Entity *keys, const glm::vec3 *position, const glm::quat *orientation, const glm::vec3 *scale, const data::opt_index parent, size_t count) { // Get parent reference Data::Ptr par_ref{}; if (parent.is_set()) { try { par_ref = table->get_reference(parent); } catch (std::out_of_range &e) { // Not found -> Invalid parent provided throw std::invalid_argument("Adding records to parent that can't be found."); } } // Perform for each record in sequence bool result = false; const Entity *k = keys; const glm::vec3 *p = position; const glm::quat *o = orientation; const glm::vec3 *s = scale; data::opt_index last_added = parent.is_set() ? *par_ref.first_child : data::opt_index(); for (size_t i = 0; i < count; i++, k++, p++, o++, s++) { // Construct data Data data = { *p, *o, *s, transformation(*p, *o, *s), parent, data::opt_index(), parent.is_set() ? last_added : data::opt_index(), data::opt_index() }; // Add it (skipping if failed) data::opt_index just_added = table->add(*k, data); result = just_added.is_set() || result; // Set as last added's previous sibling if added non-root if (last_added.is_set() && just_added.is_set()) { // Get reference Data::Ptr last_ref{}; try { last_ref = table->get_reference(last_added); } catch (std::out_of_range &e) { // Not found -> just added it, something is VERY wrong throw std::invalid_argument(i == 0 || !result ? // i.e. if first success "Parent references first child that can't be found." : "Record that was just added can't be found."); } // Set previous sibling last_ref.prev_sibling->set(just_added); } // Update last added index if non-root, skipping failures if (just_added.is_set() && parent.is_set()) { last_added.set(just_added); } } // Set parent's first child to the last added record if (parent.is_set()) { par_ref.first_child->set(last_added); } // Update parent's matrix to propagate it to new children if (parent.is_set()) { update_matrix(parent); } return result; } /** * \brief Change the subject's parent * * The subject is added to the start of the parent's children list * * \param e Subject entity * \param parent Parent index (unset for root) */ // Note: Uses opt_index instead of Entity because it needs to be able to express an empty parent (root) void TransformationTable::adopt(const Entity &e, const data::opt_index parent) { // Get the subject reference Data::Ptr ref{}; auto idx = table->lookup(e); try { ref = table->get_reference(e); } catch (std::out_of_range &e) { // Not found -> nothing to update return; } // Remove from original tree auto original_parent = *ref.parent; if (original_parent.is_set()) { // Get original parent reference Data::Ptr par_ref{}; try { par_ref = table->get_reference(original_parent); } catch (std::out_of_range &e) { // Not found -> table structure broken, something is VERY wrong throw std::invalid_argument("Record references parent that can't be found."); } // Make parent point to next sibling if necessary if (par_ref.first_child->is_set()) { par_ref.first_child->set(*ref.next_sibling); } // Connect neighbouring siblings auto prev_sib = *ref.prev_sibling; auto next_sib = *ref.next_sibling; if (prev_sib.is_set()) { Data::Ptr prev_ref{}; try { prev_ref = table->get_reference(prev_sib); } catch (std::out_of_range &e) { // Not found -> table structure broken, something is VERY wrong throw std::invalid_argument("Record references previous sibling that can't be found."); } prev_ref.next_sibling->set(next_sib); } if (next_sib.is_set()) { Data::Ptr next_ref{}; try { next_ref = table->get_reference(next_sib); } catch (std::out_of_range &e) { // Not found -> table structure broken, something is VERY wrong throw std::invalid_argument("Record references next sibling that can't be found."); } next_ref.prev_sibling->set(prev_sib); } } // Add to destination tree ref.parent->set(parent); if (!parent.is_set()) { // Make root ref.prev_sibling->unset(); ref.next_sibling->unset(); } else { // Get new parent reference Data::Ptr par_ref{}; try { par_ref = table->get_reference(parent); } catch (std::out_of_range &e) { // Not found -> Invalid parent provided throw std::invalid_argument("Tried to set parent to one that can't be found."); } // Make first child auto sibling = *par_ref.first_child; par_ref.first_child->set(idx); // Link with new next sibling Data::Ptr sib_ref{}; try { sib_ref = table->get_reference(sibling); } catch (std::out_of_range &e) { // Not found -> Invalid parent provided throw std::invalid_argument("Record references first child that can't be found."); } sib_ref.prev_sibling->set(idx); ref.next_sibling->set(sibling); } } /** * \brief Update world transformation matrix of a record at the provided index * * \param idx Record index * \param siblings Whether to also update following siblings */ // Note: siblings flag is used to simplify recursion void TransformationTable::update_matrix(data::opt_index idx, bool siblings) { // Check the index is set if (!idx.is_set()) { // Nothing to update return; } // Get data Data::Ptr data{}; try { data = table->get_reference(idx); } catch (std::out_of_range &e) { // Index out of range -> nothing to update return; } // Retrieve parent matrix glm::mat4 parent; if (data.parent->is_set()) { // Get parent reference Data::Ptr par_ref{}; try { par_ref = table->get_reference(*data.parent); } catch (std::out_of_range &e) { // Not found -> Invalid parent provided throw std::invalid_argument("Record references parent that can't be found."); } parent = *par_ref.matrix; } else { parent = glm::mat4(1.0f); } // Update own matrix *data.matrix = parent * transformation(*data.position, *data.orientation, *data.scale); // Update the children if (data.first_child->is_set()) { update_matrix(*data.first_child, true); } // Update siblings if asked to if (siblings && data.next_sibling->is_set()) { update_matrix(*data.next_sibling, true); } } /** * \brief Update world transformation matrix of entity * * \param e Entity * \param siblings Whether to also update following siblings */ // Note: siblings flag is used to simplify recursion void TransformationTable::update_matrix(Entity e, bool siblings) { // Look up record and pass to index-based overload update_matrix(table->lookup(e), siblings); } /** * \brief Remove record at the provided index and its children * * \param idx Record index * \return `true` iff the structure was modified */ bool TransformationTable::remove(data::opt_index idx) { // Check the index is set if (!idx.is_set()) { // Nothing to remove return false; } // Get the data Data::Ptr data{}; try { data = table->get_reference(idx); } catch (std::out_of_range &e) { return false; } // Recursively destroy children while (data.first_child->is_set()) { // Remove first child auto first_child = *data.first_child; bool removed = remove(first_child); // Adjust index and data if we got moved by this removal if (removed && idx.get() == table->size()) { // Removal happened and index is now outside the table -> got moved to first_child idx = first_child; try { data = table->get_reference(idx); } catch (std::out_of_range &e) { // Previously valid first child index is now outside -> it was last but by above so were we // -> somehow we were our first child -> fatal error throw std::exception(); } } else if (!removed) { // Child wasn't removed -> should never happen - break potential infinite loop and note the error //TODO there probably is a better exception for this throw std::invalid_argument("Record child couldn't be removed."); } } // Remove references to this record if (data.parent->is_set()) { // Get the reference to parent Data::Ptr ref{}; try { ref = table->get_reference(*data.parent); } catch (std::out_of_range &e) { // Not found -> Invalid parent provided throw std::invalid_argument("Record references parent that can't be found."); } // Check we are removing the first child if ((*ref.first_child) == idx) { // Replace with next sibling ref.first_child->set(*data.next_sibling); } } if (data.next_sibling->is_set()) { // Get the reference next sibling Data::Ptr ref{}; try { ref = table->get_reference(*data.next_sibling); } catch (std::out_of_range &e) { // Not found -> Invalid sibling provided throw std::invalid_argument("Record references next sibling that can't be found."); } // Set next sibling's previous sibling to mine (or lack thereof) ref.prev_sibling->set(*data.prev_sibling); } if (data.prev_sibling->is_set()) { // Get the reference to previous sibling Data::Ptr ref{}; try { ref = table->get_reference(*data.prev_sibling); } catch (std::out_of_range &e) { // Not found -> Invalid sibling provided throw std::invalid_argument("Record references previous sibling that can't be found."); } // Set previous sibling's next sibling to mine (or lack thereof) ref.next_sibling->set(*data.next_sibling); } // Remove the record return table->remove(idx).is_set(); } /** * \brief Remove entity's record and those of its children * * \param key Entity * \return `true` iff the structure was modified */ bool TransformationTable::remove(const Entity &key) { // Look up record and pass to index-based overload return remove(table->lookup(key)); } /** * \brief Translate entities * * Translate given entities. * Updates both the position and the matrix. * * \param e Entities * \param delta Translation vectors * \param count Number of entities */ void TransformationTable::translate(Entity *e, glm::vec3 *delta, size_t count) { // For every entity, set the value for (unsigned j = 0; j < count; j++, e++, delta++) { // Get reference Data::Ptr ref{}; try { ref = table->get_reference(*e); } catch (std::out_of_range &e) { // Not found -> skip continue; } // Set the value *ref.position += *delta; // Update matrix update_matrix(*e); } } /** * \brief Rotate entities * * Rotate given entities. * Updates both the orientation and the matrix. * * \param e Entities * \param delta Rotation quaternions * \param count Number of entities */ void TransformationTable::rotate(Entity *e, glm::quat *delta, size_t count) { // For every entity, set the value for (unsigned j = 0; j < count; j++, e++, delta++) { // Get reference Data::Ptr ref{}; try { ref = table->get_reference(*e); } catch (std::out_of_range &e) { // Not found -> skip continue; } // Set the value *ref.orientation = *delta * *ref.orientation; // Update matrix update_matrix(*e); } } /** * \brief Scale entities * * Scale (multiplicatively) given entities. * Updates both the scale and the matrix. * Scaling is done by component-wise multiplying current scale by the vector. * * \param e Entities * \param delta Scale vectors * \param count Number of entities */ void TransformationTable::scale(Entity *e, glm::vec3 *delta, size_t count) { // For every index, set the value for (unsigned j = 0; j < count; j++, e++, delta++) { // Get reference Data::Ptr ref{}; try { ref = table->get_reference(*e); } catch (std::out_of_range &e) { // Not found -> skip continue; } // Set the value *ref.scale *= *delta; // Update matrix update_matrix(*e); } } /** * \brief Set position entities * * Set position of givne entities. * Updates both the position and the matrix. * * \param e Entities * \param position New position vectors * \param count Number of entities */ void TransformationTable::set_position(Entity *e, glm::vec3 *position, size_t count) { // For every index, set the value for (unsigned j = 0; j < count; j++, e++, position++) { // Get reference Data::Ptr ref{}; try { ref = table->get_reference(*e); } catch (std::out_of_range &e) { // Not found -> skip continue; } // Set the value *ref.position = *position; // Update matrix update_matrix(*e); } } /** * \brief Set orientation of entities * * Set orientation of given entities. * Updates both the orientation and the matrix. * * \param e Entities * \param orientation New orientation quaternions * \param count Number of entities */ void TransformationTable::set_orientation(Entity *e, glm::quat *orientation, size_t count) { // For every index, set the value for (unsigned j = 0; j < count; j++, e++, orientation++) { // Get reference Data::Ptr ref{}; try { ref = table->get_reference(*e); } catch (std::out_of_range &e) { // Not found -> skip continue; } // Set the value *ref.orientation = *orientation; // Update matrix update_matrix(*e); } } /** * \brief Set scale of entities * * Set scale of givne entities. * Updates both the scale and the matrix. * * \param e Entities * \param scale New scale vectors * \param count Number of entities */ void TransformationTable::set_scale(Entity *e, glm::vec3 *scale, size_t count) { // For every index, set the value for (unsigned j = 0; j < count; j++, e++, scale++) { // Get reference Data::Ptr ref{}; try { ref = table->get_reference(*e); } catch (std::out_of_range &e) { // Not found -> skip continue; } // Set the value *ref.scale = *scale; // Update matrix update_matrix(*e); } } /** * \brief Show ImGui debug information */ void TransformationTable::show_debug() { ImGui::Text("Table type: %s", table->type_name()); ImGui::Text("Record size: %lu bytes", sizeof(Data)); ImGui::Text("Records: %lu (%lu bytes)", table->size(), sizeof(Data) * table->size()); ImGui::Text("Allocated: %lu (%lu bytes)", table->allocated(), sizeof(Data) * table->allocated()); ImGui::Text("Pages allocated: %lu", table->pages()); if (ImGui::Button("Query")) { ImGui::OpenPopup("Component Manager Query"); } if (ImGui::BeginPopupModal("Component Manager Query", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { show_query(); ImGui::Separator(); if (ImGui::Button("Close")) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } /** * \brief Show ImGui form for querying data from a manager of this component */ void TransformationTable::show_query() { ImGui::TextUnformatted("Entity:"); ImGui::InputInt2("index - generation", query_idx_gen); if (ImGui::Button("Refresh")) { if (query_idx_gen[0] >= 0 && query_idx_gen[1] >= 0) { try { Entity entity(static_cast<unsigned>(query_idx_gen[0]), static_cast<unsigned>(query_idx_gen[1])); query_entity = entity; query_buffer = table->get_copy(entity); query_success = true; } catch (std::out_of_range&) { query_buffer = {}; query_success = false; } } else { query_buffer = {}; query_success = false; } } ImGui::Separator(); if (query_success) { ImGui::Text("Position: %.3f, %.3f, %.3f", query_buffer.position.x, query_buffer.position.y, query_buffer.position.z); ImGui::TextUnformatted("Orientation:"); ImGui::SameLine(); debug::show_quat(query_buffer.orientation); ImGui::Text("Scale: %.3f, %.3f, %.3f", query_buffer.scale.x, query_buffer.scale.y, query_buffer.scale.z); debug::show_matrix(query_buffer.matrix); ImGui::Text("Parent: %s", (!query_buffer.parent.is_set()) ? "none" : table->lookup(query_buffer.parent).str().c_str()); ImGui::Text("First child: %s", (!query_buffer.first_child.is_set()) ? "none" : table->lookup(query_buffer.first_child).str().c_str()); ImGui::Text("Next sibling: %s", (!query_buffer.next_sibling.is_set()) ? "none" : table->lookup(query_buffer.next_sibling).str().c_str()); ImGui::Text("Previous sibling: %s", (!query_buffer.prev_sibling.is_set()) ? "none" : table->lookup(query_buffer.prev_sibling).str().c_str()); ImGui::Spacing(); if (ImGui::Button("Set Position")) { query_pos = query_buffer.position; ImGui::OpenPopup("set position"); } ImGui::SameLine(); if (ImGui::Button("Set Orientation")) { query_ori = query_buffer.orientation; ImGui::OpenPopup("set orientation"); } ImGui::SameLine(); if (ImGui::Button("Set Scale")) { query_sca = query_buffer.scale; ImGui::OpenPopup("set scale"); } ImGui::Spacing(); if (ImGui::Button("Translate")) { query_pos_delta = {}; ImGui::OpenPopup("translate"); } ImGui::SameLine(); if (ImGui::Button("Rotate")) { query_ori_delta = glm::quat(); ImGui::OpenPopup("rotate"); } ImGui::SameLine(); if (ImGui::Button("Scale")) { query_sca_fac = {}; ImGui::OpenPopup("scale"); } } else { ImGui::TextUnformatted("No record found"); } // Set position dialog if (ImGui::BeginPopupModal("set position", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::InputFloat3("position", &query_pos.x); ImGui::Separator(); if (ImGui::Button("Cancel")) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set")) { set_position(&query_entity, &query_pos, 1); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } // Set orientation dialog if (ImGui::BeginPopupModal("set orientation", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::InputFloat4("orientation", &query_ori.x); ImGui::Separator(); if (ImGui::Button("Cancel")) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set")) { set_orientation(&query_entity, &query_ori, 1); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } // Set scale dialog if (ImGui::BeginPopupModal("set scale", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::InputFloat3("scale", &query_sca.x); ImGui::Separator(); if (ImGui::Button("Cancel")) { ImGui::CloseCurrentPopup(); } if (ImGui::Button("Set")) { set_scale(&query_entity, &query_sca, 1); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } // Translate dialog if (ImGui::BeginPopupModal("translate", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::InputFloat3("delta", &query_pos_delta.x); ImGui::Separator(); if (ImGui::Button("Cancel")) { ImGui::CloseCurrentPopup(); } ImGui::SameLine(); if (ImGui::Button("Translate")) { translate(&query_entity, &query_pos_delta, 1); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } // Rotate dialog if (ImGui::BeginPopupModal("rotate", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::InputFloat4("delta", &query_ori_delta.x); ImGui::Separator(); if (ImGui::Button("Cancel")) { ImGui::CloseCurrentPopup(); } ImGui::SameLine(); if (ImGui::Button("Rotate")) { rotate(&query_entity, &query_ori_delta, 1); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } // Scale dialog if (ImGui::BeginPopupModal("scale", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::InputFloat3("factor", &query_sca_fac.x); ImGui::Separator(); if (ImGui::Button("Cancel")) { ImGui::CloseCurrentPopup(); } ImGui::SameLine(); if (ImGui::Button("Scale")) { scale(&query_entity, &query_sca_fac, 1); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } //--- End TransformationTable implementation }
35.837321
180
0.54
pilif0
fafedb44c024c06ab46e9455b325a6456997bb17
659
cpp
C++
leetcode/problems/14.cpp
songhn233/ACM_Steps
6f2edeca9bf4fc999a8148bc90b2d8d0e59d48fe
[ "CC0-1.0" ]
1
2020-08-10T21:40:21.000Z
2020-08-10T21:40:21.000Z
leetcode/problems/14最长公共前缀.cpp
songhn233/Algorithm-Packages
56d6f3c2467c175ab8a19b82bdfb25fc881e2206
[ "CC0-1.0" ]
null
null
null
leetcode/problems/14最长公共前缀.cpp
songhn233/Algorithm-Packages
56d6f3c2467c175ab8a19b82bdfb25fc881e2206
[ "CC0-1.0" ]
null
null
null
class Solution { public: string longestCommonPrefix(vector<string>& strs) { if(!strs.size()) return ""; int lim=(int)strs[0].size(); int ans=0; for(int i=0;i<strs.size();i++) lim=min(lim,(int)strs[i].size()); for(int len=0;len<lim;len++) { int flag=1; for(int i=1;i<strs.size();i++) { if(strs[i][len]==strs[0][len]) continue; flag=0;break; } if(flag) { ans=len+1; continue; } else break; } return (strs[0].substr(0,ans)); } };
26.36
72
0.412747
songhn233
4f025729a7dcb010bdadcb39ce99f409443265c4
664
cpp
C++
src/logging/checkpoint_manager_factory.cpp
17zhangw/peloton
484d76df9344cb5c153a2c361c5d5018912d4cf4
[ "Apache-2.0" ]
3
2018-01-08T01:06:17.000Z
2019-06-17T23:14:36.000Z
src/logging/checkpoint_manager_factory.cpp
17zhangw/peloton
484d76df9344cb5c153a2c361c5d5018912d4cf4
[ "Apache-2.0" ]
5
2017-04-23T17:16:14.000Z
2017-04-25T03:14:16.000Z
src/logging/checkpoint_manager_factory.cpp
17zhangw/peloton
484d76df9344cb5c153a2c361c5d5018912d4cf4
[ "Apache-2.0" ]
3
2018-02-25T23:30:33.000Z
2018-04-08T10:11:42.000Z
//===----------------------------------------------------------------------===// // // Peloton // // checkpoint_manager_factory.cpp // // Identification: src/logging/checkpoint_manager_factory.cpp // // Copyright (c) 2015-16, Carnegie Mellon University Database Group // //===----------------------------------------------------------------------===// #include "logging/checkpoint_manager_factory.h" namespace peloton { namespace logging { CheckpointingType CheckpointManagerFactory::checkpointing_type_ = CheckpointingType::ON; int CheckpointManagerFactory::checkpointing_thread_count_ = 1; } // namespace gc } // namespace peloton
27.666667
88
0.566265
17zhangw
4f02f43d3d4b90036f71076db2839fab390e8a0e
6,356
cpp
C++
SRC/domain/load/NodalThermalAction.cpp
steva44/OpenSees
417c3be117992a108c6bbbcf5c9b63806b9362ab
[ "TCL" ]
8
2019-03-05T16:25:10.000Z
2020-04-17T14:12:03.000Z
SRC/domain/load/NodalThermalAction.cpp
steva44/OpenSees
417c3be117992a108c6bbbcf5c9b63806b9362ab
[ "TCL" ]
null
null
null
SRC/domain/load/NodalThermalAction.cpp
steva44/OpenSees
417c3be117992a108c6bbbcf5c9b63806b9362ab
[ "TCL" ]
3
2019-09-21T03:11:11.000Z
2020-01-19T07:29:37.000Z
/* ****************************************************************** ** ** OpenSees - Open System for Earthquake Engineering Simulation ** ** Pacific Earthquake Engineering Research Center ** ** ** ** ** ** (C) Copyright 1999, The Regents of the University of California ** ** All Rights Reserved. ** ** ** ** Commercial use of this program without express permission of the ** ** University of California, Berkeley, is strictly prohibited. See ** ** file 'COPYRIGHT' in main directory for information on usage and ** ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. ** ** ** ** Developed by: ** ** Frank McKenna (fmckenna@ce.berkeley.edu) ** ** Gregory L. Fenves (fenves@ce.berkeley.edu) ** ** Filip C. Filippou (filippou@ce.berkeley.edu) ** ** ** ** ****************************************************************** */ // $Revision: 1.1 $ // $Date: 2011-07-18 10:11:35 $ // $Source: /usr/local/cvs/OpenSees/SRC/domain/load/NodalThermalAction.cpp,v $ //Written by Liming Jiang [http://openseesforfire.github.io] // Description: This file contains the class implementation for NodalThermalAction. // NodalThermalAction is a thermal field class created to store the temperature // distribution through the depth of section defined by temperature and location. #include <Channel.h> #include <FEM_ObjectBroker.h> #include <Information.h> #include <Parameter.h> #include <NodalThermalAction.h> #include <Vector.h> NodalThermalAction::NodalThermalAction(int tag, int theNodeTag, double t1, double locY1, double t2, double locY2, Vector* crds) :NodalLoad(tag, theNodeTag,LOAD_TAG_NodalThermalAction),data(18),Crds(0), ThermalActionType(1),theSeries(0) { Temp[0] = t1; Temp[8] = t2; Loc[0]=locY1; Loc[8]=locY2; for(int i= 1; i<8;i++){ Temp[i]=Temp[0]-i*(Temp[0]-Temp[8])/8; Loc[i]=Loc[0]-i*(Loc[0]-Loc[8])/8; } Factors.Zero(); if(crds!=0) Crds = (*crds); } NodalThermalAction::NodalThermalAction(int tag, int theNodeTag, const Vector& locy, TimeSeries* theSeries,Vector* crds ) :NodalLoad(tag, theNodeTag, LOAD_TAG_NodalThermalAction),theSeries(theSeries),Crds(0), data(18),ThermalActionType(1) { for(int i=0 ;i<15;i++) { Temp[i]=1; TempApp[i]=0; } for(int i =0;i<9;i++) Loc[i]=locy(i); Factors.Zero(); if(crds!=0) Crds = (*crds); } NodalThermalAction::NodalThermalAction(int tag, int theNodeTag, double locY1, double locY2,double locZ1,double locZ2, TimeSeries* theSeries, Vector* crds ) :NodalLoad(tag, theNodeTag, LOAD_TAG_NodalThermalAction),theSeries(theSeries),Crds(0), data(25),ThermalActionType(2) { Loc[0]=locY1;Loc[4]=locY2; Loc[5]=locZ1 ;Loc[9] = locZ2; for(int i= 1; i<4;i++){ Loc[i]=Loc[0]+i*(Loc[4]-Loc[0])/4; //locs through the depth Loc[5+i]=Loc[5]+i*(Loc[9]-Loc[5])/4; //locs through the width } for(int i=0 ;i<15;i++) { Temp[i]=1; //Here the original temp is set as 1, which will be factorized by the value obtained from TempApp[i]=0; } Factors.Zero(); if(crds!=0) Crds = (*crds); } NodalThermalAction::~NodalThermalAction() { indicator=0; if(theSeries!=0) delete theSeries; theSeries=0; } const Vector & NodalThermalAction::getData(int &type) { type=LOAD_TAG_NodalThermalAction; if(ThermalActionType==1){ for(int i=0; i<9;i++) { data(2*i) = TempApp[i]; data(2*i+1)= Loc[i]; } } else if(ThermalActionType==2){ //data(0) = T1; //data(1) = LocY1; //.... //data(8) = T5; // data(9) = LocY5; //data(10) = T6; //data(11) = T7; //data(13) = LocZ1; //... //data(22) = T14; //data(23) = T15; //data(24) = LocZ5; for(int i=0; i<5;i++) { data(2*i) = TempApp[i]; //5 temps through y data(2*i+1)= Loc[i]; //5 locs through y data(3*i+10) = TempApp[i+5]; //5 temps through Z in bottom flange data(3*i+11)= TempApp[i+10]; //5 temps through Z in top flange data(3*i+12)= Loc[i+5]; //5 locs through Z } } else { opserr<<"NodalThermalAction::getData, ThermalActionType tag " <<ThermalActionType<<"is invalid"<<endln; } Factors.Zero(); return data; //data to store Temperature and location of 9 datapoints } void NodalThermalAction::applyLoad(const Vector &factors) { opserr<<"NodalThermalAction::applyLoad(Vector& factors) should not be called)"<<endln; } void NodalThermalAction::applyLoad(double time) { // first determine the load factor if (theSeries!= 0) { Factors=((PathTimeSeriesThermal*)theSeries)->getFactors(time); //opserr<<"factors"<<Factors<<endln; for(int i=0;i<15;i++) { TempApp[i]=Factors(i); if((ThermalActionType==1)&&(i==8)) break; else if((ThermalActionType==2)&&(i==14)) break; } }else{ for(int i=0;i<15;i++) { TempApp[i]=Temp[i]*time; if((ThermalActionType==1)&&(i==8)) break; else if((ThermalActionType==2)&&(i==14)) break; } } } int NodalThermalAction::getThermalActionType() { return ThermalActionType; } const Vector& NodalThermalAction::getCrds() { return Crds; } /* int NodalThermalAction::sendSelf(int commitTag, Channel &theChannel) { return -1; } int NodalThermalAction::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { return -1; } */ // do it later void NodalThermalAction::Print(OPS_Stream &s, int flag) { s << "NodalThermalAction: " << this->getNodeTag() << endln; }
28.375
144
0.540592
steva44
4f04260bab906ab2065732a7e010e9fce8b83feb
4,901
hpp
C++
third_party/omr/gc/base/ParallelSweepChunk.hpp
xiacijie/omr-wala-linkage
a1aff7aef9ed131a45555451abde4615a04412c1
[ "Apache-2.0" ]
null
null
null
third_party/omr/gc/base/ParallelSweepChunk.hpp
xiacijie/omr-wala-linkage
a1aff7aef9ed131a45555451abde4615a04412c1
[ "Apache-2.0" ]
null
null
null
third_party/omr/gc/base/ParallelSweepChunk.hpp
xiacijie/omr-wala-linkage
a1aff7aef9ed131a45555451abde4615a04412c1
[ "Apache-2.0" ]
null
null
null
/******************************************************************************* * Copyright (c) 1991, 2015 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ * or the Apache License, Version 2.0 which accompanies this distribution and * is available at https://www.apache.org/licenses/LICENSE-2.0. * * This Source Code may also be made available under the following * Secondary Licenses when the conditions for such availability set * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU * General Public License, version 2 with the GNU Classpath * Exception [1] and GNU General Public License, version 2 with the * OpenJDK Assembly Exception [2]. * * [1] https://www.gnu.org/software/classpath/license.html * [2] http://openjdk.java.net/legal/assembly-exception.html * * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception *******************************************************************************/ /** * @file * @ingroup GC_Base */ #if !defined(PARALLELSWEEPCHUNK_HPP_) #define PARALLELSWEEPCHUNK_HPP_ #include "omrcfg.h" #include "omrcomp.h" #include "modronbase.h" #include <string.h> #include "BaseNonVirtual.hpp" class MM_MemoryPool; class MM_HeapLinkedFreeHeader; /** * @todo Provide class documentation * @ingroup GC_Base */ class MM_ParallelSweepChunk : public MM_BaseNonVirtual { public: void *chunkBase; void *chunkTop; void *leadingFreeCandidate; uintptr_t leadingFreeCandidateSize; void *trailingFreeCandidate; uintptr_t trailingFreeCandidateSize; uintptr_t projection; MM_HeapLinkedFreeHeader *freeListHead; uintptr_t freeListHeadSize; MM_HeapLinkedFreeHeader *freeListTail; uintptr_t freeListTailSize; MM_HeapLinkedFreeHeader *previousFreeListTail; /**< previous free entry of freeListTail */ bool _coalesceCandidate; /**< Flag if the chunk can coalesce with the previous chunks free information */ MM_MemoryPool *memoryPool; uintptr_t freeBytes; uintptr_t freeHoles; uintptr_t _darkMatterBytes; uintptr_t _darkMatterSamples; uintptr_t _scannableBytes; /**< sum of scannable object sizes - sample only */ uintptr_t _nonScannableBytes; /**< sum of non-scannable object sizes - sample only */ uintptr_t _largestFreeEntry; /**< largest free entry found in the given chunk */ MM_HeapLinkedFreeHeader *_previousLargestFreeEntry; /**< previous free entry of the Largest Free Entry */ MM_ParallelSweepChunk *_previous; /**< previous heap address ordered chunk */ MM_ParallelSweepChunk *_next; /**< next heap address ordered chunk */ #if defined(OMR_GC_CONCURRENT_SWEEP) MM_ParallelSweepChunk *_nextChunk; uintptr_t _concurrentSweepState; #endif /* OMR_GC_CONCURRENT_SWEEP */ /* Split Free List Data */ MM_HeapLinkedFreeHeader* _splitCandidate; MM_HeapLinkedFreeHeader* _splitCandidatePreviousEntry; uintptr_t _accumulatedFreeSize; uintptr_t _accumulatedFreeHoles; /** * clear the Chunk object. */ MMINLINE void clear() { *this = MM_ParallelSweepChunk(); } /** * Calculate the physical size of the chunk. * @return the size in bytes the chunk represents on the heap. */ MMINLINE uintptr_t size() { return (((uintptr_t)chunkTop) - ((uintptr_t)chunkBase)); } /** * Update the previous largest Free Entry and the largest free entry size (only be called from SweepPoolManagerSplitAddressOrderedList) */ MMINLINE void updateLargestFreeEntry(UDATA largestFreeEntrySizeCandidate, MM_HeapLinkedFreeHeader * previousLargestFreeEntryCandidate) { if (largestFreeEntrySizeCandidate > _largestFreeEntry) { _previousLargestFreeEntry = previousLargestFreeEntryCandidate; _largestFreeEntry = largestFreeEntrySizeCandidate; } } /** * Create a ParallelSweepChunk object. */ MM_ParallelSweepChunk() : MM_BaseNonVirtual(), chunkBase(NULL), chunkTop(NULL), leadingFreeCandidate(NULL), leadingFreeCandidateSize(0), trailingFreeCandidate(NULL), trailingFreeCandidateSize(0), projection(0), freeListHead(NULL), freeListHeadSize(0), freeListTail(NULL), freeListTailSize(0), previousFreeListTail(NULL), _coalesceCandidate(false), memoryPool(NULL), freeBytes(0), freeHoles(0), _darkMatterBytes(0), _darkMatterSamples(0), _scannableBytes(0), _nonScannableBytes(0), _largestFreeEntry(0), _previousLargestFreeEntry(NULL), _previous(NULL), _next(NULL), #if defined(OMR_GC_CONCURRENT_SWEEP) _nextChunk(NULL), _concurrentSweepState(0), #endif /* OMR_GC_CONCURRENT_SWEEP */ _splitCandidate(NULL), _splitCandidatePreviousEntry(NULL), _accumulatedFreeSize(0), _accumulatedFreeHoles(0) { _typeId = __FUNCTION__; }; }; #endif /* PARALLELSWEEPCHUNK_HPP_ */
30.823899
136
0.742093
xiacijie
4f0437cb67266296fc7aefed3565e03c80990162
725
cpp
C++
src_smartcontract_db/trx/transaction/SchemaObjectIdPublisher.cpp
alinous-core/codable-cash
32a86a152a146c592bcfd8cc712f4e8cb38ee1a0
[ "MIT" ]
6
2019-01-06T05:02:39.000Z
2020-10-01T11:45:32.000Z
src_smartcontract_db/trx/transaction/SchemaObjectIdPublisher.cpp
Codablecash/codablecash
8816b69db69ff2f5da6cdb6af09b8fb21d3df1d9
[ "MIT" ]
209
2018-05-18T03:07:02.000Z
2022-03-26T11:42:41.000Z
src_smartcontract_db/trx/transaction/SchemaObjectIdPublisher.cpp
Codablecash/codablecash
8816b69db69ff2f5da6cdb6af09b8fb21d3df1d9
[ "MIT" ]
3
2019-07-06T09:16:36.000Z
2020-10-15T08:23:28.000Z
/* * SchemaObjectIdPublisher.cpp * * Created on: 2020/05/14 * Author: iizuka */ #include "trx/transaction/SchemaObjectIdPublisher.h" #include "schema_table/schema/SchemaManager.h" namespace codablecash { SchemaObjectIdPublisher::SchemaObjectIdPublisher(SchemaManager* schema) { this->schema = schema; } SchemaObjectIdPublisher::~SchemaObjectIdPublisher() { this->schema = nullptr; } uint64_t SchemaObjectIdPublisher::newOid() { return this->schema->newSchemaObjectId(); } void SchemaObjectIdPublisher::saveSchema() { this->schema->save(); } uint64_t SchemaObjectIdPublisher::getSchemaObjectVersionId() const noexcept { return this->schema->getSchemaObjectVersionId(); } } /* namespace codablecash */
20.714286
77
0.761379
alinous-core
4f058587b050cb1a19c9a0f6beeb8e8d690c1ef0
2,093
cpp
C++
src/util/logger.cpp
neuromancer85/Rack
7e49a697d43bc204f68408779ac2015c66e7dd14
[ "BSD-2-Clause", "BSD-3-Clause" ]
1
2019-04-14T20:18:06.000Z
2019-04-14T20:18:06.000Z
src/util/logger.cpp
neuromancer85/Rack
7e49a697d43bc204f68408779ac2015c66e7dd14
[ "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
src/util/logger.cpp
neuromancer85/Rack
7e49a697d43bc204f68408779ac2015c66e7dd14
[ "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
#include "util/common.hpp" #include "asset.hpp" #include <stdarg.h> namespace rack { static FILE *logFile = NULL; static std::chrono::high_resolution_clock::time_point startTime; void loggerInit(bool devMode) { startTime = std::chrono::high_resolution_clock::now(); if (devMode) { logFile = stderr; } else { std::string logFilename = assetLocal("log.txt"); logFile = fopen(logFilename.c_str(), "w"); } } void loggerDestroy() { if (logFile != stderr) { fclose(logFile); } } static const char* const loggerText[] = { "debug", "info", "warn", "fatal" }; static const int loggerColor[] = { 35, 34, 33, 31 }; static void loggerLogVa(LoggerLevel level, const char *file, int line, const char *format, va_list args) { auto nowTime = std::chrono::high_resolution_clock::now(); int duration = std::chrono::duration_cast<std::chrono::milliseconds>(nowTime - startTime).count(); if (logFile == stderr) fprintf(logFile, "\x1B[%dm", loggerColor[level]); fprintf(logFile, "[%.03f %s %s:%d] ", duration / 1000.0, loggerText[level], file, line); if (logFile == stderr) fprintf(logFile, "\x1B[0m"); vfprintf(logFile, format, args); fprintf(logFile, "\n"); fflush(logFile); } void loggerLog(LoggerLevel level, const char *file, int line, const char *format, ...) { va_list args; va_start(args, format); loggerLogVa(level, file, line, format, args); va_end(args); } /** Deprecated. Included for ABI compatibility */ #undef debug #undef info #undef warn #undef fatal void debug(const char *format, ...) { va_list args; va_start(args, format); loggerLogVa(DEBUG_LEVEL, "", 0, format, args); va_end(args); } void info(const char *format, ...) { va_list args; va_start(args, format); loggerLogVa(INFO_LEVEL, "", 0, format, args); va_end(args); } void warn(const char *format, ...) { va_list args; va_start(args, format); loggerLogVa(WARN_LEVEL, "", 0, format, args); va_end(args); } void fatal(const char *format, ...) { va_list args; va_start(args, format); loggerLogVa(FATAL_LEVEL, "", 0, format, args); va_end(args); } } // namespace rack
20.722772
106
0.679408
neuromancer85
4f0708ea47732abeb881744baa66d5a0345c8601
122
cpp
C++
src/core/NormalColor.cpp
tody411/SimpleMeshViewer
25aa62371bf815316244387cb1a69a27b47f80c0
[ "MIT" ]
null
null
null
src/core/NormalColor.cpp
tody411/SimpleMeshViewer
25aa62371bf815316244387cb1a69a27b47f80c0
[ "MIT" ]
null
null
null
src/core/NormalColor.cpp
tody411/SimpleMeshViewer
25aa62371bf815316244387cb1a69a27b47f80c0
[ "MIT" ]
null
null
null
/*! \file NormalColor.cpp \author Tody NormalColor definition. date 2015/12/20 */ #include "NormalColor.h"
10.166667
25
0.655738
tody411
4f0952950e4f169a4926327a6061edbe93969fce
788
cpp
C++
142. Linked List Cycle II.cpp
corn1ng/LeetCode-Solution
e7b6f77dd407c9a5cc8be43dc9b0e5d9bc185b95
[ "Apache-2.0" ]
6
2017-11-18T02:16:35.000Z
2017-12-17T06:30:40.000Z
142. Linked List Cycle II.cpp
corn1ng/LeetCode-Solution
e7b6f77dd407c9a5cc8be43dc9b0e5d9bc185b95
[ "Apache-2.0" ]
null
null
null
142. Linked List Cycle II.cpp
corn1ng/LeetCode-Solution
e7b6f77dd407c9a5cc8be43dc9b0e5d9bc185b95
[ "Apache-2.0" ]
null
null
null
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *detectCycle(ListNode *head) { if (head == NULL || head->next == NULL) { return NULL; } ListNode* slow =head; ListNode* fast =head; while(fast!=NULL&& fast->next!=NULL) { fast =fast->next->next; slow =slow->next; if(fast==slow) { while(head!=slow) { head=head->next; slow=slow->next; } return head; } } return NULL; } };
21.297297
48
0.404822
corn1ng
4f09c0aa6d2ec11d5508db81927b6ae88aad240a
15,873
cpp
C++
src/slib/ui/list_control_gtk.cpp
inogroup/SLib
6c053c8f47f04240b8444eac5f316effdee2eb01
[ "MIT" ]
2
2021-07-29T18:29:25.000Z
2021-09-07T08:51:14.000Z
src/slib/ui/list_control_gtk.cpp
inogroup/SLib
6c053c8f47f04240b8444eac5f316effdee2eb01
[ "MIT" ]
1
2021-07-29T18:22:35.000Z
2021-07-29T18:59:41.000Z
src/slib/ui/list_control_gtk.cpp
inogroup/SLib
6c053c8f47f04240b8444eac5f316effdee2eb01
[ "MIT" ]
3
2021-07-29T17:08:12.000Z
2021-12-14T06:21:41.000Z
/* * Copyright (c) 2008-2018 SLIBIO <https://github.com/SLIBIO> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "slib/ui/definition.h" #if defined(SLIB_UI_IS_GTK) #include "slib/ui/list_control.h" #include "slib/ui/core.h" #include "view_gtk.h" namespace slib { namespace priv { namespace list_control { static gfloat TranslateAlignment(Alignment _align) { gfloat align = 0; if(_align == Alignment::Center){ align = 0.5f; }else if(_align == Alignment::Right){ align = 1.0f; } return align; } static int GetModelRows(GtkTreeModel* model) { return (int)((sl_size)(g_object_get_data((GObject*)model, "rows"))); } static void SetModelRows(GtkTreeModel* model, int rows) { g_object_set_data((GObject*)model, "rows", (gpointer)(sl_size)rows); } class ListControlHelper : public ListControl { public: static sl_uint32 getColumnsCountFromListView(GtkTreeView* handle) { GList* _list = gtk_tree_view_get_columns(handle); return g_list_length(_list); } void applyColumnsCount(GtkTreeView* handle) { ObjectLocker lock(this); sl_uint32 nNew = (sl_uint32)(m_columns.getCount()); sl_uint32 nOrig = getColumnsCountFromListView(handle); if (nOrig == nNew) { return; } if (nOrig > nNew) { for (sl_uint32 i = nOrig; i > nNew; i--) { GtkTreeViewColumn *column = gtk_tree_view_get_column(handle, i - 1); gtk_tree_view_remove_column(handle, column); } } else { for (sl_uint32 i = nOrig; i < nNew; i++) { GtkCellRenderer* renderer = gtk_cell_renderer_text_new (); GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", i, sl_null); gtk_tree_view_append_column(handle, column); } } } void copyColumns(GtkTreeView* handle) { applyColumnsCount(handle); ListLocker<ListControlColumn> columns(m_columns); for (sl_size i = 0; i < columns.count; i++) { ListControlColumn& column = columns[i]; int width = (int)(column.width); if (width < 0) { width = 0; } GtkTreeViewColumn *treecolumn = gtk_tree_view_get_column(handle, i); if(treecolumn){ StringCstr title = column.title; gtk_tree_view_column_set_title(treecolumn, title.getData()); gtk_tree_view_column_set_fixed_width(treecolumn, width); gtk_tree_view_column_set_alignment(treecolumn, TranslateAlignment(column.align)); } } } void applyRowsCount(GtkTreeView* handle) { GtkTreeModel *model = gtk_tree_view_get_model(handle); gtk_tree_view_set_model(handle, sl_null); SetModelRows(model, m_nRows); gtk_tree_view_set_model(handle, model); } void setupModel(GtkTreeView* view); }; static ListControlHelper* GetModelView(GtkTreeModel* model) { return (ListControlHelper*)((sl_size)(g_object_get_data((GObject*)model, "view"))); } static void SetModelView(GtkTreeModel* model, ListControl* view) { g_object_set_data((GObject*)model, "view", view); } struct SlibListControlModel { GObject parent; }; struct SlibListControlModelClass { GObjectClass parent_class; }; static void slib_list_control_model_class_init(SlibListControlModelClass* cls) { } static void slib_list_control_model_init(SlibListControlModel* obj) { } static gboolean list_control_model_get_iter(GtkTreeModel* model, GtkTreeIter* iter, GtkTreePath* path) { int rows = GetModelRows(model); if (rows) { iter->stamp = gtk_tree_path_get_indices(path)[0];; return 1; } else { return 0; } } static gboolean list_control_model_iter_next(GtkTreeModel* model, GtkTreeIter* iter) { int rows = GetModelRows(model); int index = iter->stamp; if (index < rows - 1 && index >= 0) { iter->stamp = index + 1; return 1; }else{ return 0; } } static gboolean list_control_model_iter_has_child(GtkTreeModel* model, GtkTreeIter* iter) { return 0; } static gboolean list_control_model_iter_children(GtkTreeModel* model, GtkTreeIter* iter, GtkTreeIter* parent) { return 0; } static gint list_control_model_iter_n_children(GtkTreeModel* model, GtkTreeIter* iter) { return GetModelRows(model); } static gboolean list_control_model_iter_nth_child(GtkTreeModel* model, GtkTreeIter* iter, GtkTreeIter* parent, gint n) { return 0; } static gboolean list_control_model_iter_parent(GtkTreeModel* model, GtkTreeIter* iter, GtkTreeIter* child) { return 0; } static GtkTreePath* list_control_model_get_path(GtkTreeModel* model, GtkTreeIter* iter) { int rows = GetModelRows(model); if (iter->stamp >= rows) { return sl_null; } return gtk_tree_path_new_from_indices(iter->stamp, -1); } static void list_control_model_get_value(GtkTreeModel* model, GtkTreeIter* iter, gint column, GValue* value) { ListControlHelper* helper = GetModelView(model); g_value_init(value, G_TYPE_STRING); StringCstr str(helper->getItemText(iter->stamp, column)); g_value_set_string(value, (gchar*)(str.getData())); } static gint list_control_model_get_n_columns(GtkTreeModel* model) { ListControlHelper* helper = GetModelView(model); return helper->getColumnsCount(); } static GType list_control_model_get_column_type(GtkTreeModel* model, gint index) { return G_TYPE_STRING; } static GtkTreeModelFlags list_control_model_get_flags (GtkTreeModel *tree_model) { return (GtkTreeModelFlags)(GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY); } static void slib_list_control_model_tree_model_init(GtkTreeModelIface *iface) { iface->get_flags = list_control_model_get_flags; iface->get_n_columns = list_control_model_get_n_columns; iface->get_column_type = list_control_model_get_column_type; iface->get_value = list_control_model_get_value; iface->get_iter = list_control_model_get_iter; iface->get_path = list_control_model_get_path; iface->iter_next = list_control_model_iter_next; iface->iter_children = list_control_model_iter_children; iface->iter_has_child = list_control_model_iter_has_child; iface->iter_parent = list_control_model_iter_parent; iface->iter_n_children = list_control_model_iter_n_children; iface->iter_nth_child = list_control_model_iter_nth_child; } G_DEFINE_TYPE_WITH_CODE( SlibListControlModel, slib_list_control_model, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(GTK_TYPE_TREE_MODEL, slib_list_control_model_tree_model_init)) GtkTreeModel* list_control_model_new () { SlibListControlModel *result; result = (SlibListControlModel *)g_object_new(slib_list_control_model_get_type(), NULL); return GTK_TREE_MODEL(result); } void ListControlHelper::setupModel(GtkTreeView* view) { GtkTreeModel* model = list_control_model_new(); SetModelView(model, this); SetModelRows(model, m_nRows); gtk_tree_view_set_model(view, model); } class ListControlInstance : public GTK_ViewInstance, public IListControlInstance { SLIB_DECLARE_OBJECT public: GtkTreeView* m_handleTreeView; public: ListControlInstance() { m_handleTreeView = sl_null; } GtkTreeView* getHandle() { return (GtkTreeView*)m_handleTreeView; } Ref<ListControlHelper> getHelper() { return CastRef<ListControlHelper>(getView()); } void initialize(View* _view) override { GtkScrolledWindow* handleScrollWindow = (GtkScrolledWindow*)m_handle; ListControlHelper* view = (ListControlHelper*)_view; gtk_scrolled_window_set_policy(handleScrollWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(handleScrollWindow, GTK_SHADOW_ETCHED_IN); GtkTreeView* handle = (GtkTreeView*)gtk_tree_view_new(); if (handle) { m_handleTreeView = handle; gtk_widget_set_can_focus((GtkWidget*)handle, 1); gtk_container_add((GtkContainer*)handleScrollWindow, (GtkWidget*)handle); gtk_widget_show((GtkWidget*)handle); GtkTreeSelection* selection = gtk_tree_view_get_selection(handle); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); GtkAdjustment *hadjustment, *vadjustment; hadjustment = gtk_tree_view_get_hadjustment (handle); vadjustment = gtk_tree_view_get_vadjustment (handle); gtk_adjustment_set_step_increment (hadjustment, 10.0); gtk_adjustment_set_step_increment (vadjustment, 10.0); gtk_tree_view_set_hadjustment(handle, hadjustment); gtk_tree_view_set_vadjustment(handle, vadjustment); view->copyColumns(handle); view->setupModel(handle); refreshRowsCount(view); g_signal_connect((GtkWidget*)selection, "changed", G_CALLBACK(_callback_selection_changed), handleScrollWindow); g_signal_connect((GtkWidget*)handle, "button-press-event", G_CALLBACK(_callback_button_press_event), handleScrollWindow); } } void refreshColumnsCount(ListControl* view) override { GtkTreeView* handle = getHandle(); if (handle) { (static_cast<ListControlHelper*>(view))->applyColumnsCount(handle); } } void refreshRowsCount(ListControl* view) override { GtkTreeView* handle = getHandle(); if (handle) { (static_cast<ListControlHelper*>(view))->applyRowsCount(handle); } } void setHeaderText(ListControl* view, sl_uint32 iCol, const String& _text) override { GtkTreeView* handle = getHandle(); if (handle) { GtkTreeViewColumn* column = gtk_tree_view_get_column(handle, iCol); if (column) { StringCstr text(_text); gtk_tree_view_column_set_title(column, text.getData()); } } } void setColumnWidth(ListControl* view, sl_uint32 iCol, sl_ui_len width) override { GtkTreeView* handle = getHandle(); if (handle) { GtkTreeViewColumn* column = gtk_tree_view_get_column(handle, iCol); if (column) { gtk_tree_view_column_set_fixed_width(column, width); } } } void setHeaderAlignment(ListControl* view, sl_uint32 iCol, const Alignment& align) override { GtkTreeView* handle = getHandle(); if (handle) { GtkTreeViewColumn* column = gtk_tree_view_get_column(handle, iCol); if (column) { gtk_tree_view_column_set_alignment(column, TranslateAlignment(align)); } } } void setColumnAlignment(ListControl* view, sl_uint32 iCol, const Alignment& align) override { GtkTreeView* handle = getHandle(); if (handle) { GtkTreeViewColumn* column = gtk_tree_view_get_column(handle, iCol); if (column) { gtk_tree_view_column_set_alignment(column, TranslateAlignment(align)); } } } sl_bool getSelectedRow(ListControl* view, sl_int32& _out) override { GtkTreeView* handle = getHandle(); if (handle) { GtkTreeSelection* selection = gtk_tree_view_get_selection(handle); GtkTreeIter iter; gboolean bRet = gtk_tree_selection_get_selected(selection, sl_null, &iter); if (bRet){ _out = iter.stamp; return sl_true; } } return sl_false; } static void _callback_selection_changed(GtkTreeSelection* selection, gpointer user_data) { Ref<ListControlHelper> helper = Ref<ListControlHelper>::from(UIPlatform::getView((GtkWidget*)user_data)); if (helper.isNull()) { return; } GtkTreeIter iter; gtk_tree_selection_get_selected(selection, sl_null, &iter); helper->dispatchSelectRow(iter.stamp); } static gboolean _callback_button_press_event(GtkWidget*, GdkEvent* _event, gpointer user_data) { Ref<ListControlInstance> instance = Ref<ListControlInstance>::from(UIPlatform::getViewInstance((GtkWidget*)user_data)); if (instance.isNull()) { return 0; } Ref<ListControlHelper> helper = Ref<ListControlHelper>::from(instance->getView()); if (helper.isNull()) { return 0; } GtkTreeView* handle = instance->getHandle(); if (!handle) { return 0; } GtkTreeModel* model = gtk_tree_view_get_model(handle); if (!model) { return 0; } int nRows = GetModelRows(model); if (!nRows) { return 0; } GList* columns = gtk_tree_view_get_columns(handle); if (!columns) { return 0; } int nColumns = g_list_length(columns); if (!nColumns) { return 0; } GtkTreePath * path = gtk_tree_path_new_first(); if (!path) { return 0; } GdkEventButton* event = (GdkEventButton*)_event; gint x = event->x; gint y = event->y; GtkAdjustment* adjust_h = gtk_tree_view_get_hadjustment(handle); x += gtk_adjustment_get_value(adjust_h); GtkAdjustment* adjust_v = gtk_tree_view_get_vadjustment(handle); y += gtk_adjustment_get_value(adjust_v); if (y < 0) { y = 0; } int iCol = -1; int heightRow = 1; { for(int i = 0; i < nColumns; i++){ GtkTreeViewColumn* column = gtk_tree_view_get_column(handle, i); GdkRectangle rect; gtk_tree_view_get_cell_area(handle, path, column, &rect); if(x > rect.x && x < rect.x + rect.width){ iCol = i; } heightRow = rect.height; } if (heightRow < 1) { heightRow = 1; } } int iRow = y / heightRow; if (iRow >= nRows) { iRow = -1; } sl_int32 iSel = -1; instance->getSelectedRow(helper, iSel); if(iRow != iSel){ helper->dispatchSelectRow(iRow); } UIPoint pt = helper->convertCoordinateFromScreen(UI::getCursorPos()); if (event->button == 1) { if (event->type == GDK_BUTTON_PRESS) { helper->dispatchClickRow(iRow, pt); } else if (event->type == GDK_2BUTTON_PRESS) { helper->dispatchDoubleClickRow(iRow, pt); } } else if (event->button == 3) { if (event->type == GDK_BUTTON_PRESS) { helper->dispatchRightButtonClickRow(iRow, pt); } } return 0; } }; SLIB_DEFINE_OBJECT(ListControlInstance, GTK_ViewInstance) } } using namespace priv::list_control; Ref<ViewInstance> ListControl::createNativeWidget(ViewInstance* parent) { GtkWidget* handle = gtk_scrolled_window_new(sl_null, sl_null); return GTK_ViewInstance::create<ListControlInstance>(this, parent, handle); } Ptr<IListControlInstance> ListControl::getListControlInstance() { return CastRef<ListControlInstance>(getViewInstance()); } } #endif
29.780488
127
0.685882
inogroup
4f0b8e3e0b239f3021682ecde241ec91de0c91ef
455
cpp
C++
src/iGPS/iGPSMain.cpp
mandad/moos-ivp-manda
6bc81d14aba7c537b7932d6135eed7a5b39c3c52
[ "MIT" ]
9
2016-02-25T03:25:53.000Z
2022-03-27T09:47:50.000Z
src/iGPS/iGPSMain.cpp
mandad/moos-ivp-manda
6bc81d14aba7c537b7932d6135eed7a5b39c3c52
[ "MIT" ]
null
null
null
src/iGPS/iGPSMain.cpp
mandad/moos-ivp-manda
6bc81d14aba7c537b7932d6135eed7a5b39c3c52
[ "MIT" ]
4
2016-06-02T17:42:42.000Z
2021-12-15T09:37:55.000Z
// $Header: /raid/cvs-server/REPOSITORY/software/MOOS/interface/general/iGPS/iGPSMain.cpp,v 5.1 2005/04/27 20:41:40 anrp Exp $ // copyright (2001-2003) Massachusetts Institute of Technology (pnewman et al.) #include "GPSInstrument.h" int main(int argc , char * argv[]) { const char * sMissionFile = "Mission.moos"; if (argc > 1) { sMissionFile = argv[1]; } CGPSInstrument GPSInstrument; GPSInstrument.Run("iGPS", sMissionFile); return 0; }
21.666667
126
0.70989
mandad
4f0dae6b71009e00599150edd26cf7a2a8e17a7d
1,168
cc
C++
src/preload/child/spawn_strategy/chroot_fake.cc
TheEvilSkeleton/zypak
51c8771bc6bb1f68e41663e01c487b414481c57e
[ "BSD-3-Clause" ]
49
2019-11-25T02:29:23.000Z
2022-03-31T05:28:18.000Z
src/preload/child/spawn_strategy/chroot_fake.cc
TheEvilSkeleton/zypak
51c8771bc6bb1f68e41663e01c487b414481c57e
[ "BSD-3-Clause" ]
21
2020-03-12T02:33:24.000Z
2022-03-30T14:00:16.000Z
src/preload/child/spawn_strategy/chroot_fake.cc
TheEvilSkeleton/zypak
51c8771bc6bb1f68e41663e01c487b414481c57e
[ "BSD-3-Clause" ]
5
2020-09-27T11:53:53.000Z
2022-03-23T19:20:07.000Z
// Copyright 2020 Endless Mobile, Inc. // Portions copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Pretend that /proc/self/exe isn't accessible due to sandboxing. #include <errno.h> #include <fcntl.h> #include <stdarg.h> #include <sys/syscall.h> #include <unistd.h> #include "base/base.h" #include "preload/declare_override.h" namespace { constexpr std::string_view kSandboxTestPath = "/proc/self/exe"; } // namespace // The syscall *must* be used directly, as TCMalloc calls open very early on and therefore many // memory allocations will cause it to crash. DECLARE_OVERRIDE_THROW(int, open64, const char* path, int flags, ...) { int mode = 0; // Load the mode if needed. if (__OPEN_NEEDS_MODE(flags)) { va_list va; va_start(va, flags); mode = va_arg(va, int); va_end(va); } if (path == kSandboxTestPath) { errno = ENOENT; return -1; } // On x64 systems, off64_t and off_t are the same at the ABI level, so O_LARGEFILE // isn't needed. return syscall(__NR_openat, AT_FDCWD, path, flags, mode); }
25.955556
95
0.699486
TheEvilSkeleton
4f10b650fd613a328f5facda87217c80389a95d8
54,793
cpp
C++
TelemetrySourcerer/TelemetrySourcerer.cpp
fcccode/TelemetrySourcerer
d90068aed05fb444b20de59c9935ba43f4daf0dc
[ "Apache-2.0" ]
1
2021-06-15T16:51:21.000Z
2021-06-15T16:51:21.000Z
TelemetrySourcerer/TelemetrySourcerer.cpp
W00t3k/TelemetrySourcerer
3c29c86f49eab9f7bd630b1b0741bdf6f9189b68
[ "Apache-2.0" ]
null
null
null
TelemetrySourcerer/TelemetrySourcerer.cpp
W00t3k/TelemetrySourcerer
3c29c86f49eab9f7bd630b1b0741bdf6f9189b68
[ "Apache-2.0" ]
1
2020-10-23T04:04:16.000Z
2020-10-23T04:04:16.000Z
#include <Windows.h> #include <stdlib.h> #include <string.h> #include <tchar.h> #include <commctrl.h> #include <windowsx.h> #include <strsafe.h> #include <TlHelp32.h> #include <string> #include "TelemetrySourcerer.h" #include "KmCallbacks.h" #include "UmHooks.h" #include "UmETW.h" using namespace std; // Global variables HINSTANCE g_hInst; struct WINDOW_HANDLES { HWND Main; HWND StatusBar; HWND TabControl; // Kernel-mode Callbacks HWND KmcPage; HWND KmcRefreshButton; HWND KmcSuppressButton; HWND KmcRevertButton; HWND KmcCountLabel; HWND KmcTipLabel; HWND KmcListView; // User-mode Hooks HWND UmhPage; HWND UmhRefreshButton; HWND UmhRestoreButton; HWND UmhLoadButton; HWND UmhCountLabel; HWND UmhTipLabel; HWND UmhListView; // User-mode ETW Traces HWND UmePage; HWND UmeRefreshButton; HWND UmeDisableButton; HWND UmeStopButton; HWND UmeCountLabel; HWND UmeTipLabel; HWND UmeListView; // About HWND AbtPage; HWND AbtLabel; } wh; struct WINDOW_DATA { std::vector<PCALLBACK_ENTRY> KmcCallbacks; std::vector<PLOADED_MODULE> UmhModules; std::vector<PTRACING_SESSION> UmeSessions; } wd; // Function: WinMain // Description: Entry point for the application. int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // The main window class name. static TCHAR szWindowClass[] = _T("DesktopApp"); // The string that appears in the application's title bar. WCHAR szTitle[MAX_PATH] = { 0 }; StringCbPrintfW(szTitle, MAX_PATH, L"%s v%s by @Jackson_T (%s %s)", TOOL_NAME, VERSION, _T(__DATE__), _T(__TIME__)); WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = MainWndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, IDI_APPLICATION); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_APPLICATION); RegisterClassEx(&wcex); // Store instance handle in our global variable. g_hInst = hInstance; // Create the main window and show it. wh.Main = CreateWindowEx( NULL, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 900, 500, NULL, NULL, hInstance, NULL ); ShowWindow(wh.Main, nCmdShow); UpdateWindow(wh.Main); // Main message loop: MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; } // Function: MainWndProc // Description: Processes messages for the main window. LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam; switch (message) { case WM_CREATE: { PaintWindow(hWnd); KmcLoadResults(); UmhLoadResults(); UmeLoadResults(); ShowWindow(wh.KmcPage, SW_SHOW); break; } case WM_DESTROY: { PostQuitMessage(0); break; } case WM_GETMINMAXINFO: { lpMMI->ptMinTrackSize.x = 900; // Set minimum dimensions to 900x500. lpMMI->ptMinTrackSize.y = 500; lpMMI->ptMaxTrackSize.x = 900; // Set maximum dimensions to 900x500. lpMMI->ptMaxTrackSize.y = 500; break; } case WM_SIZE: { ResizeWindow(hWnd); break; } case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGE: { DWORD TabIndex = TabCtrl_GetCurSel(wh.TabControl); ShowWindow(wh.KmcPage, (TabIndex == 0) ? SW_SHOW : SW_HIDE); ShowWindow(wh.UmhPage, (TabIndex == 1) ? SW_SHOW : SW_HIDE); ShowWindow(wh.UmePage, (TabIndex == 2) ? SW_SHOW : SW_HIDE); ShowWindow(wh.AbtPage, (TabIndex == 3) ? SW_SHOW : SW_HIDE); break; } } break; } case WM_CLOSE: UnloadDriver(); default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; } // Function: KmcWndProc // Description: Processes messages for the kernel-mode callbacks tab. LRESULT CALLBACK KmcWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: { switch (HIWORD(wParam)) { case BN_CLICKED: { if (wh.KmcRefreshButton == (HWND)lParam) KmcLoadResults(); else if (wh.KmcSuppressButton == (HWND)lParam) KmcSuppressCallback(); else if (wh.KmcRevertButton == (HWND)lParam) KmcRevertCallback(); break; } } break; } case WM_NOTIFY: { NMLVDISPINFO* plvdi; switch (((LPNMHDR)lParam)->code) { case LVN_GETDISPINFO: { plvdi = (NMLVDISPINFO*)lParam; PCALLBACK_ENTRY Callback = wd.KmcCallbacks.at(plvdi->item.lParam); LPWSTR Module = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH); StringCbPrintfW(Module, MAX_PATH, L"%ls + 0x%x", Callback->ModuleName, Callback->ModuleOffset); switch (plvdi->item.iSubItem) { case 0: { switch (Callback->Type) { case CALLBACK_TYPE::PsLoadImage: plvdi->item.pszText = (LPWSTR)L"Image Load"; break; case CALLBACK_TYPE::PsProcessCreation: plvdi->item.pszText = (LPWSTR)L"Process Creation"; break; case CALLBACK_TYPE::PsThreadCreation: plvdi->item.pszText = (LPWSTR)L"Thread Creation"; break; case CALLBACK_TYPE::CmRegistry: plvdi->item.pszText = (LPWSTR)L"Registry"; break; case CALLBACK_TYPE::ObProcessHandlePre: case CALLBACK_TYPE::ObProcessHandlePost: case CALLBACK_TYPE::ObThreadHandlePre: case CALLBACK_TYPE::ObThreadHandlePost: case CALLBACK_TYPE::ObDesktopHandlePre: case CALLBACK_TYPE::ObDesktopHandlePost: plvdi->item.pszText = (LPWSTR)L"Object Handle"; break; case CALLBACK_TYPE::MfCreatePre: case CALLBACK_TYPE::MfCreatePost: case CALLBACK_TYPE::MfCreateNamedPipePre: case CALLBACK_TYPE::MfCreateNamedPipePost: case CALLBACK_TYPE::MfClosePre: case CALLBACK_TYPE::MfClosePost: case CALLBACK_TYPE::MfReadPre: case CALLBACK_TYPE::MfReadPost: case CALLBACK_TYPE::MfWritePre: case CALLBACK_TYPE::MfWritePost: case CALLBACK_TYPE::MfQueryInformationPre: case CALLBACK_TYPE::MfQueryInformationPost: case CALLBACK_TYPE::MfSetInformationPre: case CALLBACK_TYPE::MfSetInformationPost: case CALLBACK_TYPE::MfQueryEaPre: case CALLBACK_TYPE::MfQueryEaPost: case CALLBACK_TYPE::MfSetEaPre: case CALLBACK_TYPE::MfSetEaPost: case CALLBACK_TYPE::MfFlushBuffersPre: case CALLBACK_TYPE::MfFlushBuffersPost: case CALLBACK_TYPE::MfQueryVolumeInformationPre: case CALLBACK_TYPE::MfQueryVolumeInformationPost: case CALLBACK_TYPE::MfSetVolumeInformationPre: case CALLBACK_TYPE::MfSetVolumeInformationPost: case CALLBACK_TYPE::MfDirectoryControlPre: case CALLBACK_TYPE::MfDirectoryControlPost: case CALLBACK_TYPE::MfFileSystemControlPre: case CALLBACK_TYPE::MfFileSystemControlPost: case CALLBACK_TYPE::MfDeviceControlPre: case CALLBACK_TYPE::MfDeviceControlPost: case CALLBACK_TYPE::MfInternalDeviceControlPre: case CALLBACK_TYPE::MfInternalDeviceControlPost: case CALLBACK_TYPE::MfShutdownPre: case CALLBACK_TYPE::MfShutdownPost: case CALLBACK_TYPE::MfLockControlPre: case CALLBACK_TYPE::MfLockControlPost: case CALLBACK_TYPE::MfCleanupPre: case CALLBACK_TYPE::MfCleanupPost: case CALLBACK_TYPE::MfCreateMailslotPre: case CALLBACK_TYPE::MfCreateMailslotPost: case CALLBACK_TYPE::MfQuerySecurityPre: case CALLBACK_TYPE::MfQuerySecurityPost: case CALLBACK_TYPE::MfSetSecurityPre: case CALLBACK_TYPE::MfSetSecurityPost: case CALLBACK_TYPE::MfPowerPre: case CALLBACK_TYPE::MfPowerPost: case CALLBACK_TYPE::MfSystemControlPre: case CALLBACK_TYPE::MfSystemControlPost: case CALLBACK_TYPE::MfDeviceChangePre: case CALLBACK_TYPE::MfDeviceChangePost: case CALLBACK_TYPE::MfQueryQuotaPre: case CALLBACK_TYPE::MfQueryQuotaPost: case CALLBACK_TYPE::MfSetQuotaPre: case CALLBACK_TYPE::MfSetQuotaPost: case CALLBACK_TYPE::MfPnpPre: case CALLBACK_TYPE::MfPnpPost: plvdi->item.pszText = (LPWSTR)L"File System"; break; default: plvdi->item.pszText = (LPWSTR)L"Unknown"; break; } break; } case 1: { switch (Callback->Type) { case CALLBACK_TYPE::PsLoadImage: plvdi->item.pszText = (LPWSTR)L"PsSetLoadImageNotifyRoutine"; break; case CALLBACK_TYPE::PsProcessCreation: plvdi->item.pszText = (LPWSTR)L"PsSetCreateProcessNotifyRoutine"; break; case CALLBACK_TYPE::PsThreadCreation: plvdi->item.pszText = (LPWSTR)L"PsSetCreateThreadNotifyRoutine"; break; case CALLBACK_TYPE::CmRegistry: plvdi->item.pszText = (LPWSTR)L"CmRegisterCallbackEx"; break; case CALLBACK_TYPE::ObProcessHandlePre: plvdi->item.pszText = (LPWSTR)L"PsProcessType (pre)"; break; case CALLBACK_TYPE::ObProcessHandlePost: plvdi->item.pszText = (LPWSTR)L"PsProcessType (post)"; break; case CALLBACK_TYPE::ObThreadHandlePre: plvdi->item.pszText = (LPWSTR)L"PsThreadType (pre)"; break; case CALLBACK_TYPE::ObThreadHandlePost: plvdi->item.pszText = (LPWSTR)L"PsThreadType (post)"; break; case CALLBACK_TYPE::ObDesktopHandlePre: plvdi->item.pszText = (LPWSTR)L"ExDesktopObjectType (pre)"; break; case CALLBACK_TYPE::ObDesktopHandlePost: plvdi->item.pszText = (LPWSTR)L"ExDesktopObjectType (post)"; break; case CALLBACK_TYPE::MfCreatePre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CREATE (pre)"; break; case CALLBACK_TYPE::MfCreatePost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CREATE (post)"; break; case CALLBACK_TYPE::MfCreateNamedPipePre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CREATE_NAMED_PIPE (pre)"; break; case CALLBACK_TYPE::MfCreateNamedPipePost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CREATE_NAMED_PIPE (post)"; break; case CALLBACK_TYPE::MfClosePre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CLOSE (pre)"; break; case CALLBACK_TYPE::MfClosePost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CLOSE (post)"; break; case CALLBACK_TYPE::MfReadPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_READ (pre)"; break; case CALLBACK_TYPE::MfReadPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_READ (post)"; break; case CALLBACK_TYPE::MfWritePre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_WRITE (pre)"; break; case CALLBACK_TYPE::MfWritePost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_WRITE (post)"; break; case CALLBACK_TYPE::MfQueryInformationPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_INFORMATION (pre)"; break; case CALLBACK_TYPE::MfQueryInformationPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_INFORMATION (post)"; break; case CALLBACK_TYPE::MfSetInformationPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_INFORMATION (pre)"; break; case CALLBACK_TYPE::MfSetInformationPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_INFORMATION (post)"; break; case CALLBACK_TYPE::MfQueryEaPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_EA (pre)"; break; case CALLBACK_TYPE::MfQueryEaPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_EA (post)"; break; case CALLBACK_TYPE::MfSetEaPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_EA (pre)"; break; case CALLBACK_TYPE::MfSetEaPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_EA (post)"; break; case CALLBACK_TYPE::MfFlushBuffersPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_FLUSH_BUFFERS (pre)"; break; case CALLBACK_TYPE::MfFlushBuffersPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_FLUSH_BUFFERS (post)"; break; case CALLBACK_TYPE::MfQueryVolumeInformationPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_VOLUME_INFORMATION (pre)"; break; case CALLBACK_TYPE::MfQueryVolumeInformationPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_VOLUME_INFORMATION (post)"; break; case CALLBACK_TYPE::MfSetVolumeInformationPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_VOLUME_INFORMATION (pre)"; break; case CALLBACK_TYPE::MfSetVolumeInformationPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_VOLUME_INFORMATION (post)"; break; case CALLBACK_TYPE::MfDirectoryControlPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_DIRECTORY_CONTROL (pre)"; break; case CALLBACK_TYPE::MfDirectoryControlPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_DIRECTORY_CONTROL (post)"; break; case CALLBACK_TYPE::MfFileSystemControlPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_FILE_SYSTEM_CONTROL (pre)"; break; case CALLBACK_TYPE::MfFileSystemControlPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_FILE_SYSTEM_CONTROL (post)"; break; case CALLBACK_TYPE::MfDeviceControlPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_DEVICE_CONTROL (pre)"; break; case CALLBACK_TYPE::MfDeviceControlPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_DEVICE_CONTROL (post)"; break; case CALLBACK_TYPE::MfInternalDeviceControlPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_INTERNAL_DEVICE_CONTROL (pre)"; break; case CALLBACK_TYPE::MfInternalDeviceControlPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_INTERNAL_DEVICE_CONTROL (post)"; break; case CALLBACK_TYPE::MfShutdownPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SHUTDOWN (pre)"; break; case CALLBACK_TYPE::MfShutdownPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SHUTDOWN (post)"; break; case CALLBACK_TYPE::MfLockControlPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_LOCK_CONTROL (pre)"; break; case CALLBACK_TYPE::MfLockControlPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_LOCK_CONTROL (post)"; break; case CALLBACK_TYPE::MfCleanupPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CLEANUP (pre)"; break; case CALLBACK_TYPE::MfCleanupPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CLEANUP (post)"; break; case CALLBACK_TYPE::MfCreateMailslotPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CREATE_MAILSLOT (pre)"; break; case CALLBACK_TYPE::MfCreateMailslotPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_CREATE_MAILSLOT (post)"; break; case CALLBACK_TYPE::MfQuerySecurityPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_SECURITY (pre)"; break; case CALLBACK_TYPE::MfQuerySecurityPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_SECURITY (post)"; break; case CALLBACK_TYPE::MfSetSecurityPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_SECURITY (pre)"; break; case CALLBACK_TYPE::MfSetSecurityPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_SECURITY (post)"; break; case CALLBACK_TYPE::MfPowerPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_POWER (pre)"; break; case CALLBACK_TYPE::MfPowerPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_POWER (post)"; break; case CALLBACK_TYPE::MfSystemControlPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SYSTEM_CONTROL (pre)"; break; case CALLBACK_TYPE::MfSystemControlPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SYSTEM_CONTROL (post)"; break; case CALLBACK_TYPE::MfDeviceChangePre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_DEVICE_CHANGE (pre)"; break; case CALLBACK_TYPE::MfDeviceChangePost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_DEVICE_CHANGE (post)"; break; case CALLBACK_TYPE::MfQueryQuotaPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_QUOTA (pre)"; break; case CALLBACK_TYPE::MfQueryQuotaPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_QUERY_QUOTA (post)"; break; case CALLBACK_TYPE::MfSetQuotaPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_QUOTA (pre)"; break; case CALLBACK_TYPE::MfSetQuotaPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_SET_QUOTA (post)"; break; case CALLBACK_TYPE::MfPnpPre: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_PNP (pre)"; break; case CALLBACK_TYPE::MfPnpPost: plvdi->item.pszText = (LPWSTR)L"IRP_MJ_PNP (post)"; break; default: plvdi->item.pszText = (LPWSTR)L"Unknown"; break; } break; } case 2: { plvdi->item.pszText = Module; break; } case 3: { plvdi->item.pszText = (Callback->Suppressed) ? (LPWSTR)L"Yes" : (LPWSTR)L"No"; break; } default: plvdi->item.pszText = (LPWSTR)L"N/A"; break; } } case NM_CUSTOMDRAW: { LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; BOOL IsNotable = FALSE; BOOL IsSuppressed = FALSE; ULONG CallbackIndex = lplvcd->nmcd.lItemlParam; if (wd.KmcCallbacks.size()) { PCALLBACK_ENTRY Callback = wd.KmcCallbacks.at(CallbackIndex); if (Callback->Notable) IsNotable = TRUE; if (Callback->Suppressed) IsSuppressed = TRUE; } switch (lplvcd->nmcd.dwDrawStage) { case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; case CDDS_ITEMPREPAINT: { if (IsSuppressed) { lplvcd->clrText = RGB(255, 255, 255); lplvcd->clrTextBk = RGB(128, 128, 128); } else if (IsNotable) { lplvcd->clrText = RGB(0, 0, 0); lplvcd->clrTextBk = RGB(255, 255, 200); } else { lplvcd->clrText = RGB(0, 0, 0); lplvcd->clrTextBk = RGB(255, 255, 255); } return CDRF_NEWFONT; } case CDDS_SUBITEM | CDDS_ITEMPREPAINT: return CDRF_NEWFONT; } break; } } break; } default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; } // Function: UmhWndProc // Description: Processes messages for the user-mode hooks tab. LRESULT CALLBACK UmhWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: { switch (HIWORD(wParam)) { case BN_CLICKED: { if (wh.UmhRefreshButton == (HWND)lParam) UmhLoadResults(); else if (wh.UmhRestoreButton == (HWND)lParam) UmhRestoreFunction(); else if (wh.UmhLoadButton == (HWND)lParam) UmhLoadDll(); break; } } break; } case WM_NOTIFY: { NMLVDISPINFO* plvdi; switch (((LPNMHDR)lParam)->code) { case LVN_GETDISPINFO: { plvdi = (NMLVDISPINFO*)lParam; int ModuleIndex = HIWORD(plvdi->item.lParam); int FunctionIndex = LOWORD(plvdi->item.lParam); PLOADED_MODULE lm = wd.UmhModules.at(ModuleIndex); PHOOKED_FUNCTION hf = lm->HookedFunctions.at(FunctionIndex); LPWSTR Ordinal = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH); StringCbPrintfW(Ordinal, MAX_PATH, L"%d", hf->Ordinal); LPWSTR Address = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH); StringCbPrintfW(Address, MAX_PATH, L"0x%p", (ULONG64)hf->Address); switch (plvdi->item.iSubItem) { case 0: plvdi->item.pszText = (LPWSTR)lm->Path; break; case 1: plvdi->item.pszText = (LPWSTR)hf->Name; break; case 2: plvdi->item.pszText = Ordinal; break; case 3: plvdi->item.pszText = Address; break; default: plvdi->item.pszText = (LPWSTR)L"N/A"; break; } } } break; } default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; } // Function: UmeWndProc // Description: Processes messages for the ETW sessions tab. LRESULT CALLBACK UmeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: { switch (HIWORD(wParam)) { case BN_CLICKED: { if (wh.UmeRefreshButton == (HWND)lParam) UmeLoadResults(); else if (wh.UmeDisableButton == (HWND)lParam) UmeDisableSelectedProvider(); else if (wh.UmeStopButton == (HWND)lParam) UmeStopTracingSession(); break; } } break; } case WM_NOTIFY: { NMLVDISPINFO* plvdi; switch (((LPNMHDR)lParam)->code) { case LVN_GETDISPINFO: { plvdi = (NMLVDISPINFO*)lParam; int SessionIndex = HIWORD(plvdi->item.lParam); int ProviderIndex = LOWORD(plvdi->item.lParam); PTRACING_SESSION ts = wd.UmeSessions.at(SessionIndex); PTRACE_PROVIDER tp = ts->EnabledProviders.at(ProviderIndex); switch (plvdi->item.iSubItem) { case 0: plvdi->item.pszText = (LPWSTR)ts->InstanceName; break; case 1: plvdi->item.pszText = (LPWSTR)tp->ProviderName; break; default: plvdi->item.pszText = (LPWSTR)L"N/A"; break; } break; } case NM_CUSTOMDRAW: { LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; BOOL IsNotable = FALSE; int SessionIndex = HIWORD(lplvcd->nmcd.lItemlParam); int ProviderIndex = LOWORD(lplvcd->nmcd.lItemlParam); if (wd.UmeSessions.size()) { PTRACING_SESSION ts = wd.UmeSessions.at(SessionIndex); if (ts->Notable) IsNotable = TRUE; else if (ts->EnabledProviders.size()) IsNotable = ts->EnabledProviders.at(ProviderIndex)->Notable; } switch (lplvcd->nmcd.dwDrawStage) { case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; case CDDS_ITEMPREPAINT: { if (IsNotable) { lplvcd->clrText = RGB(0, 0, 0); lplvcd->clrTextBk = RGB(255, 255, 200); } else { lplvcd->clrText = RGB(0, 0, 0); lplvcd->clrTextBk = RGB(255, 255, 255); } return CDRF_NEWFONT; } case CDDS_SUBITEM | CDDS_ITEMPREPAINT: return CDRF_NEWFONT; } break; } } break; } default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; } // Function: PaintWindow // Description: Paints the main window. // Called from: MainWndProc VOID PaintWindow(HWND hWnd) { // Get global instance. g_hInst = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); // Get bounding box for window. RECT rcMain; GetClientRect(hWnd, &rcMain); // Set font to default GUI font. LOGFONT lf; GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lf); HFONT hFont = CreateFont( lf.lfHeight, lf.lfWidth, lf.lfEscapement, lf.lfOrientation, lf.lfWeight, lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily, lf.lfFaceName); SendMessage(hWnd, WM_SETFONT, (WPARAM)hFont, TRUE); // Begin painting. PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); // Status bar. wh.StatusBar = CreateWindowEx( NULL, // no extended styles STATUSCLASSNAME, // name of status bar class (PCTSTR)NULL, // no text when first created WS_CHILD | WS_VISIBLE, // creates a visible child window 0, 0, 0, 0, // ignores size and position hWnd, // handle to parent window (HMENU)0, // child window identifier g_hInst, // handle to application instance NULL); // no window creation data SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Ready"); // Tab control. wh.TabControl = CreateWindowEx( NULL, // Extended styles WC_TABCONTROL, // Predefined class; Unicode assumed L"", // Control text WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, // Styles 0, // X position 0, // Y position rcMain.right, // Control width rcMain.bottom - 22, // Control height hWnd, // Parent window NULL, // No menu. g_hInst, // Global instance handle NULL); // Pointer not needed SendMessage(wh.TabControl, WM_SETFONT, (WPARAM)hFont, TRUE); /** * Kernel-mode Callbacks */ TCITEM tie; tie.mask = TCIF_TEXT; tie.pszText = (LPWSTR)L"Kernel-mode Callbacks"; TabCtrl_InsertItem(wh.TabControl, 0, &tie); wh.KmcPage = CreateWindowEx( NULL, WC_STATIC, L"", WS_CHILD | WS_VISIBLE, 0, 25, rcMain.right - 5, rcMain.bottom - 55, wh.TabControl, NULL, g_hInst, NULL); SetWindowLongPtr(wh.KmcPage, GWLP_WNDPROC, (LONG_PTR)KmcWndProc); wh.KmcRefreshButton = CreateWindowEx( NULL, L"BUTTON", L"Refresh Results", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 5, 5, 100, 30, wh.KmcPage, (HMENU)1, g_hInst, NULL); SendMessage(wh.KmcRefreshButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.KmcSuppressButton = CreateWindowEx( NULL, L"BUTTON", L"Suppress Callback", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 110, 5, 100, 30, wh.KmcPage, NULL, g_hInst, NULL); SendMessage(wh.KmcSuppressButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.KmcRevertButton = CreateWindowEx( NULL, L"BUTTON", L"Revert Callback", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 215, 5, 100, 30, wh.KmcPage, NULL, g_hInst, NULL); SendMessage(wh.KmcRevertButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.KmcCountLabel = CreateWindowEx( NULL, WC_STATIC, L"Count: 0 callbacks.", WS_CHILD | WS_VISIBLE, 320, 5, 350, 15, wh.KmcPage, NULL, g_hInst, NULL); SendMessage(wh.KmcCountLabel, WM_SETFONT, (WPARAM)hFont, TRUE); wh.KmcTipLabel = CreateWindowEx( NULL, WC_STATIC, L"Tip: No results? Run elevated to load the driver.", WS_CHILD | WS_VISIBLE, 320, 20, 250, 15, wh.KmcPage, NULL, g_hInst, NULL); SendMessage(wh.KmcTipLabel, WM_SETFONT, (WPARAM)hFont, TRUE); wh.KmcListView = CreateWindowEx( NULL, WC_LISTVIEW, L"", WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SINGLESEL, 5, 40, rcMain.right - 15, rcMain.bottom - 100, wh.KmcPage, (HMENU)0, g_hInst, NULL); ListView_SetExtendedListViewStyle(wh.KmcListView, LVS_EX_FULLROWSELECT); LVCOLUMN lvc = { 0 }; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.iSubItem = 0; lvc.pszText = (LPWSTR)L"Collection Type"; lvc.cx = 150; ListView_InsertColumn(wh.KmcListView, 0, &lvc); lvc.iSubItem = 1; lvc.pszText = (LPWSTR)L"Callback Type"; lvc.cx = 300; ListView_InsertColumn(wh.KmcListView, 1, &lvc); lvc.iSubItem = 2; lvc.pszText = (LPWSTR)L"Module"; lvc.cx = 250; ListView_InsertColumn(wh.KmcListView, 2, &lvc); lvc.iSubItem = 3; lvc.pszText = (LPWSTR)L"Is Suppressed?"; lvc.cx = 100; ListView_InsertColumn(wh.KmcListView, 3, &lvc); /** * User-mode Hooks */ tie.pszText = (LPWSTR)L"User-mode Hooks"; TabCtrl_InsertItem(wh.TabControl, 1, &tie); wh.UmhPage = CreateWindowEx( NULL, WC_STATIC, L"", WS_CHILD | WS_VISIBLE, 0, 25, rcMain.right - 5, rcMain.bottom - 55, wh.TabControl, NULL, g_hInst, NULL); SetWindowLongPtr(wh.UmhPage, GWLP_WNDPROC, (LONG_PTR)UmhWndProc); wh.UmhRefreshButton = CreateWindowEx( NULL, L"BUTTON", L"Refresh Results", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 5, 5, 100, 30, wh.UmhPage, NULL, g_hInst, NULL); SendMessage(wh.UmhRefreshButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmhRestoreButton = CreateWindowEx( NULL, L"BUTTON", L"Restore Function", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 110, 5, 100, 30, wh.UmhPage, NULL, g_hInst, NULL); SendMessage(wh.UmhRestoreButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmhLoadButton = CreateWindowEx( NULL, L"BUTTON", L"Load Testing DLL", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 215, 5, 100, 30, wh.UmhPage, NULL, g_hInst, NULL); SendMessage(wh.UmhLoadButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmhCountLabel = CreateWindowEx( NULL, WC_STATIC, L"Count: 0 hooked functions.", WS_CHILD | WS_VISIBLE, 320, 5, 350, 15, wh.UmhPage, NULL, g_hInst, NULL); SendMessage(wh.UmhCountLabel, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmhTipLabel = CreateWindowEx( NULL, WC_STATIC, L"Tip: Validate unhooking by loading a test DLL.", WS_CHILD | WS_VISIBLE, 320, 20, 250, 15, wh.UmhPage, NULL, g_hInst, NULL); SendMessage(wh.UmhTipLabel, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmhListView = CreateWindowEx( NULL, WC_LISTVIEW, L"", WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SINGLESEL, 5, 40, rcMain.right - 15, rcMain.bottom - 100, wh.UmhPage, (HMENU)0, g_hInst, NULL); ListView_SetExtendedListViewStyle(wh.UmhListView, LVS_EX_FULLROWSELECT); lvc.iSubItem = 0; lvc.pszText = (LPWSTR)L"Module"; lvc.cx = 250; ListView_InsertColumn(wh.UmhListView, 0, &lvc); lvc.iSubItem = 1; lvc.pszText = (LPWSTR)L"Function Name"; lvc.cx = 300; ListView_InsertColumn(wh.UmhListView, 1, &lvc); lvc.iSubItem = 2; lvc.pszText = (LPWSTR)L"Ordinal"; lvc.cx = 100; ListView_InsertColumn(wh.UmhListView, 2, &lvc); lvc.iSubItem = 3; lvc.pszText = (LPWSTR)L"Virtual Address"; lvc.cx = 200; ListView_InsertColumn(wh.UmhListView, 3, &lvc); /** * ETW Trace Sessions */ tie.pszText = (LPWSTR)L"ETW Trace Sessions"; TabCtrl_InsertItem(wh.TabControl, 2, &tie); wh.UmePage = CreateWindowEx( NULL, WC_STATIC, L"", WS_CHILD | WS_VISIBLE, 0, 25, rcMain.right - 5, rcMain.bottom - 55, wh.TabControl, NULL, g_hInst, NULL); SetWindowLongPtr(wh.UmePage, GWLP_WNDPROC, (LONG_PTR)UmeWndProc); wh.UmeRefreshButton = CreateWindowEx( NULL, L"BUTTON", L"Refresh Results", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 5, 5, 100, 30, wh.UmePage, NULL, g_hInst, NULL); SendMessage(wh.UmeRefreshButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmeDisableButton = CreateWindowEx( NULL, L"BUTTON", L"Disable Provider", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 110, 5, 100, 30, wh.UmePage, NULL, g_hInst, NULL); SendMessage(wh.UmeDisableButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmeStopButton = CreateWindowEx( NULL, L"BUTTON", L"Stop Session", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 215, 5, 100, 30, wh.UmePage, NULL, g_hInst, NULL); SendMessage(wh.UmeStopButton, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmeCountLabel = CreateWindowEx( NULL, WC_STATIC, L"Count: 0 sessions.", WS_CHILD | WS_VISIBLE, 320, 5, 350, 15, wh.UmePage, NULL, g_hInst, NULL); SendMessage(wh.UmeCountLabel, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmeTipLabel = CreateWindowEx( NULL, WC_STATIC, L"Tip: Missing results? Run as SYSTEM to view more sessions.", WS_CHILD | WS_VISIBLE, 320, 20, 300, 15, wh.UmePage, NULL, g_hInst, NULL); SendMessage(wh.UmeTipLabel, WM_SETFONT, (WPARAM)hFont, TRUE); wh.UmeListView = CreateWindowEx( NULL, WC_LISTVIEW, L"", WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SINGLESEL, 5, 40, rcMain.right - 15, rcMain.bottom - 100, wh.UmePage, (HMENU)0, g_hInst, NULL); ListView_SetExtendedListViewStyle(wh.UmeListView, LVS_EX_FULLROWSELECT); lvc.iSubItem = 0; lvc.pszText = (LPWSTR)L"Session"; lvc.cx = 300; ListView_InsertColumn(wh.UmeListView, 0, &lvc); lvc.iSubItem = 1; lvc.pszText = (LPWSTR)L"Enabled Provider"; lvc.cx = 300; ListView_InsertColumn(wh.UmeListView, 1, &lvc); /** * About Page */ tie.pszText = (LPWSTR)L"About"; TabCtrl_InsertItem(wh.TabControl, 3, &tie); wh.AbtPage = CreateWindowEx( NULL, WC_STATIC, L"", WS_CHILD | WS_VISIBLE, // | WS_BORDER, 0, 25, rcMain.right - 5, rcMain.bottom - 55, wh.TabControl, NULL, g_hInst, NULL); wh.AbtLabel = CreateWindowEx( NULL, WC_STATIC, L"Telemetry Sourcerer is a utility that can be used to enumerate " L"and disable common sources of events used by endpoint security " L"products (AV/EDR).\n\n" L"Developed by @Jackson_T (2020), leveraging code from @gentilkiwi, " L"@fdiskyou, and @0x00dtm. Licenced under the Apache License v2.0.\n\n" L"Use of this tool is intended for research purposes only and does " L"not attempt to be OPSEC-safe.\n\n" L"Code: github.com/jthuraisamy/TelemetrySourcerer\n" L"Methodology: jackson-t.ca/edr-reversing-evading-01.html\n", WS_CHILD | WS_VISIBLE | SS_CENTER, 5, 150, rcMain.right - 10, rcMain.bottom - 60, wh.AbtPage, NULL, g_hInst, NULL); SendMessage(wh.AbtLabel, WM_SETFONT, (WPARAM)hFont, TRUE); // END PAINTING ShowWindow(wh.UmhPage, SW_HIDE); ShowWindow(wh.UmePage, SW_HIDE); ShowWindow(wh.AbtPage, SW_HIDE); ShowWindow(wh.KmcPage, SW_HIDE); EndPaint(hWnd, &ps); } // Function: ResizeWindow // Description: Handles window resizes (currently not supported). // Called from: MainWndProc VOID ResizeWindow(HWND hWnd) { RECT rcClient; GetClientRect(hWnd, &rcClient); SetWindowPos(wh.TabControl, HWND_TOP, 0, 0, rcClient.right, rcClient.bottom - 22, SWP_SHOWWINDOW); SetWindowPos(wh.KmcPage, HWND_TOP, 0, 25, rcClient.right - 5, rcClient.bottom - 40, SWP_SHOWWINDOW); SetWindowPos(wh.StatusBar, NULL, 0, rcClient.bottom - 10, rcClient.right, 10, SWP_NOZORDER); } // Function: KmcLoadResults // Description: Loads kernel-mode callback results. // Called from: MainWndProc after painting, and KmcWndProc when clicking the refresh button. VOID KmcLoadResults() { DWORD DriverStatus = LoadDriver(); switch (DriverStatus) { case ERROR_FILE_NOT_FOUND: MessageBox( NULL, L"Could not find TelemetrySourcererDriver.sys.\n\n" L"Please ensure it is in the same directory as the executable.", TOOL_NAME, MB_ICONERROR); break; case ERROR_INVALID_IMAGE_HASH: MessageBox( NULL, L"The signature for the driver failed verification.\n\n" L"To load kernel-mode callback results, either enable test signing, " L"or sign this driver with a valid certificate.", TOOL_NAME, MB_ICONERROR); break; default: break; } SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Loading kernel-mode callbacks..."); // Delete rows and fetch latest results. ListView_DeleteAllItems(wh.KmcListView); wd.KmcCallbacks = GetCallbacks(wd.KmcCallbacks); DWORD ListItemCount = 0; for (int CallbackIndex = 0; CallbackIndex < wd.KmcCallbacks.size(); CallbackIndex++) { LVITEM lvi = { 0 }; lvi.pszText = LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message. lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM; lvi.stateMask = 0; lvi.iSubItem = 0; lvi.state = 0; lvi.iItem = ListItemCount++; lvi.lParam = CallbackIndex; ListView_InsertItem(wh.KmcListView, &lvi); } LPWSTR CountText = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH); StringCbPrintfW(CountText, MAX_PATH, L"Count: %d callbacks.", wd.KmcCallbacks.size()); Static_SetText(wh.KmcCountLabel, CountText); SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Ready"); } // Function: KmcSuppressCallback // Description: Suppresses the selected callback (if eligible). // Called from: KmcWndProc when clicking the suppress button. VOID KmcSuppressCallback() { int SelectedIndex = ListView_GetNextItem(wh.KmcListView, -1, LVNI_SELECTED); if (SelectedIndex != -1) { LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = SelectedIndex; lvi.iSubItem = 0; ListView_GetItem(wh.KmcListView, &lvi); PCALLBACK_ENTRY Callback = wd.KmcCallbacks.at(lvi.lParam); WCHAR MessageTitle[MAX_PATH] = { 0 }; StringCbPrintfW(MessageTitle, MAX_PATH, L"%ls + 0x%x", Callback->ModuleName, Callback->ModuleOffset); if (SuppressCallback(Callback)) { Callback->Suppressed = TRUE; MessageBox(NULL, L"Successfully suppressed callback!", MessageTitle, MB_OK | MB_ICONINFORMATION); KmcLoadResults(); ListView_EnsureVisible(wh.KmcListView, SelectedIndex, FALSE); } else { MessageBox(NULL, L"Callback could not be suppressed for unspecified reason.", MessageTitle, MB_OK | MB_ICONERROR); } } } // Function: KmcRevertCallback // Description: Reverts the selected callback (if suppressed/eligible). // Called from: KmcWndProc when clicking the revert button. VOID KmcRevertCallback() { int SelectedIndex = ListView_GetNextItem(wh.KmcListView, -1, LVNI_SELECTED); if (SelectedIndex != -1) { LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = SelectedIndex; lvi.iSubItem = 0; ListView_GetItem(wh.KmcListView, &lvi); PCALLBACK_ENTRY Callback = wd.KmcCallbacks.at(lvi.lParam); WCHAR MessageTitle[MAX_PATH] = { 0 }; StringCbPrintfW(MessageTitle, MAX_PATH, L"%ls + 0x%x", &Callback->ModuleName, Callback->ModuleOffset); if (Callback->Suppressed) { if (Callback->OriginalQword == GetSuppressionValue(Callback->Type)) { MessageBox(NULL, L"The callback could not be reverted because the function's original first bytes are unknown.", MessageTitle, MB_OK | MB_ICONERROR); } else if (RevertCallback(Callback)) { Callback->Suppressed = FALSE; MessageBox(NULL, L"Successfully reverted callback!", MessageTitle, MB_OK | MB_ICONINFORMATION); KmcLoadResults(); ListView_EnsureVisible(wh.KmcListView, SelectedIndex, FALSE); } else { MessageBox(NULL, L"Callback could not be reverted for unspecified reason.", MessageTitle, MB_OK | MB_ICONERROR); } } else { MessageBox(NULL, L"The selected callback is currently not suppressed.", MessageTitle, MB_OK | MB_ICONERROR); } } } // Function: UmhLoadResults // Description: Loads user-mode inline hook results. // Called from: MainWndProc after painting, and UmhWndProc when clicking the refresh button. VOID UmhLoadResults() { SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Loading user-mode hooks..."); // Delete rows and fetch latest results. ListView_DeleteAllItems(wh.UmhListView); wd.UmhModules = CheckAllModulesForHooks(); DWORD ListItemCount = 0; for (int ModuleIndex = 0; ModuleIndex < wd.UmhModules.size(); ModuleIndex++) { PLOADED_MODULE lm = wd.UmhModules.at(ModuleIndex); for (int FunctionIndex = 0; FunctionIndex < lm->HookedFunctions.size(); FunctionIndex++) { LVITEM lvi = { 0 }; lvi.pszText = LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message. lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM; lvi.stateMask = 0; lvi.iSubItem = 0; lvi.state = 0; lvi.iItem = ListItemCount++; lvi.lParam = (ModuleIndex << 16) | FunctionIndex; ListView_InsertItem(wh.UmhListView, &lvi); } } LPWSTR CountText = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH); StringCbPrintfW(CountText, MAX_PATH, L"Count: %d hooked functions.", ListItemCount); Static_SetText(wh.UmhCountLabel, CountText); SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Ready"); } // Function: UmhRestoreFunction // Description: Unhooks the selected function. // Called from: UmhWndProc when clicking the restore button. VOID UmhRestoreFunction() { int SelectedIndex = ListView_GetNextItem(wh.UmhListView, -1, LVNI_SELECTED); if (SelectedIndex != -1) { LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = SelectedIndex; lvi.iSubItem = 0; ListView_GetItem(wh.UmhListView, &lvi); int ModuleIndex = HIWORD(lvi.lParam); int FunctionIndex = LOWORD(lvi.lParam); PLOADED_MODULE Module = wd.UmhModules.at(ModuleIndex); PHOOKED_FUNCTION Function = Module->HookedFunctions.at(FunctionIndex); WCHAR MessageTitle[MAX_PATH] = { 0 }; StringCbPrintfW(MessageTitle, MAX_PATH, L"%ls: %ls", Module->Path, Function->Name); if (RestoreHookedFunction(Function)) MessageBox(NULL, L"Successfully unhooked function!", MessageTitle, MB_OK | MB_ICONINFORMATION); else MessageBox(NULL, L"Function could not be unhooked for unspecified reason.", MessageTitle, MB_OK | MB_ICONERROR); UmhLoadResults(); ListView_EnsureVisible(wh.UmhListView, SelectedIndex, FALSE); } } // Function: UmhLoadDll // Description: Loads a testing DLL to validate unhooking efficacy. // Called from: UmhWndProc when clicking the load DLL button. VOID UmhLoadDll() { SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Loading test DLL..."); WCHAR DllPath[MAX_PATH] = { 0 }; OPENFILENAMEW OpenFileName = { 0 }; OpenFileName.lStructSize = sizeof(OpenFileName); OpenFileName.hwndOwner = wh.Main; OpenFileName.lpstrFilter = L"DLL Files (*.dll)\0*.DLL\0"; OpenFileName.lpstrFile = DllPath; OpenFileName.nMaxFile = MAX_PATH; GetOpenFileNameW(&OpenFileName); LoadLibraryW(DllPath); // ToDo validation. SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Ready"); } // Function: UmeLoadResults // Description: Load ETW trace session results. // Called from: MainWndProc after painting, and UmeWndProc when clicking the refresh button. VOID UmeLoadResults() { SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Loading ETW sessions..."); // Delete rows and fetch latest results. ListView_DeleteAllItems(wh.UmeListView); wd.UmeSessions = GetSessions(); DWORD ListItemCount = 0; for (int SessionIndex = 0; SessionIndex < wd.UmeSessions.size(); SessionIndex++) { PTRACING_SESSION ts = wd.UmeSessions.at(SessionIndex); for (int ProviderIndex = 0; ProviderIndex < ts->EnabledProviders.size(); ProviderIndex++) { LVITEM lvi = { 0 }; lvi.pszText = LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message. lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM; lvi.stateMask = 0; lvi.iSubItem = 0; lvi.state = 0; lvi.iItem = ListItemCount++; lvi.lParam = ((ULONG)SessionIndex << 16) | ProviderIndex; ListView_InsertItem(wh.UmeListView, &lvi); } } LPWSTR CountText = (LPWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAX_PATH); StringCbPrintfW(CountText, MAX_PATH, L"Count: %d sessions.", wd.UmeSessions.size()); Static_SetText(wh.UmeCountLabel, CountText); SendMessage(wh.StatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)L"Ready"); } // Function: UmeDisableSelectedProvider // Description: Disables the selected provider for the session (if eligible). // Called from: UmeWndProc when clicking the disable provider button. VOID UmeDisableSelectedProvider() { int SelectedIndex = ListView_GetNextItem(wh.UmeListView, -1, LVNI_SELECTED); if (SelectedIndex != -1) { LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = SelectedIndex; lvi.iSubItem = 0; ListView_GetItem(wh.UmeListView, &lvi); int SessionIndex = HIWORD(lvi.lParam); int ProviderIndex = LOWORD(lvi.lParam); PTRACING_SESSION Session = wd.UmeSessions.at(SessionIndex); PTRACE_PROVIDER Provider = Session->EnabledProviders.at(ProviderIndex); WCHAR MessageTitle[MAX_PATH] = { 0 }; StringCbPrintfW(MessageTitle, MAX_PATH, L"%ls: %ls", Session->InstanceName, Provider->ProviderName); DWORD Status = DisableProvider(Session->LoggerId, &Provider->ProviderId); switch (Status) { case ERROR_SUCCESS: MessageBox(NULL, L"Successfully disabled provider!", MessageTitle, MB_OK | MB_ICONINFORMATION); break; case ERROR_ACCESS_DENIED: MessageBox(NULL, L"Denied. Administrative privileges required.", MessageTitle, MB_OK | MB_ICONERROR); break; default: MessageBox(NULL, L"Provider could not be disabled for unspecified reason.", MessageTitle, MB_OK | MB_ICONERROR); break; } UmeLoadResults(); ListView_EnsureVisible(wh.UmeListView, SelectedIndex, FALSE); } } // Function: UmeDisableSelectedProvider // Description: Stops the selected session (if eligible). // Called from: UmeWndProc when clicking the stop session button. VOID UmeStopTracingSession() { int SelectedIndex = ListView_GetNextItem(wh.UmeListView, -1, LVNI_SELECTED); if (SelectedIndex != -1) { LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = SelectedIndex; lvi.iSubItem = 0; ListView_GetItem(wh.UmeListView, &lvi); int SessionIndex = HIWORD(lvi.lParam); int ProviderIndex = LOWORD(lvi.lParam); PTRACING_SESSION Session = wd.UmeSessions.at(SessionIndex); PTRACE_PROVIDER Provider = Session->EnabledProviders.at(ProviderIndex); DWORD Status = StopTracingSession(Session->LoggerId); switch (Status) { case ERROR_SUCCESS: MessageBox(NULL, L"Successfully stopped tracing session!", Session->InstanceName, MB_OK | MB_ICONINFORMATION); break; case ERROR_ACCESS_DENIED: MessageBox(NULL, L"Denied. Administrative privileges required.", Session->InstanceName, MB_OK | MB_ICONERROR); break; default: MessageBox(NULL, L"Session could not be stopped for unspecified reason.", Session->InstanceName, MB_OK | MB_ICONERROR); break; } UmeLoadResults(); ListView_EnsureVisible(wh.UmeListView, SelectedIndex, FALSE); } }
33.82284
165
0.56447
fcccode
4f12a2671100892beca4832941ba211623aca4ab
1,538
hpp
C++
include/network/Client.hpp
raccoman/ft_irc
c510c70feeb193a7da6de995478bf75d25014f6e
[ "MIT" ]
2
2022-03-03T22:28:13.000Z
2022-03-09T10:17:16.000Z
include/network/Client.hpp
raccoman/ft_irc
c510c70feeb193a7da6de995478bf75d25014f6e
[ "MIT" ]
null
null
null
include/network/Client.hpp
raccoman/ft_irc
c510c70feeb193a7da6de995478bf75d25014f6e
[ "MIT" ]
null
null
null
#ifndef FT_IRC_CLIENT_HPP # define FT_IRC_CLIENT_HPP enum ClientState { HANDSHAKE, LOGIN, PLAY, DISCONNECTED }; class Client; #include <vector> #include <string> #include <sys/poll.h> #include <sys/socket.h> #include "utils.hpp" #include "Channel.hpp" class Client { typedef std::vector<pollfd>::iterator pollfds_iterator; private: int _fd; std::string _hostname; int _port; std::string _nickname; std::string _username; std::string _realname; ClientState _state; Channel *_channel; public: Client(int fd, const std::string &hostname, int port); ~Client(); int getFD() const { return _fd; }; std::string getHostname() const { return _hostname; }; int getPort() const { return _port; }; bool isRegistered() const { return _state == ::PLAY; }; std::string getNickname() const { return _nickname; }; std::string getUsername() const { return _username; }; std::string getRealName() const { return _realname; }; std::string getPrefix() const; Channel *getChannel() const { return _channel; }; void setNickname(const std::string &nickname) { _nickname = nickname; }; void setUsername(const std::string &username) { _username = username; }; void setRealName(const std::string &realname) { _realname = realname; }; void setState(ClientState state) { _state = state; }; void setChannel(Channel *channel) { _channel = channel; }; void write(const std::string &message) const; void reply(const std::string &reply); void welcome(); void join(Channel *channel); void leave(); }; #endif
18.756098
73
0.704811
raccoman
4f17469cfa992c7baf9e80d81660f488403846d1
33,733
cpp
C++
src/r_utility.cpp
protocultor/gzdoom
ec2c69e76abbd1eb48f2b7c5b1c0c1e22867f47c
[ "RSA-MD" ]
1
2020-09-22T22:34:00.000Z
2020-09-22T22:34:00.000Z
src/r_utility.cpp
protocultor/gzdoom
ec2c69e76abbd1eb48f2b7c5b1c0c1e22867f47c
[ "RSA-MD" ]
null
null
null
src/r_utility.cpp
protocultor/gzdoom
ec2c69e76abbd1eb48f2b7c5b1c0c1e22867f47c
[ "RSA-MD" ]
null
null
null
//----------------------------------------------------------------------------- // // Copyright 1993-1996 id Software // Copyright 1994-1996 Raven Software // Copyright 1999-2016 Randy Heit // Copyright 2002-2016 Christoph Oelckers // // This program 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. // // 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see http://www.gnu.org/licenses/ // //----------------------------------------------------------------------------- // // DESCRIPTION: // Rendering main loop and setup functions, // utility functions (BSP, geometry, trigonometry). // See tables.c, too. // //----------------------------------------------------------------------------- // HEADER FILES ------------------------------------------------------------ #include <stdlib.h> #include <math.h> #include "templates.h" #include "doomdef.h" #include "d_net.h" #include "doomstat.h" #include "m_random.h" #include "m_bbox.h" #include "r_sky.h" #include "st_stuff.h" #include "c_dispatch.h" #include "v_video.h" #include "stats.h" #include "i_video.h" #include "a_sharedglobal.h" #include "p_3dmidtex.h" #include "r_data/r_interpolate.h" #include "po_man.h" #include "p_effect.h" #include "st_start.h" #include "v_font.h" #include "r_renderer.h" #include "serializer.h" #include "r_utility.h" #include "d_player.h" #include "p_local.h" #include "g_levellocals.h" #include "p_maputl.h" #include "sbar.h" #include "vm.h" #include "i_time.h" #include "actorinlines.h" // EXTERNAL DATA DECLARATIONS ---------------------------------------------- extern bool DrawFSHUD; // [RH] Defined in d_main.cpp EXTERN_CVAR (Bool, cl_capfps) // TYPES ------------------------------------------------------------------- struct InterpolationViewer { struct instance { DVector3 Pos; DRotator Angles; }; AActor *ViewActor; int otic; instance Old, New; }; // PRIVATE DATA DECLARATIONS ----------------------------------------------- static TArray<InterpolationViewer> PastViewers; static FRandom pr_torchflicker ("TorchFlicker"); static FRandom pr_hom; bool NoInterpolateView; // GL needs access to this. static TArray<DVector3a> InterpolationPath; // PUBLIC DATA DEFINITIONS ------------------------------------------------- CVAR (Bool, r_deathcamera, false, CVAR_ARCHIVE) CVAR (Int, r_clearbuffer, 0, 0) CVAR (Bool, r_drawvoxels, true, 0) CVAR (Bool, r_drawplayersprites, true, 0) // [RH] Draw player sprites? CUSTOM_CVAR(Float, r_quakeintensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { if (self < 0.f) self = 0.f; else if (self > 1.f) self = 1.f; } int viewwindowx; int viewwindowy; int viewwidth; int viewheight; FRenderViewpoint::FRenderViewpoint() { player = nullptr; Pos = { 0.0, 0.0, 0.0 }; ActorPos = { 0.0, 0.0, 0.0 }; Angles = { 0.0, 0.0, 0.0 }; Path[0] = { 0.0, 0.0, 0.0 }; Path[1] = { 0.0, 0.0, 0.0 }; Cos = 0.0; Sin = 0.0; TanCos = 0.0; TanSin = 0.0; camera = nullptr; sector = nullptr; FieldOfView = 90.; // Angles in the SCREENWIDTH wide window TicFrac = 0.0; FrameTime = 0; extralight = 0; showviewer = false; } FRenderViewpoint r_viewpoint; FViewWindow r_viewwindow; bool r_NoInterpolate; angle_t LocalViewAngle; int LocalViewPitch; bool LocalKeyboardTurner; int setblocks; bool setsizeneeded; unsigned int R_OldBlend = ~0; int validcount = 1; // increment every time a check is made FCanvasTextureInfo *FCanvasTextureInfo::List; DVector3a view; DAngle viewpitch; DEFINE_GLOBAL(LocalViewPitch); // CODE -------------------------------------------------------------------- //========================================================================== // // R_SetFOV // // Changes the field of view in degrees // //========================================================================== void R_SetFOV (FRenderViewpoint &viewpoint, DAngle fov) { if (fov < 5.) fov = 5.; else if (fov > 170.) fov = 170.; if (fov != viewpoint.FieldOfView) { viewpoint.FieldOfView = fov; setsizeneeded = true; } } //========================================================================== // // R_SetViewSize // // Do not really change anything here, because it might be in the middle // of a refresh. The change will take effect next refresh. // //========================================================================== void R_SetViewSize (int blocks) { setsizeneeded = true; setblocks = blocks; } //========================================================================== // // R_SetWindow // //========================================================================== void R_SetWindow (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, int windowSize, int fullWidth, int fullHeight, int stHeight, bool renderingToCanvas) { if (windowSize >= 11) { viewwidth = fullWidth; freelookviewheight = viewheight = fullHeight; } else if (windowSize == 10) { viewwidth = fullWidth; viewheight = stHeight; freelookviewheight = fullHeight; } else { viewwidth = ((setblocks*fullWidth)/10) & (~15); viewheight = ((setblocks*stHeight)/10)&~7; freelookviewheight = ((setblocks*fullHeight)/10)&~7; } if (renderingToCanvas) { viewwindow.WidescreenRatio = fullWidth / (float)fullHeight; } else { viewwindow.WidescreenRatio = ActiveRatio(fullWidth, fullHeight); DrawFSHUD = (windowSize == 11); } // [RH] Sky height fix for screens not 200 (or 240) pixels tall R_InitSkyMap (); viewwindow.centery = viewheight/2; viewwindow.centerx = viewwidth/2; if (AspectTallerThanWide(viewwindow.WidescreenRatio)) { viewwindow.centerxwide = viewwindow.centerx; } else { viewwindow.centerxwide = viewwindow.centerx * AspectMultiplier(viewwindow.WidescreenRatio) / 48; } DAngle fov = viewpoint.FieldOfView; // For widescreen displays, increase the FOV so that the middle part of the // screen that would be visible on a 4:3 display has the requested FOV. if (viewwindow.centerxwide != viewwindow.centerx) { // centerxwide is what centerx would be if the display was not widescreen fov = DAngle::ToDegrees(2 * atan(viewwindow.centerx * tan(fov.Radians()/2) / double(viewwindow.centerxwide))); if (fov > 170.) fov = 170.; } viewwindow.FocalTangent = tan(fov.Radians() / 2); } //========================================================================== // // R_ExecuteSetViewSize // //========================================================================== void R_ExecuteSetViewSize (FRenderViewpoint &viewpoint, FViewWindow &viewwindow) { setsizeneeded = false; V_SetBorderNeedRefresh(); R_SetWindow (viewpoint, viewwindow, setblocks, SCREENWIDTH, SCREENHEIGHT, StatusBar->GetTopOfStatusbar()); // Handle resize, e.g. smaller view windows with border and/or status bar. viewwindowx = (screen->GetWidth() - viewwidth) >> 1; // Same with base row offset. viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (StatusBar->GetTopOfStatusbar() - viewheight) >> 1; } //========================================================================== // // r_visibility // // Controls how quickly light ramps across a 1/z range. // //========================================================================== double R_ClampVisibility(double vis) { // Allow negative visibilities, just for novelty's sake return clamp(vis, -204.7, 204.7); // (205 and larger do not work in 5:4 aspect ratio) } CUSTOM_CVAR(Float, r_visibility, 8.0f, CVAR_NOINITCALL) { if (netgame && self != 8.0f) { Printf("Visibility cannot be changed in net games.\n"); self = 8.0f; } else { float clampValue = (float)R_ClampVisibility(self); if (self != clampValue) self = clampValue; } } //========================================================================== // // R_GetGlobVis // // Calculates the global visibility constant used by the software renderer // //========================================================================== double R_GetGlobVis(const FViewWindow &viewwindow, double vis) { vis = R_ClampVisibility(vis); double virtwidth = screen->GetWidth(); double virtheight = screen->GetHeight(); if (AspectTallerThanWide(viewwindow.WidescreenRatio)) { virtheight = (virtheight * AspectMultiplier(viewwindow.WidescreenRatio)) / 48; } else { virtwidth = (virtwidth * AspectMultiplier(viewwindow.WidescreenRatio)) / 48; } double YaspectMul = 320.0 * virtheight / (200.0 * virtwidth); double InvZtoScale = YaspectMul * viewwindow.centerx; double wallVisibility = vis; // Prevent overflow on walls double maxVisForWall = (InvZtoScale * (screen->GetWidth() * r_Yaspect) / (viewwidth * screen->GetHeight() * viewwindow.FocalTangent)); maxVisForWall = 32767.0 / maxVisForWall; if (vis < 0 && vis < -maxVisForWall) wallVisibility = -maxVisForWall; else if (vis > 0 && vis > maxVisForWall) wallVisibility = maxVisForWall; wallVisibility = InvZtoScale * screen->GetWidth() * AspectBaseHeight(viewwindow.WidescreenRatio) / (viewwidth * screen->GetHeight() * 3) * (wallVisibility * viewwindow.FocalTangent); return wallVisibility / viewwindow.FocalTangent; } //========================================================================== // // CVAR screenblocks // // Selects the size of the visible window // //========================================================================== CUSTOM_CVAR (Int, screenblocks, 10, CVAR_ARCHIVE) { if (self > 12) self = 12; else if (self < 3) self = 3; else R_SetViewSize (self); } //========================================================================== // // R_PointInSubsector // //========================================================================== subsector_t *R_PointInSubsector (fixed_t x, fixed_t y) { node_t *node; int side; // single subsector is a special case if (level.nodes.Size() == 0) return &level.subsectors[0]; node = level.HeadNode(); do { side = R_PointOnSide (x, y, node); node = (node_t *)node->children[side]; } while (!((size_t)node & 1)); return (subsector_t *)((uint8_t *)node - 1); } //========================================================================== // // R_Init // //========================================================================== void R_Init () { StartScreen->Progress(); // Colormap init moved back to InitPalette() //R_InitColormaps (); //StartScreen->Progress(); R_InitTranslationTables (); R_SetViewSize (screenblocks); Renderer->Init(); } //========================================================================== // // R_Shutdown // //========================================================================== void R_Shutdown () { FCanvasTextureInfo::EmptyList(); } //========================================================================== // // R_InterpolateView // //========================================================================== //CVAR (Int, tf, 0, 0) EXTERN_CVAR (Bool, cl_noprediction) void R_InterpolateView (FRenderViewpoint &viewpoint, player_t *player, double Frac, InterpolationViewer *iview) { if (NoInterpolateView) { InterpolationPath.Clear(); NoInterpolateView = false; iview->Old = iview->New; } int oldgroup = R_PointInSubsector(iview->Old.Pos)->sector->PortalGroup; int newgroup = R_PointInSubsector(iview->New.Pos)->sector->PortalGroup; DAngle oviewangle = iview->Old.Angles.Yaw; DAngle nviewangle = iview->New.Angles.Yaw; if (!cl_capfps) { if ((iview->Old.Pos.X != iview->New.Pos.X || iview->Old.Pos.Y != iview->New.Pos.Y) && InterpolationPath.Size() > 0) { DVector3 view = iview->New.Pos; // Interpolating through line portals is a messy affair. // What needs be done is to store the portal transitions of the camera actor as waypoints // and then find out on which part of the path the current view lies. // Needless to say, this doesn't work for chasecam mode. if (!viewpoint.showviewer) { double pathlen = 0; double zdiff = 0; double totalzdiff = 0; DAngle adiff = 0.; DAngle totaladiff = 0.; double oviewz = iview->Old.Pos.Z; double nviewz = iview->New.Pos.Z; DVector3a oldpos = { { iview->Old.Pos.X, iview->Old.Pos.Y, 0 }, 0. }; DVector3a newpos = { { iview->New.Pos.X, iview->New.Pos.Y, 0 }, 0. }; InterpolationPath.Push(newpos); // add this to the array to simplify the loops below for (unsigned i = 0; i < InterpolationPath.Size(); i += 2) { DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; DVector3a &end = InterpolationPath[i]; pathlen += (end.pos - start.pos).Length(); totalzdiff += start.pos.Z; totaladiff += start.angle; } double interpolatedlen = Frac * pathlen; for (unsigned i = 0; i < InterpolationPath.Size(); i += 2) { DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; DVector3a &end = InterpolationPath[i]; double fraglen = (end.pos - start.pos).Length(); zdiff += start.pos.Z; adiff += start.angle; if (fraglen <= interpolatedlen) { interpolatedlen -= fraglen; } else { double fragfrac = interpolatedlen / fraglen; oviewz += zdiff; nviewz -= totalzdiff - zdiff; oviewangle += adiff; nviewangle -= totaladiff - adiff; DVector2 viewpos = start.pos + (fragfrac * (end.pos - start.pos)); viewpoint.Pos = { viewpos, oviewz + Frac * (nviewz - oviewz) }; break; } } InterpolationPath.Pop(); viewpoint.Path[0] = iview->Old.Pos; viewpoint.Path[1] = viewpoint.Path[0] + (InterpolationPath[0].pos - viewpoint.Path[0]).XY().MakeResize(pathlen); } } else { DVector2 disp = Displacements.getOffset(oldgroup, newgroup); viewpoint.Pos = iview->Old.Pos + (iview->New.Pos - iview->Old.Pos - disp) * Frac; viewpoint.Path[0] = viewpoint.Path[1] = iview->New.Pos; } } else { viewpoint.Pos = iview->New.Pos; viewpoint.Path[0] = viewpoint.Path[1] = iview->New.Pos; } if (player != NULL && !(player->cheats & CF_INTERPVIEW) && player - players == consoleplayer && viewpoint.camera == player->mo && !demoplayback && iview->New.Pos.X == viewpoint.camera->X() && iview->New.Pos.Y == viewpoint.camera->Y() && !(player->cheats & (CF_TOTALLYFROZEN|CF_FROZEN)) && player->playerstate == PST_LIVE && player->mo->reactiontime == 0 && !NoInterpolateView && !paused && (!netgame || !cl_noprediction) && !LocalKeyboardTurner) { viewpoint.Angles.Yaw = (nviewangle + AngleToFloat(LocalViewAngle & 0xFFFF0000)).Normalized180(); DAngle delta = player->centering ? DAngle(0.) : AngleToFloat(int(LocalViewPitch & 0xFFFF0000)); viewpoint.Angles.Pitch = clamp<DAngle>((iview->New.Angles.Pitch - delta).Normalized180(), player->MinPitch, player->MaxPitch); viewpoint.Angles.Roll = iview->New.Angles.Roll.Normalized180(); } else { viewpoint.Angles.Pitch = (iview->Old.Angles.Pitch + deltaangle(iview->Old.Angles.Pitch, iview->New.Angles.Pitch) * Frac).Normalized180(); viewpoint.Angles.Yaw = (oviewangle + deltaangle(oviewangle, nviewangle) * Frac).Normalized180(); viewpoint.Angles.Roll = (iview->Old.Angles.Roll + deltaangle(iview->Old.Angles.Roll, iview->New.Angles.Roll) * Frac).Normalized180(); } // Due to interpolation this is not necessarily the same as the sector the camera is in. viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector; bool moved = false; while (!viewpoint.sector->PortalBlocksMovement(sector_t::ceiling)) { if (viewpoint.Pos.Z > viewpoint.sector->GetPortalPlaneZ(sector_t::ceiling)) { viewpoint.Pos += viewpoint.sector->GetPortalDisplacement(sector_t::ceiling); viewpoint.ActorPos += viewpoint.sector->GetPortalDisplacement(sector_t::ceiling); viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector; moved = true; } else break; } if (!moved) { while (!viewpoint.sector->PortalBlocksMovement(sector_t::floor)) { if (viewpoint.Pos.Z < viewpoint.sector->GetPortalPlaneZ(sector_t::floor)) { viewpoint.Pos += viewpoint.sector->GetPortalDisplacement(sector_t::floor); viewpoint.ActorPos += viewpoint.sector->GetPortalDisplacement(sector_t::floor); viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector; moved = true; } else break; } } } //========================================================================== // // R_ResetViewInterpolation // //========================================================================== void R_ResetViewInterpolation () { InterpolationPath.Clear(); NoInterpolateView = true; } //========================================================================== // // R_SetViewAngle // //========================================================================== void R_SetViewAngle (FRenderViewpoint &viewpoint, const FViewWindow &viewwindow) { viewpoint.Sin = viewpoint.Angles.Yaw.Sin(); viewpoint.Cos = viewpoint.Angles.Yaw.Cos(); viewpoint.TanSin = viewwindow.FocalTangent * viewpoint.Sin; viewpoint.TanCos = viewwindow.FocalTangent * viewpoint.Cos; } //========================================================================== // // FindPastViewer // //========================================================================== static InterpolationViewer *FindPastViewer (AActor *actor) { for (unsigned int i = 0; i < PastViewers.Size(); ++i) { if (PastViewers[i].ViewActor == actor) { return &PastViewers[i]; } } // Not found, so make a new one InterpolationViewer iview; memset(&iview, 0, sizeof(iview)); iview.ViewActor = actor; iview.otic = -1; InterpolationPath.Clear(); return &PastViewers[PastViewers.Push (iview)]; } //========================================================================== // // R_FreePastViewers // //========================================================================== void R_FreePastViewers () { InterpolationPath.Clear(); PastViewers.Clear (); } //========================================================================== // // R_ClearPastViewer // // If the actor changed in a non-interpolatable way, remove it. // //========================================================================== void R_ClearPastViewer (AActor *actor) { InterpolationPath.Clear(); for (unsigned int i = 0; i < PastViewers.Size(); ++i) { if (PastViewers[i].ViewActor == actor) { // Found it, so remove it. if (i == PastViewers.Size()) { PastViewers.Delete (i); } else { PastViewers.Pop (PastViewers[i]); } } } } //========================================================================== // // R_RebuildViewInterpolation // //========================================================================== void R_RebuildViewInterpolation(player_t *player) { if (player == NULL || player->camera == NULL) return; if (!NoInterpolateView) return; NoInterpolateView = false; InterpolationViewer *iview = FindPastViewer(player->camera); iview->Old = iview->New; InterpolationPath.Clear(); } //========================================================================== // // R_GetViewInterpolationStatus // //========================================================================== bool R_GetViewInterpolationStatus() { return NoInterpolateView; } //========================================================================== // // R_ClearInterpolationPath // //========================================================================== void R_ClearInterpolationPath() { InterpolationPath.Clear(); } //========================================================================== // // R_AddInterpolationPoint // //========================================================================== void R_AddInterpolationPoint(const DVector3a &vec) { InterpolationPath.Push(vec); } //========================================================================== // // QuakePower // //========================================================================== static double QuakePower(double factor, double intensity, double offset) { double randumb; if (intensity == 0) { randumb = 0; } else { randumb = pr_torchflicker.GenRand_Real2() * (intensity * 2) - intensity; } return factor * (offset + randumb); } //========================================================================== // // R_SetupFrame // //========================================================================== void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor *actor) { if (actor == NULL) { I_Error ("Tried to render from a NULL actor."); } player_t *player = actor->player; unsigned int newblend; InterpolationViewer *iview; bool unlinked = false; if (player != NULL && player->mo == actor) { // [RH] Use camera instead of viewplayer viewpoint.camera = player->camera; if (viewpoint.camera == NULL) { viewpoint.camera = player->camera = player->mo; } } else { viewpoint.camera = actor; } if (viewpoint.camera == NULL) { I_Error ("You lost your body. Bad dehacked work is likely to blame."); } iview = FindPastViewer (viewpoint.camera); int nowtic = I_GetTime (); if (iview->otic != -1 && nowtic > iview->otic) { iview->otic = nowtic; iview->Old = iview->New; } if (player != NULL && gamestate != GS_TITLELEVEL && ((player->cheats & CF_CHASECAM) || (r_deathcamera && viewpoint.camera->health <= 0))) { sector_t *oldsector = R_PointInSubsector(iview->Old.Pos)->sector; // [RH] Use chasecam view DVector3 campos; DAngle camangle; P_AimCamera (viewpoint.camera, campos, camangle, viewpoint.sector, unlinked); // fixme: This needs to translate the angle, too. iview->New.Pos = campos; iview->New.Angles.Yaw = camangle; viewpoint.showviewer = true; // Interpolating this is a very complicated thing because nothing keeps track of the aim camera's movement, so whenever we detect a portal transition // it's probably best to just reset the interpolation for this move. // Note that this can still cause problems with unusually linked portals if (viewpoint.sector->PortalGroup != oldsector->PortalGroup || (unlinked && ((iview->New.Pos.XY() - iview->Old.Pos.XY()).LengthSquared()) > 256*256)) { iview->otic = nowtic; iview->Old = iview->New; r_NoInterpolate = true; } viewpoint.ActorPos = campos; } else { viewpoint.ActorPos = iview->New.Pos = { viewpoint.camera->Pos().XY(), viewpoint.camera->player ? viewpoint.camera->player->viewz : viewpoint.camera->Z() + viewpoint.camera->GetCameraHeight() }; viewpoint.sector = viewpoint.camera->Sector; viewpoint.showviewer = false; } iview->New.Angles = viewpoint.camera->Angles; if (viewpoint.camera->player != 0) { player = viewpoint.camera->player; } if (iview->otic == -1 || r_NoInterpolate) { R_ResetViewInterpolation (); iview->otic = nowtic; } viewpoint.TicFrac = I_GetTimeFrac (); if (cl_capfps || r_NoInterpolate) { viewpoint.TicFrac = 1.; } R_InterpolateView (viewpoint, player, viewpoint.TicFrac, iview); R_SetViewAngle (viewpoint, viewwindow); interpolator.DoInterpolations (viewpoint.TicFrac); // Keep the view within the sector's floor and ceiling if (viewpoint.sector->PortalBlocksMovement(sector_t::ceiling)) { double theZ = viewpoint.sector->ceilingplane.ZatPoint(viewpoint.Pos) - 4; if (viewpoint.Pos.Z > theZ) { viewpoint.Pos.Z = theZ; } } if (viewpoint.sector->PortalBlocksMovement(sector_t::floor)) { double theZ = viewpoint.sector->floorplane.ZatPoint(viewpoint.Pos) + 4; if (viewpoint.Pos.Z < theZ) { viewpoint.Pos.Z = theZ; } } if (!paused) { FQuakeJiggers jiggers; memset(&jiggers, 0, sizeof(jiggers)); if (DEarthquake::StaticGetQuakeIntensities(viewpoint.TicFrac, viewpoint.camera, jiggers) > 0) { double quakefactor = r_quakeintensity; DVector3 pos; pos.Zero(); if (jiggers.RollIntensity != 0 || jiggers.RollWave != 0) { viewpoint.Angles.Roll += QuakePower(quakefactor, jiggers.RollIntensity, jiggers.RollWave); } if (jiggers.RelIntensity.X != 0 || jiggers.RelOffset.X != 0) { pos.X += QuakePower(quakefactor, jiggers.RelIntensity.X, jiggers.RelOffset.X); } if (jiggers.RelIntensity.Y != 0 || jiggers.RelOffset.Y != 0) { pos.Y += QuakePower(quakefactor, jiggers.RelIntensity.Y, jiggers.RelOffset.Y); } if (jiggers.RelIntensity.Z != 0 || jiggers.RelOffset.Z != 0) { pos.Z += QuakePower(quakefactor, jiggers.RelIntensity.Z, jiggers.RelOffset.Z); } // [MC] Tremendous thanks to Marisa Kirisame for helping me with this. // Use a rotation matrix to make the view relative. if (!pos.isZero()) { DAngle yaw = viewpoint.camera->Angles.Yaw; DAngle pitch = viewpoint.camera->Angles.Pitch; DAngle roll = viewpoint.camera->Angles.Roll; DVector3 relx, rely, relz; DMatrix3x3 rot = DMatrix3x3(DVector3(0., 0., 1.), yaw.Cos(), yaw.Sin()) * DMatrix3x3(DVector3(0., 1., 0.), pitch.Cos(), pitch.Sin()) * DMatrix3x3(DVector3(1., 0., 0.), roll.Cos(), roll.Sin()); relx = DVector3(1., 0., 0.)*rot; rely = DVector3(0., 1., 0.)*rot; relz = DVector3(0., 0., 1.)*rot; viewpoint.Pos += relx * pos.X + rely * pos.Y + relz * pos.Z; } if (jiggers.Intensity.X != 0 || jiggers.Offset.X != 0) { viewpoint.Pos.X += QuakePower(quakefactor, jiggers.Intensity.X, jiggers.Offset.X); } if (jiggers.Intensity.Y != 0 || jiggers.Offset.Y != 0) { viewpoint.Pos.Y += QuakePower(quakefactor, jiggers.Intensity.Y, jiggers.Offset.Y); } if (jiggers.Intensity.Z != 0 || jiggers.Offset.Z != 0) { viewpoint.Pos.Z += QuakePower(quakefactor, jiggers.Intensity.Z, jiggers.Offset.Z); } } } viewpoint.extralight = viewpoint.camera->player ? viewpoint.camera->player->extralight : 0; // killough 3/20/98, 4/4/98: select colormap based on player status // [RH] Can also select a blend newblend = 0; TArray<lightlist_t> &lightlist = viewpoint.sector->e->XFloor.lightlist; if (lightlist.Size() > 0) { for(unsigned int i = 0; i < lightlist.Size(); i++) { secplane_t *plane; int viewside; plane = (i < lightlist.Size()-1) ? &lightlist[i+1].plane : &viewpoint.sector->floorplane; viewside = plane->PointOnSide(viewpoint.Pos); // Reverse the direction of the test if the plane was downward facing. // We want to know if the view is above it, whatever its orientation may be. if (plane->fC() < 0) viewside = -viewside; if (viewside > 0) { // 3d floor 'fog' is rendered as a blending value PalEntry blendv = lightlist[i].blend; // If no alpha is set, use 50% if (blendv.a==0 && blendv!=0) blendv.a=128; newblend = blendv.d; break; } } } else { const sector_t *s = viewpoint.sector->GetHeightSec(); if (s != NULL) { newblend = s->floorplane.PointOnSide(viewpoint.Pos) < 0 ? s->bottommap : s->ceilingplane.PointOnSide(viewpoint.Pos) < 0 ? s->topmap : s->midmap; if (APART(newblend) == 0 && newblend >= fakecmaps.Size()) newblend = 0; } } // [RH] Don't override testblend unless entering a sector with a // blend different from the previous sector's. Same goes with // NormalLight's maps pointer. if (R_OldBlend != newblend) { R_OldBlend = newblend; if (APART(newblend)) { BaseBlendR = RPART(newblend); BaseBlendG = GPART(newblend); BaseBlendB = BPART(newblend); BaseBlendA = APART(newblend) / 255.f; } else { BaseBlendR = BaseBlendG = BaseBlendB = 0; BaseBlendA = 0.f; } } validcount++; if (r_clearbuffer != 0) { int color; int hom = r_clearbuffer; if (hom == 3) { hom = ((screen->FrameTime / 128) & 1) + 1; } if (hom == 1) { color = GPalette.BlackIndex; } else if (hom == 2) { color = GPalette.WhiteIndex; } else if (hom == 4) { color = (screen->FrameTime / 32) & 255; } else { color = pr_hom(); } Renderer->SetClearColor(color); } } //========================================================================== // // FCanvasTextureInfo :: Add // // Assigns a camera to a canvas texture. // //========================================================================== void FCanvasTextureInfo::Add (AActor *viewpoint, FTextureID picnum, double fov) { FCanvasTextureInfo *probe; FCanvasTexture *texture; if (!picnum.isValid()) { return; } texture = static_cast<FCanvasTexture *>(TexMan[picnum]); if (!texture->bHasCanvas) { Printf ("%s is not a valid target for a camera\n", texture->Name.GetChars()); return; } // Is this texture already assigned to a camera? for (probe = List; probe != NULL; probe = probe->Next) { if (probe->Texture == texture) { // Yes, change its assignment to this new camera if (probe->Viewpoint != viewpoint || probe->FOV != fov) { texture->bFirstUpdate = true; } probe->Viewpoint = viewpoint; probe->FOV = fov; return; } } // No, create a new assignment probe = new FCanvasTextureInfo; probe->Viewpoint = viewpoint; probe->Texture = texture; probe->PicNum = picnum; probe->FOV = fov; probe->Next = List; texture->bFirstUpdate = true; List = probe; } // [ZZ] expose this to ZScript void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fov) { FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); if (textureid.isValid()) { // Only proceed if the texture actually has a canvas. FTexture *tex = TexMan[textureid]; if (tex && tex->bHasCanvas) { FCanvasTextureInfo::Add(viewpoint, textureid, fov); } } } DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture) { PARAM_PROLOGUE; PARAM_OBJECT(viewpoint, AActor); PARAM_STRING(texturename); // [ZZ] there is no point in having this as FTextureID because it's easier to refer to a cameratexture by name and it isn't executed too often to cache it. PARAM_FLOAT(fov); SetCameraToTexture(viewpoint, texturename, fov); return 0; } //========================================================================== // // FCanvasTextureInfo :: UpdateAll // // Updates all canvas textures that were visible in the last frame. // //========================================================================== void FCanvasTextureInfo::UpdateAll () { FCanvasTextureInfo *probe; for (probe = List; probe != NULL; probe = probe->Next) { if (probe->Viewpoint != NULL && probe->Texture->bNeedsUpdate) { Renderer->RenderTextureView(probe->Texture, probe->Viewpoint, probe->FOV); } } } //========================================================================== // // FCanvasTextureInfo :: EmptyList // // Removes all camera->texture assignments. // //========================================================================== void FCanvasTextureInfo::EmptyList () { FCanvasTextureInfo *probe, *next; for (probe = List; probe != NULL; probe = next) { next = probe->Next; probe->Texture->Unload(); delete probe; } List = NULL; } //========================================================================== // // FCanvasTextureInfo :: Serialize // // Reads or writes the current set of mappings in an archive. // //========================================================================== void FCanvasTextureInfo::Serialize(FSerializer &arc) { if (arc.isWriting()) { if (List != nullptr) { if (arc.BeginArray("canvastextures")) { FCanvasTextureInfo *probe; for (probe = List; probe != nullptr; probe = probe->Next) { if (probe->Texture != nullptr && probe->Viewpoint != nullptr) { if (arc.BeginObject(nullptr)) { arc("viewpoint", probe->Viewpoint) ("fov", probe->FOV) ("texture", probe->PicNum) .EndObject(); } } } arc.EndArray(); } } } else { if (arc.BeginArray("canvastextures")) { AActor *viewpoint = nullptr; double fov; FTextureID picnum; while (arc.BeginObject(nullptr)) { arc("viewpoint", viewpoint) ("fov", fov) ("texture", picnum) .EndObject(); Add(viewpoint, picnum, fov); } arc.EndArray(); } } } //========================================================================== // // FCanvasTextureInfo :: Mark // // Marks all viewpoints in the list for the collector. // //========================================================================== void FCanvasTextureInfo::Mark() { for (FCanvasTextureInfo *probe = List; probe != NULL; probe = probe->Next) { GC::Mark(probe->Viewpoint); } } //========================================================================== // // CVAR transsouls // // How translucent things drawn with STYLE_SoulTrans are. Normally, only // Lost Souls have this render style. // Values less than 0.25 will automatically be set to // 0.25 to ensure some degree of visibility. Likewise, values above 1.0 will // be set to 1.0, because anything higher doesn't make sense. // //========================================================================== CUSTOM_CVAR(Float, transsouls, 0.75f, CVAR_ARCHIVE) { if (self < 0.25f) { self = 0.25f; } else if (self > 1.f) { self = 1.f; } } CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE | CVAR_SERVERINFO) { if (self>90.f) self = 90.f; else if (self<-90.f) self = -90.f; if (usergame) { // [SP] Update pitch limits to the netgame/gamesim. players[consoleplayer].SendPitchLimits(); } }
27.358475
195
0.582041
protocultor
4f1bea9165ac077f1d67cf85a7f116ae9d8c33d7
732
cpp
C++
src/Readers/GenMETReader.cpp
jjacob/AnalysisSoftware
670513bcde9c3df46077f906246e912627ee251a
[ "Apache-2.0" ]
null
null
null
src/Readers/GenMETReader.cpp
jjacob/AnalysisSoftware
670513bcde9c3df46077f906246e912627ee251a
[ "Apache-2.0" ]
null
null
null
src/Readers/GenMETReader.cpp
jjacob/AnalysisSoftware
670513bcde9c3df46077f906246e912627ee251a
[ "Apache-2.0" ]
null
null
null
/* * GenMETReader.cpp * * Created on: Jul 9, 2012 * Author: phzss */ #include "../../interface/Readers/GenMETReader.h" namespace BAT { GenMETReader::GenMETReader() : exReader(),// eyReader(),// genMET_() { } GenMETReader::GenMETReader(TChainPointer input) : exReader(input, "GenMET.ExTrue"), // eyReader(input, "GenMET.EyTrue"), // genMET_() { } GenMETReader::~GenMETReader() { } //MC content only void GenMETReader::initialise() { exReader.initialiseBlindly(); eyReader.initialiseBlindly(); } const METPointer GenMETReader::getGenMET() { readGenMET(); return genMET_; } void GenMETReader::readGenMET() { genMET_ = METPointer(new MET(exReader.getVariableAt(0), eyReader.getVariableAt(0))); } }
16.636364
85
0.685792
jjacob
4f1c3eba82e7e3b0a78a6eb8bbf7a3ca78280a0e
1,686
cpp
C++
src/knMotor/WheelGroupSample.cpp
hhutz/kn_wheel_group
18ed3220bd46282ec9cbe38e8a573e6f2de49f05
[ "NASA-1.3" ]
null
null
null
src/knMotor/WheelGroupSample.cpp
hhutz/kn_wheel_group
18ed3220bd46282ec9cbe38e8a573e6f2de49f05
[ "NASA-1.3" ]
null
null
null
src/knMotor/WheelGroupSample.cpp
hhutz/kn_wheel_group
18ed3220bd46282ec9cbe38e8a573e6f2de49f05
[ "NASA-1.3" ]
null
null
null
/* -*- C++ -*- ***************************************************************** * Copyright (c) 2013 United States Government as represented by the * Administrator of the National Aeronautics and Space Administration. * All rights reserved. * * Licensed under the NASA Open Source Agreement, Version 1.3 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://opensource.org/licenses/NASA-1.3 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************** * * Project: RoverSw * Module: knMotor * Author: Hans Utz * *****************************************************************************/ #include "WheelGroupSample.h" #include <iostream> namespace kn { using namespace std; std::ostream& operator<< (std::ostream& ostr, WheelGroupSample const& rhs) { ostr << "{" << static_cast<MotorGroupSample const&>(rhs) << ", " << endl << " " << rhs.curvature << ", " << rhs.curvatureRate << ", " << rhs.speed << ", " << rhs.crabAngle << ", " << endl << " " << rhs.targetCurvature << ", " << rhs.targetCurvatureRate << ", " << rhs.targetSpeed << ", " << rhs.targetCrabAngle << ", " << rhs.targetCrabRate << "}"; return ostr; } }
33.058824
80
0.541518
hhutz
b7b4cc2ceeaca61f766274be7fbc063959f1fd1f
9,423
cpp
C++
src/plugins/opls/oplsatomtyper.cpp
quizzmaster/chemkit
803e4688b514008c605cb5c7790f7b36e67b68fc
[ "BSD-3-Clause" ]
34
2015-01-24T23:59:41.000Z
2020-11-12T13:48:01.000Z
src/plugins/opls/oplsatomtyper.cpp
soplwang/chemkit
d62b7912f2d724a05fa8be757f383776fdd5bbcb
[ "BSD-3-Clause" ]
4
2015-12-28T20:29:16.000Z
2016-01-26T06:48:19.000Z
src/plugins/opls/oplsatomtyper.cpp
soplwang/chemkit
d62b7912f2d724a05fa8be757f383776fdd5bbcb
[ "BSD-3-Clause" ]
17
2015-01-23T14:50:24.000Z
2021-06-10T15:43:50.000Z
/****************************************************************************** ** ** Copyright (C) 2009-2011 Kyle Lutz <kyle.r.lutz@gmail.com> ** All rights reserved. ** ** This file is a part of the chemkit project. For more information ** see <http://www.chemkit.org>. ** ** 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 chemkit project 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. ** ******************************************************************************/ #include "oplsatomtyper.h" // --- Construction and Destruction ---------------------------------------- // OplsAtomTyper::OplsAtomTyper(const chemkit::Molecule *molecule) : chemkit::AtomTyper("opls") { setMolecule(molecule); } OplsAtomTyper::~OplsAtomTyper() { } // --- Properties ---------------------------------------------------------- // void OplsAtomTyper::setMolecule(const chemkit::Molecule *molecule) { chemkit::AtomTyper::setMolecule(molecule); if(!molecule){ m_typeNumbers.resize(0); return; } m_typeNumbers = std::vector<int>(molecule->atomCount()); for(size_t index = 0; index < molecule->atomCount(); index++){ const chemkit::Atom *atom = molecule->atom(index); // hydrogen if(atom->is(chemkit::Atom::Hydrogen)){ if(atom->isTerminal()){ const chemkit::Atom *neighbor = atom->neighbor(0); if(neighbor->is(chemkit::Atom::Oxygen)){ if(neighbor->neighborCount() == 2 && neighbor->neighborCount(chemkit::Atom::Hydrogen) == 2){ setTypeNumber(index, 76); // SPC hydrogen in water (HW) } else{ setTypeNumber(index, 94); // hydrogen in alcohol (HO) } } else if(neighbor->is(chemkit::Atom::Carbon)){ setTypeNumber(index, 82); // alkane C-H } else if(neighbor->is(chemkit::Atom::Nitrogen)){ if(neighbor->neighborCount(chemkit::Atom::Hydrogen) == 3){ setTypeNumber(index, 70); // hydrogen in ammonia (H) } } } } // helium else if(atom->is(chemkit::Atom::Helium)){ setTypeNumber(index, 43); // helium atom } // lithium else if(atom->is(chemkit::Atom::Lithium)){ setTypeNumber(index, 345); // lithium 1+ ion (Li) } // carbon else if(atom->is(chemkit::Atom::Carbon)){ if(atom->neighborCount() == 4){ if(atom->neighborCount(chemkit::Atom::Carbon) == 2){ setTypeNumber(index, 78); // alkane -CH2- } else if(atom->neighborCount(chemkit::Atom::Carbon) == 1 && atom->neighborCount(chemkit::Atom::Hydrogen) == 3){ setTypeNumber(index, 77); // alkane -CH3 } else if(atom->neighborCount(chemkit::Atom::Oxygen) == 1){ setTypeNumber(index, 96); // alcohol CH3OH } } else if(atom->neighborCount() == 3){ if(atom->isAromatic()){ setTypeNumber(index, 87); // aromatic carbon } } } // nitrogen else if(atom->is(chemkit::Atom::Nitrogen)){ if(atom->neighborCount() == 3){ if(atom->neighborCount(chemkit::Atom::Hydrogen) == 3){ setTypeNumber(index, 69); // nitrogen in ammonia (NT) } } } // oxygen else if(atom->is(chemkit::Atom::Oxygen)){ if(atom->neighborCount() == 1){ const chemkit::Atom *neighbor = atom->neighbor(0); const chemkit::Bond *neighborBond = atom->bonds()[0]; if(neighbor->is(chemkit::Atom::Carbon) && neighborBond->order() == chemkit::Bond::Double){ setTypeNumber(index, 220); // ketone C=O (O) } } else if(atom->neighborCount() == 2){ if(atom->neighborCount(chemkit::Atom::Hydrogen) == 2){ setTypeNumber(index, 75); // SPC oxygen in water (OW) } else if(atom->neighborCount(chemkit::Atom::Hydrogen) == 1){ setTypeNumber(index, 93); // oxygen in alcohol (OH) } } } // fluorine else if(atom->is(chemkit::Atom::Fluorine)){ if(atom->formalCharge() < 0){ setTypeNumber(index, 340); // fluoride ion (F) } } // neon else if(atom->is(chemkit::Atom::Neon)){ setTypeNumber(index, 44); // neon atom } // sodium else if(atom->is(chemkit::Atom::Sodium)){ setTypeNumber(index, 346); // sodium ion } // magnesium else if(atom->is(chemkit::Atom::Magnesium)){ setTypeNumber(index, 350); // magnesium ion (Mg) } // phosphorus else if(atom->is(chemkit::Atom::Phosphorus)){ if(atom->neighborCount() == 4){ if(atom->neighborCount(chemkit::Atom::Oxygen) > 0){ setTypeNumber(index, 378); // phosphate P } } } // sulfur else if(atom->is(chemkit::Atom::Sulfur)){ if(atom->neighborCount() == 2){ if(atom->neighborCount(chemkit::Atom::Hydrogen) == 1){ setTypeNumber(index, 139); // sulfur in thiol (SH) } else if(atom->neighborCount(chemkit::Atom::Hydrogen) == 2){ setTypeNumber(index, 140); // sulfur in hydrogen sulfide (SH) } else if(atom->neighborCount(chemkit::Atom::Sulfur) == 1){ setTypeNumber(index, 142); // disulfide -S-S- (S) } else{ setTypeNumber(index, 141); // sulfide -S- (S) } } } // chlorine else if(atom->is(chemkit::Atom::Chlorine)){ if(atom->formalCharge() < 0){ setTypeNumber(index, 341); // chloride ion (Cl) } } // argon else if(atom->is(chemkit::Atom::Argon)){ setTypeNumber(index, 45); // argon atom } // potassium else if(atom->is(chemkit::Atom::Potassium)){ setTypeNumber(index, 347); // potassium 1+ ion (K) } // calcium else if(atom->is(chemkit::Atom::Calcium)){ setTypeNumber(index, 351); // calcium 2+ ion (Ca) } // zinc else if(atom->is(chemkit::Atom::Zinc)){ if(atom->formalCharge() == 2){ setTypeNumber(index, 834); // zinc 2+ ion (Zn) } } // bromine else if(atom->is(chemkit::Atom::Bromine)){ if(atom->formalCharge() < 0){ setTypeNumber(index, 342); // bromide ion (Br) } } // krypton else if(atom->is(chemkit::Atom::Krypton)){ setTypeNumber(index, 46); // krypton atom } // iodine else if(atom->is(chemkit::Atom::Iodine)){ setTypeNumber(index, 343); // iodide ion (I) } // xenon else if(atom->is(chemkit::Atom::Xenon)){ setTypeNumber(index, 47); // xenon atom } } } // --- Types --------------------------------------------------------------- // std::string OplsAtomTyper::type(const chemkit::Atom *atom) const { return boost::lexical_cast<std::string>(m_typeNumbers[atom->index()]); } void OplsAtomTyper::setTypeNumber(int index, int typeNumber) { m_typeNumbers[index] = typeNumber; } int OplsAtomTyper::typeNumber(const chemkit::Atom *atom) const { return m_typeNumbers[atom->index()]; }
38.304878
106
0.519898
quizzmaster
b7b8652b33682cdf1d93575f77c3fc2e073dd2ef
602
cpp
C++
DEMCUASO.cpp
phuongnam2002/testlib
a5cb8e2be7ac7a7e7dca7942a79ec20076f5d1aa
[ "MIT" ]
2
2022-01-14T13:34:09.000Z
2022-02-21T07:27:29.000Z
DEMCUASO.cpp
phuongnam2002/testlib
a5cb8e2be7ac7a7e7dca7942a79ec20076f5d1aa
[ "MIT" ]
null
null
null
DEMCUASO.cpp
phuongnam2002/testlib
a5cb8e2be7ac7a7e7dca7942a79ec20076f5d1aa
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; int main () { int n, m; cin>>m>>n; char Building[600][600]; for (int i=0; i<5*m+1; i++) { for (int j=0; j<5*n+1; j++) { cin>>Building[i][j]; } } int tt[]={0, 0, 0, 0, 0}; int t=0; int dauI=1, dauJ=1; for (int i=0; i<m; i++) { if (i!=0) dauI+=5; dauJ=1; for (int j=0; j<n; j++) { if (j!=0) dauJ+=5; tt[0]++; for (int k=0; k<4; k++) { if (Building[dauI+k][dauJ]=='*') { tt[k+1]++; tt[k]--; } } } } for (int i=0; i<5; i++) cout<<tt[i]<<" "; return 0; }
15.05
43
0.405316
phuongnam2002
b7bab5d00a61006828984a29123eeb94d262d13e
234
inl
C++
TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.inl
cflowe/ACE
5ff60b41adbe1772372d1a43bcc1f2726ff8f810
[ "DOC" ]
36
2015-01-10T07:27:33.000Z
2022-03-07T03:32:08.000Z
TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.inl
cflowe/ACE
5ff60b41adbe1772372d1a43bcc1f2726ff8f810
[ "DOC" ]
2
2018-08-13T07:30:51.000Z
2019-02-25T03:04:31.000Z
TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.inl
cflowe/ACE
5ff60b41adbe1772372d1a43bcc1f2726ff8f810
[ "DOC" ]
38
2015-01-08T14:12:06.000Z
2022-01-19T08:33:00.000Z
/** * @file Implicit_Deactivator.inl * * $Id: Implicit_Deactivator.inl 43909 2002-03-09 00:13:51Z coryan $ * * @author Carlos O'Ryan <coryan@uci.edu> */ ACE_INLINE void Implicit_Deactivator::release (void) { this->id_ = 0; }
16.714286
68
0.683761
cflowe
b7bb751b14dbdb5e2313c7bafb7f8c13dd0c200b
688
hpp
C++
include/cand/can.hpp
zenitheesc/CAND
f746b7fce2e63453f25dbb82810f461b4f05190e
[ "Unlicense" ]
null
null
null
include/cand/can.hpp
zenitheesc/CAND
f746b7fce2e63453f25dbb82810f461b4f05190e
[ "Unlicense" ]
7
2021-11-20T16:31:42.000Z
2022-02-23T14:09:13.000Z
include/cand/can.hpp
zenitheesc/cand
f746b7fce2e63453f25dbb82810f461b4f05190e
[ "Unlicense" ]
null
null
null
#pragma once #include <cstring> #include <iomanip> #include <iostream> #include <string> #include <unistd.h> #include <vector> #include <net/if.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <linux/can.h> #include <linux/can/raw.h> class CAN { private: int m_fileDescriptor; std::string m_interfaceName; public: CAN(const std::string&); ~CAN(); void socketWrite(const struct can_frame&); auto getFileDescriptor() const -> int; void setFilter(const struct can_filter&); }; const CAN& operator<<(CAN&, struct can_frame&); const struct can_frame& operator>>(CAN&, struct can_frame&); std::ostream& operator<<(std::ostream&, struct can_frame&);
20.235294
60
0.696221
zenitheesc
b7c0d771b0b5697979aaf28bc3fd464c46f851eb
954
cpp
C++
PrCmp/LeetCode/w3e2.cpp
ayhon/CPPWorkspace
57d6410236096ffa0bae20b88b3e330632edc928
[ "MIT" ]
null
null
null
PrCmp/LeetCode/w3e2.cpp
ayhon/CPPWorkspace
57d6410236096ffa0bae20b88b3e330632edc928
[ "MIT" ]
null
null
null
PrCmp/LeetCode/w3e2.cpp
ayhon/CPPWorkspace
57d6410236096ffa0bae20b88b3e330632edc928
[ "MIT" ]
null
null
null
#include <iostream> #include <vector> #include <stack> #include <queue> #include <string> using namespace std; bool checkValidString(string s) { stack<pair<char, int>> pila; deque<int> stars; for(int i = 0; i < s.size(); i++) { if(s[i] == '{') pila.push(make_pair(s[i], i)); else if (s[i] == '}') { if(!pila.empty() && pila.top().first != '}') pila.pop(); else pila.push(make_pair('}', i)); } else if (s[i] == '*') stars.push_back(i); } if(pila.empty()) { return true; } else { bool ok = true; while(!pila.empty() && pila.top().first == '{' && ok) { if(stars.back() < pila.top().second) ok = false; else { stars.pop_back(); pila.pop(); } } while(!pila.empty() && ok) { if(stars.front() > pila.top().second) ok = false; else { stars.pop_front(); pila.pop(); } } return ok; } } int main() { string s; cin >> s; cout << (checkValidString(s)? "Válido" : "No válido") << '\n'; }
19.875
63
0.541929
ayhon
b7c825f624e2bd7eac8956f9f195c383a0d262cb
2,888
cpp
C++
modules/gapi/src/api/kernels_video.cpp
tailsu/opencv
743f1810c7ad4895b0df164395abfb54c9e8015d
[ "Apache-2.0" ]
3
2020-06-18T07:35:48.000Z
2021-06-14T15:34:25.000Z
modules/gapi/src/api/kernels_video.cpp
tailsu/opencv
743f1810c7ad4895b0df164395abfb54c9e8015d
[ "Apache-2.0" ]
3
2019-08-28T14:18:49.000Z
2020-02-11T10:02:57.000Z
modules/gapi/src/api/kernels_video.cpp
tailsu/opencv
743f1810c7ad4895b0df164395abfb54c9e8015d
[ "Apache-2.0" ]
1
2021-04-20T08:12:22.000Z
2021-04-20T08:12:22.000Z
// This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // // Copyright (C) 2020 Intel Corporation #include "precomp.hpp" #include <opencv2/gapi/video.hpp> namespace cv { namespace gapi { using namespace video; GBuildPyrOutput buildOpticalFlowPyramid(const GMat &img, const Size &winSize, const GScalar &maxLevel, bool withDerivatives, int pyrBorder, int derivBorder, bool tryReuseInputImage) { return GBuildOptFlowPyramid::on(img, winSize, maxLevel, withDerivatives, pyrBorder, derivBorder, tryReuseInputImage); } GOptFlowLKOutput calcOpticalFlowPyrLK(const GMat &prevImg, const GMat &nextImg, const cv::GArray<cv::Point2f> &prevPts, const cv::GArray<cv::Point2f> &predPts, const Size &winSize, const GScalar &maxLevel, const TermCriteria &criteria, int flags, double minEigThresh) { return GCalcOptFlowLK::on(prevImg, nextImg, prevPts, predPts, winSize, maxLevel, criteria, flags, minEigThresh); } GOptFlowLKOutput calcOpticalFlowPyrLK(const cv::GArray<cv::GMat> &prevPyr, const cv::GArray<cv::GMat> &nextPyr, const cv::GArray<cv::Point2f> &prevPts, const cv::GArray<cv::Point2f> &predPts, const Size &winSize, const GScalar &maxLevel, const TermCriteria &criteria, int flags, double minEigThresh) { return GCalcOptFlowLKForPyr::on(prevPyr, nextPyr, prevPts, predPts, winSize, maxLevel, criteria, flags, minEigThresh); } GMat BackgroundSubtractor(const GMat& src, const BackgroundSubtractorParams& bsp) { return GBackgroundSubtractor::on(src, bsp); } } //namespace gapi } //namespace cv
46.580645
90
0.441828
tailsu
b7cc715ec2ea825ba120709b548e5c4eb2a3696d
32,912
cpp
C++
csgocheat/hacks/c_ragebot.cpp
garryhvh420/e_xyz
668d8c8c2b7ccfc3bae9e321b1a50379a5e33ec9
[ "Apache-2.0" ]
null
null
null
csgocheat/hacks/c_ragebot.cpp
garryhvh420/e_xyz
668d8c8c2b7ccfc3bae9e321b1a50379a5e33ec9
[ "Apache-2.0" ]
null
null
null
csgocheat/hacks/c_ragebot.cpp
garryhvh420/e_xyz
668d8c8c2b7ccfc3bae9e321b1a50379a5e33ec9
[ "Apache-2.0" ]
null
null
null
#include "c_ragebot.h" #include "c_aimhelper.h" #include "c_trace_system.h" #include "../utils/math.h" #include "../sdk/c_weapon_system.h" #include "../sdk/c_debug_overlay.h" #include "c_prediction_system.h" #include "c_antiaim.h" #include "c_resolver.h" #include "../menu/c_menu.h" #include "../hacks/c_hitmarker.h" void c_ragebot::aim(c_cs_player* local, c_user_cmd* cmd, bool& send_packet) { last_pitch = std::nullopt; const auto weapon = reinterpret_cast<c_base_combat_weapon*>( client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle())); if (!weapon) return; const auto wpn_info = weapon_system->get_weapon_data(weapon->get_item_definition()); if (!wpn_info) return; if (!local->can_shoot(cmd, global_vars_base->curtime)) return; const auto weapon_cfg = c_aimhelper::get_weapon_conf(); if (!weapon_cfg.has_value()) return; std::vector<aim_info> hitpoints = {}; client_entity_list()->for_each_player([&](c_cs_player* player) -> void { if (!player->is_enemy() || !player->is_alive() || player->get_gun_game_immunity()) return; const auto latest = animation_system->get_latest_animation(player); if (!latest.has_value()) return; const auto rtt = 2.f * net_channel->get_latency(flow_outgoing); const auto breaking_lagcomp = latest.value()->lag && latest.value()->lag <= 17 && is_breaking_lagcomp(latest.value()); const auto can_delay_shot = (latest.value()->lag > time_to_ticks(rtt) + global_vars_base->interval_per_tick); const auto delay_shot = (time_to_ticks(rtt) + time_to_ticks(global_vars_base->curtime - latest.value()->sim_time) + global_vars_base->interval_per_tick >= latest.value()->lag); const auto oldest = animation_system->get_oldest_animation(player); const auto firing = animation_system->get_latest_firing_animation(player); //firing const auto upPitch = animation_system->get_latest_upPitch_animation(player); //uppitch const auto sideways = animation_system->get_latest_sideways_animation(player); //sideways const auto uncrouched = animation_system->get_uncrouched_animation(player); if (breaking_lagcomp && delay_shot && can_delay_shot) return; if (breaking_lagcomp && !can_delay_shot) return; /* priority order://highest chance of hitting firing uppitch sideways uncrouched latest oldest */ /* we could add if the target is sideways to us we could add something to check if its the highest damage potential (kill potential, prio a kill over doing dmg) scan more than first and last */ std::optional<aim_info> aimbot_info; if (firing.has_value()) { const auto alternative = scan_record(local, firing.value());//shooting if (alternative.has_value()) { if (!aimbot_info.has_value() || (alternative.value().damage > aimbot_info.value().damage)) aimbot_info = alternative; } } else if (sideways.has_value()) { const auto alternative = scan_record(local, sideways.value());//sideways fuck desync if (alternative.has_value()) { if (!aimbot_info.has_value() || (alternative.value().damage > aimbot_info.value().damage)) aimbot_info = alternative; } } else if (upPitch.has_value()) { const auto alternative = scan_record(local, upPitch.value());//lookingup if (alternative.has_value()) { if (!aimbot_info.has_value() || (alternative.value().damage > aimbot_info.value().damage)) aimbot_info = alternative; } } else if (!aimbot_info.has_value() && uncrouched.has_value()){//use this only if we have nothing better lol, i suppose this is against fakeduck? const auto alternative = scan_record(local, uncrouched.value());//uncroched cuz we are gay or something? if (alternative.has_value() && (!aimbot_info.has_value() || alternative.value().damage > aimbot_info.value().damage)) aimbot_info = alternative; } else if(!aimbot_info.has_value()){//we are running out of ideas, try some normal stuff const auto alternative = scan_record(local, latest.value());//latest if (alternative.has_value() && (!aimbot_info.has_value() || aimbot_info.value().damage < alternative.value().damage)) aimbot_info = alternative; } else if (!aimbot_info.has_value() && oldest.has_value() && latest.value() != oldest.value() /*&& oldest.value()->velocity.length2d() >= .1f*/) {//no need for velocity check he could have changed angles const auto alternative = scan_record(local, oldest.value()); // is there no other record? if ((alternative.has_value() && !aimbot_info.has_value()) || /*(aimbot_info.has_value() && aimbot_info.value().animation->velocity.length2d() < .1f) ||*///fucking useless (alternative.has_value() && aimbot_info.has_value() && alternative.value().damage > aimbot_info.value().damage)) aimbot_info = alternative; } if (aimbot_info.has_value()) hitpoints.push_back(aimbot_info.value()); }); aim_info best_match = { c_vector3d(), -FLT_MAX, nullptr, false, c_vector3d(), 0.f, 0.f, c_cs_player::hitbox::head, 0 }; // find best target spot of all valid spots. for (auto& hitpoint : hitpoints) if (hitpoint.damage > best_match.damage) best_match = hitpoint; // stop if no target found. if (best_match.damage < 0.f) return; // run autostop. if (cmd->buttons & ~c_user_cmd::jump) { autostop(local, cmd); } if (config.rage.fakelag_settings.fake_lag_on_peek_delay && antiaim->is_on_peek) { const auto entity_weapon = reinterpret_cast<c_base_combat_weapon*>(client_entity_list()->get_client_entity_from_handle(best_match.animation->player->get_current_weapon_handle())); auto should_return = true; auto on_ground = best_match.animation->player->is_on_ground(); c_base_animating::animation_layers layers = *best_match.animation->player->get_animation_layers(); if (best_match.animation->player->get_health() <= weapon_cfg.value().body_aim_health) should_return = false; if (entity_weapon && entity_weapon->get_current_clip() <= 2) should_return = false; if (!on_ground) should_return = false; if (best_match.animation->player->get_sequence_activity(layers[1].sequence) == act_csgo_reload && layers[1].cycle < 0.99f) should_return = false; if (entity_weapon && entity_weapon->get_item_definition() == weapon_knife || entity_weapon->get_item_definition() == weapon_knife_t || entity_weapon->get_item_definition() == weapon_taser || entity_weapon->get_item_definition() == weapon_c4) should_return = false; if (should_return && !best_match.animation->didshot && !best_match.animation->upPitch && !best_match.animation->sideways) return; } // scope the weapon. if ((wpn_info->get_weapon_id() == weapon_g3sg1 || wpn_info->get_weapon_id() == weapon_scar20 || wpn_info->get_weapon_id() == weapon_ssg08 || wpn_info->get_weapon_id() == weapon_awp || wpn_info->get_weapon_id() == weapon_sg556 || wpn_info->get_weapon_id() == weapon_aug) && weapon->get_zoom_level() == 0) cmd->buttons |= c_user_cmd::flags::attack2; // calculate angle. const auto angle = math::calc_angle(local->get_shoot_position(), best_match.position); // store pitch for eye correction. last_pitch = angle.x; // optimize multipoint and select final aimpoint. //c_aimhelper::optimize_multipoint(best_match);//nice to call this but its not doing anything, not changing the targetangle //debug_overlay()->add_line_overlay(local->get_shoot_position(), best_match.position, 255, 0, 0, true, 0.1); // auto doesmatch = best_match.animation->player->get_health() <= weapon_cfg.value().hp_health_override; if (c_aimhelper::is_hitbox_a_body(best_match.hitbox)) { if (!c_aimhelper::can_hit(local, best_match.animation, best_match.position, weapon_cfg.value().hitchance_body / 100.f, best_match.hitbox)) return; } else if (c_aimhelper::is_hitbox_a_body(best_match.hitbox) && best_match.animation->player->get_health() <= weapon_cfg.value().hp_health_override) { if (!c_aimhelper::can_hit(local, best_match.animation, best_match.position, weapon_cfg.value().hp_body_hitchance / 100.f, best_match.hitbox)) return; } else if (!(c_aimhelper::is_hitbox_a_body(best_match.hitbox)) && best_match.animation->player->get_health() <= weapon_cfg.value().hp_health_override) { if (!c_aimhelper::can_hit(local, best_match.animation, best_match.position, weapon_cfg.value().hp_head_hitchance / 100.f, best_match.hitbox)) return; } else if (!c_aimhelper::can_hit(local, best_match.animation, best_match.position, weapon_cfg.value().hitchance_head / 100.f, best_match.hitbox)) return; // store shot info for resolver. if (!best_match.alt_attack) { resolver::shot shot{}; shot.damage = best_match.damage; shot.start = local->get_shoot_position(); shot.end = best_match.position; shot.hitgroup = best_match.hitgroup; shot.hitbox = best_match.hitbox; shot.time = global_vars_base->curtime; shot.record = *best_match.animation; shot.manual = false; shot.tickcount = cmd->tick_count - time_to_ticks(best_match.animation->sim_time) + time_to_ticks(calculate_lerp()); shot.sideways = best_match.animation->sideways; shot.uppitch = best_match.animation->upPitch; shot.shotting = best_match.animation->didshot; shot.index = best_match.animation->index; char msg[255]; static const auto hit_msg = __("Fired at with BT %d. Type: %s Hitbox: %s"); _rt(hit, hit_msg); char type[255]; char phitbox[255]; if (shot.shotting) sprintf(type, "Shooting"); else if (shot.sideways) sprintf(type, "SideW"); else if (shot.uppitch) sprintf(type, "UP"); else sprintf(type, "Nothing"); switch (shot.hitbox) { case c_cs_player::hitbox::head: sprintf(phitbox, "Head"); break; case c_cs_player::hitbox::pelvis: sprintf(phitbox, "Pelvis"); break; default: sprintf(phitbox, "Unk"); break; } sprintf_s(msg, hit, shot.tickcount, type, phitbox); logging->info(msg); switch (config.rage.resolver) { case 1:c_resolver::register_shot(std::move(shot)); break; case 2:c_resolver_beta::register_shot(std::move(shot)); break; } } // set correct information to user_cmd. cmd->viewangles = angle; cmd->tick_count = time_to_ticks(best_match.animation->sim_time + calculate_lerp()) ;//+ time_to_ticks() if (weapon_cfg.value().auto_shoot && GetAsyncKeyState(config.rage.fake_duck)) { if (local->get_duck_amount() == 0.f) { cmd->buttons |= best_match.alt_attack ? c_user_cmd::attack2 : c_user_cmd::attack; } } else if (weapon_cfg.value().auto_shoot && cmd->buttons & c_user_cmd::duck) { cmd->buttons |= best_match.alt_attack ? c_user_cmd::attack2 : c_user_cmd::attack; } else { cmd->buttons |= best_match.alt_attack ? c_user_cmd::attack2 : c_user_cmd::attack; } } void c_ragebot::autostop(c_cs_player* local, c_user_cmd* cmd) { if (cmd->buttons & c_user_cmd::jump) return; static const auto nospread = cvar()->find_var(_("weapon_accuracy_nospread")); const auto weapon = reinterpret_cast<c_base_combat_weapon*>( client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle())); if (nospread->get_int() || !local->is_on_ground() || (weapon && weapon->get_item_definition() == weapon_taser) && local->is_on_ground()) return; const auto wpn_info = weapon_system->get_weapon_data(weapon->get_item_definition()); if (!wpn_info) return; auto& info = get_autostop_info(cmd); if (info.call_time == global_vars_base->curtime) { info.did_stop = true; return; } info.did_stop = false; info.call_time = global_vars_base->curtime; if (local->get_velocity().length2d() <= wpn_info->get_standing_accuracy(weapon)) return; else { cmd->forwardmove = 0.f; cmd->sidemove = 0.f; prediction_system->repredict(local, cmd); if (config.rage.slow_walk && GetAsyncKeyState(config.rage.slow_walk)) { antiaim->is_slow_walking = true; info.did_stop = true; return; } else antiaim->is_slow_walking = false; if (local->get_velocity().length2d() <= wpn_info->get_standing_accuracy(weapon)) return; } c_qangle dir; math::vector_angles(prediction_system->unpredicted_velocity, dir); const auto angles = engine_client()->get_view_angles(); dir.y = angles.y - dir.y; c_vector3d move; math::angle_vectors(dir, move); if (prediction_system->unpredicted_velocity.length2d() > .1f) move *= -math::forward_bounds / std::max(std::abs(move.x), std::abs(move.y)); cmd->forwardmove = move.x; cmd->sidemove = move.y; const auto backup = cmd->viewangles; cmd->viewangles = angles; prediction_system->repredict(local, cmd); cmd->viewangles = backup; if (local->get_velocity().length2d() > prediction_system->unpredicted_velocity.length2d()) { cmd->forwardmove = 0.f; cmd->sidemove = 0.f; } prediction_system->repredict(local, cmd); } std::optional<c_ragebot::aim_info> c_ragebot::scan_record(c_cs_player* local, c_animation_system::animation* animation) { const auto weapon = reinterpret_cast<c_base_combat_weapon*>( client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle())); if (!weapon) return std::nullopt; const auto info = weapon_system->get_weapon_data(weapon->get_item_definition()); if (!info) return std::nullopt; const auto is_zeus = weapon->get_item_definition() == weapon_taser; const auto is_knife = !is_zeus && info->WeaponType == weapontype_knife; if (is_knife) return scan_record_knife(local, animation); return scan_record_aimbot(local, animation); } std::optional<c_ragebot::aim_info> c_ragebot::scan_record_aimbot(c_cs_player * local, c_animation_system::animation* animation, std::optional<c_vector3d> pos) { const auto weapon_cfg = c_aimhelper::get_weapon_conf(); if (!animation || !animation->player || !weapon_cfg.has_value()) return std::nullopt; const auto weapon = reinterpret_cast<c_base_combat_weapon*>(client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle())); if (!weapon) return std::nullopt; const auto info = animation_system->get_animation_info(animation->player); if (!info) return std::nullopt; const auto cfg = weapon_cfg.value(); /*TODO: 89 1D ? ? ? ? 8B C3 + 2 + //g_netgraph xref: "vgui/white", 0x131B8 = (int)(1.0f / m_Framerate) lets use the game :) FPS OPTIMIZATION MODE USING ABOVE */ const float client_frame_rate = (int)(1.0f / *(float*)(net_graph + 0x131B8)); auto should_optimize = client_frame_rate <= cfg.optimize_fps; auto should_baim = false; const auto center = animation->player->get_hitbox_position(c_cs_player::hitbox::pelvis, animation->bones); const auto slow_walk = animation->anim_state.feet_yaw_rate >= 0.01 && animation->anim_state.feet_yaw_rate <= 0.8; const auto is_moving = animation->velocity.length2d() > 0.1f && animation->player->is_on_ground() && !slow_walk; if (center.has_value()) { const auto center_wall = trace_system->wall_penetration(pos.value_or(local->get_shoot_position()), center.value(), animation); if (center_wall.has_value() && center_wall.value().hitbox == c_cs_player::hitbox::pelvis && center_wall.value().damage - 10.f > animation->player->get_health()) should_baim = true; } if (!should_baim) { const auto data = weapon_system->get_weapon_data(weapon->get_item_definition()); if (!data) return std::nullopt; if (animation->player->get_health() <= cfg.body_aim_health) should_baim = true; if (cfg.smart_aim) { if (animation->player->get_health() <= 50) should_baim = true; if (animation->player->get_velocity().length2d() > 0.1 && !animation->player->is_on_ground()) should_baim = true; if (slow_walk) should_baim = true; } if (cfg.body_aim_in_air) if (animation->player->get_velocity().length2d() > 0.1 && !animation->player->is_on_ground()) should_baim = true; if (cfg.body_aim_lethal && animation->player->get_health() < data->iDamage) should_baim = true; if (cfg.body_aim_slow_walk) if (slow_walk) should_baim = true; if (GetAsyncKeyState(cfg.body_aim_key)) should_baim = true; if (info->missed_due_to_resolver >= cfg.body_after_x_missed_resolver + 1) should_baim = true; if (info->missed_due_to_spread >= cfg.body_after_x_missed_spread + 1) should_baim = true; if (cfg.body_aim_if_not_on_shot && !animation->didshot) should_baim = true; } aim_info best_match = { c_vector3d(), -FLT_MAX, nullptr, false, c_vector3d(), 0.f, 0.f, c_cs_player::hitbox::head, 0 }; const auto scan_box = [&](c_cs_player::hitbox hitbox) { auto box = animation->player->get_hitbox_position(hitbox, const_cast<matrix3x4*>(animation->bones)); if (!box.has_value()) return; auto scale_hitbox = 0.f; switch (hitbox) { case c_cs_player::hitbox::head: scale_hitbox = cfg.head_scale / 100.f; break; case c_cs_player::hitbox::neck: scale_hitbox = cfg.head_scale / 100.f; break; case c_cs_player::hitbox::upper_chest: scale_hitbox = cfg.chest_scale / 100.f; break; case c_cs_player::hitbox::chest: scale_hitbox = cfg.chest_scale / 100.f; break; case c_cs_player::hitbox::thorax: scale_hitbox = cfg.stomach_scale / 100.f; break; case c_cs_player::hitbox::pelvis: scale_hitbox = cfg.pelvis_scale / 100.f; break; case c_cs_player::hitbox::left_thigh: scale_hitbox = cfg.legs_scale / 100.f; break; case c_cs_player::hitbox::right_thigh: scale_hitbox = cfg.legs_scale / 100.f; break; case c_cs_player::hitbox::left_foot: scale_hitbox = cfg.feet_scale / 100.f; break; case c_cs_player::hitbox::right_foot: scale_hitbox = cfg.feet_scale / 100.f; break; } auto points = pos.has_value() ? std::vector<aim_info>() : c_aimhelper::select_multipoint(animation, hitbox, hitgroup_head, scale_hitbox); points.emplace_back(box.value(), 0.f, animation, false, box.value(), 0.f, 0.f, hitbox, hitgroup_head); const auto low_hitchance = pos.has_value(); for (auto& point : points) { if (point.rs > 0.f && low_hitchance) continue; const auto wall = trace_system->wall_penetration(pos.value_or(local->get_shoot_position()), point.position, animation); if (!wall.has_value()) continue; if (hitbox == c_cs_player::hitbox::head && hitbox != wall.value().hitbox) continue; point.hitgroup = wall.value().hitgroup; if (hitbox == c_cs_player::hitbox::upper_chest && (wall.value().hitbox == c_cs_player::hitbox::head || wall.value().hitbox == c_cs_player::hitbox::neck)) continue; point.damage = wall.value().damage; if (point.damage > best_match.damage) best_match = point; } }; std::vector<c_cs_player::hitbox> hitboxes_scan; auto should_head_neck_only = animation->didshot; auto should_override_head_aim = cfg.override_head_aim_only; if (should_head_neck_only && should_override_head_aim) { if (should_baim) should_head_neck_only = false; //todo other conditions. } if (should_head_neck_only && cfg.head_aim_only_while_firing) // run our only head/neck hitscan { if (hitboxes_scan.size() > 0) hitboxes_scan.clear(); if (cfg.on_shot_hitscan_head) { hitboxes_scan.push_back(c_cs_player::hitbox::head); //hitboxes_scan.push_back(c_cs_player::hitbox::neck); } if (cfg.on_shot_hitscan_body) { hitboxes_scan.push_back(c_cs_player::hitbox::upper_chest); hitboxes_scan.push_back(c_cs_player::hitbox::chest); hitboxes_scan.push_back(c_cs_player::hitbox::thorax); hitboxes_scan.push_back(c_cs_player::hitbox::pelvis); } } else if (should_baim) // run our standard body_aim hitscan { if (hitboxes_scan.size() > 0) hitboxes_scan.clear(); if (is_moving ? cfg.hitscan_chest_moving : cfg.hitscan_chest_moving) { hitboxes_scan.push_back(c_cs_player::hitbox::upper_chest); //hitboxes_scan.push_back(c_cs_player::hitbox::chest);//i dont like this } if (is_moving ? cfg.hitscan_stomach_moving : cfg.hitscan_stomach) hitboxes_scan.push_back(c_cs_player::hitbox::thorax); if (is_moving ? cfg.hitscan_pelvis_moving : cfg.hitscan_pelvis) hitboxes_scan.push_back(c_cs_player::hitbox::pelvis); if (is_moving ? cfg.hitscan_legs_moving : cfg.hitscan_legs) { hitboxes_scan.push_back(c_cs_player::hitbox::left_thigh); hitboxes_scan.push_back(c_cs_player::hitbox::right_thigh); } if (is_moving ? cfg.hitscan_feet_moving : cfg.hitscan_feet) { //hitboxes_scan.push_back(c_cs_player::hitbox::left_calf);//lets not waste ressources //hitboxes_scan.push_back(c_cs_player::hitbox::right_calf); hitboxes_scan.push_back(c_cs_player::hitbox::left_foot); hitboxes_scan.push_back(c_cs_player::hitbox::right_foot); } } else // run our normal hitscan { if (hitboxes_scan.size() > 0) hitboxes_scan.clear(); if (is_moving ? cfg.hitscan_head_moving : cfg.hitscan_head) { hitboxes_scan.push_back(c_cs_player::hitbox::head); //hitboxes_scan.push_back(c_cs_player::hitbox::neck);//dont need 1000 scans } if (is_moving ? cfg.hitscan_chest_moving : cfg.hitscan_chest) { hitboxes_scan.push_back(c_cs_player::hitbox::upper_chest); //hitboxes_scan.push_back(c_cs_player::hitbox::chest);//i dont like this } if (is_moving ? cfg.hitscan_stomach_moving : cfg.hitscan_stomach) hitboxes_scan.push_back(c_cs_player::hitbox::thorax); if (is_moving ? cfg.hitscan_pelvis_moving : cfg.hitscan_pelvis) hitboxes_scan.push_back(c_cs_player::hitbox::pelvis); if (is_moving ? cfg.hitscan_legs_moving : cfg.hitscan_legs) { hitboxes_scan.push_back(c_cs_player::hitbox::left_thigh); hitboxes_scan.push_back(c_cs_player::hitbox::right_thigh); } if (is_moving ? cfg.hitscan_feet_moving : cfg.hitscan_feet) { //hitboxes_scan.push_back(c_cs_player::hitbox::left_calf);//lets not waste ressources //hitboxes_scan.push_back(c_cs_player::hitbox::right_calf); hitboxes_scan.push_back(c_cs_player::hitbox::left_foot); hitboxes_scan.push_back(c_cs_player::hitbox::right_foot); } } auto can_fire_at_hitbox = false; if (animation->didshot || animation->sideways) {//cuz we can hitboxes_scan.clear(); hitboxes_scan.push_back(c_cs_player::hitbox::head); hitboxes_scan.push_back(c_cs_player::hitbox::pelvis); } //if(!hitboxes_scan.size()) //hitboxes_scan.push_back(c_cs_player::hitbox::head);//scan head or we wont do anything jesus for (const auto& hitbox : hitboxes_scan) //do our hitscan for our hitboxes scan_box(hitbox); //check if we can hit the hitbox! if (weapon_cfg.value().min_dmg_hp && animation->player->get_health() <= weapon_cfg.value().hp || animation->player->get_health() < weapon_cfg.value().min_dmg) { if (best_match.damage >= animation->player->get_health() + cfg.min_dmg_hp_slider || best_match.damage - 10.f >= static_cast<float>(animation->player->get_health())) { can_fire_at_hitbox = true; } } else if (animation->player->get_health() <= weapon_cfg.value().hp_health_override) { if (best_match.damage >= cfg.hp_mindmg || best_match.damage - 10.f >= static_cast<float>(animation->player->get_health())) { can_fire_at_hitbox = true; } } else if (!(weapon_cfg.value().min_dmg_hp) && !(animation->player->get_health() <= weapon_cfg.value().hp) || !(animation->player->get_health() < weapon_cfg.value().min_dmg)) { if (best_match.damage >= cfg.min_dmg || best_match.damage - 10.f >= static_cast<float>(animation->player->get_health())) { can_fire_at_hitbox = true; } } else if (can_fire_at_hitbox == false) { //aimbot cannot fire at the player lets figure out why? //lets try head :) //scan_box(c_cs_player::hitbox::head); //lets hitscan the head only! :) if (weapon_cfg.value().min_dmg_hp && animation->player->get_health() <= weapon_cfg.value().hp || animation->player->get_health() < weapon_cfg.value().min_dmg) { if (best_match.damage >= animation->player->get_health() + cfg.min_dmg_hp_slider || best_match.damage - 10.f >= static_cast<float>(animation->player->get_health())) can_fire_at_hitbox = true; } else { if (best_match.damage >= cfg.min_dmg || best_match.damage - 10.f >= static_cast<float>(animation->player->get_health())) can_fire_at_hitbox = true; } } if (can_fire_at_hitbox == true) return best_match; else return std::nullopt; } std::optional<c_ragebot::aim_info> c_ragebot::scan_record_knife(c_cs_player * local, c_animation_system::animation* animation) { static const auto is_behind = [] (c_cs_player* local, c_animation_system::animation* animation) -> bool { auto vec_los = animation->origin - local->get_origin(); vec_los.z = 0.0f; c_vector3d forward; math::angle_vectors(animation->eye_angles, forward); forward.z = 0.0f; return vec_los.normalize().dot(forward) > 0.475f; }; static const auto should_stab = [] (c_cs_player* local, c_animation_system::animation* animation) -> bool { struct table_t { unsigned char swing[2][2][2]; unsigned char stab[2][2]; }; static const table_t table = { { { { 25, 90 }, { 21, 76 } }, { { 40, 90 }, { 34, 76 } } }, { { 65, 180 }, { 55, 153 } } }; const auto weapon = reinterpret_cast<c_base_combat_weapon*>( client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle())); if (!weapon) return false; const auto has_armor = animation->player->get_armor() > 0; const auto first_swing = weapon->get_next_primary_attack() + 0.4f < global_vars_base->curtime; const auto behind = is_behind(local, animation); const int stab_dmg = table.stab[has_armor][behind]; const int slash_dmg = table.swing[false][has_armor][behind]; const int swing_dmg = table.swing[first_swing][has_armor][behind]; if (animation->player->get_health() <= swing_dmg) return false; if (animation->player->get_health() <= stab_dmg) return true; if (animation->player->get_health() > swing_dmg + slash_dmg + stab_dmg) return true; return false; }; const auto studio_model = model_info_client()->get_studio_model(animation->player->get_model()); if (!studio_model) return std::nullopt; const auto stab = should_stab(local, animation); const auto range = stab ? 32.0f : 48.0f; game_trace tr; auto spot = animation->player->get_hitbox_position(c_cs_player::hitbox::upper_chest, animation->bones); const auto hitbox = studio_model->get_hitbox(static_cast<uint32_t>(c_cs_player::hitbox::upper_chest), 0); if (!spot.has_value() || !hitbox) return std::nullopt; c_vector3d forward; const auto calc = math::calc_angle(local->get_shoot_position(), spot.value()); math::angle_vectors(calc, forward); spot.value() += forward * hitbox->radius; c_trace_system::run_emulated(animation, [&] () -> void { uint32_t filter[4] = { c_engine_trace::get_filter_simple_vtable(), reinterpret_cast<uint32_t>(local), 0, 0 }; ray r; c_vector3d aim; const auto angle = math::calc_angle(local->get_shoot_position(), spot.value()); math::angle_vectors(angle, aim); const auto end = local->get_shoot_position() + aim * range; r.init(local->get_shoot_position(), end); engine_trace()->trace_ray(r, mask_solid, reinterpret_cast<trace_filter*>(filter), &tr); if (tr.fraction >= 1.0f) { const c_vector3d min(-16.f, -16.f, -18.f); const c_vector3d max(16.f, 16.f, 18.f); r.init(local->get_shoot_position(), end, min, max); engine_trace()->trace_ray(r, mask_solid, reinterpret_cast<trace_filter*>(filter), &tr); } }); if (tr.entity != animation->player) return std::nullopt; return aim_info { tr.endpos, 100.f, animation, stab, c_vector3d(), 0.f, 0.f, c_cs_player::hitbox::head, 0 }; } std::optional<c_ragebot::aim_info> c_ragebot::scan_record_gun(c_cs_player* local, c_animation_system::animation* animation, std::optional<c_vector3d> pos) { const auto weapon_cfg = c_aimhelper::get_weapon_conf(); if (!animation || !animation->player || !weapon_cfg.has_value()) return std::nullopt; const auto weapon = reinterpret_cast<c_base_combat_weapon*>(client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle())); if (!weapon) return std::nullopt; const auto info = animation_system->get_animation_info(animation->player); if (!info) return std::nullopt; const auto cfg = weapon_cfg.value(); auto should_baim = false; const auto center = animation->player->get_hitbox_position(c_cs_player::hitbox::pelvis, animation->bones); if (center.has_value()) { const auto center_wall = trace_system->wall_penetration(pos.value_or(local->get_shoot_position()), center.value(), animation); if (center_wall.has_value() && center_wall.value().hitbox == c_cs_player::hitbox::pelvis && center_wall.value().damage - 10.f > animation->player->get_health()) should_baim = true; } aim_info best_match = { c_vector3d(), -FLT_MAX, nullptr, false, c_vector3d(), 0.f, 0.f, c_cs_player::hitbox::head, 0 }; const auto scan_box = [&](c_cs_player::hitbox hitbox) { auto box = animation->player->get_hitbox_position(hitbox, const_cast<matrix3x4*>(animation->bones)); if (!box.has_value()) return; auto scale_hitbox = 0.f; switch (hitbox) { case c_cs_player::hitbox::head: scale_hitbox = cfg.head_scale / 100.f; break; case c_cs_player::hitbox::neck: scale_hitbox = cfg.head_scale / 100.f; break; case c_cs_player::hitbox::upper_chest: scale_hitbox = cfg.chest_scale / 100.f; break; case c_cs_player::hitbox::chest: scale_hitbox = cfg.chest_scale / 100.f; break; case c_cs_player::hitbox::thorax: scale_hitbox = cfg.stomach_scale / 100.f; break; case c_cs_player::hitbox::pelvis: scale_hitbox = cfg.pelvis_scale / 100.f; break; case c_cs_player::hitbox::left_thigh: scale_hitbox = cfg.legs_scale / 100.f; break; case c_cs_player::hitbox::right_thigh: scale_hitbox = cfg.legs_scale / 100.f; break; } auto points = pos.has_value() ? std::vector<aim_info>() : c_aimhelper::select_multipoint(animation, hitbox, hitgroup_head, scale_hitbox); points.emplace_back(box.value(), 0.f, animation, false, box.value(), 0.f, 0.f, hitbox, hitgroup_head); for (auto& point : points) { const auto wall = trace_system->wall_penetration(pos.value_or(local->get_shoot_position()), point.position, animation); if (!wall.has_value()) continue; if (hitbox == c_cs_player::hitbox::head && hitbox != wall.value().hitbox) continue; point.hitgroup = wall.value().hitgroup; if (hitbox == c_cs_player::hitbox::upper_chest && (wall.value().hitbox == c_cs_player::hitbox::head || wall.value().hitbox == c_cs_player::hitbox::neck)) continue; point.damage = wall.value().damage; if (point.damage > best_match.damage) best_match = point; } }; if (should_baim) for (const auto& hitbox : c_cs_player::hitboxes_baim) scan_box(hitbox); else for (const auto& hitbox : c_cs_player::hitboxes_aiming) scan_box(hitbox); if (weapon_cfg.value().min_dmg_hp && animation->player->get_health() <= weapon_cfg.value().hp || animation->player->get_health() < weapon_cfg.value().min_dmg) { if (best_match.damage >= animation->player->get_health() + cfg.min_dmg_hp_slider || best_match.damage - 10.f >= animation->player->get_health()) return best_match; } else if (animation->player->get_health() <= weapon_cfg.value().hp_health_override) { if (best_match.damage >= cfg.hp_mindmg || best_match.damage - 10.f >= animation->player->get_health()) return best_match; } else if (!weapon_cfg.value().min_dmg_hp && !(animation->player->get_health() <= weapon_cfg.value().hp) || !(animation->player->get_health() < weapon_cfg.value().min_dmg)) { if (best_match.damage >= cfg.min_dmg || best_match.damage - 10.f >= animation->player->get_health()) return best_match; } //else if (should_baim) //scan_box(c_cs_player::hitbox::head); return std::nullopt; } c_ragebot::autostop_info& c_ragebot::get_autostop_info(c_user_cmd *cmd) { if (cmd->buttons & ~c_user_cmd::jump) { static autostop_info info{ -FLT_MAX, false }; return info; } c_ragebot::autostop_info stop; return stop; } bool c_ragebot::is_breaking_lagcomp(c_animation_system::animation* animation) { static constexpr auto teleport_dist = 64 * 64; const auto info = animation_system->get_animation_info(animation->player); if (!info || info->frames.size() < 2) return false; if (info->frames[0].dormant) return false; auto prev_org = info->frames[0].origin; auto skip_first = true; // walk context looking for any invalidating event for (auto& record : info->frames) { if (skip_first) { skip_first = false; continue; } if (record.dormant) break; auto delta = record.origin - prev_org; if (delta.length2dsqr() > teleport_dist) { // lost track, too much difference return true; } // did we find a context smaller than target time? if (record.sim_time <= animation->sim_time) break; // hurra, stop prev_org = record.origin; } return false; }
31.953398
243
0.713934
garryhvh420
b7ccc055fac9110813305fd35b7dd24ed67d8900
5,011
cpp
C++
test/test_state.cpp
stfnwong/smips
f305d24e16632b0a4907607386fc9d98f3d389b5
[ "MIT" ]
null
null
null
test/test_state.cpp
stfnwong/smips
f305d24e16632b0a4907607386fc9d98f3d389b5
[ "MIT" ]
null
null
null
test/test_state.cpp
stfnwong/smips
f305d24e16632b0a4907607386fc9d98f3d389b5
[ "MIT" ]
null
null
null
/* * TEST_STATE * Unit tests for SMIPS CPU State structure * * Stefan Wong 2020 */ #define CATCH_CONFIG_MAIN #include "catch/catch.hpp" #include <iostream> #include <iomanip> #include <vector> #include <string> // unit(s) under test #include "State.hpp" #include "Program.hpp" // for assembly helper function #include "Lexer.hpp" #include "Assembler.hpp" Program assem_helper(const std::string& src) { Lexer lex; Assembler assem; lex.loadSource(src); lex.lex(); assem.loadSource(lex.getSourceInfo()); assem.assemble(); return assem.getProgram(); } // add $s0, $s1. $s2 const std::vector<uint8_t> add_example = { 0x02, 0x32, 0x80, 0x20 }; // lw $t0 32($s3) const std::vector<uint8_t> lw_example = { 0x8E, 0x68, 0x00, 0x20 }; // j 1028 const std::vector<uint8_t> j_example = { 0x08, 0x00, 0x01, 0x01 }; TEST_CASE("test_state_init", "[classic]") { State test_state; REQUIRE(test_state.pc == 0); REQUIRE(test_state.instr == 0); REQUIRE(test_state.op_bits == 0); REQUIRE(test_state.func == 0); REQUIRE(test_state.rs == 0); REQUIRE(test_state.rt == 0); REQUIRE(test_state.rd == 0); REQUIRE(test_state.shamt == 0); REQUIRE(test_state.imm == 0); REQUIRE(test_state.tmp == 0); REQUIRE(test_state.hi == 0); REQUIRE(test_state.lo == 0); REQUIRE(test_state.mem_addr == 0); REQUIRE(test_state.mem_data == 0); // check registers for(int i = 0; i < 32; ++i) REQUIRE(test_state.reg[i] == 0); } TEST_CASE("test_state_zero_mem", "[classic]") { State test_state; // put some junk in the memory std::vector<uint8_t> dummy_data = {0xDE, 0xAD, 0xBE, 0xEF}; test_state.writeMem(dummy_data, 0); test_state.writeMem(dummy_data, 32); test_state.writeMem(dummy_data, 64); for(unsigned int i = 0; i < dummy_data.size(); ++i) { REQUIRE(test_state.mem[i] == dummy_data[i]); REQUIRE(test_state.mem[i+32] == dummy_data[i]); REQUIRE(test_state.mem[i+64] == dummy_data[i]); } test_state.clearMem(); for(unsigned int i = 0; i < test_state.mem.size(); ++i) REQUIRE(test_state.mem[i] == 0); } TEST_CASE("test_decode_j", "[classic]") { State test_state; test_state.writeMem(j_example, 0); test_state.fetch(); test_state.decode(); REQUIRE(test_state.imm == 257); } // ================ INSTRUCTION PIPLINES ======== // TEST_CASE("test_add_pipeline", "[classic]") { State test_state; test_state.writeMem(add_example, 0); // ensure all registers are zero'd at start up time for(int i = 0; i < 32; ++i) REQUIRE(test_state.reg[i] == 0); test_state.fetch(); REQUIRE(test_state.instr == 0x02328020); REQUIRE(test_state.pc == 4); test_state.decode(); REQUIRE(test_state.rd == REG_SAVED_0); REQUIRE(test_state.rs == REG_SAVED_1); REQUIRE(test_state.rt == REG_SAVED_2); // lets set the values of those registers to be // R[rs] = 1 // R[rt] = 2 // so that R[rd] will be 3 test_state.reg[test_state.rs] = 1; test_state.reg[test_state.rt] = 2; // now execute this add test_state.execute(); REQUIRE(test_state.alu == 3); } TEST_CASE("test_lw_pipeline", "[classic]") { State test_state; test_state.writeMem(lw_example, 0); // ensure all registers are zero'd at start up time for(int i = 0; i < 32; ++i) REQUIRE(test_state.reg[i] == 0); test_state.fetch(); REQUIRE(test_state.instr == 0x8E680020); REQUIRE(test_state.pc == 4); test_state.decode(); REQUIRE(test_state.rs == 19); REQUIRE(test_state.rt == 8); REQUIRE(test_state.imm == 32); // Set the test up so that the word we want to load is at offset 64 // Since the offset in the example instruction is 32, we place 32 // in $rs and pre-load the memory. test_state.reg[test_state.rs] = 32; const std::vector<uint8_t> dummy_data = {0xDE, 0xAD, 0xBE, 0xEF}; test_state.writeMem(dummy_data, 64); // now execute this lw test_state.execute(); REQUIRE(test_state.mem_addr == 64); test_state.memory(); REQUIRE(test_state.mem_data == int32_t(0xDEADBEEF)); test_state.write_back(); REQUIRE(test_state.reg[test_state.rt] == int32_t(0xDEADBEEF)); for(unsigned int i = 0; i < dummy_data.size(); ++i) REQUIRE(test_state.mem[test_state.mem_addr+i] == dummy_data[i]); } TEST_CASE("test_j_pipeline", "[classic]") { State test_state; test_state.writeMem(j_example, 0); // ensure all registers are zero'd at start up time for(int i = 0; i < 32; ++i) REQUIRE(test_state.reg[i] == 0); test_state.fetch(); REQUIRE(test_state.instr == 0x08000101); REQUIRE(test_state.pc == 4); test_state.decode(); REQUIRE(test_state.imm == 257); REQUIRE(test_state.pc == 4); test_state.execute(); REQUIRE(test_state.pc == 1028+4); // nothing actually happens in memory or write-back phase for jumps }
25.566327
73
0.633407
stfnwong
b7ce06f1d48c7e1edfb14fe58053aedf6e6b4292
1,337
cpp
C++
oxygine/src/Font.cpp
sanyaade-teachings/oxygine-framework_back
6bbc9ba40e2bfb6c27c2ac008a434244c57b6df6
[ "MIT" ]
null
null
null
oxygine/src/Font.cpp
sanyaade-teachings/oxygine-framework_back
6bbc9ba40e2bfb6c27c2ac008a434244c57b6df6
[ "MIT" ]
null
null
null
oxygine/src/Font.cpp
sanyaade-teachings/oxygine-framework_back
6bbc9ba40e2bfb6c27c2ac008a434244c57b6df6
[ "MIT" ]
null
null
null
#include "Font.h" #include "core/NativeTexture.h" namespace oxygine { /* int key2hash(int g) { int k = g; if ((g & 0xC0) == 0xC0) { k = k >> 8; } k = k & 0x3f; //log::messageln("key: %d hash: %d", g, k); return k; //return g; } */ Font::Font():_size(0), _baselineDistance(0), _scaleFactor(1.0f) { } Font::~Font() { } void Font::init(const char *name, int size, int baselineDistance, int lineHeight) { setName(name); _size = size; _baselineDistance = baselineDistance; _lineHeight = lineHeight; _glyphs.reserve(200); } void Font::addGlyph(const glyph &gl) { _glyphs.push_back(gl); } bool glyphFindPred (const glyph &g, int code) { return g.ch < code; } bool glyphsComparePred(const glyph &ob1, const glyph &ob2) { return ob1.ch < ob2.ch; } void Font::sortGlyphs() { sort(_glyphs.begin(), _glyphs.end(), glyphsComparePred); } const glyph *Font::getGlyph(int ch) const { glyphs::const_iterator it = lower_bound(_glyphs.begin(), _glyphs.end(), ch, glyphFindPred); if (it != _glyphs.end()) { const glyph &g = *it; if (g.ch == ch) return &g; } return 0; } int Font::getBaselineDistance() const { return _baselineDistance; } int Font::getSize() const { return _size; } int Font::getLineHeight() const { return _lineHeight; } }
15.729412
93
0.623785
sanyaade-teachings
b7ce090af68997617309ec3bc87022de75d8d4c5
1,358
cpp
C++
Source/Renderer/Framebuffer.cpp
RichierichorgYoutube/First
e1908df3743683424a1bbe2275c54a9089f2a462
[ "Apache-2.0" ]
null
null
null
Source/Renderer/Framebuffer.cpp
RichierichorgYoutube/First
e1908df3743683424a1bbe2275c54a9089f2a462
[ "Apache-2.0" ]
null
null
null
Source/Renderer/Framebuffer.cpp
RichierichorgYoutube/First
e1908df3743683424a1bbe2275c54a9089f2a462
[ "Apache-2.0" ]
null
null
null
#include "Framebuffer.h" #include <iostream> GLuint g_FBO; GLuint g_Tex; GLuint g_RBO; bool setupFrameBuffers(){ glGenFramebuffers(1, &g_FBO); glBindFramebuffer(GL_FRAMEBUFFER, g_FBO); //Render texture glGenTextures(1, &g_Tex); glBindTexture(GL_TEXTURE_2D, g_Tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_X, g_Y, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); //Bind render texture to framebuffer glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, g_Tex, 0); //Render Buffer glGenRenderbuffers(1, &g_RBO); glBindRenderbuffer(GL_RENDERBUFFER, g_RBO); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, g_X, g_Y); glBindRenderbuffer(GL_RENDERBUFFER, 0); //Bind render buffer to framebuffer glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, g_RBO); if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){ glBindFramebuffer(GL_FRAMEBUFFER, 0); std::cout << "FRAME BUFFER ERROR: NOT COMPLETE" << std::endl; return false; } //Disable new framebuffer glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; }
30.863636
99
0.731222
RichierichorgYoutube
b7ce28795d72c30bcd582da19ecfd2bbd99ee28f
15,428
cpp
C++
Engine/Source/Assets/Material.cpp
jkorn2324/jkornEngine
5822f2a311ed62e6ca495919872f0f436d300733
[ "MIT" ]
null
null
null
Engine/Source/Assets/Material.cpp
jkorn2324/jkornEngine
5822f2a311ed62e6ca495919872f0f436d300733
[ "MIT" ]
null
null
null
Engine/Source/Assets/Material.cpp
jkorn2324/jkornEngine
5822f2a311ed62e6ca495919872f0f436d300733
[ "MIT" ]
null
null
null
#include "EnginePCH.h" #include "Material.h" #include "JsonFileParser.h" #include "JsonUtils.h" #include "AssetSerializer.h" #include "AssetManager.h" #include "AssetCache.h" #include "AssetMapper.h" #include <rapidjson\stringbuffer.h> namespace Engine { static ConstantBuffer* s_internalMaterialConstantBuffer = nullptr; static uint32_t s_numMaterials = 0; Material::Material() : m_shader(), m_materialConstantBuffer(nullptr), m_textures(nullptr), m_numTextures(1), m_materialConstants({}), m_internalMaterialConstants({}) { if (s_numMaterials <= 0) { s_internalMaterialConstantBuffer = ConstantBuffer::Create( &m_internalMaterialConstants, sizeof(InternalMaterialConstants)); } s_numMaterials++; m_textures = new MaterialTextureData[m_numTextures]; for (uint32_t i = 0; i < m_numTextures; i++) { m_textures[i] = MaterialTextureData(); } } Material::Material(const MaterialConstantsLayout& layout) : m_shader(), m_materialConstantBuffer(nullptr), m_textures(nullptr), m_numTextures(1), m_materialConstants(layout), m_internalMaterialConstants({}) { if (s_numMaterials <= 0) { s_internalMaterialConstantBuffer = ConstantBuffer::Create( &m_internalMaterialConstants, sizeof(InternalMaterialConstants)); } s_numMaterials++; m_textures = new MaterialTextureData[m_numTextures]; for (uint32_t i = 0; i < m_numTextures; i++) { m_textures[i] = MaterialTextureData(); } m_materialConstantBuffer = ConstantBuffer::Create( m_materialConstants.GetRawBuffer(), m_materialConstants.GetBufferSize()); } Material::Material(const Material& material) : m_shader(material.m_shader), m_materialConstantBuffer(nullptr), m_textures(nullptr), m_numTextures(material.m_numTextures), m_materialConstants(material.m_materialConstants), m_internalMaterialConstants(material.m_internalMaterialConstants) { s_numMaterials++; m_textures = new MaterialTextureData[m_numTextures]; for (uint32_t i = 0; i < m_numTextures; i++) { m_textures[i] = MaterialTextureData( material.m_textures[i].texture); } m_materialConstantBuffer = ConstantBuffer::Create( m_materialConstants.GetRawBuffer(), m_materialConstants.GetBufferSize()); } Material::~Material() { s_numMaterials--; if (s_numMaterials <= 0) { delete s_internalMaterialConstantBuffer; } delete[] m_textures; delete m_materialConstantBuffer; } Material& Material::operator=(const Material& material) { delete[] m_textures; delete m_materialConstantBuffer; m_shader = material.m_shader; m_numTextures = material.m_numTextures; m_materialConstants = material.m_materialConstants; m_internalMaterialConstants = material.m_internalMaterialConstants; m_textures = new MaterialTextureData[m_numTextures]; for (uint32_t i = 0; i < m_numTextures; i++) { m_textures[i] = MaterialTextureData( material.m_textures[i].texture); } m_materialConstantBuffer = ConstantBuffer::Create( m_materialConstants.GetRawBuffer(), m_materialConstants.GetBufferSize()); return *this; } void Material::SetConstantsLayout(const MaterialConstantsLayout& layout) { m_materialConstants = MaterialConstants(layout); if (m_materialConstantBuffer != nullptr) { delete m_materialConstantBuffer; } m_materialConstantBuffer = ConstantBuffer::Create( m_materialConstants.GetRawBuffer(), m_materialConstants.GetBufferSize()); } void Material::SetConstantsLayout(const MaterialConstantsLayout& layout, size_t layoutSize) { m_materialConstants = MaterialConstants(layout, layoutSize); if (m_materialConstantBuffer != nullptr) { delete m_materialConstantBuffer; } m_materialConstantBuffer = ConstantBuffer::Create( m_materialConstants.GetRawBuffer(), m_materialConstants.GetBufferSize()); } void Material::SetShader(const AssetRef<Shader>& shader) { m_shader = shader; } void Material::SetTextureData(uint32_t slot, const MaterialTextureData& materialTextureData) { SetTexture(slot, materialTextureData.texture); } void Material::SetTexture(uint32_t slot, const AssetRef<Texture>& texture) { if (slot >= m_numTextures) { return; } switch (slot) { // Default Texture Slot. case 0: { if (!texture) { // Removes the flag only if it exists. if (m_internalMaterialConstants.c_materialFlags & MaterialFlag_DefaultTexture) { m_internalMaterialConstants.c_materialFlags ^= MaterialFlag_DefaultTexture; } } else { m_internalMaterialConstants.c_materialFlags |= MaterialFlag_DefaultTexture; } break; } } MaterialTextureData& materialTextureData = m_textures[slot]; materialTextureData.texture = texture; } void Material::Bind() const { Bind(PER_SHADER_CONSTANTS_SLOT); } void Material::Bind(uint32_t constantBufferSlot) const { if (m_materialConstantBuffer == nullptr || !m_shader) { return; } m_shader->Bind(); m_materialConstantBuffer->SetData( m_materialConstants.GetRawBuffer(), m_materialConstants.GetBufferSize()); m_materialConstantBuffer->Bind(constantBufferSlot, PIXEL_SHADER | VERTEX_SHADER); s_internalMaterialConstantBuffer->SetData( &m_internalMaterialConstants, sizeof(m_internalMaterialConstants)); s_internalMaterialConstantBuffer->Bind(MATERIAL_CONSTANTS_SLOT, PIXEL_SHADER | VERTEX_SHADER); for (uint32_t i = 0; i < m_numTextures; i++) { const auto& texture = m_textures[i]; if (texture.texture) { texture.texture->Bind(i); } } } #pragma region serialization static MaterialConstantLayoutAttribute LoadMaterialAttributeConstantLayoutType(rapidjson::Value& value, char*& valueBuffer, size_t& offset) { std::string name; MaterialConstantLayoutType layoutType; bool padding = false; ReadString(value, "Name", name); ReadEnum<MaterialConstantLayoutType>(value, "Type", layoutType); ReadBool(value, "Pad", padding); MaterialConstantLayoutAttribute attribute = { name, layoutType, padding }; // Appends the attribute data to the value buffer. char* ptrValue = valueBuffer + offset; switch (layoutType) { case LayoutType_Bool: { bool boolValue; ReadBool(value, "Value", boolValue); std::memcpy(ptrValue, reinterpret_cast<char*>(&boolValue), attribute.layoutStride); break; } case LayoutType_Float: { float floatValue; ReadFloat(value, "Value", floatValue); std::memcpy(ptrValue, reinterpret_cast<char*>(&floatValue), attribute.layoutStride); break; } case LayoutType_Int16: { int16_t int16Value; ReadInt16(value, "Value", int16Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&int16Value), attribute.layoutStride); break; } case LayoutType_Int32: { int32_t int32Value; ReadInt32(value, "Value", int32Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&int32Value), attribute.layoutStride); break; } case LayoutType_Int64: { int64_t int64Value; ReadInt64(value, "Value", int64Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&int64Value), attribute.layoutStride); break; } case LayoutType_Uint16: { uint16_t int16Value; ReadUint16(value, "Value", int16Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&int16Value), attribute.layoutStride); break; } case LayoutType_Uint32: { uint32_t int32Value; ReadUint32(value, "Value", int32Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&int32Value), attribute.layoutStride); break; } case LayoutType_Uint64: { uint64_t int64Value; ReadUint64(value, "Value", int64Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&int64Value), attribute.layoutStride); break; } case LayoutType_Vector2: { MathLib::Vector2 vector2Value; ReadVector2(value, "Value", vector2Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&vector2Value), attribute.layoutStride); break; } case LayoutType_Vector3: { MathLib::Vector3 vector3Value; ReadVector3(value, "Value", vector3Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&vector3Value), attribute.layoutStride); break; } case LayoutType_Vector4: { MathLib::Vector4 vector4Value; ReadVector4(value, "Value", vector4Value); std::memcpy(ptrValue, reinterpret_cast<char*>(&vector4Value), attribute.layoutStride); break; } case LayoutType_Quaternion: { MathLib::Quaternion quaternionValue; ReadQuaternion(value, "Value", quaternionValue); std::memcpy(ptrValue, reinterpret_cast<char*>(&quaternionValue), attribute.layoutStride); break; } } offset += attribute.layoutStride; return attribute; } bool Material::DeserializeFromFile(Material& material, AssetDeserializationFileData& value) { JsonFileParser jsonFileParser(value.filePath); if (!jsonFileParser.IsValid()) { return false; } MaterialConstantsLayout layout; char* materialConstantBuffer = nullptr; rapidjson::Document& document = jsonFileParser.GetDocument(); size_t layoutByteSize = 0; // Deserializes the buffer layout with values. if (document.HasMember("Layout")) { rapidjson::Value& layoutValue = document["Layout"].GetObject(); if (!ReadSize(layoutValue, "Size", layoutByteSize) || layoutByteSize <= 0) { return false; } materialConstantBuffer = new char[layoutByteSize]; size_t currentOffset = 0; if (layoutValue.HasMember("Attributes")) { rapidjson::Value& attributes = layoutValue["Attributes"].GetArray(); for (rapidjson::SizeType i = 0; i < attributes.Size(); i++) { rapidjson::Value& attributeValue = attributes[i].GetObject(); MaterialConstantLayoutAttribute attribute = LoadMaterialAttributeConstantLayoutType(attributeValue, materialConstantBuffer, currentOffset); layout.layoutAttributes.push_back(attribute); } } } // Applies the material constants. { material.SetConstantsLayout(layout, layoutByteSize); MaterialConstants& constants = material.GetMaterialConstants(); constants.SetRawBuffer(materialConstantBuffer); delete[] materialConstantBuffer; } // Reads & Loads the shader from its GUID. { uint64_t shaderGUID; ReadUint64(document, "Shader", shaderGUID); std::filesystem::path assetPath = AssetManager::GetAssetMapper().GetPath(shaderGUID); if (std::filesystem::exists(assetPath)) { AssetManager::GetShaders().Load(material.m_shader, assetPath); } } // Reads and loads the textures from its GUIDs. { uint64_t currentTextureGUID; if (document.HasMember("Textures")) { ReadUint32(document, "NumTextures", material.m_numTextures); rapidjson::Value& texturesArray = document["Textures"].GetArray(); for (uint32_t i = 0; i < material.m_numTextures; i++) { rapidjson::Value& textureValue = texturesArray[i].GetObject(); ReadUint64(textureValue, "GUID", currentTextureGUID); if (currentTextureGUID != 0) { GUID guid(currentTextureGUID); AssetRef<Texture> texture; AssetManager::GetTextures().Load(texture, AssetManager::GetAssetMapper().GetPath(guid)); material.SetTexture(i, texture); } } } } return true; } bool Material::SerializeToFile(Material& material, AssetSerializationFileData& metaData) { // Writes to a material file. JsonFileWriter fileWriter(metaData.filePath); // Writes the constant buffer attribute layout. { fileWriter.BeginObject("Layout"); fileWriter.Write("Size", material.m_materialConstants.m_totalBufferSize); fileWriter.BeginArray("Attributes"); for (auto& pair : material.m_materialConstants.m_materialConstants) { fileWriter.BeginObject(); fileWriter.Write("Name", pair.first); fileWriter.Write<uint32_t>("Type", pair.second.layoutType); fileWriter.Write<bool>("Pad", pair.second.pad); // Writes the Value of the given type. switch (pair.second.layoutType) { case LayoutType_Bool: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<bool>(pair.first)); break; } case LayoutType_Float: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<float>(pair.first)); break; } case LayoutType_Int16: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<int16_t>(pair.first)); break; } case LayoutType_Int32: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<int32_t>(pair.first)); break; } case LayoutType_Int64: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<int64_t>(pair.first)); break; } case LayoutType_Uint16: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<uint16_t>(pair.first)); break; } case LayoutType_Uint32: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<uint32_t>(pair.first)); break; } case LayoutType_Uint64: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<uint64_t>(pair.first)); break; } case LayoutType_Quaternion: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<MathLib::Quaternion>(pair.first)); break; } case LayoutType_Vector2: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<MathLib::Vector2>(pair.first)); break; } case LayoutType_Vector3: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<MathLib::Vector3>(pair.first)); break; } case LayoutType_Vector4: { fileWriter.Write("Value", *material.m_materialConstants.GetMaterialConstant<MathLib::Vector4>(pair.first)); break; } } fileWriter.EndObject(); } fileWriter.EndArray(); fileWriter.EndObject(); } // Writes the shadedr to the json. if (material.HasShader()) { GUID shaderGUID; material.m_shader.GetGUID(shaderGUID); fileWriter.Write("Shader", (uint64_t)shaderGUID); } else { fileWriter.Write("Shader", 0); } // Writes the textures to a json. { fileWriter.Write("NumTextures", material.m_numTextures); fileWriter.BeginArray("Textures"); GUID guid; for (uint32_t i = 0; i < material.m_numTextures; i++) { MaterialTextureData materialTextureData = material.m_textures[i]; fileWriter.BeginObject(); if (materialTextureData.texture) { materialTextureData.texture.GetGUID(guid); fileWriter.Write("GUID", (uint64_t)guid); } else { fileWriter.Write("GUID", 0); } fileWriter.EndObject(); } fileWriter.EndArray(); } fileWriter.Flush(); return true; } bool Material::SerializeToMetaFile(Material& material, AssetSerializationMetaFileData& metaData) { { JsonFileWriter writer(metaData.metaFilePath); writer.Write("GUID", (uint64_t)metaData.guid); writer.Flush(); } return true; } bool Material::DeserializeMetaFile(Material& material, AssetDeserializationMetaFileData& metaData) { return true; } #pragma endregion Material* Material::Create(const MaterialConstantsLayout& constants) { return new Material(constants); } Material* Material::Create() { return new Material; } }
26.692042
104
0.717332
jkorn2324
b7d25d4fdfd33fa8369a9adfdd25ea05cccce789
10,593
tcc
C++
src/flens/symmetricmatrix.tcc
wmotte/toolkid
2a8f82e1492c9efccde9a4935ce3019df1c68cde
[ "MIT" ]
null
null
null
src/flens/symmetricmatrix.tcc
wmotte/toolkid
2a8f82e1492c9efccde9a4935ce3019df1c68cde
[ "MIT" ]
null
null
null
src/flens/symmetricmatrix.tcc
wmotte/toolkid
2a8f82e1492c9efccde9a4935ce3019df1c68cde
[ "MIT" ]
null
null
null
/* * Copyright (c) 2007, Michael Lehn * * 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 FLENS development group 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. */ namespace flens { // == SyMatrix ================================================================= template <typename FS> SyMatrix<FS>::SyMatrix() { } template <typename FS> SyMatrix<FS>::SyMatrix(int dim, StorageUpLo upLo, int firstIndex) : _fs(dim, dim, firstIndex, firstIndex), _upLo(upLo) { } template <typename FS> SyMatrix<FS>::SyMatrix(const FS &fs, StorageUpLo upLo) : _fs(fs), _upLo(upLo) { } template <typename FS> SyMatrix<FS>::SyMatrix(const SyMatrix<FS> &rhs) : _fs(rhs.engine()), _upLo(rhs.upLo()) { } template <typename FS> template <typename RHS> SyMatrix<FS>::SyMatrix(const SyMatrix<RHS> &rhs) : _fs(rhs.engine()), _upLo(rhs.upLo()) { } template <typename FS> SyMatrix<FS>::SyMatrix(const TrMatrix<FS> &rhs) : _fs(rhs.engine()), _upLo(rhs.upLo()) { assert(rhs.unitDiag()==NonUnit); } template <typename FS> template <typename RHS> SyMatrix<FS>::SyMatrix(const TrMatrix<RHS> &rhs) : _fs(rhs.engine()), _upLo(rhs.upLo()) { assert(rhs.unitDiag()==NonUnit); } // -- operators ---------------------------------------------------------------- template <typename FS> SyMatrix<FS> & SyMatrix<FS>::operator*=(T alpha) { scal(alpha, *this); return *this; } template <typename FS> SyMatrix<FS> & SyMatrix<FS>::operator/=(T alpha) { scal(T(1)/alpha, *this); return *this; } template <typename FS> const typename SyMatrix<FS>::T & SyMatrix<FS>::operator()(int row, int col) const { #ifndef NDEBUG if (_upLo==Upper) { assert(col>=row); } else { assert(col<=row); } #endif return _fs(row, col); } template <typename FS> typename SyMatrix<FS>::T & SyMatrix<FS>::operator()(int row, int col) { #ifndef NDEBUG if (_upLo==Upper) { assert(col>=row); } else { assert(col<=row); } #endif return _fs(row, col); } // -- methods ------------------------------------------------------------------ // for BLAS/LAPACK template <typename FS> StorageUpLo SyMatrix<FS>::upLo() const { return _upLo; } template <typename FS> int SyMatrix<FS>::dim() const { assert(_fs.numRows()==_fs.numCols()); return _fs.numRows(); } template <typename FS> int SyMatrix<FS>::leadingDimension() const { return _fs.leadingDimension(); } template <typename FS> const typename SyMatrix<FS>::T * SyMatrix<FS>::data() const { return _fs.data(); } template <typename FS> typename SyMatrix<FS>::T * SyMatrix<FS>::data() { return _fs.data(); } // for element access template <typename FS> int SyMatrix<FS>::firstRow() const { return _fs.firstRow(); } template <typename FS> int SyMatrix<FS>::lastRow() const { return _fs.lastRow(); } template <typename FS> int SyMatrix<FS>::firstCol() const { return _fs.firstCol(); } template <typename FS> int SyMatrix<FS>::lastCol() const { return _fs.lastCol(); } template <typename FS> Range SyMatrix<FS>::rows() const { return _(firstRow(), lastRow()); } template <typename FS> Range SyMatrix<FS>::cols() const { return _(firstCol(), lastCol()); } // -- implementation ----------------------------------------------------------- template <typename FS> const FS & SyMatrix<FS>::engine() const { return _fs; } template <typename FS> FS & SyMatrix<FS>::engine() { return _fs; } // == SbMatrix ================================================================= template <typename BS> SbMatrix<BS>::SbMatrix() { } template <typename BS> SbMatrix<BS>::SbMatrix(int dim, StorageUpLo upLo, int numOffDiags, int firstIndex) : _bs(dim, dim, (upLo==Lower) ? numOffDiags : 0, (upLo==Upper) ? numOffDiags : 0, firstIndex), _upLo(upLo) { } template <typename BS> SbMatrix<BS>::SbMatrix(const BS &bs, StorageUpLo upLo) : _bs(bs), _upLo(upLo) { } template <typename BS> SbMatrix<BS>::SbMatrix(const SbMatrix<BS> &rhs) : _bs(rhs.engine()), _upLo(rhs.upLo()) { } template <typename BS> template <typename RHS> SbMatrix<BS>::SbMatrix(const SbMatrix<RHS> &rhs) : _bs(rhs.engine()), _upLo(rhs.upLo()) { } template <typename BS> SbMatrix<BS>::SbMatrix(const TbMatrix<BS> &rhs) : _bs(rhs.engine()), _upLo(rhs.upLo()) { assert(rhs.unitDiag()==NonUnit); } template <typename BS> template <typename RHS> SbMatrix<BS>::SbMatrix(const TbMatrix<RHS> &rhs) : _bs(rhs.engine()), _upLo(rhs.upLo()) { assert(rhs.unitDiag()==NonUnit); } // -- operators ---------------------------------------------------------------- template <typename BS> SbMatrix<BS> & SbMatrix<BS>::operator*=(T alpha) { scal(alpha, *this); return *this; } template <typename BS> SbMatrix<BS> & SbMatrix<BS>::operator/=(T alpha) { scal(T(1)/alpha, *this); return *this; } template <typename BS> const typename SbMatrix<BS>::T & SbMatrix<BS>::operator()(int row, int col) const { #ifndef NDEBUG if (_upLo==Upper) { assert(col>=row); assert(col-row<=numOffDiags()); } else { assert(col<=row); assert(row-col<=numOffDiags()); } #endif return _bs(row, col); } template <typename BS> typename SbMatrix<BS>::T & SbMatrix<BS>::operator()(int row, int col) { #ifndef NDEBUG if (_upLo==Upper) { assert(col>=row); assert(col-row<=numOffDiags()); } else { assert(col<=row); assert(row-col<=numOffDiags()); } #endif return _bs(row, col); } // -- views -------------------------------------------------------------------- template <typename BS> typename SbMatrix<BS>::ConstVectorView SbMatrix<BS>::diag(int d) const { return _bs.viewDiag(d); } template <typename BS> typename SbMatrix<BS>::VectorView SbMatrix<BS>::diag(int d) { return _bs.viewDiag(d); } // -- methods ------------------------------------------------------------------ // for BLAS/LAPACK template <typename BS> StorageUpLo SbMatrix<BS>::upLo() const { return _upLo; } template <typename BS> int SbMatrix<BS>::dim() const { assert (_bs.numRows()==_bs.numCols()); return _bs.numRows(); } template <typename BS> int SbMatrix<BS>::numOffDiags() const { return (_upLo==Upper) ? _bs.numSuperDiags() : _bs.numSubDiags(); } template <typename BS> int SbMatrix<BS>::leadingDimension() const { return _bs.leadingDimension(); } template <typename BS> const typename SbMatrix<BS>::T * SbMatrix<BS>::data() const { return _bs.data(); } template <typename BS> typename SbMatrix<BS>::T * SbMatrix<BS>::data() { return _bs.data(); } // for element access template <typename BS> int SbMatrix<BS>::firstIndex() const { return _bs.firstRow(); } template <typename BS> int SbMatrix<BS>::lastIndex() const { assert(_bs.lastRow()==_bs.lastCol()); return _bs.lastRow(); } template <typename BS> Range SbMatrix<BS>::indices() const { return _(firstIndex(), lastIndex()); } template <typename BS> Range SbMatrix<BS>::diags() const { return (_upLo==Upper) ? _(0, numOffDiags()) : _(-numOffDiags(),0); } // -- implementation ----------------------------------------------------------- template <typename BS> const BS & SbMatrix<BS>::engine() const { return _bs; } template <typename BS> BS & SbMatrix<BS>::engine() { return _bs; } // == SpMatrix ================================================================= template <typename PS> SpMatrix<PS>::SpMatrix() { } template <typename PS> SpMatrix<PS>::SpMatrix(int dim, int firstIndex) : _ps(dim, firstIndex) { } template <typename PS> SpMatrix<PS>::SpMatrix(const PS &ps) : _ps(ps) { } // -- operators ---------------------------------------------------------------- template <typename PS> const typename SpMatrix<PS>::T & SpMatrix<PS>::operator()(int row, int col) const { return _ps(row, col); } template <typename PS> typename SpMatrix<PS>::T & SpMatrix<PS>::operator()(int row, int col) { return _ps(row, col); } // -- methods ------------------------------------------------------------------ // for BLAS/LAPACK template <typename PS> StorageUpLo SpMatrix<PS>::upLo() const { return StorageInfo<PS>::upLo; } template <typename PS> int SpMatrix<PS>::dim() const { return _ps.dim(); } template <typename PS> const typename SpMatrix<PS>::T * SpMatrix<PS>::data() const { return _ps.data(); } template <typename PS> typename SpMatrix<PS>::T * SpMatrix<PS>::data() { return _ps.data(); } // for element access template <typename PS> int SpMatrix<PS>::firstIndex() const { return _ps.firstIndex(); } template <typename PS> int SpMatrix<PS>::lastIndex() const { return _ps.lastIndex(); } template <typename PS> Range SpMatrix<PS>::indices() const { return _(firstIndex(), lastIndex()); } // -- implementation ----------------------------------------------------------- template <typename PS> const PS & SpMatrix<PS>::engine() const { return _ps; } template <typename PS> PS & SpMatrix<PS>::engine() { return _ps; } } // namespace flens
19.472426
82
0.608515
wmotte
b7da5088d7622a8874588da7d57077b61ee4e02d
205
hpp
C++
random/shuffle_container.hpp
ankit6776/cplib-cpp
b9f8927a6c7301374c470856828aa1f5667d967b
[ "MIT" ]
20
2021-06-21T00:18:54.000Z
2022-03-17T17:45:44.000Z
random/shuffle_container.hpp
ankit6776/cplib-cpp
b9f8927a6c7301374c470856828aa1f5667d967b
[ "MIT" ]
56
2021-06-03T14:42:13.000Z
2022-03-26T14:15:30.000Z
random/shuffle_container.hpp
ankit6776/cplib-cpp
b9f8927a6c7301374c470856828aa1f5667d967b
[ "MIT" ]
3
2019-12-11T06:45:45.000Z
2020-09-07T13:45:32.000Z
#pragma once #include <algorithm> #include <chrono> #include <random> // CUT begin std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); // std::shuffle(v.begin(), v.end(), rng);
22.777778
78
0.687805
ankit6776
b7db576950dafc9c7f98fbaaeafab3897adc6511
88
hpp
C++
FFmpegServer/FFmpegYAGuiDroidCapture_PacketQueue/include/Common/Object.hpp
aalekhm/OpenFF
9df23a21727f29a871f7239ccf15e3100ae9780e
[ "MIT" ]
null
null
null
FFmpegServer/FFmpegYAGuiDroidCapture_PacketQueue/include/Common/Object.hpp
aalekhm/OpenFF
9df23a21727f29a871f7239ccf15e3100ae9780e
[ "MIT" ]
null
null
null
FFmpegServer/FFmpegYAGuiDroidCapture_PacketQueue/include/Common/Object.hpp
aalekhm/OpenFF
9df23a21727f29a871f7239ccf15e3100ae9780e
[ "MIT" ]
null
null
null
#pragma once template<typename T> struct SPacket { T m_pData; SPacket* m_pNext; };
9.777778
20
0.704545
aalekhm
b7dc786a4ffac993a857123d5a525252eef56964
3,464
cpp
C++
lib/slikenet/Samples/CrashReporter/SendFileTo.cpp
TRUEPADDii/GothicMultiplayerLauncher
1ae083a62c083fc99bb9b1358a223ae02174af3f
[ "WTFPL" ]
2
2018-04-09T12:54:20.000Z
2018-12-07T20:34:53.000Z
lib/slikenet/Samples/CrashReporter/SendFileTo.cpp
TRUEPADDii/GothicMultiplayerLauncher
1ae083a62c083fc99bb9b1358a223ae02174af3f
[ "WTFPL" ]
4
2018-04-10T23:28:47.000Z
2021-05-16T20:35:21.000Z
lib/slikenet/Samples/CrashReporter/SendFileTo.cpp
TRUEPADDii/GothicMultiplayerLauncher
1ae083a62c083fc99bb9b1358a223ae02174af3f
[ "WTFPL" ]
3
2019-02-13T15:10:03.000Z
2021-07-12T19:24:07.000Z
/* * Original work: Copyright (c) 2014, Oculus VR, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * RakNet License.txt file in the licenses directory of this source tree. An additional grant * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * * Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. */ #include "slikenet/WindowsIncludes.h" #include "SendFileTo.h" #include <shlwapi.h> #include <tchar.h> #include <stdio.h> #include <direct.h> #include "slikenet/linux_adapter.h" #include "slikenet/osx_adapter.h" bool CSendFileTo::SendMail(HWND hWndParent, const char *strAttachmentFilePath, const char *strAttachmentFileName, const char *strSubject, const char *strBody, const char *strRecipient) { // if (strAttachmentFileName==0) // return false; // if (!hWndParent || !::IsWindow(hWndParent)) // return false; HINSTANCE hMAPI = LoadLibrary(_T("MAPI32.DLL")); if (!hMAPI) return false; ULONG (PASCAL *SendMail)(ULONG, ULONG_PTR, MapiMessage*, FLAGS, ULONG); (FARPROC&)SendMail = GetProcAddress(hMAPI, "MAPISendMail"); if (!SendMail) return false; // char szFileName[_MAX_PATH]; // char szPath[_MAX_PATH]; char szName[_MAX_PATH]; char szSubject[_MAX_PATH]; char szBody[_MAX_PATH]; char szAddress[_MAX_PATH]; char szSupport[_MAX_PATH]; //strcpy_s(szFileName, strAttachmentFileName); //strcpy_s(szPath, strAttachmentFilePath); if (strAttachmentFileName) strcpy_s(szName, strAttachmentFileName); strcpy_s(szSubject, strSubject); strcpy_s(szBody, strBody); sprintf_s(szAddress, "SMTP:%s", strRecipient); //strcpy_s(szSupport, "Support"); char fullPath[_MAX_PATH]; if (strAttachmentFileName && strAttachmentFilePath) { if (strlen(strAttachmentFilePath)<3 || strAttachmentFilePath[1]!=':' || (strAttachmentFilePath[2]!='\\' && strAttachmentFilePath[2]!='/')) { // Make relative paths absolute _getcwd(fullPath, _MAX_PATH); strcat_s(fullPath, "/"); strcat_s(fullPath, strAttachmentFilePath); } else strcpy_s(fullPath, strAttachmentFilePath); // All slashes have to be \\ and not / int len=(unsigned int)strlen(fullPath); int i; for (i=0; i < len; i++) { if (fullPath[i]=='/') fullPath[i]='\\'; } } MapiFileDesc fileDesc; if (strAttachmentFileName && strAttachmentFilePath) { ZeroMemory(&fileDesc, sizeof(fileDesc)); fileDesc.nPosition = (ULONG)-1; fileDesc.lpszPathName = fullPath; fileDesc.lpszFileName = szName; } MapiRecipDesc recipDesc; ZeroMemory(&recipDesc, sizeof(recipDesc)); recipDesc.lpszName = szSupport; recipDesc.ulRecipClass = MAPI_TO; recipDesc.lpszName = szAddress+5; recipDesc.lpszAddress = szAddress; MapiMessage message; ZeroMemory(&message, sizeof(message)); message.nRecipCount = 1; message.lpRecips = &recipDesc; message.lpszSubject = szSubject; message.lpszNoteText = szBody; if (strAttachmentFileName && strAttachmentFilePath) { message.nFileCount = 1; message.lpFiles = &fileDesc; } int nError = SendMail(0, (ULONG_PTR)hWndParent, &message, MAPI_LOGON_UI|MAPI_DIALOG, 0); if (nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE) return false; return true; }
28.393443
184
0.727771
TRUEPADDii
b7dd6a077e49a5a43f1548d3a4f1175fb294b5f1
1,402
cpp
C++
Easy/125_isPalindrome/125_isPalindrome/main.cpp
yangbingjie/Leetcode
2f1e386cfb8b2d7d49cf0e7dcf0bce1c936e1916
[ "MIT" ]
1
2020-10-08T06:15:37.000Z
2020-10-08T06:15:37.000Z
Easy/125_isPalindrome/125_isPalindrome/main.cpp
yangbingjie/Leetcode
2f1e386cfb8b2d7d49cf0e7dcf0bce1c936e1916
[ "MIT" ]
null
null
null
Easy/125_isPalindrome/125_isPalindrome/main.cpp
yangbingjie/Leetcode
2f1e386cfb8b2d7d49cf0e7dcf0bce1c936e1916
[ "MIT" ]
null
null
null
// // main.cpp // 125_isPalindrome // // Created by Bella Yang on 2019/10/15. // Copyright © 2019 Bella Yang. All rights reserved. // #include <iostream> #include <string> using namespace std; class Solution { public: bool isSame(char ch1, char ch2){ if (isChar(ch1) ^ isChar(ch2)) { return false; } if (isChar(ch1) && isChar(ch2)) { return ch1 == ch2 || abs(ch1 - ch2) == abs('a' - 'A'); } return ch1 == ch2; } bool isChar(char ch){ return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } bool isNumber(char ch){ return (ch >= '0' && ch <= '9'); } bool isPalindrome(string s) { for (int i = 0, j = int(s.size() - 1); i < j; i++,j--) { while (i < s.size() && !isChar(s[i]) && !isNumber(s[i])) { i++; } while (j > -1 && !isChar(s[j]) && !isNumber(s[j])) { j--; } if (i == s.size() && j < 0) { return true; } if ((i == s.size() && j >= 0) || (i < s.size() && j < 0)) { return false; } if (!isSame(s[i], s[j])) { return false; } } return true; } }; int main(int argc, const char * argv[]) { Solution s; cout << s.isPalindrome(".,"); return 0; }
25.490909
71
0.409415
yangbingjie
b7df2a6c877b4767b8bb6d2ddca849ced1e90ee1
3,909
cpp
C++
src/Event.cpp
irov/GOAP
f8d5f061537019fccdd143b232aa8a869fdb0b2d
[ "MIT" ]
14
2016-10-07T21:53:02.000Z
2021-12-13T02:57:19.000Z
src/Event.cpp
irov/GOAP
f8d5f061537019fccdd143b232aa8a869fdb0b2d
[ "MIT" ]
null
null
null
src/Event.cpp
irov/GOAP
f8d5f061537019fccdd143b232aa8a869fdb0b2d
[ "MIT" ]
4
2016-09-01T10:06:29.000Z
2021-12-13T02:57:20.000Z
/* * Copyright (C) 2017-2019, Yuriy Levchenko <irov13@mail.ru> * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ #include "Event.h" #include "GOAP/EventProviderInterface.h" #include "GOAP/StlAllocator.h" #include <algorithm> namespace GOAP { ////////////////////////////////////////////////////////////////////////// Event::Event( Allocator * _allocator ) : EventInterface( _allocator ) , m_providers( StlAllocator<ProviderDesc>( _allocator ) ) , m_providersAdd( StlAllocator<ProviderDesc>( _allocator ) ) , m_process( 0 ) { } ////////////////////////////////////////////////////////////////////////// Event::~Event() { } ////////////////////////////////////////////////////////////////////////// void Event::addProvider( const EventProviderInterfacePtr & _eventProvider ) { ProviderDesc desc; desc.provider = _eventProvider; desc.dead = false; if( m_process == 0 ) { m_providers.emplace_back( desc ); } else { m_providersAdd.emplace_back( desc ); } } ////////////////////////////////////////////////////////////////////////// bool Event::removeProvider( const EventProviderInterfacePtr & _eventProvider ) { VectorProviders::iterator it_found_add = std::find_if( m_providersAdd.begin(), m_providersAdd.end(), [&_eventProvider]( const Event::ProviderDesc & _desc ) { return _desc.provider == _eventProvider; } ); if( it_found_add != m_providersAdd.end() ) { m_providersAdd.erase( it_found_add ); return true; } VectorProviders::iterator it_found = std::find_if( m_providers.begin(), m_providers.end(), [&_eventProvider]( const Event::ProviderDesc & _desc ) { return _desc.provider == _eventProvider; } ); if( it_found == m_providers.end() ) { return false; } if( m_process == 0 ) { m_providers.erase( it_found ); } else { ProviderDesc & desc = *it_found; desc.provider = nullptr; desc.dead = true; } return true; } ////////////////////////////////////////////////////////////////////////// void Event::clearProviders() { m_providersAdd.clear(); if( m_process != 0 ) { for( ProviderDesc & desc : m_providers ) { desc.dead = true; } return; } m_providers.clear(); } ////////////////////////////////////////////////////////////////////////// void Event::call() { this->incref(); ++m_process; for( const ProviderDesc & desc : m_providers ) { if( desc.dead == true ) { continue; } EventProviderInterfacePtr provider = desc.provider; bool remove = provider->onEvent(); if( remove == false ) { continue; } if( desc.dead == true ) { continue; } this->removeProvider( provider ); } --m_process; if( m_process == 0 ) { m_providers.insert( m_providers.end(), m_providersAdd.begin(), m_providersAdd.end() ); m_providersAdd.clear(); VectorProviders::iterator it_erase = std::remove_if( m_providers.begin(), m_providers.end(), []( const Event::ProviderDesc & _desc ) { return _desc.dead; } ); m_providers.erase( it_erase, m_providers.end() ); } this->decref(); } }
26.06
163
0.458173
irov
b7e0f7e05b98aa6f773744013e4cf0c614dfe08c
2,670
cpp
C++
cpp/template_test.cpp
dibayendu/codekata
4055af08d3e8fd373e3dd8107f5bde82c74fe92f
[ "MIT" ]
null
null
null
cpp/template_test.cpp
dibayendu/codekata
4055af08d3e8fd373e3dd8107f5bde82c74fe92f
[ "MIT" ]
null
null
null
cpp/template_test.cpp
dibayendu/codekata
4055af08d3e8fd373e3dd8107f5bde82c74fe92f
[ "MIT" ]
null
null
null
// To run the program, try the command below: // g++ tempate_test.cpp -lgtest_main -lgtest // This is a template unit testing file using googletest. // This checks if the number is prime and its factorials. #include <iostream> #include <string> #include <limits.h> #include "gtest/gtest.h" // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int Factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result *= i; } return result; } // Returns true iff n is a prime number. bool IsPrime(int n) { // Trivial case 1: small numbers if (n <= 1) return false; // Trivial case 2: even numbers if (n % 2 == 0) return n == 2; // Now, we have that n is odd and n >= 3. // Try to divide n by every odd number i, starting from 3 for (int i = 3; ; i += 2) { // We only have to try i up to the squre root of n if (i > n/i) break; // Now, we have i <= n/i < n. // If n is divisible by i, n is not prime. if (n % i == 0) return false; } // n has no integer factor in the range (1, n), and thus is prime. return true; } // Tests factorial of negative numbers. TEST(FactorialTest, Negative) { // This test is named "Negative", and belongs to the "FactorialTest" // test case. EXPECT_EQ(1, Factorial(-5)); EXPECT_EQ(1, Factorial(-1)); EXPECT_GT(Factorial(-10), 0); // <TechnicalDetails> // // EXPECT_EQ(expected, actual) is the same as // // EXPECT_TRUE((expected) == (actual)) // // except that it will print both the expected value and the actual // value when the assertion fails. This is very helpful for // debugging. Therefore in this case EXPECT_EQ is preferred. // // On the other hand, EXPECT_TRUE accepts any Boolean expression, // and is thus more general. // // </TechnicalDetails> } // Tests factorial of 0. TEST(FactorialTest, Zero) { EXPECT_EQ(1, Factorial(0)); } // Tests factorial of positive numbers. TEST(FactorialTest, Positive) { EXPECT_EQ(1, Factorial(1)); EXPECT_EQ(2, Factorial(2)); EXPECT_EQ(6, Factorial(3)); EXPECT_EQ(40320, Factorial(8)); } // Tests IsPrime() // Tests negative input. TEST(IsPrimeTest, Negative) { // This test belongs to the IsPrimeTest test case. EXPECT_FALSE(IsPrime(-1)); EXPECT_FALSE(IsPrime(-2)); EXPECT_FALSE(IsPrime(INT_MIN)); } // Tests some trivial cases. TEST(IsPrimeTest, Trivial) { EXPECT_FALSE(IsPrime(0)); EXPECT_FALSE(IsPrime(1)); EXPECT_TRUE(IsPrime(2)); EXPECT_TRUE(IsPrime(3)); } // Tests positive input. TEST(IsPrimeTest, Positive) { EXPECT_FALSE(IsPrime(4)); EXPECT_TRUE(IsPrime(5)); EXPECT_FALSE(IsPrime(6)); EXPECT_TRUE(IsPrime(23)); }
24.054054
75
0.657678
dibayendu
b7e3a93e0144f15aeac02011c61d2c20db5c71b0
395
cpp
C++
ZAPD/HighLevel/HLTexture.cpp
zbanks/ZAPD
a357277e412b5e8f0f2f0578c7d7d213e8744c8d
[ "MIT" ]
null
null
null
ZAPD/HighLevel/HLTexture.cpp
zbanks/ZAPD
a357277e412b5e8f0f2f0578c7d7d213e8744c8d
[ "MIT" ]
null
null
null
ZAPD/HighLevel/HLTexture.cpp
zbanks/ZAPD
a357277e412b5e8f0f2f0578c7d7d213e8744c8d
[ "MIT" ]
null
null
null
#include "HLTexture.h" #include "../StringHelper.h" HLTexture* HLTexture::FromPNG(std::string pngFilePath, HLTextureType texType) { // int32_t comp; HLTexture* tex = new HLTexture(); tex->type = texType; // tex->bmpRgba = (uint8_t*)stbi_load((pngFilePath).c_str(), (int32_t*)&tex->width, // (int32_t*)&tex->height, &comp, STBI_rgb_alpha); return tex; }
28.214286
85
0.635443
zbanks
b7e6c12b01031b53dc9cd82ceabda05ae7eeee86
2,074
hpp
C++
client/systems/adminPanel/dialog/markerLog.hpp
Exonical/Vanguard_Wasteland.cup_chernarus_A3
ee8f51807847f35c924bb8bf701e863387b603b8
[ "MIT" ]
1
2020-07-23T13:49:05.000Z
2020-07-23T13:49:05.000Z
client/systems/adminPanel/dialog/markerLog.hpp
Exonical/Vanguard_Wasteland.cup_chernarus_A3
ee8f51807847f35c924bb8bf701e863387b603b8
[ "MIT" ]
null
null
null
client/systems/adminPanel/dialog/markerLog.hpp
Exonical/Vanguard_Wasteland.cup_chernarus_A3
ee8f51807847f35c924bb8bf701e863387b603b8
[ "MIT" ]
null
null
null
// ****************************************************************************************** // * This project is licensed under the GNU Affero GPL v3. Copyright © 2016 A3Wasteland.com * // ****************************************************************************************** // @file Name: markerLog.hpp #define markerLogDialog 56500 #define markerLogList 56501 class MarkerLog { idd = markerLogDialog; movingEnable = false; enableSimulation = true; onLoad = "execVM 'client\systems\adminPanel\markerLog.sqf'"; class controlsBackground { class MainBackground: IGUIBack { idc = -1; colorText[] = {1, 1, 1, 1}; colorBackground[] = {0,0,0,0.6}; x = 0.1875 * (4/3) * SZ_SCALE_ABS + safezoneX; y = 0.15 * SZ_SCALE_ABS + safezoneY; w = 0.625 * (4/3) * SZ_SCALE_ABS; h = 0.661111 * SZ_SCALE_ABS; }; class TopBar: IGUIBack { idc = -1; colorText[] = {1, 1, 1, 1}; colorBackground[] = {A3W_UICOLOR_R, A3W_UICOLOR_G, A3W_UICOLOR_B, 0.8}; x = 0.1875 * (4/3) * SZ_SCALE_ABS + safezoneX; y = 0.15 * SZ_SCALE_ABS + safezoneY; w = 0.625 * (4/3) * SZ_SCALE_ABS; h = 0.05 * SZ_SCALE_ABS; }; class DialogTitleText: w_RscText { idc = -1; text = "Markers Log"; font = "PuristaMedium"; sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)"; x = 0.20 * (4/3) * SZ_SCALE_ABS + safezoneX; y = 0.155 * SZ_SCALE_ABS + safezoneY; w = 0.0844792 * (4/3) * SZ_SCALE_ABS; h = 0.0448148 * SZ_SCALE_ABS; }; }; class controls { class MarkerListBox: w_RscList { idc = markerLogList; x = 0.2 * (4/3) * SZ_SCALE_ABS + safezoneX; y = 0.225 * SZ_SCALE_ABS + safezoneY; w = 0.5925 * (4/3) * SZ_SCALE_ABS; h = 0.5 * SZ_SCALE_ABS; }; class RefreshButton: w_RscButton { idc = -1; text = "Refresh"; onButtonClick = "call compile preprocessFileLineNumbers 'client\systems\adminPanel\markerLog.sqf'"; x = 0.2 * (4/3) * SZ_SCALE_ABS + safezoneX; y = 0.748 * SZ_SCALE_ABS + safezoneY; w = 0.05 * (4/3) * SZ_SCALE_ABS; h = 0.04 * SZ_SCALE_ABS; }; }; };
26.253165
102
0.563645
Exonical
b7ea14bebef43c6e0b4aae9f1f572d0768277454
6,589
hxx
C++
libbutl/char-scanner.hxx
build2/libbutl
405dfa3e28ab71d4f6b5210faba0e3600070a0f3
[ "MIT" ]
6
2018-05-31T06:16:37.000Z
2021-03-19T10:37:11.000Z
libbutl/char-scanner.hxx
build2/libbutl
405dfa3e28ab71d4f6b5210faba0e3600070a0f3
[ "MIT" ]
3
2020-06-19T05:08:42.000Z
2021-09-29T05:23:07.000Z
libbutl/char-scanner.hxx
build2/libbutl
405dfa3e28ab71d4f6b5210faba0e3600070a0f3
[ "MIT" ]
1
2020-06-16T14:56:48.000Z
2020-06-16T14:56:48.000Z
// file : libbutl/char-scanner.hxx -*- C++ -*- // license : MIT; see accompanying LICENSE file #pragma once #include <string> // char_traits #include <cassert> #include <cstddef> // size_t #include <cstdint> // uint64_t #include <climits> // INT_* #include <utility> // pair, make_pair() #include <istream> #include <libbutl/bufstreambuf.hxx> #include <libbutl/export.hxx> namespace butl { // Refer to utf8_validator for details. // struct noop_validator { std::pair<bool, bool> validate (char) {return std::make_pair (true, true);} std::pair<bool, bool> validate (char c, std::string&) {return validate (c);} }; // Low-level character stream scanner. Normally used as a base for // higher-level lexers. // template <typename V = noop_validator, std::size_t N = 1> class char_scanner { public: using validator_type = V; static constexpr const std::size_t unget_depth = N; // If the crlf argument is true, then recognize Windows newlines (0x0D // 0x0A) and convert them to just '\n' (0x0A). Note that a standalone // 0x0D is treated "as if" it was followed by 0x0A and multiple 0x0D // are treated as one. // // Note also that if the stream happens to be bufstreambuf-based, then it // includes a number of optimizations that assume nobody else is messing // with the stream. // // The line and position arguments can be used to override the start line // and position in the stream (useful when re-scanning data saved with the // save_* facility). // char_scanner (std::istream&, bool crlf = true, std::uint64_t line = 1, std::uint64_t position = 0); char_scanner (std::istream&, validator_type, bool crlf = true, std::uint64_t line = 1, std::uint64_t position = 0); char_scanner (const char_scanner&) = delete; char_scanner& operator= (const char_scanner&) = delete; // Scanner interface. // public: // Extended character. It includes line/column/position information and is // capable of representing EOF and invalid characters. // // Note that implicit conversion of EOF/invalid to char_type results in // NUL character (which means in most cases it is safe to compare xchar to // char without checking for EOF). // class xchar { public: using traits_type = std::char_traits<char>; using int_type = traits_type::int_type; using char_type = traits_type::char_type; int_type value; // Note that the column is of the codepoint this byte belongs to. // std::uint64_t line; std::uint64_t column; // Logical character position (see bufstreambuf for details on the // logical part) if the scanned stream is bufstreambuf-based and always // zero otherwise. // std::uint64_t position; static int_type invalid () {return traits_type::eof () != INT_MIN ? INT_MIN : INT_MAX;} operator char_type () const { return value != traits_type::eof () && value != invalid () ? static_cast<char_type> (value) : char_type (0); } xchar (int_type v = 0, std::uint64_t l = 0, std::uint64_t c = 0, std::uint64_t p = 0) : value (v), line (l), column (c), position (p) {} }; // Note that if any of the get() or peek() functions return an invalid // character, then the scanning has failed and none of them should be // called again. xchar get (); // As above but in case of an invalid character also return the // description of why it is invalid. // xchar get (std::string& what); void get (const xchar& peeked); // Get previously peeked character (faster). void unget (const xchar&); // Note that if there is an "ungot" character, peek() will return that. // xchar peek (); // As above but in case of an invalid character also return the // description of why it is invalid. // xchar peek (std::string& what); // Tests. In the future we can add tests line alpha(), alnum(), etc. // static bool eos (const xchar& c) {return c.value == xchar::traits_type::eof ();} static bool invalid (const xchar& c) {return c.value == xchar::invalid ();} // Line, column and position of the next character to be extracted from // the stream by peek() or get(). // std::uint64_t line; std::uint64_t column; std::uint64_t position; // Ability to save raw data as it is being scanned. Note that the // character is only saved when it is got, not peeked. // public: void save_start (std::string& b) { assert (save_ == nullptr); save_ = &b; } void save_stop () { assert (save_ != nullptr); save_ = nullptr; } struct save_guard { explicit save_guard (char_scanner& s, std::string& b): s_ (&s) {s.save_start (b);} void stop () {if (s_ != nullptr) {s_->save_stop (); s_ = nullptr;}} ~save_guard () {stop ();} private: char_scanner* s_; }; protected: using int_type = typename xchar::int_type; using char_type = typename xchar::char_type; int_type peek_ (); void get_ (); std::uint64_t pos_ () const; xchar get (std::string* what); xchar peek (std::string* what); protected: std::istream& is_; validator_type val_; bool decoded_ = true; // The peeked character is last byte of sequence. bool validated_ = false; // The peeked character has been validated. // Note that if you are reading from the buffer directly, then it is also // your responsibility to call the validator and save the data (see // save_*(). // // Besides that, make sure that the peek() call preceding the scan is // followed by the get() call (see validated_, decoded_, and unpeek_ for // the hairy details; realistically, you would probably only direct-scan // ASCII fragments). // bufstreambuf* buf_; // NULL if not bufstreambuf-based. const char_type* gptr_; const char_type* egptr_; std::string* save_ = nullptr; bool crlf_; bool eos_ = false; std::size_t ungetn_ = 0; xchar ungetb_[N]; bool unpeek_ = false; xchar unpeekc_ = '\0'; }; } #include <libbutl/char-scanner.ixx> #include <libbutl/char-scanner.txx>
26.676113
79
0.615116
build2
b7f16117c343d641e1dc1375ef028ab26ede9c8f
1,131
hpp
C++
code/binary/include/binary/implementations/simple_heap_buffer.hpp
afxres/binary-cxx
ef84b0d5324c5add5ea8a09340471efc6221f91f
[ "MIT" ]
1
2019-11-21T06:37:04.000Z
2019-11-21T06:37:04.000Z
code/binary/include/binary/implementations/simple_heap_buffer.hpp
afxres/binary-cxx
ef84b0d5324c5add5ea8a09340471efc6221f91f
[ "MIT" ]
null
null
null
code/binary/include/binary/implementations/simple_heap_buffer.hpp
afxres/binary-cxx
ef84b0d5324c5add5ea8a09340471efc6221f91f
[ "MIT" ]
1
2019-11-26T16:47:56.000Z
2019-11-26T16:47:56.000Z
#pragma once #include "../abstract_buffer.hpp" namespace mikodev::binary::implementations { class simple_heap_buffer final : public abstract_buffer { private: byte_ptr buffer_; simple_heap_buffer(byte_ptr buffer, length_t length) : abstract_buffer(length), buffer_(buffer) {} public: simple_heap_buffer() : simple_heap_buffer(nullptr, 0) {} virtual byte_ptr buffer() override { return buffer_; } virtual ~simple_heap_buffer() override { if (buffer_ == nullptr) return; std::free(reinterpret_cast<void*>(buffer_)); buffer_ = nullptr; } virtual abstract_buffer_ptr create(length_t length) override { if (length == 0) return std::make_shared<simple_heap_buffer>(); byte_ptr buffer = reinterpret_cast<byte_ptr>(std::malloc(length)); if (buffer == nullptr) exceptions::throw_helper::throw_out_of_memory(); return std::shared_ptr<simple_heap_buffer>(new simple_heap_buffer(buffer, length)); } }; }
29.763158
106
0.617153
afxres
b7f75cde29c555019fe4d1a335999f535cd63ac5
24,475
cpp
C++
Emscripten/G3MEmscripten/G3MEmscripten/NativeGL_Emscripten.cpp
glob3mobile/g3m
2b2c6422f05d13e0855b1dbe4e0afed241184193
[ "BSD-2-Clause" ]
70
2015-02-06T14:39:14.000Z
2022-01-07T08:32:48.000Z
Emscripten/G3MEmscripten/G3MEmscripten/NativeGL_Emscripten.cpp
glob3mobile/g3m
2b2c6422f05d13e0855b1dbe4e0afed241184193
[ "BSD-2-Clause" ]
118
2015-01-21T10:18:00.000Z
2018-10-16T15:00:57.000Z
Emscripten/G3MEmscripten/G3MEmscripten/NativeGL_Emscripten.cpp
glob3mobile/g3m
2b2c6422f05d13e0855b1dbe4e0afed241184193
[ "BSD-2-Clause" ]
41
2015-01-10T22:29:27.000Z
2021-06-08T11:56:16.000Z
#include "NativeGL_Emscripten.hpp" #include <emscripten/emscripten.h> #include "G3M/GPUProgram.hpp" #include "G3M/Matrix44D.hpp" #include "G3M/GPUUniform.hpp" #include "G3M/GPUAttributeVec3Float.hpp" #include "G3M/GPUAttributeVec4Float.hpp" #include "G3M/GPUAttributeVec2Float.hpp" #include "FloatBuffer_Emscripten.hpp" #include "ShortBuffer_Emscripten.hpp" #include "GLUniformID_Emscripten.hpp" #include "GLTextureID_Emscripten.hpp" #include "Image_Emscripten.hpp" using namespace emscripten; NativeGL_Emscripten::NativeGL_Emscripten(const val& gl) : _gl(gl), GL_FLOAT ( gl["FLOAT" ].as<int>() ), GL_ARRAY_BUFFER ( gl["ARRAY_BUFFER" ].as<int>() ), GL_STATIC_DRAW ( gl["STATIC_DRAW" ].as<int>() ), GL_ELEMENT_ARRAY_BUFFER ( gl["ELEMENT_ARRAY_BUFFER" ].as<int>() ), GL_UNSIGNED_SHORT ( gl["UNSIGNED_SHORT" ].as<int>() ), GL_NO_ERROR ( gl["NO_ERROR" ].as<int>() ), GL_INVALID_ENUM ( gl["INVALID_ENUM" ].as<int>() ), GL_INVALID_VALUE ( gl["INVALID_VALUE" ].as<int>() ), GL_INVALID_OPERATION ( gl["INVALID_OPERATION" ].as<int>() ), GL_INVALID_FRAMEBUFFER_OPERATION( gl["INVALID_FRAMEBUFFER_OPERATION" ].as<int>() ), GL_OUT_OF_MEMORY ( gl["OUT_OF_MEMORY" ].as<int>() ), GL_CONTEXT_LOST_WEBGL ( gl["CONTEXT_LOST_WEBGL" ].as<int>() ), GL_FRONT ( gl["FRONT" ].as<int>() ), GL_BACK ( gl["BACK" ].as<int>() ), GL_FRONT_AND_BACK ( gl["FRONT_AND_BACK" ].as<int>() ), GL_COLOR_BUFFER_BIT ( gl["COLOR_BUFFER_BIT" ].as<int>() ), GL_DEPTH_BUFFER_BIT ( gl["DEPTH_BUFFER_BIT" ].as<int>() ), GL_POLYGON_OFFSET_FILL ( gl["POLYGON_OFFSET_FILL" ].as<int>() ), GL_DEPTH_TEST ( gl["DEPTH_TEST" ].as<int>() ), GL_BLEND ( gl["BLEND" ].as<int>() ), GL_CULL_FACE ( gl["CULL_FACE" ].as<int>() ), GL_TRIANGLES ( gl["TRIANGLES" ].as<int>() ), GL_TRIANGLE_STRIP ( gl["TRIANGLE_STRIP" ].as<int>() ), GL_TRIANGLE_FAN ( gl["TRIANGLE_FAN" ].as<int>() ), GL_LINES ( gl["LINES" ].as<int>() ), GL_LINE_STRIP ( gl["LINE_STRIP" ].as<int>() ), GL_LINE_LOOP ( gl["LINE_LOOP" ].as<int>() ), GL_POINTS ( gl["POINTS" ].as<int>() ), GL_UNSIGNED_BYTE ( gl["UNSIGNED_BYTE" ].as<int>() ), GL_UNSIGNED_INT ( gl["UNSIGNED_INT" ].as<int>() ), GL_INT ( gl["INT" ].as<int>() ), GL_FLOAT_VEC2 ( gl["FLOAT_VEC2" ].as<int>() ), GL_FLOAT_VEC3 ( gl["FLOAT_VEC3" ].as<int>() ), GL_FLOAT_VEC4 ( gl["FLOAT_VEC4" ].as<int>() ), GL_BOOL ( gl["BOOL" ].as<int>() ), GL_FLOAT_MAT4 ( gl["FLOAT_MAT4" ].as<int>() ), GL_ONE ( gl["ONE" ].as<int>() ), GL_ZERO ( gl["ZERO" ].as<int>() ), GL_SRC_ALPHA ( gl["SRC_ALPHA" ].as<int>() ), GL_ONE_MINUS_SRC_ALPHA ( gl["ONE_MINUS_SRC_ALPHA" ].as<int>() ), GL_TEXTURE_2D ( gl["TEXTURE_2D" ].as<int>() ), GL_TEXTURE_MIN_FILTER ( gl["TEXTURE_MIN_FILTER" ].as<int>() ), GL_TEXTURE_MAG_FILTER ( gl["TEXTURE_MAG_FILTER" ].as<int>() ), GL_TEXTURE_WRAP_S ( gl["TEXTURE_WRAP_S" ].as<int>() ), GL_TEXTURE_WRAP_T ( gl["TEXTURE_WRAP_T" ].as<int>() ), GL_NEAREST ( gl["NEAREST" ].as<int>() ), GL_LINEAR ( gl["LINEAR" ].as<int>() ), GL_NEAREST_MIPMAP_NEAREST ( gl["NEAREST_MIPMAP_NEAREST" ].as<int>() ), GL_NEAREST_MIPMAP_LINEAR ( gl["NEAREST_MIPMAP_LINEAR" ].as<int>() ), GL_LINEAR_MIPMAP_NEAREST ( gl["LINEAR_MIPMAP_NEAREST" ].as<int>() ), GL_LINEAR_MIPMAP_LINEAR ( gl["LINEAR_MIPMAP_LINEAR" ].as<int>() ), GL_REPEAT ( gl["REPEAT" ].as<int>() ), GL_CLAMP_TO_EDGE ( gl["CLAMP_TO_EDGE" ].as<int>() ), GL_MIRRORED_REPEAT ( gl["MIRRORED_REPEAT" ].as<int>() ), GL_PACK_ALIGNMENT ( gl["PACK_ALIGNMENT" ].as<int>() ), GL_UNPACK_ALIGNMENT ( gl["UNPACK_ALIGNMENT" ].as<int>() ), GL_RGBA ( gl["RGBA" ].as<int>() ), GL_VIEWPORT ( gl["VIEWPORT" ].as<int>() ), GL_ACTIVE_ATTRIBUTES ( gl["ACTIVE_ATTRIBUTES" ].as<int>() ), GL_ACTIVE_UNIFORMS ( gl["ACTIVE_UNIFORMS" ].as<int>() ), GL_TEXTURE0 ( gl["TEXTURE0" ].as<int>() ), GL_VERTEX_SHADER ( gl["VERTEX_SHADER" ].as<int>() ), GL_FRAGMENT_SHADER ( gl["FRAGMENT_SHADER" ].as<int>() ), GL_COMPILE_STATUS ( gl["COMPILE_STATUS" ].as<int>() ), GL_LINK_STATUS ( gl["LINK_STATUS" ].as<int>() ), GL_SAMPLER_2D ( gl["SAMPLER_2D" ].as<int>() ) { } void NativeGL_Emscripten::useProgram(GPUProgram* program) const { //Check: On WEBGL FloatBuffers do not check if they are already bound val jsoProgram = _shaderList[ program->getProgramID() ]; _gl.call<void>("useProgram", jsoProgram); } void NativeGL_Emscripten::uniform2f(const IGLUniformID* location, float x, float y) const { GLUniformID_Emscripten* locEM = (GLUniformID_Emscripten*) location; val id = locEM->getId(); _gl.call<void>("uniform2f", id, x, y); } void NativeGL_Emscripten::uniform1f(const IGLUniformID* location, float x) const { GLUniformID_Emscripten* locEM = (GLUniformID_Emscripten*) location; val id = locEM->getId(); _gl.call<void>("uniform1f", id, x); } void NativeGL_Emscripten::uniform1i(const IGLUniformID* location, int v) const { GLUniformID_Emscripten* locEM = (GLUniformID_Emscripten*) location; val id = locEM->getId(); _gl.call<void>("uniform1i", id, v); } void NativeGL_Emscripten::uniformMatrix4fv(const IGLUniformID* location, bool transpose, const Matrix44D* matrix) const { GLUniformID_Emscripten* locEM = (GLUniformID_Emscripten*) location; val id = locEM->getId(); const FloatBuffer_Emscripten* floatBuffer = (FloatBuffer_Emscripten*) matrix->getColumnMajorFloatBuffer(); val buffer = floatBuffer->getBuffer(); _gl.call<void>("uniformMatrix4fv", id, transpose, buffer); } void NativeGL_Emscripten::clearColor(float red, float green, float blue, float alpha) const { _gl.call<void>("clearColor", red, green, blue, alpha); } void NativeGL_Emscripten::clear(int buffers) const { _gl.call<void>("clear", buffers); } void NativeGL_Emscripten::uniform4f(const IGLUniformID* location, float v0, float v1, float v2, float v3) const { GLUniformID_Emscripten* locEM = (GLUniformID_Emscripten*) location; val id = locEM->getId(); _gl.call<void>("uniform4f", id, v0, v1, v2, v3); } void NativeGL_Emscripten::uniform3f(const IGLUniformID* location, float v0, float v1, float v2) const { GLUniformID_Emscripten* locEM = (GLUniformID_Emscripten*) location; val id = locEM->getId(); _gl.call<void>("uniform3f", id, v0, v1, v2); } void NativeGL_Emscripten::enable(int feature) const { _gl.call<void>("enable", feature); } void NativeGL_Emscripten::disable(int feature) const { _gl.call<void>("disable", feature); } void NativeGL_Emscripten::polygonOffset(float factor, float units) const { _gl.call<void>("polygonOffset", factor, units); } val NativeGL_Emscripten::createBuffer() const { return _gl.call<val>("createBuffer"); } void NativeGL_Emscripten::bindBuffer(const val& webGLBuffer) const { _gl.call<void>("bindBuffer", GL_ARRAY_BUFFER, webGLBuffer); } void NativeGL_Emscripten::bufferData(const val& webGLBuffer) const { _gl.call<void>("bufferData", GL_ARRAY_BUFFER, webGLBuffer, GL_STATIC_DRAW); } void NativeGL_Emscripten::deleteBuffer(const val& webGLBuffer) const { _gl.call<void>("deleteBuffer", webGLBuffer); } void NativeGL_Emscripten::vertexAttribPointer(int index, int size, bool normalized, int stride, const IFloatBuffer* buffer) const { val webGLBuffer = ((FloatBuffer_Emscripten*) buffer)->bindVBO(this); _gl.call<void>("vertexAttribPointer", index, size, GL_FLOAT, normalized, stride, 0); } void NativeGL_Emscripten::drawElements(int mode, int count, IShortBuffer* indices) const { ShortBuffer_Emscripten* indicesEM = (ShortBuffer_Emscripten*) indices; val webGLBuffer = indicesEM->getWebGLBuffer(this); _gl.call<void>("bindBuffer", GL_ELEMENT_ARRAY_BUFFER, webGLBuffer); val array = indicesEM->getBuffer(); _gl.call<void>("bufferData", GL_ELEMENT_ARRAY_BUFFER, array, GL_STATIC_DRAW); _gl.call<void>("drawElements", mode, count, GL_UNSIGNED_SHORT, 0); } void NativeGL_Emscripten::lineWidth(float width) const { _gl.call<void>("lineWidth", width); } int NativeGL_Emscripten::getError() const { const int e = _gl.call<int>("getError"); if (e == GL_INVALID_ENUM) { emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "NativeGL_Emscripten: INVALID_ENUM"); } else if (e == GL_INVALID_VALUE) { emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "NativeGL_Emscripten: INVALID_VALUE"); } else if (e == GL_INVALID_OPERATION) { emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "NativeGL_Emscripten: INVALID_OPERATION"); } else if (e == GL_OUT_OF_MEMORY) { emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "NativeGL_Emscripten: INVALID_OPERATION"); } else if (e == GL_CONTEXT_LOST_WEBGL) { emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "NativeGL_Emscripten: CONTEXT_LOST_WEBGL"); } return e; } void NativeGL_Emscripten::blendFunc(int sfactor, int dfactor) const { _gl.call<void>("blendFunc", sfactor, dfactor); } void NativeGL_Emscripten::bindTexture(int target, const IGLTextureID* texture) const { GLTextureID_Emscripten* textureEM = (GLTextureID_Emscripten*) texture; val textureID = textureEM->getWebGLTexture(); _gl.call<void>("bindTexture", target, textureID); } /* Delete Texture from GPU, and answer if the TextureID can be reused */ bool NativeGL_Emscripten::deleteTexture(const IGLTextureID* texture) const { GLTextureID_Emscripten* textureEM = (GLTextureID_Emscripten*) texture; val textureID = textureEM->getWebGLTexture(); _gl.call<void>("deleteTexture", textureID); return false; } void NativeGL_Emscripten::enableVertexAttribArray(int location) const { _gl.call<void>("enableVertexAttribArray", location); } void NativeGL_Emscripten::disableVertexAttribArray(int location) const { _gl.call<void>("disableVertexAttribArray", location); } void NativeGL_Emscripten::pixelStorei(int pname, int param) const { _gl.call<void>("pixelStorei", pname, param); } std::vector<IGLTextureID*> NativeGL_Emscripten::genTextures(int n) const { std::vector<IGLTextureID*> result; // result.reserve(n); for (size_t i = 0; i < n; i++) { val texture = _gl.call<val>("createTexture"); GLTextureID_Emscripten* textureID = new GLTextureID_Emscripten(texture); result.push_back(textureID); } return result; } void NativeGL_Emscripten::texParameteri(int target, int par, int v) const { _gl.call<void>("texParameteri", target, par, v); } void NativeGL_Emscripten::texImage2D(const IImage* image, int format) const { Image_Emscripten* imageEM = (Image_Emscripten*) image; val domImage = imageEM->getDOMImage(); _gl.call<void>("texImage2D", GL_TEXTURE_2D, 0, format, format, GL_UNSIGNED_BYTE, domImage); } void NativeGL_Emscripten::generateMipmap(int target) const { _gl.call<void>("generateMipmap", target); } void NativeGL_Emscripten::drawArrays(int mode, int first, int count) const { _gl.call<void>("drawArrays", mode, first, count); } void NativeGL_Emscripten::cullFace(int c) const { _gl.call<void>("cullFace", c); } void NativeGL_Emscripten::getIntegerv(int v, int i[]) const { // TODO Warning: getIntegerv is not implemented in WebGL. val result = _gl.call<val>("getParameter", v); const int length = result["length"].as<int>(); for (int index = 0; index < length; index++) { i[index] = result[index].as<int>(); } } int NativeGL_Emscripten::CullFace_Front() const { return GL_FRONT; } int NativeGL_Emscripten::CullFace_Back() const { return GL_BACK; } int NativeGL_Emscripten::CullFace_FrontAndBack() const { return GL_FRONT_AND_BACK; } int NativeGL_Emscripten::BufferType_ColorBuffer() const { return GL_COLOR_BUFFER_BIT; } int NativeGL_Emscripten::BufferType_DepthBuffer() const { return GL_DEPTH_BUFFER_BIT; } int NativeGL_Emscripten::Feature_PolygonOffsetFill() const { return GL_POLYGON_OFFSET_FILL; } int NativeGL_Emscripten::Feature_DepthTest() const { return GL_DEPTH_TEST; } int NativeGL_Emscripten::Feature_Blend() const { return GL_BLEND; } int NativeGL_Emscripten::Feature_CullFace() const { return GL_CULL_FACE; } int NativeGL_Emscripten::Type_Float() const { return GL_FLOAT; } int NativeGL_Emscripten::Type_UnsignedByte() const { return GL_UNSIGNED_BYTE; } int NativeGL_Emscripten::Type_UnsignedInt() const { return GL_UNSIGNED_INT; } int NativeGL_Emscripten::Type_Int() const { return GL_INT; } int NativeGL_Emscripten::Type_Vec2Float() const { return GL_FLOAT_VEC2; } int NativeGL_Emscripten::Type_Vec3Float() const { return GL_FLOAT_VEC3; } int NativeGL_Emscripten::Type_Vec4Float() const { return GL_FLOAT_VEC4; } int NativeGL_Emscripten::Type_Bool() const { return GL_BOOL; } int NativeGL_Emscripten::Type_Matrix4Float() const { return GL_FLOAT_MAT4; } int NativeGL_Emscripten::Primitive_Triangles() const { return GL_TRIANGLES; } int NativeGL_Emscripten::Primitive_TriangleStrip() const { return GL_TRIANGLE_STRIP; } int NativeGL_Emscripten::Primitive_TriangleFan() const { return GL_TRIANGLE_FAN; } int NativeGL_Emscripten::Primitive_Lines() const { return GL_LINES; } int NativeGL_Emscripten::Primitive_LineStrip() const { return GL_LINE_STRIP; } int NativeGL_Emscripten::Primitive_LineLoop() const { return GL_LINE_LOOP; } int NativeGL_Emscripten::Primitive_Points() const { return GL_POINTS; } int NativeGL_Emscripten::BlendFactor_One() const { return GL_ONE; } int NativeGL_Emscripten::BlendFactor_Zero() const { return GL_ZERO; } int NativeGL_Emscripten::BlendFactor_SrcAlpha() const { return GL_SRC_ALPHA; } int NativeGL_Emscripten::BlendFactor_OneMinusSrcAlpha() const { return GL_ONE_MINUS_SRC_ALPHA; } int NativeGL_Emscripten::TextureType_Texture2D() const { return GL_TEXTURE_2D; } int NativeGL_Emscripten::TextureParameter_MinFilter() const { return GL_TEXTURE_MIN_FILTER; } int NativeGL_Emscripten::TextureParameter_MagFilter() const { return GL_TEXTURE_MAG_FILTER; } int NativeGL_Emscripten::TextureParameter_WrapS() const { return GL_TEXTURE_WRAP_S; } int NativeGL_Emscripten::TextureParameter_WrapT() const { return GL_TEXTURE_WRAP_T; } int NativeGL_Emscripten::TextureParameterValue_Nearest() const { return GL_NEAREST; } int NativeGL_Emscripten::TextureParameterValue_Linear() const { return GL_LINEAR; } int NativeGL_Emscripten::TextureParameterValue_NearestMipmapNearest() const { return GL_NEAREST_MIPMAP_NEAREST; } int NativeGL_Emscripten::TextureParameterValue_NearestMipmapLinear() const { return GL_NEAREST_MIPMAP_LINEAR; } int NativeGL_Emscripten::TextureParameterValue_LinearMipmapNearest() const { return GL_LINEAR_MIPMAP_NEAREST; } int NativeGL_Emscripten::TextureParameterValue_LinearMipmapLinear() const { return GL_LINEAR_MIPMAP_LINEAR; } int NativeGL_Emscripten::TextureParameterValue_Repeat() const { return GL_REPEAT; } int NativeGL_Emscripten::TextureParameterValue_ClampToEdge() const { return GL_CLAMP_TO_EDGE; } int NativeGL_Emscripten::TextureParameterValue_MirroredRepeat() const { return GL_MIRRORED_REPEAT; } int NativeGL_Emscripten::Alignment_Pack() const { return GL_PACK_ALIGNMENT; } int NativeGL_Emscripten::Alignment_Unpack() const { return GL_UNPACK_ALIGNMENT; } int NativeGL_Emscripten::Format_RGBA() const { return GL_RGBA; } int NativeGL_Emscripten::Variable_Viewport() const { return GL_VIEWPORT; } int NativeGL_Emscripten::Variable_ActiveAttributes() const { return GL_ACTIVE_ATTRIBUTES; } int NativeGL_Emscripten::Variable_ActiveUniforms() const { return GL_ACTIVE_UNIFORMS; } int NativeGL_Emscripten::Error_NoError() const { return GL_NO_ERROR; } int NativeGL_Emscripten::createProgram() const { const int id = _shaderList.size(); const val jsoProgram = _gl.call<val>("createProgram"); _shaderList.push_back(jsoProgram); return id; } bool NativeGL_Emscripten::deleteProgram(int program) const { const val jsoProgram = _shaderList[program]; _gl.call<void>("deleteProgram", jsoProgram); return true; } void NativeGL_Emscripten::attachShader(int program, int shader) const { const val jsoProgram = _shaderList[program]; const val jsoShader = _shaderList[shader]; _gl.call<void>("attachShader", jsoProgram, jsoShader); } int NativeGL_Emscripten::createShader(ShaderType type) const { int shaderType; switch (type) { case ShaderType::VERTEX_SHADER: shaderType = GL_VERTEX_SHADER; break; case ShaderType::FRAGMENT_SHADER: shaderType = GL_FRAGMENT_SHADER; break; default: emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "Unknown shader type"); return 0; } const int id = _shaderList.size(); val shader = _gl.call<val>("createShader", shaderType); _shaderList.push_back(shader); return id; } bool NativeGL_Emscripten::compileShader(int shader, const std::string& source) const { const val jsoShader = _shaderList[shader]; _gl.call<void>("shaderSource", jsoShader, source); _gl.call<void>("compileShader", jsoShader); return _gl.call<bool>("getShaderParameter", jsoShader, GL_COMPILE_STATUS); } bool NativeGL_Emscripten::deleteShader(int shader) const { #warning TODO: deleteShader(int shader) implementation fails const val jsoShader = _shaderList[shader]; return true; // return _gl.call<bool>("deleteShader", jsoShader); } void NativeGL_Emscripten::printShaderInfoLog(int shader) const { const val jsoShader = _shaderList[shader]; if (!_gl.call<bool>("getShaderParameter", jsoShader, GL_COMPILE_STATUS)) { emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "Error compiling shaders: %s", _gl.call<std::string>("getShaderInfoLog", jsoShader).c_str()); } } bool NativeGL_Emscripten::linkProgram(int program) const { const val jsoProgram = _shaderList[program]; _gl.call<void>("linkProgram", jsoProgram); return _gl.call<bool>("getProgramParameter", jsoProgram, GL_LINK_STATUS); } void NativeGL_Emscripten::printProgramInfoLog(int program) const { const val jsoProgram = _shaderList[program]; if (!_gl.call<bool>("getProgramParameter", jsoProgram, GL_LINK_STATUS)) { emscripten_log(EM_LOG_CONSOLE | EM_LOG_ERROR, "Error linking program: %s", _gl.call<std::string>("getProgramInfoLog", jsoProgram).c_str()); } } void NativeGL_Emscripten::bindAttribLocation(const GPUProgram* program, int loc, const std::string& name) const { const int programID = program->getProgramID(); const val jsoProgram = _shaderList[programID]; _gl.call<void>("bindAttribLocation", jsoProgram, loc, name); } int NativeGL_Emscripten::getProgramiv(const GPUProgram* program, int param) const { const int programID = program->getProgramID(); const val jsoProgram = _shaderList[programID]; // Return the value for the passed pname given the passed program. The type returned is the natural type for the requested pname return _gl.call<int>("getProgramParameter", jsoProgram, param); } GPUUniform* NativeGL_Emscripten::getActiveUniform(const GPUProgram* program, int i) const { const int programID = program->getProgramID(); const val jsoProgram = _shaderList[programID]; const val info = _gl.call<val>("getActiveUniform", jsoProgram, i); const std::string infoName = info["name"].as<std::string>(); const val id = _gl.call<val>("getUniformLocation", jsoProgram, infoName); GLUniformID_Emscripten* glUniformID = new GLUniformID_Emscripten(id); const int infoType = info["type"].as<int>(); if (infoType == GL_FLOAT_MAT4) { return new GPUUniformMatrix4Float(infoName, glUniformID); } else if (infoType == GL_FLOAT_VEC4) { return new GPUUniformVec4Float(infoName, glUniformID); } else if (infoType == GL_FLOAT) { return new GPUUniformFloat(infoName, glUniformID); } else if (infoType == GL_FLOAT_VEC2) { return new GPUUniformVec2Float(infoName, glUniformID); } else if (infoType == GL_FLOAT_VEC3) { return new GPUUniformVec3Float(infoName, glUniformID); } else if (infoType == GL_BOOL) { return new GPUUniformBool(infoName, glUniformID); } else if (infoType == GL_SAMPLER_2D) { return new GPUUniformSampler2D(infoName, glUniformID); } else { return NULL; } } GPUAttribute* NativeGL_Emscripten::getActiveAttribute(const GPUProgram* program, int i) const { const int programID = program->getProgramID(); const val jsoProgram = _shaderList[programID]; const val info = _gl.call<val>("getActiveAttrib", jsoProgram, i); const std::string infoName = info["name"].as<std::string>(); const int id = _gl.call<int>("getAttribLocation", jsoProgram, infoName); const int infoType = info["type"].as<int>(); if (infoType == GL_FLOAT_VEC3) { return new GPUAttributeVec3Float(infoName, id); } else if (infoType == GL_FLOAT_VEC4) { return new GPUAttributeVec4Float(infoName, id); } else if (infoType == GL_FLOAT_VEC2) { return new GPUAttributeVec2Float(infoName, id); } else { return NULL; } } void NativeGL_Emscripten::depthMask(bool depthMask) const { _gl.call<void>("depthMask", depthMask); } void NativeGL_Emscripten::setActiveTexture(int i) const { _gl.call<void>("activeTexture", GL_TEXTURE0 + i); } void NativeGL_Emscripten::viewport(int x, int y, int width, int height) const { _gl.call<void>("viewport", x, y, width, height); } int NativeGL_Emscripten::getMaxTextureSize() const { //return _gl.call<int>("getParameter", _gl["MAX_TEXTURE_SIZE"].as<int>() ); return _gl.call<int>("getParameter", _gl["MAX_TEXTURE_SIZE"] ); }
36.259259
130
0.638447
glob3mobile
b7f76ee615fa6414a03506ae65cb6c4f2609c086
10,480
cpp
C++
dev/Code/Sandbox/Plugins/CryDesigner/Core/SmoothingGroupManager.cpp
jeikabu/lumberyard
07228c605ce16cbf5aaa209a94a3cb9d6c1a4115
[ "AML" ]
1,738
2017-09-21T10:59:12.000Z
2022-03-31T21:05:46.000Z
dev/Code/Sandbox/Plugins/CryDesigner/Core/SmoothingGroupManager.cpp
jeikabu/lumberyard
07228c605ce16cbf5aaa209a94a3cb9d6c1a4115
[ "AML" ]
427
2017-09-29T22:54:36.000Z
2022-02-15T19:26:50.000Z
dev/Code/Sandbox/Plugins/CryDesigner/Core/SmoothingGroupManager.cpp
jeikabu/lumberyard
07228c605ce16cbf5aaa209a94a3cb9d6c1a4115
[ "AML" ]
671
2017-09-21T08:04:01.000Z
2022-03-29T14:30:07.000Z
/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #include "StdAfx.h" #include "SmoothingGroupManager.h" #include "Model.h" bool SmoothingGroupManager::AddSmoothingGroup(const char* id_name, DesignerSmoothingGroupPtr pSmoothingGroup) { for (int i = 0, iPolygonCount(pSmoothingGroup->GetPolygonCount()); i < iPolygonCount; ++i) { CD::PolygonPtr pPolygon = pSmoothingGroup->GetPolygon(i); InvertSmoothingGroupMap::iterator ii = m_MapPolygon2GropuId.find(pPolygon); if (ii == m_MapPolygon2GropuId.end()) { continue; } m_SmoothingGroups[ii->second]->RemovePolygon(pPolygon); if (m_SmoothingGroups[ii->second]->GetPolygonCount() == 0) { m_SmoothingGroups.erase(ii->second); } } SmoothingGroupMap::iterator iSmoothingGroup = m_SmoothingGroups.find(id_name); if (iSmoothingGroup != m_SmoothingGroups.end()) { for (int i = 0, iCount(pSmoothingGroup->GetPolygonCount()); i < iCount; ++i) { iSmoothingGroup->second->AddPolygon(pSmoothingGroup->GetPolygon(i)); } } else { m_SmoothingGroups[id_name] = pSmoothingGroup; } for (int i = 0, iPolygonCount(pSmoothingGroup->GetPolygonCount()); i < iPolygonCount; ++i) { m_MapPolygon2GropuId[pSmoothingGroup->GetPolygon(i)] = id_name; } return true; } bool SmoothingGroupManager::AddPolygon(const char* id_name, CD::PolygonPtr pPolygon) { DesignerSmoothingGroupPtr pSmoothingGroup = GetSmoothingGroup(id_name); if (pSmoothingGroup == NULL) { std::vector<CD::PolygonPtr> polygons; polygons.push_back(pPolygon); return AddSmoothingGroup(id_name, new SmoothingGroup(polygons)); } InvertSmoothingGroupMap::iterator ii = m_MapPolygon2GropuId.find(pPolygon); if (ii != m_MapPolygon2GropuId.end()) { if (ii->second != id_name) { m_SmoothingGroups[ii->second]->RemovePolygon(pPolygon); if (m_SmoothingGroups[ii->second]->GetPolygonCount() == 0) { m_SmoothingGroups.erase(ii->second); } ii->second = id_name; } } else { m_MapPolygon2GropuId[pPolygon] = id_name; } pSmoothingGroup->AddPolygon(pPolygon); return true; } void SmoothingGroupManager::RemoveSmoothingGroup(const char* id_name) { SmoothingGroupMap::iterator iter = m_SmoothingGroups.find(id_name); if (iter == m_SmoothingGroups.end()) { return; } for (int i = 0, iCount(iter->second->GetPolygonCount()); i < iCount; ++i) { CD::PolygonPtr pPolygon = iter->second->GetPolygon(i); m_MapPolygon2GropuId.erase(pPolygon); } m_SmoothingGroups.erase(iter); } DesignerSmoothingGroupPtr SmoothingGroupManager::GetSmoothingGroup(const char* id_name) { SmoothingGroupMap::iterator iter = m_SmoothingGroups.find(id_name); if (iter == m_SmoothingGroups.end()) { return NULL; } return iter->second; } const char* SmoothingGroupManager::GetSmoothingGroupID(CD::PolygonPtr pPolygon) const { InvertSmoothingGroupMap::const_iterator ii = m_MapPolygon2GropuId.find(pPolygon); if (ii == m_MapPolygon2GropuId.end()) { return NULL; } return ii->second; } const char* SmoothingGroupManager::GetSmoothingGroupID(DesignerSmoothingGroupPtr pSmoothingGroup) const { SmoothingGroupMap::const_iterator ii = m_SmoothingGroups.begin(); for (; ii != m_SmoothingGroups.end(); ++ii) { if (pSmoothingGroup == ii->second) { return ii->first; } } return NULL; } void SmoothingGroupManager::Serialize(XmlNodeRef& xmlNode, bool bLoading, bool bUndo, CD::Model* pModel) { if (bLoading) { m_SmoothingGroups.clear(); m_MapPolygon2GropuId.clear(); int nCount = xmlNode->getChildCount(); for (int i = 0; i < nCount; ++i) { XmlNodeRef pSmoothingGroupNode = xmlNode->getChild(i); string id_name; int nID = 0; if (pSmoothingGroupNode->getAttr("ID", nID)) { char buffer[1024] = {0, }; sprintf(buffer, "%d", nID); id_name = buffer; } else { const char* pBuf = NULL; if (pSmoothingGroupNode->getAttr("GroupName", &pBuf)) { id_name = pBuf; } } if (!id_name.empty()) { int nCount = 0; std::vector<CD::PolygonPtr> polygons; while (1) { QString attrStr; attrStr = QStringLiteral("Polygon%1").arg(nCount++); GUID guid; if (!pSmoothingGroupNode->getAttr(attrStr.toUtf8().data(), guid)) { break; } CD::PolygonPtr pPolygon = pModel->QueryPolygon(guid); DESIGNER_ASSERT(pPolygon); if (!pPolygon) { continue; } polygons.push_back(pPolygon); } AddSmoothingGroup(id_name, new SmoothingGroup(polygons)); } } } else { SmoothingGroupMap::iterator ii = m_SmoothingGroups.begin(); for (; ii != m_SmoothingGroups.end(); ++ii) { DesignerSmoothingGroupPtr pSmoothingGroupPtr = ii->second; if (pSmoothingGroupPtr->GetPolygonCount() == 0) { continue; } XmlNodeRef pSmoothingGroupNode(xmlNode->newChild("SmoothingGroup")); pSmoothingGroupNode->setAttr("GroupName", ii->first); for (int i = 0, iPolygonCount(pSmoothingGroupPtr->GetPolygonCount()); i < iPolygonCount; ++i) { CD::PolygonPtr pPolygon = pSmoothingGroupPtr->GetPolygon(i); QString attrStr; attrStr = QStringLiteral("Polygon%1").arg(i); pSmoothingGroupNode->setAttr(attrStr.toUtf8().data(), pPolygon->GetGUID()); } } } } void SmoothingGroupManager::Clear() { m_SmoothingGroups.clear(); m_MapPolygon2GropuId.clear(); } std::vector<std::pair<string, DesignerSmoothingGroupPtr> > SmoothingGroupManager::GetSmoothingGroupList() const { std::vector<std::pair<string, DesignerSmoothingGroupPtr> > smoothingGroupList; SmoothingGroupMap::const_iterator ii = m_SmoothingGroups.begin(); for (; ii != m_SmoothingGroups.end(); ++ii) { smoothingGroupList.push_back(*ii); } return smoothingGroupList; } void SmoothingGroupManager::RemovePolygon(CD::PolygonPtr pPolygon) { InvertSmoothingGroupMap::iterator ii = m_MapPolygon2GropuId.find(pPolygon); if (ii == m_MapPolygon2GropuId.end()) { return; } string id_name = ii->second; m_MapPolygon2GropuId.erase(ii); SmoothingGroupMap::iterator iGroup = m_SmoothingGroups.find(id_name); if (iGroup == m_SmoothingGroups.end()) { DESIGNER_ASSERT(0); return; } DesignerSmoothingGroupPtr pSmoothingGroup = iGroup->second; pSmoothingGroup->RemovePolygon(pPolygon); if (pSmoothingGroup->GetPolygonCount() == 0) { RemoveSmoothingGroup(iGroup->first); } } void SmoothingGroupManager::CopyFromModel(CD::Model* pModel, const CD::Model* pSourceModel) { Clear(); SmoothingGroupManager* pSourceSmoothingGroupMgr = pSourceModel->GetSmoothingGroupMgr(); std::vector<std::pair<string, DesignerSmoothingGroupPtr> > sourceSmoothingGroupList = pSourceSmoothingGroupMgr->GetSmoothingGroupList(); for (int i = 0, iSmoothingGroupCount(sourceSmoothingGroupList.size()); i < iSmoothingGroupCount; ++i) { const char* groupName = sourceSmoothingGroupList[i].first; std::vector<CD::PolygonPtr> polygons; for (int k = 0, iPolygonCount(sourceSmoothingGroupList[i].second->GetPolygonCount()); k < iPolygonCount; ++k) { CD::PolygonPtr pPolygon = sourceSmoothingGroupList[i].second->GetPolygon(k); int nPolygonIndex = -1; int nShelfID = -1; for (int a = 0; a < CD::kMaxShelfCount; ++a) { pSourceModel->SetShelf(a); nPolygonIndex = pSourceModel->GetPolygonIndex(pPolygon); if (nPolygonIndex != -1) { nShelfID = a; break; } } if (nShelfID == -1 || nPolygonIndex == -1) { continue; } pModel->SetShelf(nShelfID); polygons.push_back(pModel->GetPolygon(nPolygonIndex)); } AddSmoothingGroup(groupName, new SmoothingGroup(polygons)); } } void SmoothingGroupManager::InvalidateAll() { SmoothingGroupMap::iterator ii = m_SmoothingGroups.begin(); for (; ii != m_SmoothingGroups.end(); ++ii) { ii->second->Invalidate(); } } string SmoothingGroupManager::GetEmptyGroupID() const { string basicName = "SG"; int count = 0; do { char buff[1024]; sprintf(buff, "%d", count); string combinedName = basicName + string(buff); if (m_SmoothingGroups.find(combinedName) == m_SmoothingGroups.end()) { return combinedName; } } while (++count < 100000); return ""; } void SmoothingGroupManager::InvalidateSmoothingGroup(CD::PolygonPtr pPolygon) { const char* groupName = GetSmoothingGroupID(pPolygon); if (groupName) { DesignerSmoothingGroupPtr pSmoothingGroupPtr = GetSmoothingGroup(groupName); pSmoothingGroupPtr->Invalidate(); } }
31.854103
140
0.606966
jeikabu
b7f779cc464e7d28a2721bad28df55d3bc650144
320
cpp
C++
VTable/Multiple_Inheritance/Child.cpp
PanagiotisDrakatos/Memory-Management-and-Advanced-Debugging-techniques
d0b9c6f6a43ba64781c859175a092d86f1ab784d
[ "MIT" ]
25
2019-02-01T00:57:50.000Z
2020-12-21T04:40:21.000Z
VTable/Multiple_Inheritance/Child.cpp
PanagiotisDrakatos/Memory-Management-and-Advanced-Debugging-techniques
d0b9c6f6a43ba64781c859175a092d86f1ab784d
[ "MIT" ]
null
null
null
VTable/Multiple_Inheritance/Child.cpp
PanagiotisDrakatos/Memory-Management-and-Advanced-Debugging-techniques
d0b9c6f6a43ba64781c859175a092d86f1ab784d
[ "MIT" ]
2
2019-02-01T04:08:01.000Z
2019-11-09T16:07:26.000Z
#include "Mother.cpp" #include "Father.cpp" class Child : public Mother, public Father { public: Child(){cout<<"Child constructor was called "<<endl<<endl;} virtual void ChildMethod() {cout<<"Child::ChildMethod()"<<endl;} void FatherFoo() override {cout<<"Child::FatherFoo()"<<endl;} int child_data; };
29.090909
68
0.675
PanagiotisDrakatos
b7f891a7ba52853c9a643b7027f065ab819ad0e3
7,570
cpp
C++
src/guidance/segregated_intersection_classification.cpp
aweatherlycap1/osrm-backend
31d6d74f90fa760aa8d1f312c2593dabcbc9a69b
[ "BSD-2-Clause" ]
null
null
null
src/guidance/segregated_intersection_classification.cpp
aweatherlycap1/osrm-backend
31d6d74f90fa760aa8d1f312c2593dabcbc9a69b
[ "BSD-2-Clause" ]
null
null
null
src/guidance/segregated_intersection_classification.cpp
aweatherlycap1/osrm-backend
31d6d74f90fa760aa8d1f312c2593dabcbc9a69b
[ "BSD-2-Clause" ]
1
2019-09-23T22:49:07.000Z
2019-09-23T22:49:07.000Z
#include "guidance/segregated_intersection_classification.hpp" #include "extractor/intersection/coordinate_extractor.hpp" #include "extractor/node_based_graph_factory.hpp" #include "util/coordinate_calculation.hpp" #include "util/name_table.hpp" namespace osrm { namespace guidance { namespace RoadPriorityClass = extractor::RoadPriorityClass; struct EdgeInfo { NodeID node; util::StringView name; // 0 - outgoing (forward), 1 - incoming (reverse), 2 - both outgoing and incoming int direction; extractor::ClassData road_class; RoadPriorityClass::Enum road_priority_class; struct LessName { bool operator()(EdgeInfo const &e1, EdgeInfo const &e2) const { return e1.name < e2.name; } }; }; bool IsSegregated(std::vector<EdgeInfo> v1, std::vector<EdgeInfo> v2, EdgeInfo const &current, double edgeLength) { if (v1.size() < 2 || v2.size() < 2) return false; auto const sort_by_name_fn = [](std::vector<EdgeInfo> &v) { std::sort(v.begin(), v.end(), EdgeInfo::LessName()); }; sort_by_name_fn(v1); sort_by_name_fn(v2); // Internal edge with the name should be connected with any other neibour edge with the same // name, e.g. isolated edge with unique name is not segregated. // b - 'b' road continues here // | // - - a - | // b - segregated edge // - - a - | if (!current.name.empty()) { auto const findNameFn = [&current](std::vector<EdgeInfo> const &v) { return std::binary_search(v.begin(), v.end(), current, EdgeInfo::LessName()); }; if (!findNameFn(v1) && !findNameFn(v2)) return false; } // set_intersection like routine to get equal result pairs std::vector<std::pair<EdgeInfo const *, EdgeInfo const *>> commons; auto i1 = v1.begin(); auto i2 = v2.begin(); while (i1 != v1.end() && i2 != v2.end()) { if (i1->name == i2->name) { if (!i1->name.empty()) commons.push_back(std::make_pair(&(*i1), &(*i2))); ++i1; ++i2; } else if (i1->name < i2->name) ++i1; else ++i2; } if (commons.size() < 2) return false; auto const check_equal_class = [](std::pair<EdgeInfo const *, EdgeInfo const *> const &e) { // Or (e.first->road_class & e.second->road_class != 0) return e.first->road_class == e.second->road_class; }; size_t equal_class_count = 0; for (auto const &e : commons) if (check_equal_class(e)) ++equal_class_count; if (equal_class_count < 2) return false; auto const get_length_threshold = [](EdgeInfo const *e) { switch (e->road_priority_class) { case RoadPriorityClass::MOTORWAY: case RoadPriorityClass::TRUNK: return 30.0; case RoadPriorityClass::PRIMARY: return 20.0; case RoadPriorityClass::SECONDARY: case RoadPriorityClass::TERTIARY: return 10.0; default: return 5.0; } }; double threshold = std::numeric_limits<double>::max(); for (auto const &e : commons) threshold = std::min(threshold, get_length_threshold(e.first) + get_length_threshold(e.second)); return edgeLength <= threshold; } std::unordered_set<EdgeID> findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory, const util::NameTable &names) { auto const &graph = factory.GetGraph(); auto const &annotation = factory.GetAnnotationData(); extractor::intersection::CoordinateExtractor coordExtractor( graph, factory.GetCompressedEdges(), factory.GetCoordinates()); auto const get_edge_length = [&](NodeID from_node, EdgeID edgeID, NodeID to_node) { auto const geom = coordExtractor.GetCoordinatesAlongRoad(from_node, edgeID, false, to_node); double length = 0.0; for (size_t i = 1; i < geom.size(); ++i) { length += util::coordinate_calculation::haversineDistance(geom[i - 1], geom[i]); } return length; }; auto const get_edge_info = [&](NodeID node, auto const &edgeData) -> EdgeInfo { /// @todo Make string normalization/lowercase/trim for comparison ... auto const id = annotation[edgeData.annotation_data].name_id; BOOST_ASSERT(id != INVALID_NAMEID); auto const name = names.GetNameForID(id); return {node, name, edgeData.reversed ? 1 : 0, annotation[edgeData.annotation_data].classes, edgeData.flags.road_classification.GetClass()}; }; auto const collect_edge_info_fn = [&](auto const &edges1, NodeID node2) { std::vector<EdgeInfo> info; for (auto const &e : edges1) { NodeID const target = graph.GetTarget(e); if (target == node2) continue; info.push_back(get_edge_info(target, graph.GetEdgeData(e))); } if (info.empty()) return info; std::sort(info.begin(), info.end(), [](EdgeInfo const &e1, EdgeInfo const &e2) { return e1.node < e2.node; }); // Merge equal infos with correct direction. auto curr = info.begin(); auto next = curr; while (++next != info.end()) { if (curr->node == next->node) { BOOST_ASSERT(curr->name == next->name); BOOST_ASSERT(curr->road_class == next->road_class); BOOST_ASSERT(curr->direction != next->direction); curr->direction = 2; } else curr = next; } info.erase( std::unique(info.begin(), info.end(), [](EdgeInfo const &e1, EdgeInfo const &e2) { return e1.node == e2.node; }), info.end()); return info; }; auto const isSegregatedFn = [&](auto const &edgeData, auto const &edges1, NodeID node1, auto const &edges2, NodeID node2, double edgeLength) { return IsSegregated(collect_edge_info_fn(edges1, node2), collect_edge_info_fn(edges2, node1), get_edge_info(node1, edgeData), edgeLength); }; std::unordered_set<EdgeID> segregated_edges; for (NodeID sourceID = 0; sourceID < graph.GetNumberOfNodes(); ++sourceID) { auto const sourceEdges = graph.GetAdjacentEdgeRange(sourceID); for (EdgeID edgeID : sourceEdges) { auto const &edgeData = graph.GetEdgeData(edgeID); if (edgeData.reversed) continue; NodeID const targetID = graph.GetTarget(edgeID); auto const targetEdges = graph.GetAdjacentEdgeRange(targetID); double const length = get_edge_length(sourceID, edgeID, targetID); if (isSegregatedFn(edgeData, sourceEdges, sourceID, targetEdges, targetID, length)) segregated_edges.insert(edgeID); } } return segregated_edges; } } // namespace guidance } // namespace osrm
31.02459
100
0.561691
aweatherlycap1
b7fe36fbf03d79dc8d8d22506dc21257c2ac1cb6
1,669
inl
C++
Shared/Base/Serialize/SerializableFactory.inl
LukaszByczynski/tbl-4edges
11f8c2a1e40271c542321d9d4d0e4ed24cce92c8
[ "MIT" ]
21
2015-07-19T13:47:17.000Z
2022-03-13T11:13:28.000Z
Shared/Base/Serialize/SerializableFactory.inl
theblacklotus/4edges
11f8c2a1e40271c542321d9d4d0e4ed24cce92c8
[ "MIT" ]
1
2018-03-24T17:54:49.000Z
2018-03-24T17:57:01.000Z
Shared/Base/Serialize/SerializableFactory.inl
jsvennevid/tbl-4edges
11f8c2a1e40271c542321d9d4d0e4ed24cce92c8
[ "MIT" ]
2
2019-02-07T20:42:13.000Z
2021-02-10T07:09:47.000Z
inline SerializableFactory::SerializableFactory(Identifier host, Identifier type, u32 size) : m_host(host), m_type(type), m_size(size), m_next(ms_first), m_structures(0) { ms_first = this; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline SerializableFactory::Identifier SerializableFactory::host() const { return m_host; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline SerializableFactory::Identifier SerializableFactory::type() const { return m_type; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline u32 SerializableFactory::size() const { return m_size; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline SerializableFactory* SerializableFactory::next() const { return m_next; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline SerializableFactory* SerializableFactory::first() { return ms_first; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline void SerializableFactory::setStructures(SerializableStructure* structures) { m_structures = structures; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline SerializableStructure* SerializableFactory::structures() const { return m_structures; }
30.345455
169
0.388856
LukaszByczynski
4d0193949a4f54b9c93433b4fc7fda3cfd35e49b
1,277
cpp
C++
chapter2/2_4.cpp
timmyjose-study/modern-cpp
86168776612c0ebdf49ab1c9b9f44baa83f187d5
[ "Unlicense" ]
null
null
null
chapter2/2_4.cpp
timmyjose-study/modern-cpp
86168776612c0ebdf49ab1c9b9f44baa83f187d5
[ "Unlicense" ]
null
null
null
chapter2/2_4.cpp
timmyjose-study/modern-cpp
86168776612c0ebdf49ab1c9b9f44baa83f187d5
[ "Unlicense" ]
null
null
null
// initializer lists #include <iostream> #include <vector> #include <initializer_list> class Foo { public: int value_a; int value_b; Foo(int a, int b): value_a(a), value_b(b) {} }; // more uniform initialisation with C++11 (and newer) class Bar { public: std::vector<int> vec; Bar(std::initializer_list<int> list) { for (auto e : list) vec.push_back(e); } void bar(std::initializer_list<int> list) { for (auto e : list) vec.push_back(e); } }; int main() { int arr[3] = {1, 2, 3}; Foo foo(1, 2); std::vector<int> vec = {1, 2, 3, 4, 5}; std::cout << "arr[0] = " << arr[0] << std::endl; std::cout << "foo: " << foo.value_a << ", " << foo.value_b << std::endl; for (std::vector<int>::iterator it = vec.begin(); it != vec.end(); it++) std::cout << *it << std::endl; Foo foo2 { 11, 12}; std::cout << "foo2 = " << foo2.value_a << ", " << foo2.value_b << std::endl; Bar bar = {1, 2, 3, 4, 5}; for (const auto& e : bar.vec) std::cout << e << std::endl; bar.bar({10, 11, 12, 13, 14, 15}); for (const auto& e : bar.vec) std::cout << e << std::endl; return 0; }
24.09434
80
0.490995
timmyjose-study
4d0298f4fa6fda8ef4417337fa2be4ad2008f732
262
hpp
C++
src/reflection/define/native/big.hpp
dmilos/reflection
0d190d4c625f80dab2d0fde10914365695d2bcc7
[ "Apache-2.0" ]
2
2020-09-04T13:11:04.000Z
2021-01-28T02:39:38.000Z
src/reflection/define/native/big.hpp
dmilos/reflection
0d190d4c625f80dab2d0fde10914365695d2bcc7
[ "Apache-2.0" ]
1
2018-12-31T10:01:19.000Z
2018-12-31T10:01:19.000Z
src/reflection/define/native/big.hpp
dmilos/reflection
0d190d4c625f80dab2d0fde10914365695d2bcc7
[ "Apache-2.0" ]
1
2020-09-04T11:00:15.000Z
2020-09-04T11:00:15.000Z
#ifndef reflection_define_big #define reflection_define_big /*big\ big.hpp block.hpp file.hpp member.hpp vector.hpp */ //#define reflection__CLASS_MEMBER_big( member_name, class_original::asdas ) #endif
13.789474
91
0.629771
dmilos
4d02f7a69b42404f97d4e32c7ac8e422ae17de37
570
cpp
C++
CodeForces.com/regular_rounds/#341/C.cpp
mstrechen/cp
ffac439840a71f70580a0ef197e47479e167a0eb
[ "MIT" ]
null
null
null
CodeForces.com/regular_rounds/#341/C.cpp
mstrechen/cp
ffac439840a71f70580a0ef197e47479e167a0eb
[ "MIT" ]
null
null
null
CodeForces.com/regular_rounds/#341/C.cpp
mstrechen/cp
ffac439840a71f70580a0ef197e47479e167a0eb
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; double flowers[100001]; int main(){ ios::sync_with_stdio(false); int n,tmp1,tmp2,p; double all,ok; double expected = 0; cin >> n >> p; for(int i = 0; i<n; i++) { cin >> tmp1 >> tmp2; all = tmp2-tmp1+1; ok = tmp2/p - (tmp1-1)/p; flowers[i] = (double)(ok/all); } for(int i=1; i<n; i++) { expected+=2000*(flowers[i]+flowers[i-1]-flowers[i]*flowers[i-1]); } expected+=2000*(flowers[0]+flowers[n-1]-flowers[0]*flowers[n-1]); cout.precision(8); cout << (fixed) <<expected; return 0; }
21.923077
68
0.582456
mstrechen
4d031011c01c795dff15496ca7c080fcc9c4216d
3,295
cpp
C++
src/foundation/GenericAdapterFactory.cpp
Bhaskers-Blu-Org2/pmod
92e3c0ecff25763dcfabab0c1fb86d58e60cbb1a
[ "MIT" ]
19
2019-06-16T02:29:24.000Z
2022-03-01T23:20:25.000Z
src/foundation/GenericAdapterFactory.cpp
microsoft/pmod
92e3c0ecff25763dcfabab0c1fb86d58e60cbb1a
[ "MIT" ]
null
null
null
src/foundation/GenericAdapterFactory.cpp
microsoft/pmod
92e3c0ecff25763dcfabab0c1fb86d58e60cbb1a
[ "MIT" ]
5
2019-11-03T11:40:25.000Z
2020-08-05T14:56:13.000Z
/*** * Copyright (C) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. * * File:GenericAdapterFactory.cpp ****/ #include "pch.h" #include "GenericAdapterFactory.h" using namespace foundation; CGenericAdapterFactory::CGenericAdapterFactory() { m_critsec.Init(); } HRESULT CGenericAdapterFactory::QueryInterfaceImpl(REFIID iid, IUnknown **ppInterface) { if (iid == IInterfaceAdapterFactory::GetIID()) { *ppInterface = static_cast<foundation::library::IInterfaceAdapterFactory *>(this); return S_OK; } else if (iid == library::IGenericAdapterFactory::GetIID()) { *ppInterface = static_cast<library::IGenericAdapterFactory *>(this); return S_OK; } return foundation::ctl::ComInspectableBase::QueryInterfaceImpl(iid,ppInterface); } // Interface IModelTypeAdapterFactory STDMETHODIMP CGenericAdapterFactory::AddAdapterEntry( _In_ IID riid_outer, _In_ IID iidTargetType, _In_ IID iidSourceType, _In_ library::CreateAdapterInstanceCallback creatorCallback) { foundation_lib::_CriticalSectionLock csl(m_critsec); _OuterEntryMap::iterator iter = m_OuterEntries.find(riid_outer); if(iter == m_OuterEntries.end()) { _IIdTargetTypeEntry targetTypeEntry; targetTypeEntry[iidTargetType] = _CallbackEntry(iidSourceType,creatorCallback); m_OuterEntries[riid_outer] = targetTypeEntry; } else { (*iter).second[iidTargetType] = _CallbackEntry(iidSourceType,creatorCallback); } return S_OK; } STDMETHODIMP CGenericAdapterFactory::TryCreateInterfaceAdapter( _In_ REFIID riid_outer, _In_ REFIID riid, _In_ foundation::IInspectable *pOuter, _In_ foundation::IInspectable *pInner, _Outptr_ foundation::IInspectable **ppInner) { _CallbackEntry callbackEntryType; if (Lookup(riid_outer, riid, callbackEntryType)) { IID iidSourceType = callbackEntryType.first; foundation::IUnknown *pCastTo = nullptr; if(iidSourceType == riid_outer || // QI the Inner first SUCCEEDED(foundation::QueryWeakReference(pInner,iidSourceType,&pCastTo)) || // then QI the Outer SUCCEEDED(foundation::QueryWeakReference(pOuter, iidSourceType, &pCastTo)) ) { IFR_ASSERT(callbackEntryType.second(pOuter, pInner, ppInner)); return S_OK; } } return E_NOINTERFACE; } bool CGenericAdapterFactory::Lookup( REFIID riid_outer, REFIID riid, _CallbackEntry& callbackEntryType) { foundation_lib::_CriticalSectionLock csl(m_critsec); _OuterEntryMap::const_iterator iter; if ((iter = m_OuterEntries.find(riid_outer)) != m_OuterEntries.end() || (iter = m_OuterEntries.find(GUID_NULL)) != m_OuterEntries.end()) { _IIdTargetTypeEntry::const_iterator iter2 = (*iter).second.find(riid); if (iter2 != (*iter).second.end()) { callbackEntryType = (*iter2).second; return true; } } return false; }
31.380952
105
0.655235
Bhaskers-Blu-Org2
4d03314e07ac0c437fd5fd456b39838e93693cde
3,791
cpp
C++
capture/ximea-usb3/CamTool/xvpSample/sampleplugin.cpp
ruedijc/jetson-cam-utils
29fb26892cc150f9679ad7d5c3220e38f733ab04
[ "MIT" ]
3
2021-02-28T10:09:54.000Z
2022-02-24T09:21:18.000Z
capture/ximea-usb3/CamTool/xvpSample/sampleplugin.cpp
ruedijc/jetson-cam-utils
29fb26892cc150f9679ad7d5c3220e38f733ab04
[ "MIT" ]
null
null
null
capture/ximea-usb3/CamTool/xvpSample/sampleplugin.cpp
ruedijc/jetson-cam-utils
29fb26892cc150f9679ad7d5c3220e38f733ab04
[ "MIT" ]
null
null
null
#include "sampleplugin.h" #include <xiRtti.h> #include <AppDelegate.h> #include <xiCoreVersion.h> #include "NegativeChnbl.h" #include "BayerPseudoColorsChnbl.h" #include "MeanGrayMeasForm.h" #include "FlipImageCnbl.h" #include "CameraTriggerForm.h" //--------------------------------------------------------------------------- bool CxSamplePlugin::init() { // register plugins that work as simple chainables - are added to chain upon request xiRTTI_REGISTER(this, CxNegativeChnbl, "CxChainable"); xiRTTI_REGISTER(this, CxBayerPseudoColorsCnbl, "CxChainable"); xiRTTI_REGISTER(this, CxFlipImageCnbl, "CxChainable"); // create plugin for measurement of mean gray on active image m_pMeanGrayMeasurement = new CxMeanGrayMeasForm; IxAppDelegate::instance()->addDockedWidget(m_pMeanGrayMeasurement, Qt::BottomDockWidgetArea, Qt::TopDockWidgetArea|Qt::BottomDockWidgetArea, false); m_pSoftwareTrigger = new CxCameraTriggerForm; IxAppDelegate::instance()->addDockedWidget(m_pSoftwareTrigger, Qt::RightDockWidgetArea, Qt::AllDockWidgetAreas, false); return true; } //--------------------------------------------------------------------------- QString CxSamplePlugin::name() const { return tr("Sample plugin"); } //--------------------------------------------------------------------------- QString CxSamplePlugin::author() const { return QString("XIMEA GmbH"); } //--------------------------------------------------------------------------- QString CxSamplePlugin::description() const { return tr("This is a plugin for educational purpose. On simple examples it demonstrates"\ "a plugin development, interface registration, chainable object implementation,"\ "communication of the plugin with the application etc."); } //--------------------------------------------------------------------------- void CxSamplePlugin::version(int &major, int &minor, int &build) const { xiCoreVersion(major, minor, build); } //--------------------------------------------------------------------------- QString CxSamplePlugin::website() const { return QString("http://www.ximea.com"); } //--------------------------------------------------------------------------- void CxSamplePlugin::loadSettings(QSettings *pSettings) { m_pSoftwareTrigger->loadSettings(pSettings); } //--------------------------------------------------------------------------- void CxSamplePlugin::saveSettings(QSettings *pSettings) { m_pSoftwareTrigger->saveSettings(pSettings); } //--------------------------------------------------------------------------- void CxSamplePlugin::activeViewChanged(int iViewId) { m_pMeanGrayMeasurement->activeViewChanged(iViewId); } //--------------------------------------------------------------------------- void CxSamplePlugin::viewGotNewImage(int iViewId, const CxImageData *pImageData) { m_pMeanGrayMeasurement->viewGotNewImage(iViewId, pImageData); } //--------------------------------------------------------------------------- bool CxSamplePlugin::viewMouseBtnPressEvent(int iViewId, QGraphicsSceneMouseEvent *event) { return m_pMeanGrayMeasurement->viewMouseBtnPressEvent(iViewId, event); } //--------------------------------------------------------------------------- bool CxSamplePlugin::viewMouseMoveEvent(int iViewId, QGraphicsSceneMouseEvent *event) { return m_pMeanGrayMeasurement->viewMouseMoveEvent(iViewId, event); } //--------------------------------------------------------------------------- bool CxSamplePlugin::viewMouseBtnReleaseEvent(int iViewId, QGraphicsSceneMouseEvent *event) { return m_pMeanGrayMeasurement->viewMouseBtnReleaseEvent(iViewId, event); }
35.764151
102
0.546294
ruedijc
4d03aa1751ee7f1900597876498ca1e4ba75bf36
29,654
cpp
C++
sources/VS/ThirdParty/wxWidgets/tests/arrays/arrays.cpp
Sasha7b9Work/S8-53M2
fdc9cb5e3feb8055fd3f7885a6f6362f62ff6b6e
[ "MIT" ]
null
null
null
sources/VS/ThirdParty/wxWidgets/tests/arrays/arrays.cpp
Sasha7b9Work/S8-53M2
fdc9cb5e3feb8055fd3f7885a6f6362f62ff6b6e
[ "MIT" ]
null
null
null
sources/VS/ThirdParty/wxWidgets/tests/arrays/arrays.cpp
Sasha7b9Work/S8-53M2
fdc9cb5e3feb8055fd3f7885a6f6362f62ff6b6e
[ "MIT" ]
null
null
null
/////////////////////////////////////////////////////////////////////////////// // Name: tests/arrays/arrays.cpp // Purpose: wxArray unit test // Author: Vadim Zeitlin, Wlodzimierz ABX Skiba // Created: 2004-04-01 // Copyright: (c) 2004 Vadim Zeitlin, Wlodzimierz Skiba /////////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- #include "testprec.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP #include "wx/dynarray.h" // ---------------------------------------------------------------------------- // helpers for testing values and sizes // ---------------------------------------------------------------------------- #define COMPARE_VALUE( array , index , value ) ( array.Item( index ) == value ) #define COMPARE_2_VALUES( array , p0 , p1 ) \ COMPARE_VALUE( array , 0 , p0 ) && \ COMPARE_VALUE( array , 1 , p1 ) #define COMPARE_3_VALUES( array , p0 , p1 , p2 ) \ COMPARE_2_VALUES( array , p0 , p1 ) && \ COMPARE_VALUE( array , 2 , p2 ) #define COMPARE_4_VALUES( array , p0 , p1 , p2 , p3 ) \ COMPARE_3_VALUES( array , p0 , p1 , p2 ) && \ COMPARE_VALUE( array , 3 , p3 ) #define COMPARE_5_VALUES( array , p0 , p1 , p2 , p3 , p4 ) \ COMPARE_4_VALUES( array , p0 , p1 , p2 , p3 ) && \ COMPARE_VALUE( array , 4 , p4 ) #define COMPARE_6_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 ) \ COMPARE_5_VALUES( array , p0 , p1 , p2 , p3 , p4 ) && \ COMPARE_VALUE( array , 5 , p5 ) #define COMPARE_7_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 ) \ COMPARE_6_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 ) && \ COMPARE_VALUE( array , 6 , p6 ) #define COMPARE_8_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 ) \ COMPARE_7_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 ) && \ COMPARE_VALUE( array , 7 , p7 ) #define COMPARE_9_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 ) \ COMPARE_8_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 ) && \ COMPARE_VALUE( array , 8 , p8 ) #define COMPARE_10_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 , p9 ) \ COMPARE_9_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 ) && \ COMPARE_VALUE( array , 9 , p9 ) #define COMPARE_COUNT( array , n ) \ (( array.GetCount() == n ) && \ ( array.Last() == array.Item( n - 1 ) )) // ---------------------------------------------------------------------------- // helpers for testing wxObjArray // ---------------------------------------------------------------------------- class Bar { public: Bar(const wxString& name) : m_name(name) { ms_bars++; } Bar(const Bar& bar) : m_name(bar.m_name) { ms_bars++; } ~Bar() { ms_bars--; } static size_t GetNumber() { return ms_bars; } const wxChar *GetName() const { return m_name.c_str(); } private: wxString m_name; static size_t ms_bars; }; size_t Bar::ms_bars = 0; WX_DECLARE_OBJARRAY(Bar, ArrayBars); #include "wx/arrimpl.cpp" WX_DEFINE_OBJARRAY(ArrayBars) // ---------------------------------------------------------------------------- // another object array test // ---------------------------------------------------------------------------- // This code doesn't make any sense, as object arrays should be used with // objects, not pointers, but it used to work, so check that it continues to // compile. WX_DECLARE_OBJARRAY(Bar*, ArrayBarPtrs); #include "wx/arrimpl.cpp" WX_DEFINE_OBJARRAY(ArrayBarPtrs) // ---------------------------------------------------------------------------- // helpers for sorting arrays and comparing items // ---------------------------------------------------------------------------- int wxCMPFUNC_CONV StringLenCompare(const wxString& first, const wxString& second) { return first.length() - second.length(); } #define DEFINE_COMPARE(name, T) \ \ int wxCMPFUNC_CONV name ## CompareValues(T first, T second) \ { \ return first - second; \ } \ \ int wxCMPFUNC_CONV name ## Compare(T* first, T* second) \ { \ return *first - *second; \ } \ \ int wxCMPFUNC_CONV name ## RevCompare(T* first, T* second) \ { \ return *second - *first; \ } \ typedef unsigned short ushort; DEFINE_COMPARE(Char, char) DEFINE_COMPARE(UShort, ushort) DEFINE_COMPARE(Int, int) WX_DEFINE_ARRAY_CHAR(char, wxArrayChar); WX_DEFINE_SORTED_ARRAY_CHAR(char, wxSortedArrayCharNoCmp); WX_DEFINE_SORTED_ARRAY_CMP_CHAR(char, CharCompareValues, wxSortedArrayChar); WX_DEFINE_ARRAY_SHORT(ushort, wxArrayUShort); WX_DEFINE_SORTED_ARRAY_SHORT(ushort, wxSortedArrayUShortNoCmp); WX_DEFINE_SORTED_ARRAY_CMP_SHORT(ushort, UShortCompareValues, wxSortedArrayUShort); WX_DEFINE_SORTED_ARRAY_CMP_INT(int, IntCompareValues, wxSortedArrayInt); struct Item { Item(int n_ = 0) : n(n_) { } int n; }; WX_DEFINE_ARRAY_PTR(Item *, ItemPtrArray); std::ostream& operator<<(std::ostream& os, const wxArrayString& arr) { os << "[ "; for ( size_t n = 0; n < arr.size(); ++n ) { if ( n ) os << ", "; os << '"' << arr[n] << '"'; } os << " ] (size=" << arr.size() << ")"; return os; } // ---------------------------------------------------------------------------- // the tests // ---------------------------------------------------------------------------- TEST_CASE("wxArrayString", "[dynarray]") { wxArrayString a1; a1.Add(wxT("thermit")); a1.Add(wxT("condor")); a1.Add(wxT("lion"), 3); a1.Add(wxT("dog")); a1.Add(wxT("human")); a1.Add(wxT("alligator")); CHECK((COMPARE_8_VALUES( a1 , wxT("thermit") , wxT("condor") , wxT("lion") , wxT("lion") , wxT("lion") , wxT("dog") , wxT("human") , wxT("alligator") ))); CHECK( COMPARE_COUNT( a1 , 8 ) ); wxArrayString a2(a1); CHECK((COMPARE_8_VALUES( a2 , wxT("thermit") , wxT("condor") , wxT("lion") , wxT("lion") , wxT("lion") , wxT("dog") , wxT("human") , wxT("alligator") ))); CHECK( COMPARE_COUNT( a2 , 8 ) ); wxSortedArrayString a3(a1); CHECK((COMPARE_8_VALUES( a3 , wxT("alligator") , wxT("condor") , wxT("dog") , wxT("human") , wxT("lion") , wxT("lion") , wxT("lion") , wxT("thermit") ))); CHECK( COMPARE_COUNT( a3 , 8 ) ); wxSortedArrayString a4; for (wxArrayString::iterator it = a1.begin(), en = a1.end(); it != en; ++it) a4.Add(*it); CHECK((COMPARE_8_VALUES( a4 , wxT("alligator") , wxT("condor") , wxT("dog") , wxT("human") , wxT("lion") , wxT("lion") , wxT("lion") , wxT("thermit") ))); CHECK( COMPARE_COUNT( a4 , 8 ) ); a1.RemoveAt(2,3); CHECK((COMPARE_5_VALUES( a1 , wxT("thermit") , wxT("condor") , wxT("dog") , wxT("human") , wxT("alligator") ))); CHECK( COMPARE_COUNT( a1 , 5 ) ); a2 = a1; CHECK((COMPARE_5_VALUES( a2 , wxT("thermit") , wxT("condor") , wxT("dog") , wxT("human") , wxT("alligator") ))); CHECK( COMPARE_COUNT( a2 , 5 ) ); a1.Sort(false); CHECK((COMPARE_5_VALUES( a1 , wxT("alligator") , wxT("condor") , wxT("dog") , wxT("human") , wxT("thermit") ))); CHECK( COMPARE_COUNT( a1 , 5 ) ); a1.Sort(true); CHECK((COMPARE_5_VALUES( a1 , wxT("thermit") , wxT("human") , wxT("dog") , wxT("condor") , wxT("alligator") ))); CHECK( COMPARE_COUNT( a1 , 5 ) ); a1.Sort(&StringLenCompare); CHECK((COMPARE_5_VALUES( a1 , wxT("dog") , wxT("human") , wxT("condor") , wxT("thermit") , wxT("alligator") ))); CHECK( COMPARE_COUNT( a1 , 5 ) ); CHECK( a1.Index( wxT("dog") ) == 0 ); CHECK( a1.Index( wxT("human") ) == 1 ); CHECK( a1.Index( wxT("humann") ) == wxNOT_FOUND ); CHECK( a1.Index( wxT("condor") ) == 2 ); CHECK( a1.Index( wxT("thermit") ) == 3 ); CHECK( a1.Index( wxT("alligator") ) == 4 ); CHECK( a1.Index( wxT("dog"), /*bCase=*/true, /*fromEnd=*/true ) == 0 ); CHECK( a1.Index( wxT("human"), /*bCase=*/true, /*fromEnd=*/true ) == 1 ); CHECK( a1.Index( wxT("humann"), /*bCase=*/true, /*fromEnd=*/true ) == wxNOT_FOUND ); CHECK( a1.Index( wxT("condor"), /*bCase=*/true, /*fromEnd=*/true ) == 2 ); CHECK( a1.Index( wxT("thermit"), /*bCase=*/true, /*fromEnd=*/true ) == 3 ); CHECK( a1.Index( wxT("alligator"), /*bCase=*/true, /*fromEnd=*/true ) == 4 ); wxArrayString a5; CHECK( a5.Add( wxT("x"), 1 ) == 0 ); CHECK( a5.Add( wxT("a"), 3 ) == 1 ); CHECK((COMPARE_4_VALUES( a5, wxT("x") , wxT("a") , wxT("a") , wxT("a") ))); a5.assign(a1.end(), a1.end()); CHECK( a5.empty() ); a5.assign(a1.begin(), a1.end()); CHECK( a5 == a1 ); const wxString months[] = { "Jan", "Feb", "Mar" }; a5.assign(months, months + WXSIZEOF(months)); CHECK( a5.size() == WXSIZEOF(months) ); CHECK((COMPARE_3_VALUES(a5, "Jan", "Feb", "Mar"))); a5.clear(); CHECK( a5.size() == 0 ); a5.resize(7, "Foo"); CHECK( a5.size() == 7 ); CHECK( a5[3] == "Foo" ); a5.resize(3); CHECK( a5.size() == 3 ); CHECK( a5[2] == "Foo" ); wxArrayString a6; a6.Add("Foo"); a6.Insert(a6[0], 1, 100); // The whole point of this code is to test self-assignment, so suppress // clang warning about it. wxCLANG_WARNING_SUPPRESS(self-assign-overloaded) wxArrayString a7; a7 = a7; CHECK( a7.size() == 0 ); a7.Add("Bar"); a7 = a7; CHECK( a7.size() == 1 ); wxCLANG_WARNING_RESTORE(self-assign-overloaded) } TEST_CASE("wxSortedArrayString", "[dynarray]") { wxSortedArrayString a; a.Add("d"); a.Add("c"); CHECK( a.Index("c") == 0 ); a.push_back("b"); a.push_back("a"); CHECK( a.Index("a") == 0 ); wxSortedArrayString ar(wxStringSortDescending); ar.Add("a"); ar.Add("b"); CHECK( ar[0] == "b" ); CHECK( ar[1] == "a" ); wxSortedArrayString ad(wxDictionaryStringSortAscending); ad.Add("AB"); ad.Add("a"); ad.Add("Aa"); CHECK( ad[0] == "a" ); CHECK( ad[1] == "Aa" ); CHECK( ad.Index("a") == 0 ); CHECK( ad.Index("Aa") == 1 ); CHECK( ad.Index("AB") == 2 ); CHECK( ad.Index("A") == wxNOT_FOUND ); CHECK( ad.Index("z") == wxNOT_FOUND ); } TEST_CASE("Arrays::Split", "[dynarray]") { // test wxSplit: { wxString str = wxT(",,,,first,second,third,,"); const wxChar *expected[] = { wxT(""), wxT(""), wxT(""), wxT(""), wxT("first"), wxT("second"), wxT("third"), wxT(""), wxT("") }; wxArrayString exparr(WXSIZEOF(expected), expected); wxArrayString realarr(wxSplit(str, wxT(','))); CHECK( exparr == realarr ); } { wxString str = wxT(",\\,first,second,third,"); const wxChar *expected[] = { wxT(""), wxT(",first"), wxT("second"), wxT("third"), wxT("") }; const wxChar *expected2[] = { wxT(""), wxT("\\"), wxT("first"), wxT("second"), wxT("third"), wxT("") }; // escaping on: wxArrayString exparr(WXSIZEOF(expected), expected); wxArrayString realarr(wxSplit(str, wxT(','), wxT('\\'))); CHECK( exparr == realarr ); // escaping turned off: wxArrayString exparr2(WXSIZEOF(expected2), expected2); wxArrayString realarr2(wxSplit(str, wxT(','), wxT('\0'))); CHECK( exparr2 == realarr2 ); } { // test is escape characters placed before non-separator character are // just ignored as they should: wxString str = wxT(",\\,,fir\\st,se\\cond\\,,\\third"); const wxChar *expected[] = { wxT(""), wxT(","), wxT("fir\\st"), wxT("se\\cond,"), wxT("\\third") }; const wxChar *expected2[] = { wxT(""), wxT("\\"), wxT(""), wxT("fir\\st"), wxT("se\\cond\\"), wxT(""), wxT("\\third") }; // escaping on: wxArrayString exparr(WXSIZEOF(expected), expected); wxArrayString realarr(wxSplit(str, wxT(','), wxT('\\'))); CHECK( exparr == realarr ); // escaping turned off: wxArrayString exparr2(WXSIZEOF(expected2), expected2); wxArrayString realarr2(wxSplit(str, wxT(','), wxT('\0'))); CHECK( exparr2 == realarr2 ); } } TEST_CASE("Arrays::Join", "[dynarray]") { // test wxJoin: { const wxChar *arr[] = { wxT("first"), wxT(""), wxT("second"), wxT("third") }; wxString expected = wxT("first,,second,third"); wxArrayString arrstr(WXSIZEOF(arr), arr); wxString result = wxJoin(arrstr, wxT(',')); CHECK( expected == result ); } { const wxChar *arr[] = { wxT("first, word"), wxT(",,second"), wxT("third,,") }; wxString expected = wxT("first\\, word,\\,\\,second,third\\,\\,"); wxString expected2 = wxT("first, word,,,second,third,,"); // escaping on: wxArrayString arrstr(WXSIZEOF(arr), arr); wxString result = wxJoin(arrstr, wxT(','), wxT('\\')); CHECK( expected == result ); // escaping turned off: wxString result2 = wxJoin(arrstr, wxT(','), wxT('\0')); CHECK( expected2 == result2 ); } { // test is escape characters placed in the original array are just ignored as they should: const wxChar *arr[] = { wxT("first\\, wo\\rd"), wxT("seco\\nd"), wxT("\\third\\") }; wxString expected = wxT("first\\\\, wo\\rd,seco\\nd,\\third\\"); wxString expected2 = wxT("first\\, wo\\rd,seco\\nd,\\third\\"); // escaping on: wxArrayString arrstr(WXSIZEOF(arr), arr); wxString result = wxJoin(arrstr, wxT(','), wxT('\\')); CHECK( expected == result ); // escaping turned off: wxString result2 = wxJoin(arrstr, wxT(','), wxT('\0')); CHECK( expected2 == result2 ); } } TEST_CASE("Arrays::SplitJoin", "[dynarray]") { wxChar separators[] = { wxT('a'), wxT(','), wxT('_'), wxT(' '), wxT('\\'), wxT('&'), wxT('{'), wxT('A'), wxT('<'), wxT('>'), wxT('\''), wxT('\n'), wxT('!'), wxT('-') }; // test with a string: split it and then rejoin it: wxString str = wxT("This is a long, long test; if wxSplit and wxJoin do work ") wxT("correctly, then splitting and joining this 'text' _multiple_ ") wxT("times shouldn't cause any loss of content.\n") wxT("This is some latex code: ") wxT("\\func{wxString}{wxJoin}{") wxT("\\param{const wxArray String\\&}{ arr}, ") wxT("\\param{const wxChar}{ sep}, ") wxT("\\param{const wxChar}{ escape = '\\'}}.\n") wxT("This is some HTML code: ") wxT("<html><head><meta http-equiv=\"content-type\">") wxT("<title>Initial page of Mozilla Firefox</title>") wxT("</meta></head></html>"); size_t i; for (i = 0; i < WXSIZEOF(separators); i++) { wxArrayString arr = wxSplit(str, separators[i]); INFO("Using separator '" << static_cast<char>(separators[i]) << "' " "and split array \"" << arr << "\""); CHECK( str == wxJoin(arr, separators[i]) ); } // test with an array: join it and then resplit it: const wxChar *arr[] = { wxT("first, second!"), wxT("this is the third!!"), wxT("\nThat's the fourth token\n\n"), wxT(" - fifth\ndummy\ntoken - "), wxT("_sixth__token__with_underscores"), wxT("The! Last! One!") }; wxArrayString theArr(WXSIZEOF(arr), arr); for (i = 0; i < WXSIZEOF(separators); i++) { wxString string = wxJoin(theArr, separators[i]); INFO("Using separator '" << static_cast<char>(separators[i]) << "' " "and joined string \"" << string << "\""); CHECK( theArr == wxSplit(string, separators[i]) ); } wxArrayString emptyArray; wxString string = wxJoin(emptyArray, wxT(';')); CHECK( string.empty() ); CHECK( wxSplit(string, wxT(';')).empty() ); CHECK( wxSplit(wxT(";"), wxT(';')).size() == 2 ); // Check for bug with escaping the escape character at the end (but not in // the middle). wxArrayString withBackslashes; withBackslashes.push_back("foo\\"); withBackslashes.push_back("bar\\baz"); string = wxJoin(withBackslashes, ':'); CHECK( string == "foo\\\\:bar\\baz" ); const wxArrayString withBackslashes2 = wxSplit(string, ':'); REQUIRE( withBackslashes2.size() == 2 ); CHECK( withBackslashes2[0] == withBackslashes[0] ); CHECK( withBackslashes2[1] == withBackslashes[1] ); } TEST_CASE("wxObjArray", "[dynarray]") { { ArrayBars bars; Bar bar(wxT("first bar in general, second bar in array (two copies!)")); CHECK( bars.GetCount() == 0 ); CHECK( Bar::GetNumber() == 1 ); bars.Add(new Bar(wxT("first bar in array"))); bars.Add(bar, 2); CHECK( bars.GetCount() == 3 ); CHECK( Bar::GetNumber() == 4 ); bars.RemoveAt(1, bars.GetCount() - 1); CHECK( bars.GetCount() == 1 ); CHECK( Bar::GetNumber() == 2 ); bars.Empty(); CHECK( bars.GetCount() == 0 ); CHECK( Bar::GetNumber() == 1 ); } CHECK( Bar::GetNumber() == 0 ); } TEST_CASE("wxObjArrayPtr", "[dynarray]") { // Just check that instantiating this class compiles. ArrayBarPtrs barptrs; CHECK( barptrs.size() == 0 ); } #define TestArrayOf(name) \ \ TEST_CASE("wxDynArray::" #name, "[dynarray]") \ { \ wxArray##name a; \ a.Add(1); \ a.Add(17,2); \ a.Add(5,3); \ a.Add(3,4); \ \ CHECK((COMPARE_10_VALUES(a,1,17,17,5,5,5,3,3,3,3))); \ CHECK( COMPARE_COUNT( a , 10 ) ); \ \ a.Sort(name ## Compare); \ \ CHECK((COMPARE_10_VALUES(a,1,3,3,3,3,5,5,5,17,17))); \ CHECK( COMPARE_COUNT( a , 10 ) ); \ \ a.Sort(name ## RevCompare); \ \ CHECK((COMPARE_10_VALUES(a,17,17,5,5,5,3,3,3,3,1))); \ CHECK( COMPARE_COUNT( a , 10 ) ); \ \ wxSortedArray##name b; \ \ b.Add(1); \ b.Add(17); \ b.Add(5); \ b.Add(3); \ \ CHECK((COMPARE_4_VALUES(b,1,3,5,17))); \ CHECK( COMPARE_COUNT( b , 4 ) ); \ CHECK( b.Index( 0 ) == wxNOT_FOUND ); \ CHECK( b.Index( 1 ) == 0 ); \ CHECK( b.Index( 3 ) == 1 ); \ CHECK( b.Index( 4 ) == wxNOT_FOUND ); \ CHECK( b.Index( 5 ) == 2 ); \ CHECK( b.Index( 6 ) == wxNOT_FOUND ); \ CHECK( b.Index( 17 ) == 3 ); \ } TestArrayOf(UShort) TestArrayOf(Char) TestArrayOf(Int) TEST_CASE("wxDynArray::Alloc", "[dynarray]") { wxArrayInt a; a.Add(17); a.Add(9); CHECK( a.GetCount() == 2 ); a.Alloc(1000); CHECK( a.GetCount() == 2 ); CHECK( a[0] == 17 ); CHECK( a[1] == 9 ); } TEST_CASE("wxDynArray::Clear", "[dynarray]") { ItemPtrArray items; WX_CLEAR_ARRAY(items); CHECK( items.size() == 0 ); items.push_back(new Item(17)); items.push_back(new Item(71)); CHECK( items.size() == 2 ); WX_CLEAR_ARRAY(items); CHECK( items.size() == 0 ); } namespace { template <typename A, typename T> void DoTestSwap(T v1, T v2, T v3) { A a1, a2; a1.swap(a2); CHECK( a1.empty() ); CHECK( a2.empty() ); a1.push_back(v1); a1.swap(a2); CHECK( a1.empty() ); CHECK( a2.size() == 1 ); a1.push_back(v2); a1.push_back(v3); a2.swap(a1); CHECK( a1.size() == 1 ); CHECK( a2.size() == 2 ); CHECK( a1[0] == v1 ); CHECK( a2[1] == v3 ); a1.swap(a2); CHECK( a1.size() == 2 ); CHECK( a2.size() == 1 ); } } // anonymous namespace TEST_CASE("wxDynArray::Swap", "[dynarray]") { DoTestSwap<wxArrayString>("Foo", "Bar", "Baz"); DoTestSwap<wxArrayInt>(1, 10, 100); DoTestSwap<wxArrayLong>(6, 28, 496); } TEST_CASE("wxDynArray::TestSTL", "[dynarray]") { wxArrayInt list1; wxArrayInt::iterator it, en; wxArrayInt::reverse_iterator rit, ren; int i; static const int COUNT = 5; for ( i = 0; i < COUNT; ++i ) list1.push_back(i); CHECK( list1.capacity() >= (size_t)COUNT ); CHECK( list1.size() == COUNT ); for ( it = list1.begin(), en = list1.end(), i = 0; it != en; ++it, ++i ) { CHECK( *it == i ); } CHECK( i == COUNT ); for ( rit = list1.rbegin(), ren = list1.rend(), i = COUNT; rit != ren; ++rit, --i ) { CHECK( *rit == i-1 ); } CHECK( i == 0 ); CHECK( *list1.rbegin() == *(list1.end()-1) ); CHECK( *list1.begin() == *(list1.rend()-1) ); it = list1.begin()+1; rit = list1.rbegin()+1; CHECK( *list1.begin() == *(it-1) ); CHECK( *list1.rbegin() == *(rit-1) ); CHECK( list1.front() == 0 ); CHECK( list1.back() == COUNT - 1 ); list1.erase(list1.begin()); list1.erase(list1.end()-1); for ( it = list1.begin(), en = list1.end(), i = 1; it != en; ++it, ++i ) { CHECK( *it == i ); } ItemPtrArray items; items.push_back(new Item(17)); CHECK( (*(items.rbegin()))->n == 17 ); CHECK( (**items.begin()).n == 17 ); WX_CLEAR_ARRAY(items); } TEST_CASE("wxDynArray::IndexFromEnd", "[dynarray]") { wxArrayInt a; a.push_back(10); a.push_back(1); a.push_back(42); CHECK( a.Index(10) == 0 ); CHECK( a.Index(1) == 1 ); CHECK( a.Index(42) == 2 ); CHECK( a.Index(10, /*bFromEnd=*/true) == 0 ); CHECK( a.Index( 1, /*bFromEnd=*/true) == 1 ); CHECK( a.Index(42, /*bFromEnd=*/true) == 2 ); } TEST_CASE("wxNaturalStringComparisonGeneric()", "[wxString][compare]") { // simple string comparison CHECK(wxCmpNaturalGeneric("a", "a") == 0); CHECK(wxCmpNaturalGeneric("a", "z") < 0); CHECK(wxCmpNaturalGeneric("z", "a") > 0); // case insensitivity CHECK(wxCmpNaturalGeneric("a", "A") == 0); CHECK(wxCmpNaturalGeneric("A", "a") == 0); CHECK(wxCmpNaturalGeneric("AB", "a") > 0); CHECK(wxCmpNaturalGeneric("a", "AB") < 0); // empty strings sort before whitespace and punctiation CHECK(wxCmpNaturalGeneric("", " ") < 0); CHECK(wxCmpNaturalGeneric(" ", "") > 0); CHECK(wxCmpNaturalGeneric("", ",") < 0); CHECK(wxCmpNaturalGeneric(",", "") > 0); // empty strings sort before numbers CHECK(wxCmpNaturalGeneric("", "0") < 0); CHECK(wxCmpNaturalGeneric("0", "") > 0); // empty strings sort before letters and symbols CHECK(wxCmpNaturalGeneric("", "abc") < 0); CHECK(wxCmpNaturalGeneric("abc", "") > 0); // whitespace and punctiation sort before numbers CHECK(wxCmpNaturalGeneric(" ", "1") < 0); CHECK(wxCmpNaturalGeneric("1", " ") > 0); CHECK(wxCmpNaturalGeneric(",", "1") < 0); CHECK(wxCmpNaturalGeneric("1", ",") > 0); // strings containing numbers sort before letters and symbols CHECK(wxCmpNaturalGeneric("00", "a") < 0); CHECK(wxCmpNaturalGeneric("a", "00") > 0); // strings containing numbers are compared by their value CHECK(wxCmpNaturalGeneric("01", "1") == 0); CHECK(wxCmpNaturalGeneric("1", "01") == 0); CHECK(wxCmpNaturalGeneric("1", "05") < 0); CHECK(wxCmpNaturalGeneric("05", "1") > 0); CHECK(wxCmpNaturalGeneric("10", "5") > 0); CHECK(wxCmpNaturalGeneric("5", "10") < 0); CHECK(wxCmpNaturalGeneric("1", "9999999999999999999") < 0); CHECK(wxCmpNaturalGeneric("9999999999999999999", "1") > 0); // comparing strings composed from whitespace, // punctuation, numbers, letters, and symbols CHECK(wxCmpNaturalGeneric("1st", " 1st") > 0); CHECK(wxCmpNaturalGeneric(" 1st", "1st") < 0); CHECK(wxCmpNaturalGeneric("1st", ",1st") > 0); CHECK(wxCmpNaturalGeneric(",1st", "1st") < 0); CHECK(wxCmpNaturalGeneric("1st", "01st") == 0); CHECK(wxCmpNaturalGeneric("01st", "1st") == 0); CHECK(wxCmpNaturalGeneric("10th", "5th") > 0); CHECK(wxCmpNaturalGeneric("5th", "10th") < 0); CHECK(wxCmpNaturalGeneric("a1st", "a01st") == 0); CHECK(wxCmpNaturalGeneric("a01st", "a1st") == 0); CHECK(wxCmpNaturalGeneric("a10th", "a5th") > 0); CHECK(wxCmpNaturalGeneric("a5th", "a10th") < 0); CHECK(wxCmpNaturalGeneric("a 10th", "a5th") < 0); CHECK(wxCmpNaturalGeneric("a5th", "a 10th") > 0); CHECK(wxCmpNaturalGeneric("a1st1", "a01st01") == 0); CHECK(wxCmpNaturalGeneric("a01st01", "a1st1") == 0); CHECK(wxCmpNaturalGeneric("a10th10", "a5th5") > 0); CHECK(wxCmpNaturalGeneric("a5th5", "a10th10") < 0); CHECK(wxCmpNaturalGeneric("a 10th 10", "a5th 5") < 0); CHECK(wxCmpNaturalGeneric("a5th 5", "a 10th 10") > 0); }
35.010626
98
0.442504
Sasha7b9Work
4d0401bd5bb069de1dbc19d7e90723d4de2e9594
4,065
cpp
C++
build/cpp_test/src/haxe/CallStack.cpp
TomBebb/hxecs
80620512df7b32d70f1b59facdf8f6349192a166
[ "BSD-3-Clause" ]
null
null
null
build/cpp_test/src/haxe/CallStack.cpp
TomBebb/hxecs
80620512df7b32d70f1b59facdf8f6349192a166
[ "BSD-3-Clause" ]
null
null
null
build/cpp_test/src/haxe/CallStack.cpp
TomBebb/hxecs
80620512df7b32d70f1b59facdf8f6349192a166
[ "BSD-3-Clause" ]
null
null
null
// Generated by Haxe 3.4.7 #include <hxcpp.h> #ifndef INCLUDED_Std #include <Std.h> #endif #ifndef INCLUDED_haxe_CallStack #include <haxe/CallStack.h> #endif #ifndef INCLUDED_haxe_StackItem #include <haxe/StackItem.h> #endif namespace haxe{ void CallStack_obj::__construct() { } Dynamic CallStack_obj::__CreateEmpty() { return new CallStack_obj; } void *CallStack_obj::_hx_vtable = 0; Dynamic CallStack_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< CallStack_obj > _hx_result = new CallStack_obj(); _hx_result->__construct(); return _hx_result; } bool CallStack_obj::_hx_isInstanceOf(int inClassId) { return inClassId==(int)0x00000001 || inClassId==(int)0x6207a884; } ::Array< ::Dynamic> CallStack_obj::exceptionStack(){ ::Array< ::String > s = ::__hxcpp_get_exception_stack(); return ::haxe::CallStack_obj::makeStack(s); } STATIC_HX_DEFINE_DYNAMIC_FUNC0(CallStack_obj,exceptionStack,return ) ::Array< ::Dynamic> CallStack_obj::makeStack(::Array< ::String > s){ ::Array< ::String > stack = s; ::Array< ::Dynamic> m = ::Array_obj< ::Dynamic>::__new(); { int _g = (int)0; while((_g < stack->length)){ ::String func = stack->__get(_g); _g = (_g + (int)1); ::Array< ::String > words = func.split(HX_("::",c0,32,00,00)); if ((words->length == (int)0)) { m->push(::haxe::StackItem_obj::CFunction_dyn()); } else { if ((words->length == (int)2)) { m->push(::haxe::StackItem_obj::Method(words->__get((int)0),words->__get((int)1))); } else { if ((words->length == (int)4)) { ::haxe::StackItem _hx_tmp = ::haxe::StackItem_obj::Method(words->__get((int)0),words->__get((int)1)); ::String words1 = words->__get((int)2); m->push(::haxe::StackItem_obj::FilePos(_hx_tmp,words1,::Std_obj::parseInt(words->__get((int)3)))); } } } } } return m; } STATIC_HX_DEFINE_DYNAMIC_FUNC1(CallStack_obj,makeStack,return ) CallStack_obj::CallStack_obj() { } bool CallStack_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp) { switch(inName.length) { case 9: if (HX_FIELD_EQ(inName,"makeStack") ) { outValue = makeStack_dyn(); return true; } break; case 14: if (HX_FIELD_EQ(inName,"exceptionStack") ) { outValue = exceptionStack_dyn(); return true; } } return false; } #if HXCPP_SCRIPTABLE static hx::StorageInfo *CallStack_obj_sMemberStorageInfo = 0; static hx::StaticInfo *CallStack_obj_sStaticStorageInfo = 0; #endif static void CallStack_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(CallStack_obj::__mClass,"__mClass"); }; #ifdef HXCPP_VISIT_ALLOCS static void CallStack_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(CallStack_obj::__mClass,"__mClass"); }; #endif hx::Class CallStack_obj::__mClass; static ::String CallStack_obj_sStaticFields[] = { HX_HCSTRING("exceptionStack","\x79","\x48","\x56","\x0b"), HX_HCSTRING("makeStack","\x7a","\xde","\xa3","\x57"), ::String(null()) }; void CallStack_obj::__register() { hx::Object *dummy = new CallStack_obj; CallStack_obj::_hx_vtable = *(void **)dummy; hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("haxe.CallStack","\x62","\x4b","\x54","\x6d"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &CallStack_obj::__GetStatic; __mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField; __mClass->mMarkFunc = CallStack_obj_sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(CallStack_obj_sStaticFields); __mClass->mMembers = hx::Class_obj::dupFunctions(0 /* sMemberFields */); __mClass->mCanCast = hx::TCanCast< CallStack_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = CallStack_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = CallStack_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = CallStack_obj_sStaticStorageInfo; #endif hx::_hx_RegisterClass(__mClass->mName, __mClass); } } // end namespace haxe
28.626761
108
0.717835
TomBebb
4d056b04fd4b4676573d90552810a11c624bf9d8
28,547
cpp
C++
src/tpe_flow_sc.cpp
duxingyi-charles/repulsive-curves
a2e7729357cf25de4147fbfaa17a039c57b13a7a
[ "MIT" ]
null
null
null
src/tpe_flow_sc.cpp
duxingyi-charles/repulsive-curves
a2e7729357cf25de4147fbfaa17a039c57b13a7a
[ "MIT" ]
null
null
null
src/tpe_flow_sc.cpp
duxingyi-charles/repulsive-curves
a2e7729357cf25de4147fbfaa17a039c57b13a7a
[ "MIT" ]
null
null
null
#include "tpe_flow_sc.h" #include "utils.h" #include "product/dense_matrix.h" #include "circle_search.h" namespace LWS { TPEFlowSolverSC::TPEFlowSolverSC(PolyCurveNetwork* g, double a, double b) : constraint(g) { curveNetwork = g; alpha = a; beta = b; ls_step_threshold = 1e-15; backproj_threshold = 1e-4; iterNum = 0; lastStepSize = 0; mg_tolerance = 1e-2; double averageLength = g->TotalLength(); averageLength /= g->NumEdges(); mg_backproj_threshold = fmin(1e-4, averageLength * mg_tolerance * 1e-2); std::cout << "Multigrid backprojection threshold set to " << mg_backproj_threshold << std::endl; UpdateTargetLengths(); useEdgeLengthScale = false; useTotalLengthScale = false; perfLogEnabled = false; } TPEFlowSolverSC::~TPEFlowSolverSC() { for (size_t i = 0; i < obstacles.size(); i++) { delete obstacles[i]; } obstacles.clear(); } void TPEFlowSolverSC::UpdateTargetLengths() { constraint.UpdateTargetValues(constraintTargets); } void TPEFlowSolverSC::ReplaceCurve(PolyCurveNetwork* new_p) { curveNetwork = new_p; constraint = ConstraintClassType(curveNetwork); UpdateTargetLengths(); if (useEdgeLengthScale) { double averageLength = curveNetwork->TotalLength() / curveNetwork->NumEdges(); lengthScaleStep = averageLength / 100; } } void TPEFlowSolverSC::EnablePerformanceLog(std::string logFile) { perfFile.open(logFile); perfLogEnabled = true; std::cout << "Started logging performance to " << logFile << std::endl; } void TPEFlowSolverSC::ClosePerformanceLog() { perfFile.close(); } void TPEFlowSolverSC::SetTotalLengthScaleTarget(double scale) { useTotalLengthScale = true; int startIndex = constraint.startIndexOfConstraint(ConstraintType::TotalLength); if (startIndex < 0) { useTotalLengthScale = false; std::cout << "No total length constraint; ignoring total length scale" << std::endl; return; } double len = curveNetwork->TotalLength(); targetLength = scale * len; lengthScaleStep = len / 100; } void TPEFlowSolverSC::SetEdgeLengthScaleTarget(double scale) { useEdgeLengthScale = true; int startIndex = constraint.startIndexOfConstraint(ConstraintType::EdgeLengths); if (startIndex < 0) { useEdgeLengthScale = false; std::cout << "No edge length constraint; ignoring edge length scale" << std::endl; return; } targetLength = scale * curveNetwork->TotalLength(); std::cout << "Setting target length to " << targetLength << " (" << scale << " times original)" << std::endl; double averageLength = curveNetwork->TotalLength() / curveNetwork->NumEdges(); lengthScaleStep = averageLength / 100; } double TPEFlowSolverSC::CurrentEnergy(SpatialTree *root) { double energy = 0; if (root) energy = TPEnergyBH(root); else energy = TPEnergyDirect(); for (CurvePotential* p : potentials) { energy += p->CurrentValue(curveNetwork); } for (Obstacle* obs : obstacles) { energy += obs->ComputeEnergy(curveNetwork); } return energy; } double TPEFlowSolverSC::TPEnergyDirect() { return TPESC::tpe_total(curveNetwork, alpha, beta); } double TPEFlowSolverSC::TPEnergyBH(SpatialTree *root) { return SpatialTree::TPEnergyBH(curveNetwork, root, alpha, beta); } void TPEFlowSolverSC::FillGradientVectorDirect(Eigen::MatrixXd &gradients) { TPESC::FillGradientVectorDirect(curveNetwork, gradients, alpha, beta); } void TPEFlowSolverSC::FillGradientVectorBH(SpatialTree *root, Eigen::MatrixXd &gradients) { // Use the spatial tree and Barnes-Hut to evaluate the gradient SpatialTree::TPEGradientBarnesHut(curveNetwork, root, gradients, alpha, beta); } void TPEFlowSolverSC::AddAllGradients(SpatialTree *tree_root, Eigen::MatrixXd &vertGradients) { // Barnes-Hut for gradient accumulation if (tree_root) { FillGradientVectorBH(tree_root, vertGradients); } else { FillGradientVectorDirect(vertGradients); } // Add gradient contributions from obstacles for (Obstacle* obs : obstacles) { obs->AddGradient(curveNetwork, vertGradients); } // Add gradient contributions from potentials for (CurvePotential* p : potentials) { p->AddGradient(curveNetwork, vertGradients); } } bool TPEFlowSolverSC::StepNaive(double h) { // Takes a fixed time step h using the L2 gradient int nVerts = curveNetwork->NumVertices(); Eigen::MatrixXd gradients(nVerts, 3); gradients.setZero(); // FillGradientVectorDirect(gradients); AddAllGradients(0, gradients); for (int i = 0; i < nVerts; i++) { CurveVertex* pt = curveNetwork->GetVertex(i); pt->SetPosition(pt->Position() - h * SelectRow(gradients, i)); } return true; } void TPEFlowSolverSC::SaveCurrentPositions() { originalPositionMatrix = curveNetwork->positions; } void TPEFlowSolverSC::RestoreOriginalPositions() { curveNetwork->positions = originalPositionMatrix; } void TPEFlowSolverSC::SetGradientStep(Eigen::MatrixXd &gradient, double delta) { curveNetwork->positions = originalPositionMatrix - delta * gradient; } double TPEFlowSolverSC::LineSearchStep(Eigen::MatrixXd &gradient, double gradDot, BVHNode3D* root, bool resetStep) { double gradNorm = gradient.norm(); //std::cout << "Norm of gradient = " << gradNorm << std::endl; double initGuess = (gradNorm > 1) ? 1.0 / gradNorm : 1.0 / sqrt(gradNorm); // Use the step size from the previous iteration, if it exists if (!resetStep && lastStepSize > fmax(ls_step_threshold, 1e-5)) { initGuess = fmin(lastStepSize * 1.5, initGuess * 4); } std::cout << " Starting line search with initial guess " << initGuess << std::endl; return LineSearchStep(gradient, initGuess, 0, gradDot, root); } double TPEFlowSolverSC::LineSearchStep(Eigen::MatrixXd &gradient, double initGuess, int doublingLimit, double gradDot, BVHNode3D* root) { double delta = initGuess; // Save initial positions SaveCurrentPositions(); double initialEnergy = CurrentEnergy(root); double gradNorm = gradient.norm(); int numBacktracks = 0, numDoubles = 0; double sigma = 0.01f; double newEnergy = initialEnergy; if (gradNorm < 1e-10) { std::cout << " Gradient is very close to zero" << std::endl; return 0; } // std::cout << "Initial energy " << initialEnergy << std::endl; while (delta > ls_step_threshold) { SetGradientStep(gradient, delta); if (root) { // Update the centers of mass to reflect the new positions root->recomputeCentersOfMass(curveNetwork); } newEnergy = CurrentEnergy(root); double decrease = initialEnergy - newEnergy; double targetDecrease = sigma * delta * gradNorm * gradDot; // If the energy hasn't decreased enough to meet the Armijo condition, // halve the step size. if (decrease < targetDecrease) { delta /= 2; numBacktracks++; } else if (decrease >= targetDecrease && numBacktracks == 0 && numDoubles < doublingLimit) { delta *= 2; numDoubles++; } // Otherwise, accept the current step. else { SetGradientStep(gradient, delta); if (root) { // Update the centers of mass to reflect the new positions root->recomputeCentersOfMass(curveNetwork); } break; } } if (delta <= ls_step_threshold) { std::cout << "Failed to find a non-trivial step after " << numBacktracks << " backtracks" << std::endl; // PlotEnergyInDirection(gradient, sigma * gradDot); // Restore initial positions if step size goes to 0 RestoreOriginalPositions(); return 0; } else { std::cout << " Energy: " << initialEnergy << " -> " << newEnergy << " (step size " << delta << ", " << numBacktracks << " backtracks)" << std::endl; return delta; } } inline double alpha_of_delta(double delta, double alpha_0, double alpha_1, double R) { return (1.0 / R) * (alpha_0 * delta + alpha_1 * delta * delta); } void TPEFlowSolverSC::SetCircleStep(Eigen::MatrixXd &P_dot, Eigen::MatrixXd &K, double sqrt_G, double R, double alpha_delta) { curveNetwork->positions = originalPositionMatrix + R * (-P_dot * (sin(alpha_delta) / sqrt_G) + R * K * (1 - cos(alpha_delta))); } double TPEFlowSolverSC::CircleSearchStep(Eigen::MatrixXd &P_dot, Eigen::MatrixXd &P_ddot, Eigen::MatrixXd &G, BVHNode3D* root) { // Save initial positions SaveCurrentPositions(); int nVerts = curveNetwork->NumVertices(); int nRows = curveNetwork->NumVertices() * 3; // TODO: use only Gram matrix or full constraint matrix? Eigen::VectorXd P_dot_vec(nRows); MatrixIntoVectorX3(P_dot, P_dot_vec); Eigen::VectorXd P_ddot_vec(nRows); MatrixIntoVectorX3(P_ddot, P_ddot_vec); double G_Pd_Pd = P_dot_vec.dot(G.block(0, 0, nRows, nRows) * P_dot_vec); double G_Pd_Pdd = P_dot_vec.dot(G.block(0, 0, nRows, nRows) * P_ddot_vec); Eigen::VectorXd K_vec = 1.0 / G_Pd_Pd * (-P_ddot_vec + P_dot_vec * (G_Pd_Pdd / G_Pd_Pd)); double R = 1.0 / sqrt(K_vec.dot(G.block(0, 0, nRows, nRows) * K_vec)); double alpha_0 = sqrt(G_Pd_Pd); double alpha_1 = 0.5 * G_Pd_Pdd / alpha_0; Eigen::MatrixXd K(nVerts, 3); K.setZero(); VectorXdIntoMatrix(K_vec, K); double delta = -2 * alpha_0 / alpha_1; std::cout << "Delta estimate = " << delta << std::endl; delta = fmax(0, delta); SetCircleStep(P_dot, K, alpha_0, R, alpha_of_delta(delta, alpha_0, alpha_1, R)); return delta; } double TPEFlowSolverSC::LSBackproject(Eigen::MatrixXd &gradient, double initGuess, Eigen::PartialPivLU<Eigen::MatrixXd> &lu, double gradDot, BVHNode3D* root) { double delta = initGuess; int attempts = 0; while ((delta > ls_step_threshold || useEdgeLengthScale) && attempts < 10) { attempts++; SetGradientStep(gradient, delta); if (root) { // Update the centers of mass to reflect the new positions root->recomputeCentersOfMass(curveNetwork); } for (int i = 0; i < 3; i++) { double maxValue = BackprojectConstraints(lu); if (maxValue < backproj_threshold) { std::cout << "Backprojection successful after " << attempts << " attempts" << std::endl; std::cout << "Used " << (i + 1) << " Newton steps on successful attempt" << std::endl; return delta; } } delta /= 2; } std::cout << "Couldn't make backprojection succeed after " << attempts << " attempts (initial step " << initGuess << ")" << std::endl; SetGradientStep(gradient, 0); BackprojectConstraints(lu); return delta; } bool TPEFlowSolverSC::StepLS(bool useBH) { int nVerts = curveNetwork->NumVertices(); Eigen::MatrixXd gradients(nVerts, 3); gradients.setZero(); // FillGradientVectorDirect(gradients); BVHNode3D *tree_root = 0; if (useBH) tree_root = CreateBVHFromCurve(curveNetwork); AddAllGradients(tree_root, gradients); double gradNorm = gradients.norm(); double step_size = LineSearchStep(gradients, 1, tree_root); delete tree_root; soboNormZero = (gradNorm < 1e-4); lastStepSize = step_size; return (step_size > ls_step_threshold); } bool TPEFlowSolverSC::StepLSConstrained(bool useBH, bool useBackproj) { std::cout << "=== Iteration " << ++iterNum << " ===" << std::endl; // Compute gradient int nVerts = curveNetwork->NumVertices(); Eigen::MatrixXd gradients(nVerts, 3); gradients.setZero(); BVHNode3D *tree_root = 0; if (useBH) tree_root = CreateBVHFromCurve(curveNetwork); AddAllGradients(tree_root, gradients); // Set up saddle matrix Eigen::MatrixXd A; int nRows = constraint.NumConstraintRows() + constraint.NumExpectedCols(); A.setZero(nRows, nRows); // Assemble constraint saddle matrix with identity in the upper-left Eigen::MatrixXd mass; mass.setIdentity(nVerts * 3, nVerts * 3); for (int i = 0; i < nVerts; i++) { double m = 1.0 / curveNetwork->GetVertex(i)->DualLength(); mass(3 * i, 3 * i) = m; mass(3 * i + 1, 3 * i + 1) = m; mass(3 * i + 2, 3 * i + 2) = m; } A.block(0, 0, nVerts * 3, nVerts * 3) = mass; constraint.FillDenseBlock(A); // Factorize it Eigen::PartialPivLU<Eigen::MatrixXd> lu; lu.compute(A); // Project gradient onto constraint differential ProjectSoboSloboGradient(lu, gradients); double gradNorm = gradients.norm(); std::cout << " Norm gradient = " << gradNorm << std::endl; double step_size = LineSearchStep(gradients, 1, tree_root); // Backprojection if (useBackproj) { step_size = LSBackproject(gradients, step_size, lu, 1, tree_root); } if (tree_root) delete tree_root; lastStepSize = step_size; soboNormZero = (gradNorm < 1e-4); return (step_size > ls_step_threshold); } double TPEFlowSolverSC::ProjectSoboSloboGradient(Eigen::PartialPivLU<Eigen::MatrixXd> &lu, Eigen::MatrixXd &gradients) { // If using per-edge length constraints, then the matrix has all coordinates merged, // so we only need one solve int nVerts = curveNetwork->NumVertices(); Eigen::VectorXd b; b.setZero(constraint.NumConstraintRows() + constraint.NumExpectedCols()); // Fill in RHS with all coordinates for (int i = 0; i < nVerts; i++) { b(3 * i) = gradients(i, 0); b(3 * i + 1) = gradients(i, 1); b(3 * i + 2) = gradients(i, 2); } // Solve for all coordinates Eigen::VectorXd ss_grad = lu.solve(b); fullDerivVector = ss_grad; for (int i = 0; i < nVerts; i++) { SetRow(gradients, i, Vector3{ss_grad(3 * i), ss_grad(3 * i + 1), ss_grad(3 * i + 2)}); } return 1; } double TPEFlowSolverSC::BackprojectConstraints(Eigen::PartialPivLU<Eigen::MatrixXd> &lu) { int nVerts = curveNetwork->NumVertices(); Eigen::VectorXd b; b.setZero(constraint.NumExpectedCols() + constraint.NumConstraintRows()); // If using per-edge length constraints, matrix has all coordinates merged, // so we only need one solve. // Fill RHS with negative constraint values double maxViolation = constraint.FillConstraintValues(b, constraintTargets, 3 * nVerts); // Solve for correction Eigen::VectorXd corr = lu.solve(b); // Apply correction for (int i = 0; i < nVerts; i++) { Vector3 correction{corr(3 * i), corr(3 * i + 1), corr(3 * i + 2)}; CurveVertex* pt = curveNetwork->GetVertex(i); pt->SetPosition(pt->Position() + correction); } // Compute constraint violation after correction maxViolation = constraint.FillConstraintValues(b, constraintTargets, 3 * nVerts); std::cout << " Constraint value = " << maxViolation << std::endl; return maxViolation; } double TPEFlowSolverSC::ProjectGradient(Eigen::MatrixXd &gradients, Eigen::MatrixXd &A, Eigen::PartialPivLU<Eigen::MatrixXd> &lu) { size_t nVerts = curveNetwork->NumVertices(); Eigen::MatrixXd l2gradients = gradients; // Assemble the Sobolev gram matrix with constraints double ss_start = Utils::currentTimeMilliseconds(); SobolevCurves::Sobolev3XWithConstraints(curveNetwork, constraint, alpha, beta, A); double ss_end = Utils::currentTimeMilliseconds(); // Factorize and solve double factor_start = Utils::currentTimeMilliseconds(); lu.compute(A); ProjectSoboSloboGradient(lu, gradients); double factor_end = Utils::currentTimeMilliseconds(); double soboDot = 0; for (int i = 0; i < gradients.rows(); i++) { soboDot += dot(SelectRow(l2gradients, i), SelectRow(gradients, i)); } return soboDot; } void TPEFlowSolverSC::GetSecondDerivative(SpatialTree* tree_root, Eigen::MatrixXd &projected1, double epsilon, Eigen::MatrixXd &secondDeriv) { Eigen::MatrixXd origPos = curveNetwork->positions; int nVerts = curveNetwork->NumVertices(); // Evaluate second point for circular line search double eps = 1e-5; // Evaluate new L2 gradients curveNetwork->positions -= eps * projected1; Eigen::MatrixXd projectedEps; projectedEps.setZero(nVerts, 3); AddAllGradients(tree_root, projectedEps); // Project a second time Eigen::MatrixXd A_eps; Eigen::PartialPivLU<Eigen::MatrixXd> lu_eps; ProjectGradient(projectedEps, A_eps, lu_eps); secondDeriv = (projectedEps - projected1) / eps; curveNetwork->positions = origPos; } bool TPEFlowSolverSC::TargetLengthReached() { if (useEdgeLengthScale || useTotalLengthScale) { double currentLength = curveNetwork->TotalLength(); return fabs(currentLength - targetLength) <= lengthScaleStep; } return true; } void TPEFlowSolverSC::MoveLengthTowardsTarget() { if (!useTotalLengthScale && !useEdgeLengthScale) { return; } if (TargetLengthReached()) { std::cout << "Target length reached; turning off length scaling" << std::endl; useEdgeLengthScale = false; useTotalLengthScale = false; return; } if (useEdgeLengthScale) { double currentLength = curveNetwork->TotalLength(); // If we're below the target length, increase edge lengths if (currentLength < targetLength) { int cStart = constraint.startIndexOfConstraint(ConstraintType::EdgeLengths); int nRows = constraint.rowsOfConstraint(ConstraintType::EdgeLengths); double diff = targetLength - currentLength; double toAdd = lengthScaleStep; if (diff < lengthScaleStep * nRows) { toAdd = diff / nRows; } for (int i = cStart; i < cStart + nRows; i++) { constraintTargets(i) += toAdd; } } else if (currentLength > targetLength) { int cStart = constraint.startIndexOfConstraint(ConstraintType::EdgeLengths); int nRows = constraint.rowsOfConstraint(ConstraintType::EdgeLengths); double diff = currentLength - targetLength; double toSubt = lengthScaleStep; if (diff < lengthScaleStep * nRows) { toSubt = diff / nRows; } for (int i = cStart; i < cStart + nRows; i++) { constraintTargets(i) -= toSubt; } } } else if (useTotalLengthScale) { double currentLength = curveNetwork->TotalLength(); if (currentLength < targetLength) { int cStart = constraint.startIndexOfConstraint(ConstraintType::TotalLength); constraintTargets(cStart) += lengthScaleStep; } else if (currentLength > targetLength) { int cStart = constraint.startIndexOfConstraint(ConstraintType::TotalLength); constraintTargets(cStart) -= lengthScaleStep; } } } bool TPEFlowSolverSC::StepSobolevLS(bool useBH, bool useBackproj) { long start = Utils::currentTimeMilliseconds(); size_t nVerts = curveNetwork->NumVertices(); Eigen::MatrixXd vertGradients; vertGradients.setZero(nVerts, 3); // If applicable, move constraint targets MoveLengthTowardsTarget(); // Assemble gradient, either exactly or with Barnes-Hut long bh_start = Utils::currentTimeMilliseconds(); BVHNode3D *tree_root = 0; if (useBH) tree_root = CreateBVHFromCurve(curveNetwork); AddAllGradients(tree_root, vertGradients); Eigen::MatrixXd l2Gradients = vertGradients; std::cout << "=== Iteration " << ++iterNum << " ===" << std::endl; double bh_end = Utils::currentTimeMilliseconds(); std::cout << " Assemble gradient " << (useBH ? "(Barnes-Hut)" : "(direct)") << ": " << (bh_end - bh_start) << " ms" << std::endl; std::cout << " L2 gradient norm = " << l2Gradients.norm() << std::endl; double length1 = curveNetwork->TotalLength(); Eigen::MatrixXd A; Eigen::PartialPivLU<Eigen::MatrixXd> lu; long project_start = Utils::currentTimeMilliseconds(); // Compute the Sobolev gradient double soboDot = ProjectGradient(vertGradients, A, lu); long project_end = Utils::currentTimeMilliseconds(); std::cout << " Sobolev gradient norm = " << soboDot << std::endl; if (isnan(soboDot)) { std::cout << "Sobolev projection produced NaN; aborting." << std::endl; return false; } double dot_acc = soboDot / (l2Gradients.norm() * vertGradients.norm()); std::cout << " Project gradient: " << (project_end - project_start) << " ms" << std::endl; // Take a line search step using this gradient double ls_start = Utils::currentTimeMilliseconds(); double step_size = LineSearchStep(vertGradients, dot_acc, tree_root); // double step_size = CircleSearchStep(vertGradients, secondDeriv, A, tree_root); double ls_end = Utils::currentTimeMilliseconds(); std::cout << " Line search: " << (ls_end - ls_start) << " ms" << std::endl; if (useEdgeLengthScale && step_size < ls_step_threshold) { vertGradients.setZero(); } // Correct for drift with backprojection double bp_start = Utils::currentTimeMilliseconds(); if (useBackproj) { step_size = LSBackproject(vertGradients, step_size, lu, dot_acc, tree_root); } double bp_end = Utils::currentTimeMilliseconds(); std::cout << " Backprojection: " << (bp_end - bp_start) << " ms" << std::endl; std::cout << " Final step size = " << step_size << std::endl; if (tree_root) { delete tree_root; } double length2 = curveNetwork->TotalLength(); std::cout << "Length " << length1 << " -> " << length2 << std::endl; long end = Utils::currentTimeMilliseconds(); std::cout << "Time = " << (end - start) << " ms" << std::endl; if (perfLogEnabled) { double bh_time = bh_end - bh_start; double mg_time = project_end - project_start; double ls_time = ls_end - ls_start; double bp_time = bp_end - bp_start; double all_time = end - start; perfFile << iterNum << ", " << bh_time << ", " << mg_time << ", " << ls_time << ", " << bp_time << ", " << all_time << std::endl; } lastStepSize = step_size; soboNormZero = (soboDot < 1e-4); return step_size > ls_step_threshold; } bool TPEFlowSolverSC::StepSobolevLSIterative(double epsilon, bool useBackproj) { std::cout << "=== Iteration " << ++iterNum << " ===" << std::endl; long all_start = Utils::currentTimeMilliseconds(); size_t nVerts = curveNetwork->NumVertices(); BVHNode3D* tree_root = 0; Eigen::MatrixXd vertGradients; vertGradients.setZero(nVerts, 3); // If applicable, move constraint targets MoveLengthTowardsTarget(); // Assemble the L2 gradient long bh_start = Utils::currentTimeMilliseconds(); tree_root = CreateBVHFromCurve(curveNetwork); AddAllGradients(tree_root, vertGradients); Eigen::MatrixXd l2gradients = vertGradients; long bh_end = Utils::currentTimeMilliseconds(); std::cout << " Barnes-Hut: " << (bh_end - bh_start) << " ms" << std::endl; // Set up multigrid stuff long mg_setup_start = Utils::currentTimeMilliseconds(); using MultigridDomain = ConstraintProjectorDomain<ConstraintClassType>; using MultigridSolver = MultigridHierarchy<MultigridDomain>; double sep = 1.0; MultigridDomain* domain = new MultigridDomain(curveNetwork, alpha, beta, sep, epsilon); MultigridSolver* multigrid = new MultigridSolver(domain); long mg_setup_end = Utils::currentTimeMilliseconds(); std::cout << " Multigrid setup: " << (mg_setup_end - mg_setup_start) << " ms" << std::endl; // Use multigrid to compute the Sobolev gradient long mg_start = Utils::currentTimeMilliseconds(); double soboDot = ProjectGradientMultigrid<MultigridDomain, MultigridSolver::EigenCG>(vertGradients, multigrid, vertGradients, mg_tolerance); double dot_acc = soboDot / (l2gradients.norm() * vertGradients.norm()); long mg_end = Utils::currentTimeMilliseconds(); std::cout << " Multigrid solve: " << (mg_end - mg_start) << " ms" << std::endl; std::cout << " Sobolev gradient norm = " << soboDot << std::endl; // Take a line search step using this gradient long ls_start = Utils::currentTimeMilliseconds(); // double step_size = CircleSearch::CircleSearchStep<MultigridSolver, MultigridSolver::EigenCG>(curveNetwork, // vertGradients, l2gradients, tree_root, multigrid, initialLengths, dot_acc, alpha, beta, 1e-6); double step_size = LineSearchStep(vertGradients, dot_acc, tree_root); long ls_end = Utils::currentTimeMilliseconds(); std::cout << " Line search: " << (ls_end - ls_start) << " ms" << std::endl; // Correct for drift with backprojection long bp_start = Utils::currentTimeMilliseconds(); if (useBackproj) { step_size = LSBackprojectMultigrid<MultigridDomain, MultigridSolver::EigenCG>(vertGradients, step_size, multigrid, tree_root, mg_tolerance); } long bp_end = Utils::currentTimeMilliseconds(); std::cout << " Backprojection: " << (bp_end - bp_start) << " ms" << std::endl; std::cout << " Final step size = " << step_size << std::endl; delete multigrid; if (tree_root) delete tree_root; long all_end = Utils::currentTimeMilliseconds(); std::cout << " Total time: " << (all_end - all_start) << " ms" << std::endl; if (perfLogEnabled) { double bh_time = bh_end - bh_start; double mg_time = mg_end - mg_setup_start; double ls_time = ls_end - ls_start; double bp_time = bp_end - bp_start; double all_time = all_end - all_start; perfFile << iterNum << ", " << bh_time << ", " << mg_time << ", " << ls_time << ", " << bp_time << ", " << all_time << std::endl; } soboNormZero = (soboDot < 1e-4); lastStepSize = step_size; return step_size > ls_step_threshold; } }
39.484094
148
0.600869
duxingyi-charles
4d07490d1ebef20ddff7a7ac3a8c0907087fe60f
12,036
hpp
C++
third_party/qpoases/include/qpOASES/SparseSolver.hpp
Shamraev/motion_imitation
9b9166436e4996e2a03b36d19f4f5422cde9c21e
[ "Apache-2.0" ]
1,452
2019-06-21T15:02:55.000Z
2022-03-31T14:44:18.000Z
third_party/qpoases/include/qpOASES/SparseSolver.hpp
Shamraev/motion_imitation
9b9166436e4996e2a03b36d19f4f5422cde9c21e
[ "Apache-2.0" ]
101
2020-09-02T00:36:25.000Z
2021-12-04T23:40:32.000Z
third_party/qpoases/include/qpOASES/SparseSolver.hpp
Shamraev/motion_imitation
9b9166436e4996e2a03b36d19f4f5422cde9c21e
[ "Apache-2.0" ]
671
2019-06-30T03:34:25.000Z
2022-03-31T08:57:22.000Z
/* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka, * Christian Kirches et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file include/qpOASES/SparseSolver.hpp * \author Andreas Waechter, Dennis Janka * \version 3.2 * \date 2012-2017 * * Interfaces to sparse linear solvers that are used in a Schur-complement * implementation in qpOASES. */ #ifndef QPOASES_SPARSESOLVER_HPP #define QPOASES_SPARSESOLVER_HPP #include <qpOASES/Utils.hpp> BEGIN_NAMESPACE_QPOASES /** * \brief Base class for linear solvers that are used in a Schur-complement * implementation in qpOASES. * * \author Andreas Waechter, Dennis Janka * \version 3.2 * \date 2012-2017 */ class SparseSolver { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ SparseSolver( ); /** Copy constructor (deep copy). */ SparseSolver( const SparseSolver& rhs /**< Rhs object. */ ); /** Destructor. */ virtual ~SparseSolver( ); /** Assignment operator (deep copy). */ virtual SparseSolver& operator=( const SparseSolver& rhs /**< Rhs object. */ ); /** Set new matrix data. The matrix is to be provided in the Harwell-Boeing format. Only the lower triangular part should be set. */ virtual returnValue setMatrixData( int_t dim, /**< Dimension of the linear system. */ int_t numNonzeros, /**< Number of nonzeros in the matrix. */ const int_t* const airn, /**< Row indices for each matrix entry. */ const int_t* const acjn, /**< Column indices for each matrix entry. */ const real_t* const avals /**< Values for each matrix entry. */ ) = 0; /** Compute factorization of current matrix. This method must be called before solve.*/ virtual returnValue factorize( ) = 0; /** Solve linear system with most recently set matrix data. */ virtual returnValue solve( int_t dim, /**< Dimension of the linear system. */ const real_t* const rhs, /**< Values for the right hand side. */ real_t* const sol /**< Solution of the linear system. */ ) = 0; /** Clears all data structures. */ virtual returnValue reset( ); /** Return the number of negative eigenvalues. */ virtual int_t getNegativeEigenvalues( ); /** Return the rank after a factorization */ virtual int_t getRank( ); /** Returns the zero pivots in case the matrix is rank deficient */ virtual returnValue getZeroPivots( int_t *&zeroPivots ); /* * PROTECTED MEMBER FUNCTIONS */ protected: /** Frees all allocated memory. * \return SUCCESSFUL_RETURN */ returnValue clear( ); /** Copies all members from given rhs object. * \return SUCCESSFUL_RETURN */ returnValue copy( const SparseSolver& rhs /**< Rhs object. */ ); /* * PROTECTED MEMBER VARIABLES */ protected: }; #ifdef SOLVER_MA27 /** * \brief Implementation of the linear solver interface using Harwell's MA27. * * \author Andreas Waechter, Dennis Janka * \version 3.2 * \date 2012-2017 */ class Ma27SparseSolver: public SparseSolver { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ Ma27SparseSolver( ); /** Copy constructor (deep copy). */ Ma27SparseSolver( const Ma27SparseSolver& rhs /**< Rhs object. */ ); /** Destructor. */ virtual ~Ma27SparseSolver( ); /** Assignment operator (deep copy). */ virtual Ma27SparseSolver& operator=( const SparseSolver& rhs /**< Rhs object. */ ); /** Set new matrix data. The matrix is to be provided in the Harwell-Boeing format. Only the lower triangular part should be set. */ virtual returnValue setMatrixData( int_t dim, /**< Dimension of the linear system. */ int_t numNonzeros, /**< Number of nonzeros in the matrix. */ const int_t* const airn, /**< Row indices for each matrix entry. */ const int_t* const acjn, /**< Column indices for each matrix entry. */ const real_t* const avals /**< Values for each matrix entry. */ ); /** Compute factorization of current matrix. This method must be called before solve.*/ virtual returnValue factorize( ); /** Solve linear system with most recently set matrix data. */ virtual returnValue solve( int_t dim, /**< Dimension of the linear system. */ const real_t* const rhs, /**< Values for the right hand side. */ real_t* const sol /**< Solution of the linear system. */ ); /** Clears all data structures. */ virtual returnValue reset( ); /** Return the number of negative eigenvalues. */ virtual int_t getNegativeEigenvalues( ); /** Return the rank after a factorization */ virtual int getRank( ); /* * PROTECTED MEMBER FUNCTIONS */ protected: /** Frees all allocated memory. * \return SUCCESSFUL_RETURN */ returnValue clear( ); /** Copies all members from given rhs object. * \return SUCCESSFUL_RETURN */ returnValue copy( const Ma27SparseSolver& rhs /**< Rhs object. */ ); /* * PRIVATE MEMBER FUNCTIONS */ private: /* * PRIVATE MEMBER VARIABLES */ private: fint_t dim; /**< Dimension of the current linear system. */ fint_t numNonzeros; /**< Number of nonzeros in the current linear system. */ fint_t la_ma27; /**< size of a_ma27 (LA in MA27) */ double* a_ma27; /**< matrix/factor for MA27 (A in MA27). If have_factorization is false, it contains the matrix entries (and has length numNonzeros), otherwise the factor (and has length la_ma27). */ fint_t* irn_ma27; /**< Row entries of matrix (IRN in MA27) */ fint_t* jcn_ma27; /**< Column entries of matrix (JCN in MA27) */ fint_t icntl_ma27[30]; /**< integer control values (ICNRL in MA27) */ double cntl_ma27[5]; /**< real control values (CNRL in MA27) */ fint_t liw_ma27; /**< length of integer work space (LIW in MA27) */ fint_t* iw_ma27; /**< integer work space (IW in MA27) */ fint_t* ikeep_ma27; /**< IKEEP in MA27 */ fint_t nsteps_ma27; /**< NSTEPS in MA27 */ fint_t maxfrt_ma27; /**< MAXFRT in MA27 */ bool have_factorization; /**< flag indicating whether factorization for current matrix has already been computed */ fint_t neig; /**< number of negative eigenvalues */ fint_t rank; /**< rank of matrix */ }; #endif /* SOLVER_MA27 */ #ifdef SOLVER_MA57 /** * \brief Implementation of the linear solver interface using Harwell's MA57. * * \author Andreas Waechter, Dennis Janka * \version 3.2 * \date 2013-2017 */ class Ma57SparseSolver: public SparseSolver { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ Ma57SparseSolver( ); /** Copy constructor (deep copy). */ Ma57SparseSolver( const Ma57SparseSolver& rhs /**< Rhs object. */ ); /** Destructor. */ virtual ~Ma57SparseSolver( ); /** Assignment operator (deep copy). */ virtual Ma57SparseSolver& operator=( const SparseSolver& rhs /**< Rhs object. */ ); /** Set new matrix data. The matrix is to be provided in the Harwell-Boeing format. Only the lower triangular part should be set. */ virtual returnValue setMatrixData( int_t dim, /**< Dimension of the linear system. */ int_t numNonzeros, /**< Number of nonzeros in the matrix. */ const int_t* const airn, /**< Row indices for each matrix entry. */ const int_t* const acjn, /**< Column indices for each matrix entry. */ const real_t* const avals /**< Values for each matrix entry. */ ); /** Compute factorization of current matrix. This method must be called before solve.*/ virtual returnValue factorize( ); /** Solve linear system with most recently set matrix data. */ virtual returnValue solve( int_t dim, /**< Dimension of the linear system. */ const real_t* const rhs, /**< Values for the right hand side. */ real_t* const sol /**< Solution of the linear system. */ ); /** Clears all data structures. */ virtual returnValue reset( ); /** Return the number of negative eigenvalues. */ virtual int_t getNegativeEigenvalues( ); /** Return the rank after a factorization */ virtual int_t getRank( ); /** Returns the zero pivots in case the matrix is rank deficient */ virtual returnValue getZeroPivots( int_t* &zeroPivots /**< ... */ ); /* * PROTECTED MEMBER FUNCTIONS */ protected: /** Frees all allocated memory. * \return SUCCESSFUL_RETURN */ returnValue clear( ); /** Copies all members from given rhs object. * \return SUCCESSFUL_RETURN */ returnValue copy( const Ma57SparseSolver& rhs /**< Rhs object. */ ); /* * PRIVATE MEMBER FUNCTIONS */ private: /* * PRIVATE MEMBER VARIABLES */ private: fint_t dim; /**< Dimension of the current linear system. */ fint_t numNonzeros; /**< Number of nonzeros in the current linear system. */ double* a_ma57; /**< matrix for MA57 (A in MA57) */ fint_t* irn_ma57; /**< Row entries of matrix (IRN in MA57) */ fint_t* jcn_ma57; /**< Column entries of matrix (JCN in MA57) */ fint_t icntl_ma57[30]; /**< integer control values (ICNRL in MA57) */ double cntl_ma57[5]; /**< real control values (CNRL in MA57) */ double* fact_ma57; /**< array for storing the factors */ fint_t lfact_ma57; /**< length of fact_ma57 */ fint_t* ifact_ma57; /**< indexing information about the factors */ fint_t lifact_ma57; /**< length of ifact_ma57 */ bool have_factorization;/**< flag indicating whether factorization for current matrix has already been computed */ fint_t neig; /**< number of negative eigenvalues */ fint_t rank; /**< rank of matrix */ fint_t* pivots; /**< sequence of pivots used in factorization */ }; #endif /* SOLVER_MA57 */ #ifdef SOLVER_NONE /** * \brief Implementation of a dummy sparse solver. An error is thrown if a factorization is attempted. * * \author Dennis Janka * \version 3.2 * \date 2015-2017 */ class DummySparseSolver: public SparseSolver { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Set new matrix data. The matrix is to be provided in the Harwell-Boeing format. Only the lower triangular part should be set. */ virtual returnValue setMatrixData( int_t dim, /**< Dimension of the linear system. */ int_t numNonzeros, /**< Number of nonzeros in the matrix. */ const int_t* const airn, /**< Row indices for each matrix entry. */ const int_t* const acjn, /**< Column indices for each matrix entry. */ const real_t* const avals /**< Values for each matrix entry. */ ); /** Compute factorization of current matrix. This method must be called before solve.*/ virtual returnValue factorize( ); /** Solve linear system with most recently set matrix data. */ virtual returnValue solve( int_t dim, /**< Dimension of the linear system. */ const real_t* const rhs, /**< Values for the right hand side. */ real_t* const sol /**< Solution of the linear system. */ ); }; #endif /* SOLVER_NONE */ END_NAMESPACE_QPOASES #endif /* QPOASES_SPARSESOLVER_HPP */ /* * end of file */
30.31738
202
0.659355
Shamraev
4d08b5284d3efcb5b6ff2e3be098baf74df4f8f6
788
cpp
C++
tests/test/lib/test_state.cpp
mkvoya/faasm
6d85a5507a2ce10fcd0c486251e1d26c0e013e28
[ "Apache-2.0" ]
1
2020-04-21T07:33:42.000Z
2020-04-21T07:33:42.000Z
test/lib/test_state.cpp
TNTtian/Faasm
377f4235063a7834724cc750697d3e0280d4a581
[ "Apache-2.0" ]
4
2020-02-03T18:54:32.000Z
2020-05-13T18:28:28.000Z
test/lib/test_state.cpp
TNTtian/Faasm
377f4235063a7834724cc750697d3e0280d4a581
[ "Apache-2.0" ]
null
null
null
#include <catch/catch.hpp> #include <faasm/state.h> using namespace faasm; namespace tests { TEST_CASE("Test masking doubles", "[state]") { // Mask of zeros to start with std::vector<uint8_t> byteMaskArray = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Mask a double in the middle auto intArray = reinterpret_cast<unsigned int *>(byteMaskArray.data()); maskDouble(intArray, 1); std::vector<uint8_t> expected = { 0, 0, 0, 0, 0, 0, 0, 0, BIT_MASK_8, BIT_MASK_8, BIT_MASK_8, BIT_MASK_8, BIT_MASK_8, BIT_MASK_8, BIT_MASK_8, BIT_MASK_8, 0, 0, 0, 0 }; REQUIRE(byteMaskArray == expected); } }
29.185185
111
0.52665
mkvoya
4d090488a69ffeede804578b578e88fac5c4d3d2
1,740
cpp
C++
STL/algorithm/transform.cpp
liangjisheng/C-Cpp
8b33ba1f43580a7bdded8bb4ce3d92983ccedb81
[ "MIT" ]
5
2019-09-17T09:12:15.000Z
2021-05-29T10:54:39.000Z
STL/algorithm/transform.cpp
liangjisheng/C-Cpp
8b33ba1f43580a7bdded8bb4ce3d92983ccedb81
[ "MIT" ]
null
null
null
STL/algorithm/transform.cpp
liangjisheng/C-Cpp
8b33ba1f43580a7bdded8bb4ce3d92983ccedb81
[ "MIT" ]
2
2021-07-26T06:36:12.000Z
2022-01-23T15:20:30.000Z
#include"iostream" #include"vector" #include"algorithm" using namespace std; // template<class InputIterator,class OutputIterator,class UnaryOperator> // OutputIterator transform(InputIterator first1,InputIterator last, // OutputIterator result,UnaryOperator op); // template<class InputIterator1,class InputIterator2, // class OutputIterator2,class BinaryOperator> // OutputIterator transform(InputIterator1 first1,InputIterator1 last1, // InputIterator2 first2,OutputIterator2 last2, // BinaryOperator binary_op); int increase(int nScore) { if(nScore<60) nScore=60; return nScore; } void print(int nScore) { cout<<nScore<<' '; } int add(int a,int b) { return a+b; } int main() { vector<int> vec; vec.push_back(23); vec.push_back(33); vec.push_back(43); vec.push_back(53); vec.push_back(63); vec.push_back(73); vec.push_back(83); cout<<"vec:"<<endl; for_each(vec.begin(),vec.end(),print); cout<<endl; // transform()可以在移动容器中数据的时候对数据进行操作 // 会将increase()函数的返回值作为处理结果保存到目标容器中 // 完成数据的移动与处理 transform(vec.begin(),vec.end(),vec.begin(),increase); cout<<"After operate:"<<endl; for_each(vec.begin(),vec.end(),print); cout<<endl; vector<int> vec1; vec1.push_back(12); vec1.push_back(22); vec1.push_back(32); vec1.push_back(42); vec1.push_back(52); vec1.push_back(62); vec1.push_back(72); cout<<"vec1:"<<endl; for_each(vec1.begin(),vec1.end(),print); cout<<endl; vector<int> sum; sum.resize(vec.size()); // 将vec和vec1中的对应元素相加,并将结果保存到sum中 transform(vec.begin(),vec.end(), // 第一个数据的范围 vec1.begin(), // 第二个数据的起始位置 sum.begin(), // 保存结果容器的起始位置 add); // 操作函数 cout<<"vec+vec1:"<<endl; for_each(sum.begin(),sum.end(),print); cout<<endl; system("pause"); return 0; }
23.513514
73
0.701724
liangjisheng
4d09296eadfb85f15d7076cb51c4a1090d1933c6
316
cpp
C++
C++/house-robber.cpp
black-shadows/LeetCode-Solutions
b1692583f7b710943ffb19b392b8bf64845b5d7a
[ "Fair", "Unlicense" ]
1
2020-04-16T08:38:14.000Z
2020-04-16T08:38:14.000Z
house-robber.cpp
Jeevan-kumar-Raj/LeetCode-Solutions-Topicwise
f1111b4edd401a3fc47111993bd7250cf4dc76da
[ "MIT" ]
null
null
null
house-robber.cpp
Jeevan-kumar-Raj/LeetCode-Solutions-Topicwise
f1111b4edd401a3fc47111993bd7250cf4dc76da
[ "MIT" ]
1
2021-12-25T14:48:56.000Z
2021-12-25T14:48:56.000Z
// Time: O(n) // Space: O(1) class Solution { public: int rob(vector<int>& nums) { int last = 0, result = 0; for (const auto& i : nums) { auto tmp = result; result = max(last + i, result); last = tmp; } return result; } };
19.75
44
0.427215
black-shadows
4d0c73022fef67c16d3d3c9df859a479c89e6cfd
16,321
cpp
C++
src/peco/net/utils.cpp
littlepush/libpeco
c0ca92ddb7a70cd8183ade1ee0ec57fd534e280e
[ "MIT" ]
1
2020-04-14T06:31:56.000Z
2020-04-14T06:31:56.000Z
src/peco/net/utils.cpp
littlepush/libpeco
c0ca92ddb7a70cd8183ade1ee0ec57fd534e280e
[ "MIT" ]
null
null
null
src/peco/net/utils.cpp
littlepush/libpeco
c0ca92ddb7a70cd8183ade1ee0ec57fd534e280e
[ "MIT" ]
null
null
null
/* utils.cpp libpeco 2022-02-17 Push Chen */ /* MIT License Copyright (c) 2019 Push Chen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "peco/net/utils.h" #include "peco/utils.h" #if PECO_TARGET_LINUX #include <endian.h> #elif PECO_TARGET_APPLE #include <libkern/OSByteOrder.h> #include <machine/endian.h> #else // Windows? #endif #if !PECO_TARGET_WIN #include <fcntl.h> #include <sys/un.h> #endif namespace peco { namespace net_utils { uint16_t h2n(uint16_t v) { return htons(v); } uint32_t h2n(uint32_t v) { return htonl(v); } uint64_t h2n(uint64_t v) { #if PECO_TARGET_OPENOS return htobe64(v); #else return htonll(v); #endif } float h2n(float v) { uint32_t *_iv = (uint32_t *)(&v); uint32_t _nv = h2n(*_iv); uint32_t *_pnv = &_nv; return *(float *)_pnv; } double h2n(double v) { uint64_t *_iv = (uint64_t *)(&v); uint64_t _nv = h2n(*_iv); uint64_t *_pnv = &_nv; return *(double *)_pnv; } uint16_t n2h(uint16_t v) { return ntohs(v); } uint32_t n2h(uint32_t v) { return ntohl(v); } uint64_t n2h(uint64_t v) { #if PECO_TARGET_OPENOS return be64toh(v); #else return ntohll(v); #endif } float n2h(float v) { uint32_t *_iv = (uint32_t *)(&v); uint32_t _nv = n2h(*_iv); uint32_t *_pnv = &_nv; return *(float *)_pnv; } double n2h(double v) { uint64_t *_iv = (uint64_t *)(&v); uint64_t _nv = n2h(*_iv); uint64_t *_pnv = &_nv; return *(double *)_pnv; } // Convert host endian to little endian #if PECO_TARGET_OPENOS uint16_t h2le(uint16_t v) { return htole16(v); } uint32_t h2le(uint32_t v) { return htole32(v); } uint64_t h2le(uint64_t v) { return htole64(v); } #elif PECO_TARGET_APPLE uint16_t h2le(uint16_t v) { return OSSwapHostToLittleInt16(v); } uint32_t h2le(uint32_t v) { return OSSwapHostToLittleInt32(v); } uint64_t h2le(uint64_t v) { return OSSwapHostToLittleInt64(v); } #else // Windows uint16_t h2le(uint16_t v) { return v; } uint32_t h2le(uint32_t v) { return v; } uint64_t h2le(uint64_t v) { return v; } #endif float h2le(float v) { uint32_t *_iv = (uint32_t *)(&v); uint32_t _lev = h2le(*_iv); uint32_t *_plev = &_lev; return *(float *)_plev; } double h2le(double v) { uint64_t *_iv = (uint64_t *)(&v); uint64_t _lev = h2le(*_iv); uint64_t *_plev = &_lev; return *(double *)_plev; } // Little Endian to Host #if PECO_TARGET_OPENOS uint16_t le2h(uint16_t v) { return le16toh(v); } uint32_t le2h(uint32_t v) { return le32toh(v); } uint64_t le2h(uint64_t v) { return le64toh(v); } #elif PECO_TARGET_APPLE uint16_t le2h(uint16_t v) { return OSSwapLittleToHostInt16(v); } uint32_t le2h(uint32_t v) { return OSSwapLittleToHostInt32(v); } uint64_t le2h(uint64_t v) { return OSSwapLittleToHostInt64(v); } #else // Windows uint16_t le2h(uint16_t v) { return v; } uint32_t le2h(uint32_t v) { return v; } uint64_t le2h(uint64_t v) { return v; } #endif float le2h(float v) { uint32_t *_iv = (uint32_t *)(&v); uint32_t _lev = le2h(*_iv); uint32_t *_plev = &_lev; return *(float *)_plev; } double le2h(double v) { uint64_t *_iv = (uint64_t *)(&v); uint64_t _lev = le2h(*_iv); uint64_t *_plev = &_lev; return *(double *)_plev; } // Convert host endian to big endian #if PECO_TARGET_OPENOS uint16_t h2be(uint16_t v) { return htobe16(v); } uint32_t h2be(uint32_t v) { return htobe32(v); } uint64_t h2be(uint64_t v) { return htobe64(v); } #elif PECO_TARGET_APPLE uint16_t h2be(uint16_t v) { return OSSwapHostToBigInt16(v); } uint32_t h2be(uint32_t v) { return OSSwapHostToBigInt32(v); } uint64_t h2be(uint64_t v) { return OSSwapHostToBigInt64(v); } #else #if defined(_MSC_VER) uint16_t h2be(uint16_t v) { return _byteswap_ushort(v); } uint32_t h2be(uint32_t v) { return _byteswap_ulong(v); } uint64_t h2be(uint64_t v) { return _byteswap_uint64(v); } #elif PECO_USE_GNU uint16_t h2be(uint16_t v) { return __builtin_bswap16(v); } uint32_t h2be(uint32_t v) { return __builtin_bswap32(v); } uint64_t h2be(uint64_t v) { return __builtin_bswap64(v); } #endif #endif float h2be(float v) { uint32_t *_iv = (uint32_t *)(&v); uint32_t _lev = h2be(*_iv); uint32_t *_plev = &_lev; return *(float *)_plev; } double h2be(double v) { uint64_t *_iv = (uint64_t *)(&v); uint64_t _lev = h2be(*_iv); uint64_t *_plev = &_lev; return *(double *)_plev; } // Big Endian to Host #if PECO_TARGET_OPENOS uint16_t be2h(uint16_t v) { return be16toh(v); } uint32_t be2h(uint32_t v) { return be32toh(v); } uint64_t be2h(uint64_t v) { return be64toh(v); } #elif PECO_TARGET_APPLE uint16_t be2h(uint16_t v) { return OSSwapBigToHostInt16(v); } uint32_t be2h(uint32_t v) { return OSSwapBigToHostInt32(v); } uint64_t be2h(uint64_t v) { return OSSwapBigToHostInt64(v); } #else #if defined(_MSC_VER) uint16_t be2h(uint16_t v) { return _byteswap_ushort(v); } uint32_t be2h(uint32_t v) { return _byteswap_ulong(v); } uint64_t be2h(uint64_t v) { return _byteswap_uint64(v); } #elif PECO_USE_GNU uint16_t be2h(uint16_t v) { return __builtin_bswap16(v); } uint32_t be2h(uint32_t v) { return __builtin_bswap32(v); } uint64_t be2h(uint64_t v) { return __builtin_bswap64(v); } #endif #endif float be2h(float v) { uint32_t *_iv = (uint32_t *)(&v); uint32_t _lev = be2h(*_iv); uint32_t *_plev = &_lev; return *(float *)_plev; } double be2h(double v) { uint64_t *_iv = (uint64_t *)(&v); uint64_t _lev = be2h(*_iv); uint64_t *_plev = &_lev; return *(double *)_plev; } // Get localhost's computer name on LAN const std::string &hostname() { static std::string _hn; if (_hn.size() == 0) { char __hostname[256] = {0}; if (gethostname(__hostname, 256) == -1) { _hn = __hostname; } } return _hn; } // Get peer info from a socket peer_t socket_peerinfo(const SOCKET_T hSo) { if (SOCKET_NOT_VALIDATE(hSo)) return peer_t::nan; struct sockaddr_in _addr; socklen_t _addrLen = sizeof(_addr); memset(&_addr, 0, sizeof(_addr)); if (0 == getpeername(hSo, (struct sockaddr *)&_addr, &_addrLen)) { return peer_t(_addr); } return peer_t::nan; } // Get local socket's port uint16_t localport(const SOCKET_T hSo) { if (SOCKET_NOT_VALIDATE(hSo)) return 0; struct sockaddr_in _addr; socklen_t _addrLen = sizeof(_addr); memset(&_addr, 0, sizeof(_addr)); if (0 == getsockname(hSo, (struct sockaddr *)&_addr, &_addrLen)) { return ntohs(_addr.sin_port); } return 0; } // Get the socket type SocketType socktype(SOCKET_T hSo) { // Get the type struct sockaddr _addr; socklen_t _len = sizeof(_addr); getsockname(hSo, &_addr, &_len); // Check un first uint16_t _sfamily = ((struct sockaddr_un *)(&_addr))->sun_family; if (_sfamily == AF_UNIX || _sfamily == AF_LOCAL) { return kSocketTypeUnixDomain; } else { int _type; _len = sizeof(_type); getsockopt(hSo, SOL_SOCKET, SO_TYPE, (char *)&_type, (socklen_t *)&_len); if (_type == SOCK_STREAM) { return kSocketTypeTCP; } else { return kSocketTypeUDP; } } } // Set the linger time for a socket // I strong suggest not to change this value unless you // know what you are doing bool lingertime(SOCKET_T hSo, bool onoff, unsigned timeout) { if (SOCKET_NOT_VALIDATE(hSo)) return false; struct linger _sol = {(onoff ? 1 : 0), (int)timeout}; return (setsockopt(hSo, SOL_SOCKET, SO_LINGER, &_sol, sizeof(_sol)) == 0); } // Set Current socket reusable or not bool reusable(SOCKET_T hSo, bool reusable) { if (SOCKET_NOT_VALIDATE(hSo)) return false; int _reused = reusable ? 1 : 0; bool _r = setsockopt(hSo, SOL_SOCKET, SO_REUSEADDR, (const char *)&_reused, sizeof(int)) != -1; if (!_r) { log::warning << "Warning: cannot set the socket as reusable." << std::endl; } return _r; } // Make current socket keep alive bool keepalive(SOCKET_T hSo, bool keepalive) { if (SOCKET_NOT_VALIDATE(hSo)) return false; int _keepalive = keepalive ? 1 : 0; return setsockopt(hSo, SOL_SOCKET, SO_KEEPALIVE, (const char *)&_keepalive, sizeof(int)); } bool __setINetNonblocking(SOCKET_T hSo, bool nonblocking) { if (SOCKET_NOT_VALIDATE(hSo)) return false; unsigned long _u = (nonblocking ? 1 : 0); bool _r = SO_NETWORK_IOCTL_CALL(hSo, FIONBIO, &_u) >= 0; if (!_r) { log::warning << "Warning: cannot change the nonblocking flag of socket." << std::endl; } return _r; } bool __setUDSNonblocking(SOCKET_T hSo, bool nonblocking) { // Set NonBlocking int _f = fcntl(hSo, F_GETFL, NULL); if (_f < 0) { log::warning << "Warning: cannot get UDS socket file info." << std::endl; return false; } if (nonblocking) { _f |= O_NONBLOCK; } else { _f &= (~O_NONBLOCK); } if (fcntl(hSo, F_SETFL, _f) < 0) { log::warning << "Warning: failed to change the nonblocking flag of UDS socket." << std::endl; return false; } return true; } // Make a socket to be nonblocking bool nonblocking(SOCKET_T hSo, bool nonblocking) { if (SOCKET_NOT_VALIDATE(hSo)) return false; uint32_t _st = socktype(hSo); if (_st == kSocketTypeUnixDomain) return __setUDSNonblocking(hSo, nonblocking); else return __setINetNonblocking(hSo, nonblocking); } bool nodelay(SOCKET_T hSo, bool nodelay) { if (SOCKET_NOT_VALIDATE(hSo)) return false; if (socktype(hSo) != kSocketTypeTCP) return true; // Try to set as tcp-nodelay int _flag = nodelay ? 1 : 0; bool _r = (setsockopt(hSo, IPPROTO_TCP, TCP_NODELAY, (const char *)&_flag, sizeof(int)) != -1); if (!_r) { log::warning << "Warning: cannot set the socket to be tcp-nodelay" << std::endl; } return _r; } // Set the socket's buffer size bool buffersize(SOCKET_T hSo, uint32_t rmem, uint32_t wmem) { if (SOCKET_NOT_VALIDATE(hSo)) return false; if (rmem != 0) { setsockopt(hSo, SOL_SOCKET, SO_RCVBUF, (char *)&rmem, sizeof(rmem)); } if (wmem != 0) { setsockopt(hSo, SOL_SOCKET, SO_SNDBUF, (char *)&wmem, sizeof(wmem)); } return true; } // Check if a socket has data to read bool has_data_pending(SOCKET_T hSo) { if (SOCKET_NOT_VALIDATE(hSo)) return false; fd_set _fs; FD_ZERO(&_fs); FD_SET(hSo, &_fs); int _ret = 0; struct timeval _tv = {0, 0}; do { FD_ZERO(&_fs); FD_SET(hSo, &_fs); _ret = ::select(hSo + 1, &_fs, NULL, NULL, &_tv); } while (_ret < 0 && errno == EINTR); // Try to peek if (_ret <= 0) return false; _ret = recv(hSo, NULL, 0, MSG_PEEK); // If _ret < 0, means recv an error signal return (_ret > 0); } // Check if a socket has buffer to write bool has_buffer_outgoing(SOCKET_T hSo) { if (SOCKET_NOT_VALIDATE(hSo)) return false; fd_set _fs; int _ret = 0; struct timeval _tv = {0, 0}; do { FD_ZERO(&_fs); FD_SET(hSo, &_fs); _ret = ::select(hSo + 1, NULL, &_fs, NULL, &_tv); } while (_ret < 0 && errno == EINTR); return (_ret > 0); } // Create Socket Handler SOCKET_T create_socket(SocketType sock_type) { SOCKET_T _so = INVALIDATE_SOCKET; if (sock_type == kSocketTypeTCP) { _so = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); } else if (sock_type == kSocketTypeUDP) { _so = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); } else if (sock_type == kSocketTypeUnixDomain) { _so = ::socket(AF_UNIX, SOCK_STREAM, 0); } else { log::error << "Error: Cannot create new socket with unknow type <" << sock_type << ">" << std::endl; return _so; } if (SOCKET_NOT_VALIDATE(_so)) { log::error << "Error: Failed to create socket with type <" << sock_type << ">" << std::endl; return _so; } // Set the socket to be nonblocking; nonblocking(_so, true); nodelay(_so, true); reusable(_so, true); keepalive(_so, true); return _so; } // Read Data From a socket size_t read(SOCKET_T hSo, char *buffer, size_t length, std::function<int(SOCKET_T, char *, size_t)> f) { if (SOCKET_NOT_VALIDATE(hSo)) return 0; size_t BUF_SIZE = length; size_t _received = 0; size_t _leftspace = BUF_SIZE; do { int _retCode = f(hSo, buffer + _received, _leftspace); if (_retCode < 0) { if (errno == EINTR) continue; // Signal 7, retry if (errno == EAGAIN || errno == EWOULDBLOCK) { // No more incoming data in this socket's cache return _received; } log::error << "Error: failed to receive data on socket(" << hSo << "), " << ::strerror(errno) << std::endl; return 0; } else if (_retCode == 0) { return 0; } else { _received += _retCode; _leftspace -= _retCode; } } while (_leftspace > 0); return _received; } bool read(std::string& buffer, SOCKET_T hSo, std::function<int(SOCKET_T, char *, size_t)> f, uint32_t max_buffer_size) { if (SOCKET_NOT_VALIDATE(hSo)) return false; bool _hasLimit = (max_buffer_size != 0); size_t BUF_SIZE = (_hasLimit ? max_buffer_size : 1024); // 1KB std::string _buffer(BUF_SIZE, '\0'); //_buffer.resize(BUF_SIZE); size_t _received = 0; size_t _leftspace = BUF_SIZE; do { int _retCode = f(hSo, &_buffer[0] + _received, _leftspace); if (_retCode < 0) { if (errno == EINTR) continue; // signal 7, retry if (errno == EAGAIN || errno == EWOULDBLOCK) { // No more data on a non-blocking socket _buffer.resize(_received); break; } // Other error _buffer.resize(0); log::error << "Error: Failed to receive data on socket(" << hSo << ", " << ::strerror(errno) << std::endl; return false; } else if (_retCode == 0) { // Peer Close _buffer.resize(0); return false; } else { _received += _retCode; _leftspace -= _retCode; if (_leftspace > 0) { // Unfull _buffer.resize(_received); break; } else { // If has limit, and left space is zero, // which means the data size has reach // the limit and we should not read any more // data from the socket this time. if (_hasLimit) break; // Otherwise, try to double the buffer // The buffer is full, try to double the buffer and try again if (BUF_SIZE * 2 <= _buffer.max_size()) { BUF_SIZE *= 2; } else if (BUF_SIZE < _buffer.max_size()) { BUF_SIZE = _buffer.max_size(); } else { break; // direct return, wait for next read. } // Resize the buffer and try to read again _leftspace = BUF_SIZE - _received; _buffer.resize(BUF_SIZE); } } } while (true); buffer = std::move(_buffer); return true; } // Write Data to a socket int write(SOCKET_T hSo, const char *data, size_t data_lenth, std::function<int(SOCKET_T, const char *, size_t)> f) { size_t _sent = 0; while (_sent < data_lenth) { int _ret = f(hSo, data + _sent, data_lenth - _sent); if (_ret < 0) { if (ENOBUFS == errno || EAGAIN == errno || EWOULDBLOCK == errno) { // No buf break; } else { log::warning << "Failed to send data on socket(" << hSo << "), " << ::strerror(errno) << std::endl; return _ret; } } else if (_ret == 0) { break; } else { _sent += _ret; } } return (int)_sent; } } // namespace net_utils } // namespace peco // Push Chen
28.533217
79
0.650818
littlepush
4d0d82bae2f9dd6d6d98ffa8f784b71acb1bd515
2,100
hpp
C++
console/pong/Ball.hpp
piotrek-szczygiel/rpi-tetris
1120b0ac024ef36f48a4fe67087e3e2c78cf83f8
[ "MIT" ]
4
2019-10-17T20:26:09.000Z
2019-11-14T12:01:57.000Z
console/pong/Ball.hpp
piotrek-szczygiel/rpi-tetris
1120b0ac024ef36f48a4fe67087e3e2c78cf83f8
[ "MIT" ]
null
null
null
console/pong/Ball.hpp
piotrek-szczygiel/rpi-tetris
1120b0ac024ef36f48a4fe67087e3e2c78cf83f8
[ "MIT" ]
null
null
null
#pragma once #include "ParticleSystem.hpp" #include "Player.hpp" #include <random> #include <raylib.h> namespace Pong { constexpr float FRICTION { 0.8F }; constexpr float SPEED_FACTOR { 800.0F }; constexpr float SPEED_FACTOR_POWER_UP { 1050.0F }; constexpr float PARTICLES_DELAY { 0.035F }; constexpr float BALL_POWER_UP_DURATION { 5.0F }; class Ball { public: Vector2 m_position; Vector2 m_speed; float m_radius; float m_power_up_timer; Ball() : m_radius { 10.0F } , m_speed_factor { SPEED_FACTOR } , m_speed {} , m_position {} , m_power_up_timer { 0.0F } , m_particles_delay { PARTICLES_DELAY } { m_normal_particle.position = { 0.0F, 0.0F }; m_normal_particle.speed = { -2.0F, 0.0F }; m_normal_particle.speed_variation = { 0.1F * SPEED_FACTOR, 0.05F * SPEED_FACTOR }; m_normal_particle.size_begin = 10.0F, m_normal_particle.size_end = 0.0F, m_normal_particle.size_variation = 4.0F; m_normal_particle.color_begin = { 255, 255, 255, 255 }; m_normal_particle.color_end = { 125, 125, 125, 0 }; m_normal_particle.life = 0.4F; m_power_up_particle.position = { 0.0F, 0.0F }; m_power_up_particle.speed = { -2.0F, 0.0F }; m_power_up_particle.speed_variation.x = 0.15F * SPEED_FACTOR_POWER_UP; m_power_up_particle.speed_variation.y = 0.1F * SPEED_FACTOR_POWER_UP; m_power_up_particle.size_begin = 15.0F, m_power_up_particle.size_end = 0.0F, m_power_up_particle.size_variation = 6.0F; m_power_up_particle.color_begin = { 254, 109, 41, 255 }; m_power_up_particle.color_end = { 254, 212, 123, 0 }; m_power_up_particle.life = 0.45F; } ~Ball() = default; void update(float dt, int max_height); void check_collision(Player* player); void init_round(); void draw(); private: float m_speed_factor; float m_particles_delay; ParticleProps m_normal_particle, m_power_up_particle; ParticleSystem m_particle_system; Vector2 compute_speed(Vector2 v); }; }
29.577465
90
0.667619
piotrek-szczygiel
4d0f14fa29ac19f33da798f7a7884ac3909d5d09
1,116
cpp
C++
6. Heaps/buildHeap_in_O(N).cpp
suraj0803/DSA
6ea21e452d7662e2351ee2a7b0415722e1bbf094
[ "MIT" ]
null
null
null
6. Heaps/buildHeap_in_O(N).cpp
suraj0803/DSA
6ea21e452d7662e2351ee2a7b0415722e1bbf094
[ "MIT" ]
null
null
null
6. Heaps/buildHeap_in_O(N).cpp
suraj0803/DSA
6ea21e452d7662e2351ee2a7b0415722e1bbf094
[ "MIT" ]
null
null
null
#include<iostream> #include<vector> using namespace std; void print(vector<int> v){ for(int x:v){ cout<<x<<" "; } cout<<endl; } bool minHeap = false; bool compare(int a, int b){ if(minHeap){ return a<b; } else{ return a>b; } } int heapify(vector<int> &v, int index) { int left = 2*index; int right = 2*index+1; int min_index = index; int last = v.size()-1; if(left <= last and compare(v[left],v[index])){ min_index = left; } if(right <= last and compare(v[right],v[index])){ min_index = right; } if(min_index!=index){ swap(v[index],v[min_index]); heapify(v,min_index); } } void buildHeap(vector<int> &v) { for(int i=(v.size()-1/2); i>=1; i--){// start from 1st non leaves and then heapify // root node is fixed heapify(v,i); } int main() { vector<int> v{-1,10,20,5,6,18,9,4};// 0th index is blocked so starting from index 1 print(v); buildHeap(v); print(v); return 0; }
18
88
0.512545
suraj0803
4d0f51aa1d5f7b021c68be77f15dbf700c45eca9
1,666
cpp
C++
PSME/agent/chassis/tests/session_test/session_test.cpp
opencomputeproject/HWMgmt-DeviceMgr-PSME
2a00188aab6f4bef3776987f0842ef8a8ea972ac
[ "Apache-2.0" ]
5
2021-10-07T15:36:37.000Z
2022-03-01T07:21:49.000Z
PSME/agent/chassis/tests/session_test/session_test.cpp
opencomputeproject/DM-Redfish-PSME
912f7b6abf5b5c2aae33c75497de4753281c6a51
[ "Apache-2.0" ]
null
null
null
PSME/agent/chassis/tests/session_test/session_test.cpp
opencomputeproject/DM-Redfish-PSME
912f7b6abf5b5c2aae33c75497de4753281c6a51
[ "Apache-2.0" ]
1
2021-03-24T19:37:58.000Z
2021-03-24T19:37:58.000Z
/*! * @brief Unit tests for generation of UUIDv5 * * @copyright * Copyright (c) 2015-2017 Intel Corporation * * @copyright * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * @copyright * http://www.apache.org/licenses/LICENSE-2.0 * * @copyright * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Edgecore DeviceManager * Copyright 2020-2021 Edgecore Networks, Inc. * * This product includes software developed at * Edgecore Networks Inc. (http://www.edge-core.com/). * * @file chassis_tree_stabilizer_test.cpp * */ #include "tree_stability/chassis_tree_stabilizer.hpp" #include "agent-framework/module/chassis_components.hpp" #include "agent-framework/module/common_components.hpp" #include "agent-framework/service_uuid.hpp" #include "gtest/gtest.h" #include <string> class TestClass1 : public ::testing::Test { public: virtual ~TestClass1(); virtual void SetUp(); virtual void TearDown(); }; TestClass1::~TestClass1() { printf("TestClass1-deconstructor\r\n"); } void TestClass1::SetUp() { printf("TestClass1-SetUp\r\n"); } void TestClass1::TearDown() { printf("TestClass1-TearDown\r\n"); } TEST_F(TestClass1, Test_Memo_1) { // TEST 1 Content here // printf("TestClass1-content\r\n"); }
23.138889
75
0.717887
opencomputeproject
4d111ffeb2e0a3a19dc24f3fbeb20669e3612e91
261
cpp
C++
VisualStudioProjects/Assembler/Assembler/FileReader.cpp
nikolabebic95/AssemblerEmulator
62ca04e4a176ec3765b95fb1610da23273a67693
[ "MIT" ]
1
2020-04-14T10:21:04.000Z
2020-04-14T10:21:04.000Z
VisualStudioProjects/Assembler/Assembler/FileReader.cpp
nikolabebic95/AssemblerEmulator
62ca04e4a176ec3765b95fb1610da23273a67693
[ "MIT" ]
null
null
null
VisualStudioProjects/Assembler/Assembler/FileReader.cpp
nikolabebic95/AssemblerEmulator
62ca04e4a176ec3765b95fb1610da23273a67693
[ "MIT" ]
1
2019-05-20T22:39:58.000Z
2019-05-20T22:39:58.000Z
#include "FileReader.h" #include "StringHelper.h" namespace bnssassembler { std::vector<std::string> FileReader::readAllLines(std::string filename) { auto raw_file = StringHelper::fileToString(filename); return StringHelper::split(raw_file, "\n"); } }
21.75
74
0.739464
nikolabebic95
4d1419b88b24596be819e55615be446ece598eca
11,137
cpp
C++
kernel/platform/pc64/src/init/LoadRootsrv.cpp
tristanseifert/kush-os
1ffd595aae8f3dc880e798eff72365b8b6c631f0
[ "0BSD" ]
4
2021-06-22T20:52:30.000Z
2022-02-04T00:19:44.000Z
kernel/platform/pc64/src/init/LoadRootsrv.cpp
tristanseifert/kush-os
1ffd595aae8f3dc880e798eff72365b8b6c631f0
[ "0BSD" ]
null
null
null
kernel/platform/pc64/src/init/LoadRootsrv.cpp
tristanseifert/kush-os
1ffd595aae8f3dc880e798eff72365b8b6c631f0
[ "0BSD" ]
null
null
null
#include "tar.h" #include "elf.h" #include <platform.h> #include <log.h> #include <runtime/SmartPointers.h> #include <mem/PhysicalAllocator.h> #include <sched/Scheduler.h> #include <sched/Task.h> #include <sched/Thread.h> #include <vm/Map.h> #include <vm/MapEntry.h> #include <bootboot.h> extern "C" BOOTBOOT bootboot; using namespace platform; // output logs about setting up the root server environment #define LOG_SETUP 0 /// VM address at which the init bundle is mapped in the task constexpr static const uintptr_t kInitBundleVmAddr = 0x690000000; /// Name of root server binary in initrd static const char *kRootSrvName = "rootsrv\0"; constexpr static const size_t kRootSrvNameLen = 8; static void RootSrvEntry(const uintptr_t); static void MapInitBundle(); static bool FindRootsrvFile(void* &outPtr, size_t &outLength); static uintptr_t ValidateSrvElf(void *elfBase, const size_t elfSize); static uintptr_t MapSrvSegments(const uintptr_t, void *elfBase, const size_t elfSize); static void AllocSrvStack(const uintptr_t, const uintptr_t); /** * Loads the root server binary from the ramdisk. */ rt::SharedPtr<sched::Task> platform::InitRootsrv() { // create the task auto task = sched::Task::alloc(); REQUIRE(task, "failed to allocate rootsrv task"); task->setName("rootsrv"); task->setCritical(true); #if LOG_SETUP log("created rootsrv task: %p $%016llx'h", static_cast<void *>(task), task->handle); #endif // create the main thread auto main = sched::Thread::userThread(task, &RootSrvEntry); main->kernelMode = false; main->setName("Main"); #if LOG_SETUP log("rootsrv thread: $%p $%p'h", static_cast<void *>(main), main->handle); #endif // done task->launch(); return task; } /** * Main entry point for the root server * * Map the init bundle -- an USTAR file -- into the task's address space, and attempt to find in * it the ELF for the root server. Once we've located it, create mappings that contain the ELF's * .text and .data segments, and allocate a .bss, and stack. * * When complete, we'll set up for an userspace return to the entry point of the ELF. * * The temporary mappings are at fixed locations; be sure that the actual ELF load addresses do * not overlap with these ranges. */ static void RootSrvEntry(const uintptr_t) { void *elfBase = nullptr; size_t elfLength = 0; // this is usally handled by the syscall auto thread = sched::Thread::current(); arch::TaskWillStart(thread->task); // map the init bundle; find the root server file MapInitBundle(); if(!FindRootsrvFile(elfBase, elfLength)) { panic("failed to find rootsrv"); } const auto diff = reinterpret_cast<uintptr_t>(elfBase) - kInitBundleVmAddr; const auto elfPhys = bootboot.initrd_ptr + diff; #if LOG_SETUP log("rootsrv ELF at %p (phys %p off %p %p) len %u", elfBase, elfPhys, diff, bootboot.initrd_ptr, elfLength); #endif // create segments for ELF const auto entry = ValidateSrvElf(elfBase, elfLength); MapSrvSegments(elfPhys, elfBase, elfLength); #if LOG_SETUP log("rootsrv entry: %p (file at %p len %u)", entry, elfBase, elfLength); #endif // set up a 128K stack constexpr static const uintptr_t kStackTop = 0x7fff80000000; constexpr static const uintptr_t kStackBottom = 0x7fff80008000; AllocSrvStack(kStackTop, (kStackBottom - kStackTop)); // XXX: offset from stack is to allow us to pop off the task info ptr (which is null) reinterpret_cast<uintptr_t *>(kStackBottom)[-1] = 0; // we've finished setup; jump to the server code #if LOG_SETUP log("going to: %p (stack %p)", entry, kStackBottom); #endif sched::Thread::current()->returnToUser(entry, kStackBottom - sizeof(uintptr_t)); } /** * Validates the loaded ELF. This ensures: * * - The file is actually an ELF. * - It is a statically linked binary. */ static uintptr_t ValidateSrvElf(void *elfBase, const size_t elfSize) { REQUIRE(elfSize > sizeof(Elf64_Ehdr), "ELF too small: %u", elfSize); int err; const auto hdr = reinterpret_cast<Elf64_Ehdr *>(elfBase); // check the magic value (and also the class, data and version) static const uint8_t kElfIdent[7] = { // ELF magic 0x7F, 0x45, 0x4C, 0x46, // 64-bit class 0x02, // data encoding: little endian 0x01, // SysV ABI 0x01 }; err = memcmp(kElfIdent, hdr->ident, 7); REQUIRE(!err, "invalid ELF ident"); // ensure header version and some other flags REQUIRE(hdr->version == 1, "invalid ELF header version %d", hdr->version); REQUIRE(hdr->type == 2, "rootsrv invalid binary type: %d", hdr->type); REQUIRE(hdr->machine == 62, "rootsrv invalid machine type: %d", hdr->machine); // EM_X86_64 // ensure the program and section headers are in bounds REQUIRE((hdr->secHdrOff + (hdr->numSecHdr * hdr->secHdrSize)) <= elfSize, "%s headers extend past end of file", "section"); REQUIRE((hdr->progHdrOff + (hdr->numProgHdr * hdr->progHdrSize)) <= elfSize, "%s headers extend past end of file", "program"); REQUIRE(hdr->progHdrSize >= sizeof(Elf64_Phdr), "invalid phdr size: %u", hdr->progHdrSize); // return entry point address return hdr->entryAddr; } /** * Reads the ELF program headers to determine which file backed sections need to be loaded. * * For this to work, all loadabale sections in the file _must_ be aligned to a page size bound; the * linker scripts the C library provides for static binaries should ensure this. * * This should take care of both the rwdata (.data) and zero-initialized (.bss) sections of the * file; they're combined into one program header entry. (These we cannot direct map; instead we * just copy the data from the initial mapping.) * * @return Entry point address */ static uintptr_t MapSrvSegments(const uintptr_t elfPhys, void *elfBase, const size_t elfSize) { int err; const auto hdr = reinterpret_cast<Elf64_Ehdr *>(elfBase); const auto pageSz = arch_page_size(); auto vm = sched::Task::current()->vm; // get location of program headers const auto pHdr = reinterpret_cast<Elf64_Phdr *>(reinterpret_cast<uintptr_t>(elfBase) + hdr->progHdrOff); // parse each of the program headers for(size_t i = 0; i < hdr->numProgHdr; i++) { // ignore all non-load program headers auto &p = pHdr[i]; if(p.type != PT_LOAD) continue; // convert the program header flags into a VM protection mode auto flags = vm::MapMode::ACCESS_USER; if(p.flags & PF_EXECUTABLE) { flags |= vm::MapMode::EXECUTE; } if(p.flags & PF_READ) { flags |= vm::MapMode::READ; } if(p.flags & PF_WRITE) { REQUIRE((p.flags & PF_EXECUTABLE) == 0, "cannot map page as WX"); flags |= vm::MapMode::WRITE; } // allocate the required pages const size_t numPages = ((p.memBytes + pageSz - 1) / pageSz); for(size_t i = 0; i < numPages; i++) { // allocate the physical page const auto page = mem::PhysicalAllocator::alloc(); REQUIRE(page, "failed to allocate physical page"); // insert mapping and zero it const auto vmAddr = p.virtAddr + (i * pageSz); err = vm->add(page, pageSz, vmAddr, flags); REQUIRE(!err, "failed to map root server program segment %u: %d", i, err); memset(reinterpret_cast<void *>(vmAddr), 0, pageSz); } // copy the data from the file void *fileOff = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(elfBase) + p.fileOff); memcpy(reinterpret_cast<void *>(p.virtAddr), fileOff, p.fileBytes); #if LOG_SETUP log("phdr %u: allocated %d pages, copied $%x from file off $%x (len $%x) vm %08x", i, numPages, p.fileBytes, p.fileOff, p.memBytes, p.virtAddr); #endif } // fish out the entry point address return hdr->entryAddr; } /** * Allocates a stack for the root server. * * @note Top address must be page aligned; length must be a page multiple. */ static void AllocSrvStack(const uintptr_t top, const uintptr_t length) { int err; const auto pageSz = arch_page_size(); const auto numPages = length / pageSz; // map each page to some anon memory auto vm = sched::Task::current()->vm; for(size_t i = 0; i < numPages; i++) { // allocate the physical page const auto page = mem::PhysicalAllocator::alloc(); REQUIRE(page, "failed to allocate physical page"); // insert mapping and zero it const auto vmAddr = top + (i * pageSz); err = vm->add(page, pageSz, vmAddr, vm::MapMode::ACCESS_USER | vm::MapMode::kKernelRW); memset(reinterpret_cast<void *>(vmAddr), 0, pageSz); } } /** * Adds a read-only mapping of the init bundle into the address space of the init task. */ static void MapInitBundle() { int err; // calculate the number of pages const auto pageSz = arch_page_size(); const size_t numPages = ((bootboot.initrd_size + pageSz - 1) / pageSz); // create an allocation auto task = sched::Task::current(); auto vm = task->vm; auto entry = vm::MapEntry::makePhys(bootboot.initrd_ptr, numPages * pageSz, vm::MappingFlags::Read); #if LOG_SETUP log("Mapped init bundle: phys %p len %u bytes to %p", bootboot.initrd_ptr, bootboot.initrd_size, kInitBundleVmAddr); #endif err = vm->add(entry, task, kInitBundleVmAddr); REQUIRE(!err, "failed to map root server init bundle: %d", err); } /** * Helper method to convert an octal string to a binary number. */ static size_t Oct2Bin(const char *str, size_t size) { size_t n = 0; auto c = str; while (size-- > 0) { n *= 8; n += *c - '0'; c++; } return n; } /** * Searches the init bundle (which is assumed to be a tar file) for the root server binary. * * @param outPtr Virtual memory address of root server binary, if found * @param outLength Length of the root server binary, if found * @return Whether the binary was located */ static bool FindRootsrvFile(void* &outPtr, size_t &outLength) { auto read = reinterpret_cast<uint8_t *>(kInitBundleVmAddr); const auto bundleEnd = kInitBundleVmAddr + bootboot.initrd_size; // iterate until we find the right header while((reinterpret_cast<uintptr_t>(read) + 512) < bundleEnd && !memcmp(read + 257, TMAGIC, 5)) { // get the size of this header and entry auto hdr = reinterpret_cast<struct posix_header *>(read); const auto size = Oct2Bin(hdr->size, 11); // compare filename if(!memcmp(hdr->name, kRootSrvName, kRootSrvNameLen)) { outLength = size; outPtr = read + 512; // XXX: is this block size _always_ 512? return true; } // advance to next entry read += (((size + 511) / 512) + 1) * 512; } return false; }
32.852507
130
0.652779
tristanseifert
4d171633fc426c6964f2007ca7f7cf7f215cd24f
396
cpp
C++
demo_with_an_image.cpp
yuki-inaho/stag
89c5c648acae90375fb8ffc4bf9453f1b15cc835
[ "MIT" ]
null
null
null
demo_with_an_image.cpp
yuki-inaho/stag
89c5c648acae90375fb8ffc4bf9453f1b15cc835
[ "MIT" ]
null
null
null
demo_with_an_image.cpp
yuki-inaho/stag
89c5c648acae90375fb8ffc4bf9453f1b15cc835
[ "MIT" ]
null
null
null
#include "Stag.h" #include <opencv2/opencv.hpp> int main() { cv::Mat image = cv::imread("00000.png", cv::IMREAD_GRAYSCALE); Stag stag(15, 7, true); stag.detectMarkers(image); stag.logResults(""); std::vector<Marker> markers = stag.getMarkerList(); cv::Mat result_image = stag.drawMarkersWithGrayImage(image); cv::imshow("result", result_image); cv::waitKey(0); return 0; }
20.842105
64
0.679293
yuki-inaho
4d18095825a90b5f380a9e80b607b58587b2bdd4
604
cpp
C++
CF/1614.cpp
jawahiir98/CP
a32566554949cd12a62151f90ac3b82b67275cac
[ "MIT" ]
null
null
null
CF/1614.cpp
jawahiir98/CP
a32566554949cd12a62151f90ac3b82b67275cac
[ "MIT" ]
null
null
null
CF/1614.cpp
jawahiir98/CP
a32566554949cd12a62151f90ac3b82b67275cac
[ "MIT" ]
null
null
null
/* /\ In The Name Of Allah /\ Author : Jawahiir Nabhan */ #include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const char nl = '\n'; int main() { int T; cin>> T; while(T--) { int N,l,r,k; cin>> N >> l >> r >> k; vector <int> a(N); for(int i = 0;i < N;i++) cin>> a[i]; sort(a.begin(), a.end()); int cnt = 0; for(int i = 0;i < N;i++){ if(a[i] >= l && a[i] <= r && a[i] <= k){ cnt += 1; k -= a[i]; } } cout<< cnt << nl; } }
20.133333
52
0.390728
jawahiir98
4d18363789494a9ef59749044f51c4b812584f2e
450
cpp
C++
src/app.cpp
ShaderKitty/geodesuka
1578f2fe3e5a7102d2e314406c89a48132a71675
[ "MIT" ]
3
2021-08-07T15:11:35.000Z
2021-11-17T18:59:45.000Z
src/app.cpp
ShaderKitty/geodesuka
1578f2fe3e5a7102d2e314406c89a48132a71675
[ "MIT" ]
null
null
null
src/app.cpp
ShaderKitty/geodesuka
1578f2fe3e5a7102d2e314406c89a48132a71675
[ "MIT" ]
null
null
null
#include <geodesuka/engine.h> #include <geodesuka/core/app.h> namespace geodesuka::core { app::app(engine* aEngine, int argc, char* argv[]) { this->Engine = aEngine; } // This is used engine side to generate thread for Application. void app::run() { // App is now ready to be run. this->ExitApp.store(false); // Initializes game loop. this->gameloop(); // Forces all threads to finish. this->Engine->Shutdown.store(true); } }
20.454545
64
0.673333
ShaderKitty
4d1ad0332c11dc690a87a9178325e4946dd8226f
1,193
cpp
C++
12085 Mobile Casanova.cpp
zihadboss/UVA-Solutions
020fdcb09da79dc0a0411b04026ce3617c09cd27
[ "Apache-2.0" ]
86
2016-01-20T11:36:50.000Z
2022-03-06T19:43:14.000Z
12085 Mobile Casanova.cpp
Mehedishihab/UVA-Solutions
474fe3d9d9ba574b97fd40ca5abb22ada95654a1
[ "Apache-2.0" ]
null
null
null
12085 Mobile Casanova.cpp
Mehedishihab/UVA-Solutions
474fe3d9d9ba574b97fd40ca5abb22ada95654a1
[ "Apache-2.0" ]
113
2015-12-04T06:40:57.000Z
2022-02-11T02:14:28.000Z
#include <iostream> using namespace std; unsigned int numbers[100005]; int main() { int N, T = 1; while (cin >> N, N) { for (int i = 0; i < N; ++i) cin >> numbers[i]; numbers[N] = 0; // Never common with the one before it cout << "Case " << T++ << ":\n"; for (int i = 0; i < N; ++i) { if (numbers[i] + 1 != numbers[i + 1]) cout << '0' << numbers[i] << '\n'; else { cout << '0' << numbers[i] << '-'; int subsequent = i + 1; for (; numbers[subsequent] + 1 == numbers[subsequent + 1]; ++subsequent) ; unsigned int start = numbers[i], end = numbers[subsequent]; //cout << "\nS: " << start << ' ' << end << '\n'; unsigned int mod = 10; while (start - (start % mod) != end - (end % mod)) mod *= 10; //cout << "Mod: " << mod << '\n'; cout << (end % mod) << '\n'; i = subsequent; } } cout << '\n'; } }
27.744186
88
0.352054
zihadboss
4d1bd538e0ec3cf9a0267ebf936c173cfe01adda
5,832
cc
C++
third_party/blink/renderer/core/html/parser/html_view_source_parser.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
third_party/blink/renderer/core/html/parser/html_view_source_parser.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
third_party/blink/renderer/core/html/parser/html_view_source_parser.cc
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
/* * Copyright (C) 2010 Google, Inc. 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. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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. */ #include "third_party/blink/renderer/core/html/parser/html_view_source_parser.h" #include <memory> #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/html/parser/html_parser_options.h" #include "third_party/blink/renderer/core/html/parser/html_token.h" #include "third_party/blink/renderer/platform/network/mime/mime_type_registry.h" namespace blink { HTMLViewSourceParser::HTMLViewSourceParser(HTMLViewSourceDocument& document, const String& mime_type) : DecodedDataDocumentParser(document), tokenizer_( std::make_unique<HTMLTokenizer>(HTMLParserOptions(&document))) { if (mime_type != "text/html" && !MIMETypeRegistry::IsXMLMIMEType(mime_type)) tokenizer_->SetState(HTMLTokenizer::kPLAINTEXTState); } void HTMLViewSourceParser::PumpTokenizer() { while (true) { StartTracker(input_.Current(), tokenizer_.get(), token_); if (!tokenizer_->NextToken(input_.Current(), token_)) return; EndTracker(input_.Current(), tokenizer_.get(), token_); GetDocument()->AddSource(SourceForToken(token_), token_); // FIXME: The tokenizer should do this work for us. if (token_.GetType() == HTMLToken::kStartTag) tokenizer_->UpdateStateFor( AttemptStaticStringCreation(token_.GetName(), kLikely8Bit)); token_.Clear(); } } void HTMLViewSourceParser::Append(const String& input) { input_.AppendToEnd(input); PumpTokenizer(); } void HTMLViewSourceParser::Finish() { Flush(); if (!input_.HaveSeenEndOfFile()) input_.MarkEndOfFile(); if (!IsDetached()) { PumpTokenizer(); GetDocument()->FinishedParsing(); } } void HTMLViewSourceParser::StartTracker(SegmentedString& current_input, HTMLTokenizer* tokenizer, HTMLToken& token) { if (token.GetType() == HTMLToken::kUninitialized && !tracker_is_started_) { previous_source_.Clear(); if (NeedToCheckTokenizerBuffer(tokenizer) && tokenizer->NumberOfBufferedCharacters()) previous_source_ = tokenizer->BufferedCharacters(); } else { previous_source_.Append(current_source_); } tracker_is_started_ = true; current_source_ = current_input; token.SetBaseOffset(current_source_.NumberOfCharactersConsumed() - previous_source_.length()); } void HTMLViewSourceParser::EndTracker(SegmentedString& current_input, HTMLTokenizer* tokenizer, HTMLToken& token) { tracker_is_started_ = false; cached_source_for_token_ = String(); // FIXME: This work should really be done by the HTMLTokenizer. wtf_size_t number_of_buffered_characters = 0u; if (NeedToCheckTokenizerBuffer(tokenizer)) { number_of_buffered_characters = tokenizer->NumberOfBufferedCharacters(); } token.end(current_input.NumberOfCharactersConsumed() - number_of_buffered_characters); } String HTMLViewSourceParser::SourceForToken(const HTMLToken& token) { if (!cached_source_for_token_.IsEmpty()) return cached_source_for_token_; wtf_size_t length; if (token.GetType() == HTMLToken::kEndOfFile) { // Consume the remainder of the input, omitting the null character we use to // mark the end of the file. length = previous_source_.length() + current_source_.length() - 1; } else { DCHECK(!token.StartIndex()); length = static_cast<wtf_size_t>(token.EndIndex() - token.StartIndex()); } StringBuilder source; source.ReserveCapacity(length); size_t i = 0; for (; i < length && !previous_source_.IsEmpty(); ++i) { source.Append(previous_source_.CurrentChar()); previous_source_.Advance(); } for (; i < length; ++i) { DCHECK(!current_source_.IsEmpty()); source.Append(current_source_.CurrentChar()); current_source_.Advance(); } cached_source_for_token_ = source.ToString(); return cached_source_for_token_; } bool HTMLViewSourceParser::NeedToCheckTokenizerBuffer( HTMLTokenizer* tokenizer) { HTMLTokenizer::State state = tokenizer->GetState(); // The temporary buffer must not be used unconditionally, because in some // states (e.g. ScriptDataDoubleEscapedStartState), data is appended to // both the temporary buffer and the token itself. return state == HTMLTokenizer::kDataState || HTMLTokenizer::IsEndTagBufferingState(state); } } // namespace blink
37.625806
80
0.717078
zealoussnow
4d1e87888a38c56943ddd8304fa9152f5b517c05
9,575
cpp
C++
DeviceCode/pal/OpenSSL/OpenSSL_1_0_0/crypto/asn1/a_strnid.cpp
Sirokujira/MicroFrameworkPK_v4_3
a0d80b4fd8eeda6dbdb58f6f7beb4f07f7ef563e
[ "Apache-2.0" ]
4
2019-01-21T11:47:53.000Z
2020-06-09T02:14:15.000Z
DeviceCode/pal/OpenSSL/OpenSSL_1_0_0/crypto/asn1/a_strnid.cpp
yisea123/NetmfSTM32
62ddb8aa0362b83d2e73f3621a56593988e3620f
[ "Apache-2.0" ]
null
null
null
DeviceCode/pal/OpenSSL/OpenSSL_1_0_0/crypto/asn1/a_strnid.cpp
yisea123/NetmfSTM32
62ddb8aa0362b83d2e73f3621a56593988e3620f
[ "Apache-2.0" ]
6
2017-11-09T11:48:10.000Z
2020-05-24T09:43:07.000Z
/* a_strnid.c */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. 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. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * licensing@OpenSSL.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED 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 OpenSSL PROJECT OR * ITS 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. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include "cryptlib.h" #include <openssl/asn1.h> #include <openssl/objects.h> #ifdef OPENSSL_SYS_WINDOWS #include <stdio.h> #include <ctype.h> #endif static STACK_OF(ASN1_STRING_TABLE) *stable = NULL; static void st_free(ASN1_STRING_TABLE *tbl); static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, const ASN1_STRING_TABLE * const *b); /* This is the global mask for the mbstring functions: this is use to * mask out certain types (such as BMPString and UTF8String) because * certain software (e.g. Netscape) has problems with them. */ static unsigned long global_mask = 0xFFFFFFFFL; void ASN1_STRING_set_default_mask(unsigned long mask) { global_mask = mask; } unsigned long ASN1_STRING_get_default_mask(void) { return global_mask; } /* This function sets the default to various "flavours" of configuration. * based on an ASCII string. Currently this is: * MASK:XXXX : a numerical mask value. * nobmp : Don't use BMPStrings (just Printable, T61). * pkix : PKIX recommendation in RFC2459. * utf8only : only use UTF8Strings (RFC2459 recommendation for 2004). * default: the default value, Printable, T61, BMP. */ int ASN1_STRING_set_default_mask_asc(const char *p) { unsigned long mask; char *end; if(!TINYCLR_SSL_STRNCMP(p, "MASK:", 5)) { if(!p[5]) return 0; mask = strtoul(p + 5, &end, 0); if(*end) return 0; } else if(!TINYCLR_SSL_STRCMP(p, "nombstr")) mask = ~((unsigned long)(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)); else if(!TINYCLR_SSL_STRCMP(p, "pkix")) mask = ~((unsigned long)B_ASN1_T61STRING); else if(!TINYCLR_SSL_STRCMP(p, "utf8only")) mask = B_ASN1_UTF8STRING; else if(!TINYCLR_SSL_STRCMP(p, "default")) mask = 0xFFFFFFFFL; else return 0; ASN1_STRING_set_default_mask(mask); return 1; } /* The following function generates an ASN1_STRING based on limits in a table. * Frequently the types and length of an ASN1_STRING are restricted by a * corresponding OID. For example certificates and certificate requests. */ ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, int inlen, int inform, int nid) { ASN1_STRING_TABLE *tbl; ASN1_STRING *str = NULL; unsigned long mask; int ret; if(!out) out = &str; tbl = ASN1_STRING_TABLE_get(nid); if(tbl) { mask = tbl->mask; if(!(tbl->flags & STABLE_NO_MASK)) mask &= global_mask; ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask, tbl->minsize, tbl->maxsize); } else ret = ASN1_mbstring_copy(out, in, inlen, inform, DIRSTRING_TYPE & global_mask); if(ret <= 0) return NULL; return *out; } /* Now the tables and helper functions for the string table: */ /* size limits: this stuff is taken straight from RFC3280 */ #define ub_name 32768 #define ub_common_name 64 #define ub_locality_name 128 #define ub_state_name 128 #define ub_organization_name 64 #define ub_organization_unit_name 64 #define ub_title 64 #define ub_email_address 128 #define ub_serial_number 64 /* This table must be kept in NID order */ static const ASN1_STRING_TABLE tbl_standard[] = { {NID_commonName, 1, ub_common_name, DIRSTRING_TYPE, 0}, {NID_countryName, 2, 2, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, {NID_localityName, 1, ub_locality_name, DIRSTRING_TYPE, 0}, {NID_stateOrProvinceName, 1, ub_state_name, DIRSTRING_TYPE, 0}, {NID_organizationName, 1, ub_organization_name, DIRSTRING_TYPE, 0}, {NID_organizationalUnitName, 1, ub_organization_unit_name, DIRSTRING_TYPE, 0}, {NID_pkcs9_emailAddress, 1, ub_email_address, B_ASN1_IA5STRING, STABLE_NO_MASK}, {NID_pkcs9_unstructuredName, 1, -1, PKCS9STRING_TYPE, 0}, {NID_pkcs9_challengePassword, 1, -1, PKCS9STRING_TYPE, 0}, {NID_pkcs9_unstructuredAddress, 1, -1, DIRSTRING_TYPE, 0}, {NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_surname, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_initials, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_serialNumber, 1, ub_serial_number, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, {NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}, {NID_name, 1, ub_name, DIRSTRING_TYPE, 0}, {NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, {NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK}, {NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK} }; static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, const ASN1_STRING_TABLE * const *b) { return (*a)->nid - (*b)->nid; } DECLARE_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table); static int table_cmp(const ASN1_STRING_TABLE *a, const ASN1_STRING_TABLE *b) { return a->nid - b->nid; } IMPLEMENT_OBJ_BSEARCH_CMP_FN(ASN1_STRING_TABLE, ASN1_STRING_TABLE, table); ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid) { int idx; ASN1_STRING_TABLE *ttmp; ASN1_STRING_TABLE fnd; fnd.nid = nid; ttmp = OBJ_bsearch_table(&fnd, tbl_standard, sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE)); if(ttmp) return ttmp; if(!stable) return NULL; idx = sk_ASN1_STRING_TABLE_find(stable, &fnd); if(idx < 0) return NULL; return sk_ASN1_STRING_TABLE_value(stable, idx); } int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, unsigned long mask, unsigned long flags) { ASN1_STRING_TABLE *tmp; char new_nid = 0; flags &= ~STABLE_FLAGS_MALLOC; if(!stable) stable = sk_ASN1_STRING_TABLE_new(sk_table_cmp); if(!stable) { ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE); return 0; } if(!(tmp = ASN1_STRING_TABLE_get(nid))) { tmp = (ASN1_STRING_TABLE*)OPENSSL_malloc(sizeof(ASN1_STRING_TABLE));//MS: cast to ASN1_STRING_TABLE* if(!tmp) { ASN1err(ASN1_F_ASN1_STRING_TABLE_ADD, ERR_R_MALLOC_FAILURE); return 0; } tmp->flags = flags | STABLE_FLAGS_MALLOC; tmp->nid = nid; new_nid = 1; } else tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags; if(minsize != -1) tmp->minsize = minsize; if(maxsize != -1) tmp->maxsize = maxsize; tmp->mask = mask; if(new_nid) sk_ASN1_STRING_TABLE_push(stable, tmp); return 1; } void ASN1_STRING_TABLE_cleanup(void) { STACK_OF(ASN1_STRING_TABLE) *tmp; tmp = stable; if(!tmp) return; stable = NULL; sk_ASN1_STRING_TABLE_pop_free(tmp, st_free); } static void st_free(ASN1_STRING_TABLE *tbl) { if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl); } IMPLEMENT_STACK_OF(ASN1_STRING_TABLE) #ifdef STRING_TABLE_TEST main() { ASN1_STRING_TABLE *tmp; int i, last_nid = -1; for (tmp = tbl_standard, i = 0; i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++) { if (tmp->nid < last_nid) { last_nid = 0; break; } last_nid = tmp->nid; } if (last_nid != 0) { TINYCLR_SSL_PRINTF("Table order OK\n"); TINYCLR_SSL_EXIT(0); } for (tmp = tbl_standard, i = 0; i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++) TINYCLR_SSL_PRINTF("Index %d, NID %d, Name=%s\n", i, tmp->nid, OBJ_nid2ln(tmp->nid)); } #endif
32.679181
102
0.726475
Sirokujira
4d1ea956eaaea5c6e3865e987283b15556b26719
1,009
hpp
C++
test/comparison/earcut.hpp
pboyer/earcut.hpp
4ad849c1eb3fa850465f6a14ba31fe03de714538
[ "ISC" ]
16
2020-12-27T16:38:06.000Z
2022-03-19T23:29:50.000Z
test/comparison/earcut.hpp
pboyer/earcut.hpp
4ad849c1eb3fa850465f6a14ba31fe03de714538
[ "ISC" ]
null
null
null
test/comparison/earcut.hpp
pboyer/earcut.hpp
4ad849c1eb3fa850465f6a14ba31fe03de714538
[ "ISC" ]
null
null
null
#pragma once #include <mapbox/earcut.hpp> #include <array> #include <memory> #include <vector> template <typename Coord, typename Polygon> class EarcutTesselator { public: using Vertex = std::array<Coord, 2>; using Vertices = std::vector<Vertex>; EarcutTesselator(const Polygon &polygon_) : polygon(polygon_) { for (const auto& ring : polygon_) { for (const auto& vertex : ring) { vertices_.emplace_back(Vertex {{ Coord(std::get<0>(vertex)), Coord(std::get<1>(vertex)) }}); } } } EarcutTesselator & operator=(const EarcutTesselator&) = delete; void run() { indices_ = mapbox::earcut(polygon); } std::vector<uint32_t> const& indices() const { return indices_; } Vertices const& vertices() const { return vertices_; } private: const Polygon &polygon; Vertices vertices_; std::vector<uint32_t> indices_; };
22.931818
80
0.582755
pboyer
4d1ebb0fdc22eed23256330354b834c1a68c3295
6,664
cc
C++
drivers/bus_driver.cc
Aden-Q/visual-transit-system-simulator
3ae48399139375ecc55ab3139230d01d3a4962f1
[ "MIT" ]
null
null
null
drivers/bus_driver.cc
Aden-Q/visual-transit-system-simulator
3ae48399139375ecc55ab3139230d01d3a4962f1
[ "MIT" ]
null
null
null
drivers/bus_driver.cc
Aden-Q/visual-transit-system-simulator
3ae48399139375ecc55ab3139230d01d3a4962f1
[ "MIT" ]
null
null
null
#include <iostream> #include <vector> #include <list> #include <random> #include <ctime> #include <string> //convert int to string for names #include "bus.h" #include "passenger.h" #include "random_passenger_generator.h" #include "route.h" #include "stop.h" int main() { int rounds = 50; //Number of rounds of generation to simulate in test srand((long)time(NULL)); //Seed the random number generator... //Stop ** all_stops = new Stop *[12]; Stop ** CC_EB_stops = new Stop *[6]; Stop ** CC_WB_stops = new Stop *[6]; std::list<Stop *> CC_EB_stops_list; std::list<Stop *> CC_WB_stops_list; //Eastbound stops Stop stop_CC_EB_1(0, 43, -92.5); //West bank station Stop stop_CC_EB_2(1); //student union station Stop stop_CC_EB_3(2, 44.973820, -93.227117); //Oak St & Washington Ave Stop stop_CC_EB_4(3, 45, -94); //before transit Stop stop_CC_EB_5(4, 46, -95); //st paul 1 Stop stop_CC_EB_6(5, 47, -96); //st paul 2 //Westbound stops Stop stop_CC_WB_1(6, 47, -96); //st paul 2 Stop stop_CC_WB_2(7, 46, -95); //st paul 1 Stop stop_CC_WB_3(8, 45, -94); //before transit Stop stop_CC_WB_4(9, 44.973820, -93.227117); //Oak St & Washington Ave Stop stop_CC_WB_5(10); //student union station Stop stop_CC_WB_6(11, 43, -92.5); //West bank station CC_EB_stops_list.push_back(&stop_CC_EB_1); CC_EB_stops[0] = &stop_CC_EB_1; CC_EB_stops_list.push_back(&stop_CC_EB_2); CC_EB_stops[1] = &stop_CC_EB_2; CC_EB_stops_list.push_back(&stop_CC_EB_3); CC_EB_stops[2] = &stop_CC_EB_3; CC_EB_stops_list.push_back(&stop_CC_EB_4); CC_EB_stops[3] = &stop_CC_EB_4; CC_EB_stops_list.push_back(&stop_CC_EB_5); CC_EB_stops[4] = &stop_CC_EB_5; CC_EB_stops_list.push_back(&stop_CC_EB_6); CC_EB_stops[5] = &stop_CC_EB_6; CC_WB_stops_list.push_back(&stop_CC_WB_1); CC_WB_stops[0] = &stop_CC_WB_1; CC_WB_stops_list.push_back(&stop_CC_WB_2); CC_WB_stops[1] = &stop_CC_WB_2; CC_WB_stops_list.push_back(&stop_CC_WB_3); CC_WB_stops[2] = &stop_CC_WB_3; CC_WB_stops_list.push_back(&stop_CC_WB_4); CC_WB_stops[3] = &stop_CC_WB_4; CC_WB_stops_list.push_back(&stop_CC_WB_5); CC_WB_stops[4] = &stop_CC_WB_5; CC_WB_stops_list.push_back(&stop_CC_WB_6); CC_WB_stops[5] = &stop_CC_WB_6; double * CC_EB_distances = new double[5]; double * CC_WB_distances = new double[5]; CC_EB_distances[0] = 5; CC_EB_distances[1] = 4; CC_EB_distances[2] = 3; CC_EB_distances[3] = 10; CC_EB_distances[4] = 6; CC_WB_distances[0] = 6; CC_WB_distances[1] = 10; CC_WB_distances[2] = 3; CC_WB_distances[3] = 4; CC_WB_distances[4] = 5; std::list<double> CC_EB_probs; //realistic .15, .3, .025, .05, .05, 0 CC_EB_probs.push_back(.15); //WB CC_EB_probs.push_back(.3); //CMU CC_EB_probs.push_back(.025); //O&W CC_EB_probs.push_back(.05); //Pre-transit CC_EB_probs.push_back(.05); //STP 1 CC_EB_probs.push_back(0); //STP 1 //TODO: is this always true? If so, we may want to reduce the length of probs to_char_type // remove possibility of generating passengers with nowhere to go std::list<double> CC_WB_probs; //realistic .35, .05, .01, .01, .2, 0 CC_WB_probs.push_back(.35); //stp 2 CC_WB_probs.push_back(.05); //stp 1 CC_WB_probs.push_back(.01); //post-transit CC_WB_probs.push_back(.01); //O&W CC_WB_probs.push_back(.02); //CMU CC_WB_probs.push_back(0); //WB RandomPassengerGenerator CC_EB_generator(CC_EB_probs, CC_EB_stops_list); RandomPassengerGenerator CC_WB_generator(CC_WB_probs, CC_WB_stops_list); Route CC1_EB("Campus Connector 1- Eastbound", CC_EB_stops, CC_EB_distances, 6, &CC_EB_generator); Route CC1_WB("Campus Connector 1- Westbound", CC_WB_stops, CC_WB_distances, 6, &CC_WB_generator); Route CC2_EB("Campus Connector 1- Eastbound", CC_EB_stops, CC_EB_distances, 6, &CC_EB_generator); Route CC2_WB("Campus Connector 1- Westbound", CC_WB_stops, CC_WB_distances, 6, &CC_WB_generator); int cc1_counter = 10000; int cc2_counter = 20000; Bus campus_connector1(std::to_string(cc1_counter), &CC1_EB, &CC1_WB, 60, 1); Bus campus_connector2(std::to_string(cc2_counter), &CC2_WB, &CC2_EB, 60, 1); std::cout << "/*\n *\n * Initial Report\n *\n*/" << std::endl; std::cout << "\t*** Bus Reports ***" << std::endl << std::endl; campus_connector1.Report(std::cout); campus_connector2.Report(std::cout); std::cout << std::endl << "\t*** Stop Reports ***" << std::endl << std::endl; std::cout << std::endl << "\t\t ~ Eastbound ~ " << std::endl << std::endl; for(std::list<Stop *>::const_iterator it = CC_EB_stops_list.begin(); it != CC_EB_stops_list.end(); it++) { (*it)->Report(std::cout); } std::cout << std::endl << "\t\t ~ Westbound ~ " << std::endl << std::endl; for(std::list<Stop *>::const_iterator it = CC_WB_stops_list.begin(); it != CC_WB_stops_list.end(); it++) { (*it)->Report(std::cout); } for (int i = 0; i < rounds; i++) { std::cout << "/*\n **\n ***\n **** Generation #" << (i+1) << "\n ***\n **\n */" << std::endl; CC1_EB.Update(); CC1_WB.Update(); campus_connector1.Update(); campus_connector2.Update(); if (campus_connector1.IsTripComplete()) { cc1_counter++; CC1_EB = Route("Campus Connector 1- Eastbound", CC_EB_stops, CC_EB_distances, 6, &CC_EB_generator); CC1_WB = Route("Campus Connector 1- Westbound", CC_WB_stops, CC_WB_distances, 6, &CC_WB_generator); campus_connector1 = Bus(std::to_string(cc1_counter), &CC1_EB, &CC1_WB, 60, 1); } if (campus_connector2.IsTripComplete()) { cc2_counter++; CC2_EB = Route("Campus Connector 1- Eastbound", CC_EB_stops, CC_EB_distances, 6, &CC_EB_generator); CC2_WB = Route("Campus Connector 1- Westbound", CC_WB_stops, CC_WB_distances, 6, &CC_WB_generator); campus_connector1 = Bus(std::to_string(cc2_counter), &CC2_EB, &CC2_WB, 60, 1); } std::cout << "\t*** Bus Reports ***" << std::endl << std::endl; campus_connector1.Report(std::cout); campus_connector2.Report(std::cout); std::cout << std::endl << "\t*** Stop Reports ***" << std::endl << std::endl; std::cout << std::endl << "\t\t ~ Eastbound ~ " << std::endl << std::endl; for(std::list<Stop *>::const_iterator it = CC_EB_stops_list.begin(); it != CC_EB_stops_list.end(); it++) { (*it)->Report(std::cout); } std::cout << std::endl << "\t\t ~ Westbound ~ " << std::endl << std::endl; for(std::list<Stop *>::const_iterator it = CC_WB_stops_list.begin(); it != CC_WB_stops_list.end(); it++) { (*it)->Report(std::cout); } std::cout << std::endl << std::endl; } return 0; }
38.520231
110
0.664916
Aden-Q
4d270d8fceded650098263a5ff502d5ac9d11ddf
2,962
hpp
C++
ishtar/include/emit/TypeName.hpp
Djelnar/mana_lang
a50feb48bd4c7a7a321bd5f28e382cbad0c6ef09
[ "MIT" ]
null
null
null
ishtar/include/emit/TypeName.hpp
Djelnar/mana_lang
a50feb48bd4c7a7a321bd5f28e382cbad0c6ef09
[ "MIT" ]
null
null
null
ishtar/include/emit/TypeName.hpp
Djelnar/mana_lang
a50feb48bd4c7a7a321bd5f28e382cbad0c6ef09
[ "MIT" ]
null
null
null
#pragma once #include <string> #include <fmt/format.h> #include "compatibility.types.hpp" #include "utils/string.split.hpp" #include "utils/string.replace.hpp" #include <map> using namespace std; struct TypeName; static map<tuple<int, int, int>, TypeName*>* __TypeName_cache = nullptr; struct TypeName { wstring FullName; [[nodiscard]] wstring get_name() const noexcept(false) { auto results = split(FullName, '/'); auto result = results[results.size() - 1]; results.clear(); return result; } [[nodiscard]] wstring get_namespace() const noexcept(false) { auto rd = split(FullName, '%'); auto& target = rd.at(1); return replace_string(target, get_name(), L""); } [[nodiscard]] wstring get_assembly_name() const noexcept(false) { auto splited = split(FullName, '%'); return splited.at(0); } TypeName(const wstring& a, const wstring& n, const wstring& c) noexcept(true) { FullName = a + L"%" + c + L"/" + n; } TypeName(const wstring& fullName) noexcept(true) { FullName = fullName; } [[nodiscard]] static TypeName* construct( const int asmIdx, const int nameIdx, const int namespaceIdx, GetConstByIndexDelegate* m) noexcept(true) { if (__TypeName_cache == nullptr) __TypeName_cache = new map<tuple<int, int, int>, TypeName*>(); auto key = make_tuple(asmIdx, nameIdx, namespaceIdx); if (__TypeName_cache->contains(key)) return __TypeName_cache->at(key); auto* result = new TypeName(m->operator()(asmIdx), m->operator()(nameIdx), m->operator()(namespaceIdx)); __TypeName_cache->insert({key, result}); return result; } static void Validate(TypeName* name) noexcept(false) { //if (!name->FullName.starts_with(L"global::")) // throw InvalidFormatException(fmt::format(L"TypeName '{0}' has invalid. [name is not start with global::]", name->FullName)); } }; template<> struct equality<TypeName*> { static bool equal(TypeName* l, TypeName* r) { return wcscmp(l->FullName.c_str(), r->FullName.c_str()) == 0; } }; template <> struct fmt::formatter<TypeName>: formatter<string_view> { template <typename FormatContext> auto format(TypeName c, FormatContext& ctx) { return formatter<string_view>::format(c.FullName, ctx); } }; template <> struct fmt::formatter<TypeName*>: formatter<string_view> { template <typename FormatContext> auto format(TypeName* c, FormatContext& ctx) { return formatter<string_view>::format(c->FullName, ctx); } }; TypeName* readTypeName(uint32_t** ip, GetConstByIndexDelegate* m) { ++(*ip); const auto asmIdx = READ32((*ip)); ++(*ip); const auto nameIdx = READ32((*ip)); ++(*ip); const auto nsIdx = READ32((*ip)); ++(*ip); return TypeName::construct(asmIdx, nameIdx, nsIdx, m); }
29.326733
138
0.630655
Djelnar
4d28deb35221698a4eb4c16efc6fd23df8704f25
94,063
cc
C++
0012_Integer_to_Roman/0012.cc
LuciusKyle/LeetCode
66c9090e5244b10eca0be50398764da2b4b48a6c
[ "Apache-2.0" ]
null
null
null
0012_Integer_to_Roman/0012.cc
LuciusKyle/LeetCode
66c9090e5244b10eca0be50398764da2b4b48a6c
[ "Apache-2.0" ]
null
null
null
0012_Integer_to_Roman/0012.cc
LuciusKyle/LeetCode
66c9090e5244b10eca0be50398764da2b4b48a6c
[ "Apache-2.0" ]
null
null
null
// Symbol Value // I 1 // V 5 // X 10 // L 50 // C 100 // D 500 // M 1000 #include <assert.h> #include <array> #include <string> #include <fstream> using std::string; char cheat_chart[][16] = { "","I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX", "XXI", "XXII", "XXIII", "XXIV", "XXV", "XXVI", "XXVII", "XXVIII", "XXIX", "XXX", "XXXI", "XXXII", "XXXIII", "XXXIV", "XXXV", "XXXVI", "XXXVII", "XXXVIII", "XXXIX", "XL", "XLI", "XLII", "XLIII", "XLIV", "XLV", "XLVI", "XLVII", "XLVIII", "XLIX", "L", "LI", "LII", "LIII", "LIV", "LV", "LVI", "LVII", "LVIII", "LIX", "LX", "LXI", "LXII", "LXIII", "LXIV", "LXV", "LXVI", "LXVII", "LXVIII", "LXIX", "LXX", "LXXI", "LXXII", "LXXIII", "LXXIV", "LXXV", "LXXVI", "LXXVII", "LXXVIII", "LXXIX", "LXXX", "LXXXI", "LXXXII", "LXXXIII", "LXXXIV", "LXXXV", "LXXXVI", "LXXXVII", "LXXXVIII", "LXXXIX", "XC", "XCI", "XCII", "XCIII", "XCIV", "XCV", "XCVI", "XCVII", "XCVIII", "XCIX", "C", "CI", "CII", "CIII", "CIV", "CV", "CVI", "CVII", "CVIII", "CIX", "CX", "CXI", "CXII", "CXIII", "CXIV", "CXV", "CXVI", "CXVII", "CXVIII", "CXIX", "CXX", "CXXI", "CXXII", "CXXIII", "CXXIV", "CXXV", "CXXVI", "CXXVII", "CXXVIII", "CXXIX", "CXXX", "CXXXI", "CXXXII", "CXXXIII", "CXXXIV", "CXXXV", "CXXXVI", "CXXXVII", "CXXXVIII", "CXXXIX", "CXL", "CXLI", "CXLII", "CXLIII", "CXLIV", "CXLV", "CXLVI", "CXLVII", "CXLVIII", "CXLIX", "CL", "CLI", "CLII", "CLIII", "CLIV", "CLV", "CLVI", "CLVII", "CLVIII", "CLIX", "CLX", "CLXI", "CLXII", "CLXIII", "CLXIV", "CLXV", "CLXVI", "CLXVII", "CLXVIII", "CLXIX", "CLXX", "CLXXI", "CLXXII", "CLXXIII", "CLXXIV", "CLXXV", "CLXXVI", "CLXXVII", "CLXXVIII", "CLXXIX", "CLXXX", "CLXXXI", "CLXXXII", "CLXXXIII", "CLXXXIV", "CLXXXV", "CLXXXVI", "CLXXXVII", "CLXXXVIII", "CLXXXIX", "CXC", "CXCI", "CXCII", "CXCIII", "CXCIV", "CXCV", "CXCVI", "CXCVII", "CXCVIII", "CXCIX", "CC", "CCI", "CCII", "CCIII", "CCIV", "CCV", "CCVI", "CCVII", "CCVIII", "CCIX", "CCX", "CCXI", "CCXII", "CCXIII", "CCXIV", "CCXV", "CCXVI", "CCXVII", "CCXVIII", "CCXIX", "CCXX", "CCXXI", "CCXXII", "CCXXIII", "CCXXIV", "CCXXV", "CCXXVI", "CCXXVII", "CCXXVIII", "CCXXIX", "CCXXX", "CCXXXI", "CCXXXII", "CCXXXIII", "CCXXXIV", "CCXXXV", "CCXXXVI", "CCXXXVII", "CCXXXVIII", "CCXXXIX", "CCXL", "CCXLI", "CCXLII", "CCXLIII", "CCXLIV", "CCXLV", "CCXLVI", "CCXLVII", "CCXLVIII", "CCXLIX", "CCL", "CCLI", "CCLII", "CCLIII", "CCLIV", "CCLV", "CCLVI", "CCLVII", "CCLVIII", "CCLIX", "CCLX", "CCLXI", "CCLXII", "CCLXIII", "CCLXIV", "CCLXV", "CCLXVI", "CCLXVII", "CCLXVIII", "CCLXIX", "CCLXX", "CCLXXI", "CCLXXII", "CCLXXIII", "CCLXXIV", "CCLXXV", "CCLXXVI", "CCLXXVII", "CCLXXVIII", "CCLXXIX", "CCLXXX", "CCLXXXI", "CCLXXXII", "CCLXXXIII", "CCLXXXIV", "CCLXXXV", "CCLXXXVI", "CCLXXXVII", "CCLXXXVIII", "CCLXXXIX", "CCXC", "CCXCI", "CCXCII", "CCXCIII", "CCXCIV", "CCXCV", "CCXCVI", "CCXCVII", "CCXCVIII", "CCXCIX", "CCC", "CCCI", "CCCII", "CCCIII", "CCCIV", "CCCV", "CCCVI", "CCCVII", "CCCVIII", "CCCIX", "CCCX", "CCCXI", "CCCXII", "CCCXIII", "CCCXIV", "CCCXV", "CCCXVI", "CCCXVII", "CCCXVIII", "CCCXIX", "CCCXX", "CCCXXI", "CCCXXII", "CCCXXIII", "CCCXXIV", "CCCXXV", "CCCXXVI", "CCCXXVII", "CCCXXVIII", "CCCXXIX", "CCCXXX", "CCCXXXI", "CCCXXXII", "CCCXXXIII", "CCCXXXIV", "CCCXXXV", "CCCXXXVI", "CCCXXXVII", "CCCXXXVIII", "CCCXXXIX", "CCCXL", "CCCXLI", "CCCXLII", "CCCXLIII", "CCCXLIV", "CCCXLV", "CCCXLVI", "CCCXLVII", "CCCXLVIII", "CCCXLIX", "CCCL", "CCCLI", "CCCLII", "CCCLIII", "CCCLIV", "CCCLV", "CCCLVI", "CCCLVII", "CCCLVIII", "CCCLIX", "CCCLX", "CCCLXI", "CCCLXII", "CCCLXIII", "CCCLXIV", "CCCLXV", "CCCLXVI", "CCCLXVII", "CCCLXVIII", "CCCLXIX", "CCCLXX", "CCCLXXI", "CCCLXXII", "CCCLXXIII", "CCCLXXIV", "CCCLXXV", "CCCLXXVI", "CCCLXXVII", "CCCLXXVIII", "CCCLXXIX", "CCCLXXX", "CCCLXXXI", "CCCLXXXII", "CCCLXXXIII", "CCCLXXXIV", "CCCLXXXV", "CCCLXXXVI", "CCCLXXXVII", "CCCLXXXVIII", "CCCLXXXIX", "CCCXC", "CCCXCI", "CCCXCII", "CCCXCIII", "CCCXCIV", "CCCXCV", "CCCXCVI", "CCCXCVII", "CCCXCVIII", "CCCXCIX", "CD", "CDI", "CDII", "CDIII", "CDIV", "CDV", "CDVI", "CDVII", "CDVIII", "CDIX", "CDX", "CDXI", "CDXII", "CDXIII", "CDXIV", "CDXV", "CDXVI", "CDXVII", "CDXVIII", "CDXIX", "CDXX", "CDXXI", "CDXXII", "CDXXIII", "CDXXIV", "CDXXV", "CDXXVI", "CDXXVII", "CDXXVIII", "CDXXIX", "CDXXX", "CDXXXI", "CDXXXII", "CDXXXIII", "CDXXXIV", "CDXXXV", "CDXXXVI", "CDXXXVII", "CDXXXVIII", "CDXXXIX", "CDXL", "CDXLI", "CDXLII", "CDXLIII", "CDXLIV", "CDXLV", "CDXLVI", "CDXLVII", "CDXLVIII", "CDXLIX", "CDL", "CDLI", "CDLII", "CDLIII", "CDLIV", "CDLV", "CDLVI", "CDLVII", "CDLVIII", "CDLIX", "CDLX", "CDLXI", "CDLXII", "CDLXIII", "CDLXIV", "CDLXV", "CDLXVI", "CDLXVII", "CDLXVIII", "CDLXIX", "CDLXX", "CDLXXI", "CDLXXII", "CDLXXIII", "CDLXXIV", "CDLXXV", "CDLXXVI", "CDLXXVII", "CDLXXVIII", "CDLXXIX", "CDLXXX", "CDLXXXI", "CDLXXXII", "CDLXXXIII", "CDLXXXIV", "CDLXXXV", "CDLXXXVI", "CDLXXXVII", "CDLXXXVIII", "CDLXXXIX", "CDXC", "CDXCI", "CDXCII", "CDXCIII", "CDXCIV", "CDXCV", "CDXCVI", "CDXCVII", "CDXCVIII", "CDXCIX", "D", "DI", "DII", "DIII", "DIV", "DV", "DVI", "DVII", "DVIII", "DIX", "DX", "DXI", "DXII", "DXIII", "DXIV", "DXV", "DXVI", "DXVII", "DXVIII", "DXIX", "DXX", "DXXI", "DXXII", "DXXIII", "DXXIV", "DXXV", "DXXVI", "DXXVII", "DXXVIII", "DXXIX", "DXXX", "DXXXI", "DXXXII", "DXXXIII", "DXXXIV", "DXXXV", "DXXXVI", "DXXXVII", "DXXXVIII", "DXXXIX", "DXL", "DXLI", "DXLII", "DXLIII", "DXLIV", "DXLV", "DXLVI", "DXLVII", "DXLVIII", "DXLIX", "DL", "DLI", "DLII", "DLIII", "DLIV", "DLV", "DLVI", "DLVII", "DLVIII", "DLIX", "DLX", "DLXI", "DLXII", "DLXIII", "DLXIV", "DLXV", "DLXVI", "DLXVII", "DLXVIII", "DLXIX", "DLXX", "DLXXI", "DLXXII", "DLXXIII", "DLXXIV", "DLXXV", "DLXXVI", "DLXXVII", "DLXXVIII", "DLXXIX", "DLXXX", "DLXXXI", "DLXXXII", "DLXXXIII", "DLXXXIV", "DLXXXV", "DLXXXVI", "DLXXXVII", "DLXXXVIII", "DLXXXIX", "DXC", "DXCI", "DXCII", "DXCIII", "DXCIV", "DXCV", "DXCVI", "DXCVII", "DXCVIII", "DXCIX", "DC", "DCI", "DCII", "DCIII", "DCIV", "DCV", "DCVI", "DCVII", "DCVIII", "DCIX", "DCX", "DCXI", "DCXII", "DCXIII", "DCXIV", "DCXV", "DCXVI", "DCXVII", "DCXVIII", "DCXIX", "DCXX", "DCXXI", "DCXXII", "DCXXIII", "DCXXIV", "DCXXV", "DCXXVI", "DCXXVII", "DCXXVIII", "DCXXIX", "DCXXX", "DCXXXI", "DCXXXII", "DCXXXIII", "DCXXXIV", "DCXXXV", "DCXXXVI", "DCXXXVII", "DCXXXVIII", "DCXXXIX", "DCXL", "DCXLI", "DCXLII", "DCXLIII", "DCXLIV", "DCXLV", "DCXLVI", "DCXLVII", "DCXLVIII", "DCXLIX", "DCL", "DCLI", "DCLII", "DCLIII", "DCLIV", "DCLV", "DCLVI", "DCLVII", "DCLVIII", "DCLIX", "DCLX", "DCLXI", "DCLXII", "DCLXIII", "DCLXIV", "DCLXV", "DCLXVI", "DCLXVII", "DCLXVIII", "DCLXIX", "DCLXX", "DCLXXI", "DCLXXII", "DCLXXIII", "DCLXXIV", "DCLXXV", "DCLXXVI", "DCLXXVII", "DCLXXVIII", "DCLXXIX", "DCLXXX", "DCLXXXI", "DCLXXXII", "DCLXXXIII", "DCLXXXIV", "DCLXXXV", "DCLXXXVI", "DCLXXXVII", "DCLXXXVIII", "DCLXXXIX", "DCXC", "DCXCI", "DCXCII", "DCXCIII", "DCXCIV", "DCXCV", "DCXCVI", "DCXCVII", "DCXCVIII", "DCXCIX", "DCC", "DCCI", "DCCII", "DCCIII", "DCCIV", "DCCV", "DCCVI", "DCCVII", "DCCVIII", "DCCIX", "DCCX", "DCCXI", "DCCXII", "DCCXIII", "DCCXIV", "DCCXV", "DCCXVI", "DCCXVII", "DCCXVIII", "DCCXIX", "DCCXX", "DCCXXI", "DCCXXII", "DCCXXIII", "DCCXXIV", "DCCXXV", "DCCXXVI", "DCCXXVII", "DCCXXVIII", "DCCXXIX", "DCCXXX", "DCCXXXI", "DCCXXXII", "DCCXXXIII", "DCCXXXIV", "DCCXXXV", "DCCXXXVI", "DCCXXXVII", "DCCXXXVIII", "DCCXXXIX", "DCCXL", "DCCXLI", "DCCXLII", "DCCXLIII", "DCCXLIV", "DCCXLV", "DCCXLVI", "DCCXLVII", "DCCXLVIII", "DCCXLIX", "DCCL", "DCCLI", "DCCLII", "DCCLIII", "DCCLIV", "DCCLV", "DCCLVI", "DCCLVII", "DCCLVIII", "DCCLIX", "DCCLX", "DCCLXI", "DCCLXII", "DCCLXIII", "DCCLXIV", "DCCLXV", "DCCLXVI", "DCCLXVII", "DCCLXVIII", "DCCLXIX", "DCCLXX", "DCCLXXI", "DCCLXXII", "DCCLXXIII", "DCCLXXIV", "DCCLXXV", "DCCLXXVI", "DCCLXXVII", "DCCLXXVIII", "DCCLXXIX", "DCCLXXX", "DCCLXXXI", "DCCLXXXII", "DCCLXXXIII", "DCCLXXXIV", "DCCLXXXV", "DCCLXXXVI", "DCCLXXXVII", "DCCLXXXVIII", "DCCLXXXIX", "DCCXC", "DCCXCI", "DCCXCII", "DCCXCIII", "DCCXCIV", "DCCXCV", "DCCXCVI", "DCCXCVII", "DCCXCVIII", "DCCXCIX", "DCCC", "DCCCI", "DCCCII", "DCCCIII", "DCCCIV", "DCCCV", "DCCCVI", "DCCCVII", "DCCCVIII", "DCCCIX", "DCCCX", "DCCCXI", "DCCCXII", "DCCCXIII", "DCCCXIV", "DCCCXV", "DCCCXVI", "DCCCXVII", "DCCCXVIII", "DCCCXIX", "DCCCXX", "DCCCXXI", "DCCCXXII", "DCCCXXIII", "DCCCXXIV", "DCCCXXV", "DCCCXXVI", "DCCCXXVII", "DCCCXXVIII", "DCCCXXIX", "DCCCXXX", "DCCCXXXI", "DCCCXXXII", "DCCCXXXIII", "DCCCXXXIV", "DCCCXXXV", "DCCCXXXVI", "DCCCXXXVII", "DCCCXXXVIII", "DCCCXXXIX", "DCCCXL", "DCCCXLI", "DCCCXLII", "DCCCXLIII", "DCCCXLIV", "DCCCXLV", "DCCCXLVI", "DCCCXLVII", "DCCCXLVIII", "DCCCXLIX", "DCCCL", "DCCCLI", "DCCCLII", "DCCCLIII", "DCCCLIV", "DCCCLV", "DCCCLVI", "DCCCLVII", "DCCCLVIII", "DCCCLIX", "DCCCLX", "DCCCLXI", "DCCCLXII", "DCCCLXIII", "DCCCLXIV", "DCCCLXV", "DCCCLXVI", "DCCCLXVII", "DCCCLXVIII", "DCCCLXIX", "DCCCLXX", "DCCCLXXI", "DCCCLXXII", "DCCCLXXIII", "DCCCLXXIV", "DCCCLXXV", "DCCCLXXVI", "DCCCLXXVII", "DCCCLXXVIII", "DCCCLXXIX", "DCCCLXXX", "DCCCLXXXI", "DCCCLXXXII", "DCCCLXXXIII", "DCCCLXXXIV", "DCCCLXXXV", "DCCCLXXXVI", "DCCCLXXXVII", "DCCCLXXXVIII", "DCCCLXXXIX", "DCCCXC", "DCCCXCI", "DCCCXCII", "DCCCXCIII", "DCCCXCIV", "DCCCXCV", "DCCCXCVI", "DCCCXCVII", "DCCCXCVIII", "DCCCXCIX", "CM", "CMI", "CMII", "CMIII", "CMIV", "CMV", "CMVI", "CMVII", "CMVIII", "CMIX", "CMX", "CMXI", "CMXII", "CMXIII", "CMXIV", "CMXV", "CMXVI", "CMXVII", "CMXVIII", "CMXIX", "CMXX", "CMXXI", "CMXXII", "CMXXIII", "CMXXIV", "CMXXV", "CMXXVI", "CMXXVII", "CMXXVIII", "CMXXIX", "CMXXX", "CMXXXI", "CMXXXII", "CMXXXIII", "CMXXXIV", "CMXXXV", "CMXXXVI", "CMXXXVII", "CMXXXVIII", "CMXXXIX", "CMXL", "CMXLI", "CMXLII", "CMXLIII", "CMXLIV", "CMXLV", "CMXLVI", "CMXLVII", "CMXLVIII", "CMXLIX", "CML", "CMLI", "CMLII", "CMLIII", "CMLIV", "CMLV", "CMLVI", "CMLVII", "CMLVIII", "CMLIX", "CMLX", "CMLXI", "CMLXII", "CMLXIII", "CMLXIV", "CMLXV", "CMLXVI", "CMLXVII", "CMLXVIII", "CMLXIX", "CMLXX", "CMLXXI", "CMLXXII", "CMLXXIII", "CMLXXIV", "CMLXXV", "CMLXXVI", "CMLXXVII", "CMLXXVIII", "CMLXXIX", "CMLXXX", "CMLXXXI", "CMLXXXII", "CMLXXXIII", "CMLXXXIV", "CMLXXXV", "CMLXXXVI", "CMLXXXVII", "CMLXXXVIII", "CMLXXXIX", "CMXC", "CMXCI", "CMXCII", "CMXCIII", "CMXCIV", "CMXCV", "CMXCVI", "CMXCVII", "CMXCVIII", "CMXCIX", "M", "MI", "MII", "MIII", "MIV", "MV", "MVI", "MVII", "MVIII", "MIX", "MX", "MXI", "MXII", "MXIII", "MXIV", "MXV", "MXVI", "MXVII", "MXVIII", "MXIX", "MXX", "MXXI", "MXXII", "MXXIII", "MXXIV", "MXXV", "MXXVI", "MXXVII", "MXXVIII", "MXXIX", "MXXX", "MXXXI", "MXXXII", "MXXXIII", "MXXXIV", "MXXXV", "MXXXVI", "MXXXVII", "MXXXVIII", "MXXXIX", "MXL", "MXLI", "MXLII", "MXLIII", "MXLIV", "MXLV", "MXLVI", "MXLVII", "MXLVIII", "MXLIX", "ML", "MLI", "MLII", "MLIII", "MLIV", "MLV", "MLVI", "MLVII", "MLVIII", "MLIX", "MLX", "MLXI", "MLXII", "MLXIII", "MLXIV", "MLXV", "MLXVI", "MLXVII", "MLXVIII", "MLXIX", "MLXX", "MLXXI", "MLXXII", "MLXXIII", "MLXXIV", "MLXXV", "MLXXVI", "MLXXVII", "MLXXVIII", "MLXXIX", "MLXXX", "MLXXXI", "MLXXXII", "MLXXXIII", "MLXXXIV", "MLXXXV", "MLXXXVI", "MLXXXVII", "MLXXXVIII", "MLXXXIX", "MXC", "MXCI", "MXCII", "MXCIII", "MXCIV", "MXCV", "MXCVI", "MXCVII", "MXCVIII", "MXCIX", "MC", "MCI", "MCII", "MCIII", "MCIV", "MCV", "MCVI", "MCVII", "MCVIII", "MCIX", "MCX", "MCXI", "MCXII", "MCXIII", "MCXIV", "MCXV", "MCXVI", "MCXVII", "MCXVIII", "MCXIX", "MCXX", "MCXXI", "MCXXII", "MCXXIII", "MCXXIV", "MCXXV", "MCXXVI", "MCXXVII", "MCXXVIII", "MCXXIX", "MCXXX", "MCXXXI", "MCXXXII", "MCXXXIII", "MCXXXIV", "MCXXXV", "MCXXXVI", "MCXXXVII", "MCXXXVIII", "MCXXXIX", "MCXL", "MCXLI", "MCXLII", "MCXLIII", "MCXLIV", "MCXLV", "MCXLVI", "MCXLVII", "MCXLVIII", "MCXLIX", "MCL", "MCLI", "MCLII", "MCLIII", "MCLIV", "MCLV", "MCLVI", "MCLVII", "MCLVIII", "MCLIX", "MCLX", "MCLXI", "MCLXII", "MCLXIII", "MCLXIV", "MCLXV", "MCLXVI", "MCLXVII", "MCLXVIII", "MCLXIX", "MCLXX", "MCLXXI", "MCLXXII", "MCLXXIII", "MCLXXIV", "MCLXXV", "MCLXXVI", "MCLXXVII", "MCLXXVIII", "MCLXXIX", "MCLXXX", "MCLXXXI", "MCLXXXII", "MCLXXXIII", "MCLXXXIV", "MCLXXXV", "MCLXXXVI", "MCLXXXVII", "MCLXXXVIII", "MCLXXXIX", "MCXC", "MCXCI", "MCXCII", "MCXCIII", "MCXCIV", "MCXCV", "MCXCVI", "MCXCVII", "MCXCVIII", "MCXCIX", "MCC", "MCCI", "MCCII", "MCCIII", "MCCIV", "MCCV", "MCCVI", "MCCVII", "MCCVIII", "MCCIX", "MCCX", "MCCXI", "MCCXII", "MCCXIII", "MCCXIV", "MCCXV", "MCCXVI", "MCCXVII", "MCCXVIII", "MCCXIX", "MCCXX", "MCCXXI", "MCCXXII", "MCCXXIII", "MCCXXIV", "MCCXXV", "MCCXXVI", "MCCXXVII", "MCCXXVIII", "MCCXXIX", "MCCXXX", "MCCXXXI", "MCCXXXII", "MCCXXXIII", "MCCXXXIV", "MCCXXXV", "MCCXXXVI", "MCCXXXVII", "MCCXXXVIII", "MCCXXXIX", "MCCXL", "MCCXLI", "MCCXLII", "MCCXLIII", "MCCXLIV", "MCCXLV", "MCCXLVI", "MCCXLVII", "MCCXLVIII", "MCCXLIX", "MCCL", "MCCLI", "MCCLII", "MCCLIII", "MCCLIV", "MCCLV", "MCCLVI", "MCCLVII", "MCCLVIII", "MCCLIX", "MCCLX", "MCCLXI", "MCCLXII", "MCCLXIII", "MCCLXIV", "MCCLXV", "MCCLXVI", "MCCLXVII", "MCCLXVIII", "MCCLXIX", "MCCLXX", "MCCLXXI", "MCCLXXII", "MCCLXXIII", "MCCLXXIV", "MCCLXXV", "MCCLXXVI", "MCCLXXVII", "MCCLXXVIII", "MCCLXXIX", "MCCLXXX", "MCCLXXXI", "MCCLXXXII", "MCCLXXXIII", "MCCLXXXIV", "MCCLXXXV", "MCCLXXXVI", "MCCLXXXVII", "MCCLXXXVIII", "MCCLXXXIX", "MCCXC", "MCCXCI", "MCCXCII", "MCCXCIII", "MCCXCIV", "MCCXCV", "MCCXCVI", "MCCXCVII", "MCCXCVIII", "MCCXCIX", "MCCC", "MCCCI", "MCCCII", "MCCCIII", "MCCCIV", "MCCCV", "MCCCVI", "MCCCVII", "MCCCVIII", "MCCCIX", "MCCCX", "MCCCXI", "MCCCXII", "MCCCXIII", "MCCCXIV", "MCCCXV", "MCCCXVI", "MCCCXVII", "MCCCXVIII", "MCCCXIX", "MCCCXX", "MCCCXXI", "MCCCXXII", "MCCCXXIII", "MCCCXXIV", "MCCCXXV", "MCCCXXVI", "MCCCXXVII", "MCCCXXVIII", "MCCCXXIX", "MCCCXXX", "MCCCXXXI", "MCCCXXXII", "MCCCXXXIII", "MCCCXXXIV", "MCCCXXXV", "MCCCXXXVI", "MCCCXXXVII", "MCCCXXXVIII", "MCCCXXXIX", "MCCCXL", "MCCCXLI", "MCCCXLII", "MCCCXLIII", "MCCCXLIV", "MCCCXLV", "MCCCXLVI", "MCCCXLVII", "MCCCXLVIII", "MCCCXLIX", "MCCCL", "MCCCLI", "MCCCLII", "MCCCLIII", "MCCCLIV", "MCCCLV", "MCCCLVI", "MCCCLVII", "MCCCLVIII", "MCCCLIX", "MCCCLX", "MCCCLXI", "MCCCLXII", "MCCCLXIII", "MCCCLXIV", "MCCCLXV", "MCCCLXVI", "MCCCLXVII", "MCCCLXVIII", "MCCCLXIX", "MCCCLXX", "MCCCLXXI", "MCCCLXXII", "MCCCLXXIII", "MCCCLXXIV", "MCCCLXXV", "MCCCLXXVI", "MCCCLXXVII", "MCCCLXXVIII", "MCCCLXXIX", "MCCCLXXX", "MCCCLXXXI", "MCCCLXXXII", "MCCCLXXXIII", "MCCCLXXXIV", "MCCCLXXXV", "MCCCLXXXVI", "MCCCLXXXVII", "MCCCLXXXVIII", "MCCCLXXXIX", "MCCCXC", "MCCCXCI", "MCCCXCII", "MCCCXCIII", "MCCCXCIV", "MCCCXCV", "MCCCXCVI", "MCCCXCVII", "MCCCXCVIII", "MCCCXCIX", "MCD", "MCDI", "MCDII", "MCDIII", "MCDIV", "MCDV", "MCDVI", "MCDVII", "MCDVIII", "MCDIX", "MCDX", "MCDXI", "MCDXII", "MCDXIII", "MCDXIV", "MCDXV", "MCDXVI", "MCDXVII", "MCDXVIII", "MCDXIX", "MCDXX", "MCDXXI", "MCDXXII", "MCDXXIII", "MCDXXIV", "MCDXXV", "MCDXXVI", "MCDXXVII", "MCDXXVIII", "MCDXXIX", "MCDXXX", "MCDXXXI", "MCDXXXII", "MCDXXXIII", "MCDXXXIV", "MCDXXXV", "MCDXXXVI", "MCDXXXVII", "MCDXXXVIII", "MCDXXXIX", "MCDXL", "MCDXLI", "MCDXLII", "MCDXLIII", "MCDXLIV", "MCDXLV", "MCDXLVI", "MCDXLVII", "MCDXLVIII", "MCDXLIX", "MCDL", "MCDLI", "MCDLII", "MCDLIII", "MCDLIV", "MCDLV", "MCDLVI", "MCDLVII", "MCDLVIII", "MCDLIX", "MCDLX", "MCDLXI", "MCDLXII", "MCDLXIII", "MCDLXIV", "MCDLXV", "MCDLXVI", "MCDLXVII", "MCDLXVIII", "MCDLXIX", "MCDLXX", "MCDLXXI", "MCDLXXII", "MCDLXXIII", "MCDLXXIV", "MCDLXXV", "MCDLXXVI", "MCDLXXVII", "MCDLXXVIII", "MCDLXXIX", "MCDLXXX", "MCDLXXXI", "MCDLXXXII", "MCDLXXXIII", "MCDLXXXIV", "MCDLXXXV", "MCDLXXXVI", "MCDLXXXVII", "MCDLXXXVIII", "MCDLXXXIX", "MCDXC", "MCDXCI", "MCDXCII", "MCDXCIII", "MCDXCIV", "MCDXCV", "MCDXCVI", "MCDXCVII", "MCDXCVIII", "MCDXCIX", "MD", "MDI", "MDII", "MDIII", "MDIV", "MDV", "MDVI", "MDVII", "MDVIII", "MDIX", "MDX", "MDXI", "MDXII", "MDXIII", "MDXIV", "MDXV", "MDXVI", "MDXVII", "MDXVIII", "MDXIX", "MDXX", "MDXXI", "MDXXII", "MDXXIII", "MDXXIV", "MDXXV", "MDXXVI", "MDXXVII", "MDXXVIII", "MDXXIX", "MDXXX", "MDXXXI", "MDXXXII", "MDXXXIII", "MDXXXIV", "MDXXXV", "MDXXXVI", "MDXXXVII", "MDXXXVIII", "MDXXXIX", "MDXL", "MDXLI", "MDXLII", "MDXLIII", "MDXLIV", "MDXLV", "MDXLVI", "MDXLVII", "MDXLVIII", "MDXLIX", "MDL", "MDLI", "MDLII", "MDLIII", "MDLIV", "MDLV", "MDLVI", "MDLVII", "MDLVIII", "MDLIX", "MDLX", "MDLXI", "MDLXII", "MDLXIII", "MDLXIV", "MDLXV", "MDLXVI", "MDLXVII", "MDLXVIII", "MDLXIX", "MDLXX", "MDLXXI", "MDLXXII", "MDLXXIII", "MDLXXIV", "MDLXXV", "MDLXXVI", "MDLXXVII", "MDLXXVIII", "MDLXXIX", "MDLXXX", "MDLXXXI", "MDLXXXII", "MDLXXXIII", "MDLXXXIV", "MDLXXXV", "MDLXXXVI", "MDLXXXVII", "MDLXXXVIII", "MDLXXXIX", "MDXC", "MDXCI", "MDXCII", "MDXCIII", "MDXCIV", "MDXCV", "MDXCVI", "MDXCVII", "MDXCVIII", "MDXCIX", "MDC", "MDCI", "MDCII", "MDCIII", "MDCIV", "MDCV", "MDCVI", "MDCVII", "MDCVIII", "MDCIX", "MDCX", "MDCXI", "MDCXII", "MDCXIII", "MDCXIV", "MDCXV", "MDCXVI", "MDCXVII", "MDCXVIII", "MDCXIX", "MDCXX", "MDCXXI", "MDCXXII", "MDCXXIII", "MDCXXIV", "MDCXXV", "MDCXXVI", "MDCXXVII", "MDCXXVIII", "MDCXXIX", "MDCXXX", "MDCXXXI", "MDCXXXII", "MDCXXXIII", "MDCXXXIV", "MDCXXXV", "MDCXXXVI", "MDCXXXVII", "MDCXXXVIII", "MDCXXXIX", "MDCXL", "MDCXLI", "MDCXLII", "MDCXLIII", "MDCXLIV", "MDCXLV", "MDCXLVI", "MDCXLVII", "MDCXLVIII", "MDCXLIX", "MDCL", "MDCLI", "MDCLII", "MDCLIII", "MDCLIV", "MDCLV", "MDCLVI", "MDCLVII", "MDCLVIII", "MDCLIX", "MDCLX", "MDCLXI", "MDCLXII", "MDCLXIII", "MDCLXIV", "MDCLXV", "MDCLXVI", "MDCLXVII", "MDCLXVIII", "MDCLXIX", "MDCLXX", "MDCLXXI", "MDCLXXII", "MDCLXXIII", "MDCLXXIV", "MDCLXXV", "MDCLXXVI", "MDCLXXVII", "MDCLXXVIII", "MDCLXXIX", "MDCLXXX", "MDCLXXXI", "MDCLXXXII", "MDCLXXXIII", "MDCLXXXIV", "MDCLXXXV", "MDCLXXXVI", "MDCLXXXVII", "MDCLXXXVIII", "MDCLXXXIX", "MDCXC", "MDCXCI", "MDCXCII", "MDCXCIII", "MDCXCIV", "MDCXCV", "MDCXCVI", "MDCXCVII", "MDCXCVIII", "MDCXCIX", "MDCC", "MDCCI", "MDCCII", "MDCCIII", "MDCCIV", "MDCCV", "MDCCVI", "MDCCVII", "MDCCVIII", "MDCCIX", "MDCCX", "MDCCXI", "MDCCXII", "MDCCXIII", "MDCCXIV", "MDCCXV", "MDCCXVI", "MDCCXVII", "MDCCXVIII", "MDCCXIX", "MDCCXX", "MDCCXXI", "MDCCXXII", "MDCCXXIII", "MDCCXXIV", "MDCCXXV", "MDCCXXVI", "MDCCXXVII", "MDCCXXVIII", "MDCCXXIX", "MDCCXXX", "MDCCXXXI", "MDCCXXXII", "MDCCXXXIII", "MDCCXXXIV", "MDCCXXXV", "MDCCXXXVI", "MDCCXXXVII", "MDCCXXXVIII", "MDCCXXXIX", "MDCCXL", "MDCCXLI", "MDCCXLII", "MDCCXLIII", "MDCCXLIV", "MDCCXLV", "MDCCXLVI", "MDCCXLVII", "MDCCXLVIII", "MDCCXLIX", "MDCCL", "MDCCLI", "MDCCLII", "MDCCLIII", "MDCCLIV", "MDCCLV", "MDCCLVI", "MDCCLVII", "MDCCLVIII", "MDCCLIX", "MDCCLX", "MDCCLXI", "MDCCLXII", "MDCCLXIII", "MDCCLXIV", "MDCCLXV", "MDCCLXVI", "MDCCLXVII", "MDCCLXVIII", "MDCCLXIX", "MDCCLXX", "MDCCLXXI", "MDCCLXXII", "MDCCLXXIII", "MDCCLXXIV", "MDCCLXXV", "MDCCLXXVI", "MDCCLXXVII", "MDCCLXXVIII", "MDCCLXXIX", "MDCCLXXX", "MDCCLXXXI", "MDCCLXXXII", "MDCCLXXXIII", "MDCCLXXXIV", "MDCCLXXXV", "MDCCLXXXVI", "MDCCLXXXVII", "MDCCLXXXVIII", "MDCCLXXXIX", "MDCCXC", "MDCCXCI", "MDCCXCII", "MDCCXCIII", "MDCCXCIV", "MDCCXCV", "MDCCXCVI", "MDCCXCVII", "MDCCXCVIII", "MDCCXCIX", "MDCCC", "MDCCCI", "MDCCCII", "MDCCCIII", "MDCCCIV", "MDCCCV", "MDCCCVI", "MDCCCVII", "MDCCCVIII", "MDCCCIX", "MDCCCX", "MDCCCXI", "MDCCCXII", "MDCCCXIII", "MDCCCXIV", "MDCCCXV", "MDCCCXVI", "MDCCCXVII", "MDCCCXVIII", "MDCCCXIX", "MDCCCXX", "MDCCCXXI", "MDCCCXXII", "MDCCCXXIII", "MDCCCXXIV", "MDCCCXXV", "MDCCCXXVI", "MDCCCXXVII", "MDCCCXXVIII", "MDCCCXXIX", "MDCCCXXX", "MDCCCXXXI", "MDCCCXXXII", "MDCCCXXXIII", "MDCCCXXXIV", "MDCCCXXXV", "MDCCCXXXVI", "MDCCCXXXVII", "MDCCCXXXVIII", "MDCCCXXXIX", "MDCCCXL", "MDCCCXLI", "MDCCCXLII", "MDCCCXLIII", "MDCCCXLIV", "MDCCCXLV", "MDCCCXLVI", "MDCCCXLVII", "MDCCCXLVIII", "MDCCCXLIX", "MDCCCL", "MDCCCLI", "MDCCCLII", "MDCCCLIII", "MDCCCLIV", "MDCCCLV", "MDCCCLVI", "MDCCCLVII", "MDCCCLVIII", "MDCCCLIX", "MDCCCLX", "MDCCCLXI", "MDCCCLXII", "MDCCCLXIII", "MDCCCLXIV", "MDCCCLXV", "MDCCCLXVI", "MDCCCLXVII", "MDCCCLXVIII", "MDCCCLXIX", "MDCCCLXX", "MDCCCLXXI", "MDCCCLXXII", "MDCCCLXXIII", "MDCCCLXXIV", "MDCCCLXXV", "MDCCCLXXVI", "MDCCCLXXVII", "MDCCCLXXVIII", "MDCCCLXXIX", "MDCCCLXXX", "MDCCCLXXXI", "MDCCCLXXXII", "MDCCCLXXXIII", "MDCCCLXXXIV", "MDCCCLXXXV", "MDCCCLXXXVI", "MDCCCLXXXVII", "MDCCCLXXXVIII", "MDCCCLXXXIX", "MDCCCXC", "MDCCCXCI", "MDCCCXCII", "MDCCCXCIII", "MDCCCXCIV", "MDCCCXCV", "MDCCCXCVI", "MDCCCXCVII", "MDCCCXCVIII", "MDCCCXCIX", "MCM", "MCMI", "MCMII", "MCMIII", "MCMIV", "MCMV", "MCMVI", "MCMVII", "MCMVIII", "MCMIX", "MCMX", "MCMXI", "MCMXII", "MCMXIII", "MCMXIV", "MCMXV", "MCMXVI", "MCMXVII", "MCMXVIII", "MCMXIX", "MCMXX", "MCMXXI", "MCMXXII", "MCMXXIII", "MCMXXIV", "MCMXXV", "MCMXXVI", "MCMXXVII", "MCMXXVIII", "MCMXXIX", "MCMXXX", "MCMXXXI", "MCMXXXII", "MCMXXXIII", "MCMXXXIV", "MCMXXXV", "MCMXXXVI", "MCMXXXVII", "MCMXXXVIII", "MCMXXXIX", "MCMXL", "MCMXLI", "MCMXLII", "MCMXLIII", "MCMXLIV", "MCMXLV", "MCMXLVI", "MCMXLVII", "MCMXLVIII", "MCMXLIX", "MCML", "MCMLI", "MCMLII", "MCMLIII", "MCMLIV", "MCMLV", "MCMLVI", "MCMLVII", "MCMLVIII", "MCMLIX", "MCMLX", "MCMLXI", "MCMLXII", "MCMLXIII", "MCMLXIV", "MCMLXV", "MCMLXVI", "MCMLXVII", "MCMLXVIII", "MCMLXIX", "MCMLXX", "MCMLXXI", "MCMLXXII", "MCMLXXIII", "MCMLXXIV", "MCMLXXV", "MCMLXXVI", "MCMLXXVII", "MCMLXXVIII", "MCMLXXIX", "MCMLXXX", "MCMLXXXI", "MCMLXXXII", "MCMLXXXIII", "MCMLXXXIV", "MCMLXXXV", "MCMLXXXVI", "MCMLXXXVII", "MCMLXXXVIII", "MCMLXXXIX", "MCMXC", "MCMXCI", "MCMXCII", "MCMXCIII", "MCMXCIV", "MCMXCV", "MCMXCVI", "MCMXCVII", "MCMXCVIII", "MCMXCIX", "MM", "MMI", "MMII", "MMIII", "MMIV", "MMV", "MMVI", "MMVII", "MMVIII", "MMIX", "MMX", "MMXI", "MMXII", "MMXIII", "MMXIV", "MMXV", "MMXVI", "MMXVII", "MMXVIII", "MMXIX", "MMXX", "MMXXI", "MMXXII", "MMXXIII", "MMXXIV", "MMXXV", "MMXXVI", "MMXXVII", "MMXXVIII", "MMXXIX", "MMXXX", "MMXXXI", "MMXXXII", "MMXXXIII", "MMXXXIV", "MMXXXV", "MMXXXVI", "MMXXXVII", "MMXXXVIII", "MMXXXIX", "MMXL", "MMXLI", "MMXLII", "MMXLIII", "MMXLIV", "MMXLV", "MMXLVI", "MMXLVII", "MMXLVIII", "MMXLIX", "MML", "MMLI", "MMLII", "MMLIII", "MMLIV", "MMLV", "MMLVI", "MMLVII", "MMLVIII", "MMLIX", "MMLX", "MMLXI", "MMLXII", "MMLXIII", "MMLXIV", "MMLXV", "MMLXVI", "MMLXVII", "MMLXVIII", "MMLXIX", "MMLXX", "MMLXXI", "MMLXXII", "MMLXXIII", "MMLXXIV", "MMLXXV", "MMLXXVI", "MMLXXVII", "MMLXXVIII", "MMLXXIX", "MMLXXX", "MMLXXXI", "MMLXXXII", "MMLXXXIII", "MMLXXXIV", "MMLXXXV", "MMLXXXVI", "MMLXXXVII", "MMLXXXVIII", "MMLXXXIX", "MMXC", "MMXCI", "MMXCII", "MMXCIII", "MMXCIV", "MMXCV", "MMXCVI", "MMXCVII", "MMXCVIII", "MMXCIX", "MMC", "MMCI", "MMCII", "MMCIII", "MMCIV", "MMCV", "MMCVI", "MMCVII", "MMCVIII", "MMCIX", "MMCX", "MMCXI", "MMCXII", "MMCXIII", "MMCXIV", "MMCXV", "MMCXVI", "MMCXVII", "MMCXVIII", "MMCXIX", "MMCXX", "MMCXXI", "MMCXXII", "MMCXXIII", "MMCXXIV", "MMCXXV", "MMCXXVI", "MMCXXVII", "MMCXXVIII", "MMCXXIX", "MMCXXX", "MMCXXXI", "MMCXXXII", "MMCXXXIII", "MMCXXXIV", "MMCXXXV", "MMCXXXVI", "MMCXXXVII", "MMCXXXVIII", "MMCXXXIX", "MMCXL", "MMCXLI", "MMCXLII", "MMCXLIII", "MMCXLIV", "MMCXLV", "MMCXLVI", "MMCXLVII", "MMCXLVIII", "MMCXLIX", "MMCL", "MMCLI", "MMCLII", "MMCLIII", "MMCLIV", "MMCLV", "MMCLVI", "MMCLVII", "MMCLVIII", "MMCLIX", "MMCLX", "MMCLXI", "MMCLXII", "MMCLXIII", "MMCLXIV", "MMCLXV", "MMCLXVI", "MMCLXVII", "MMCLXVIII", "MMCLXIX", "MMCLXX", "MMCLXXI", "MMCLXXII", "MMCLXXIII", "MMCLXXIV", "MMCLXXV", "MMCLXXVI", "MMCLXXVII", "MMCLXXVIII", "MMCLXXIX", "MMCLXXX", "MMCLXXXI", "MMCLXXXII", "MMCLXXXIII", "MMCLXXXIV", "MMCLXXXV", "MMCLXXXVI", "MMCLXXXVII", "MMCLXXXVIII", "MMCLXXXIX", "MMCXC", "MMCXCI", "MMCXCII", "MMCXCIII", "MMCXCIV", "MMCXCV", "MMCXCVI", "MMCXCVII", "MMCXCVIII", "MMCXCIX", "MMCC", "MMCCI", "MMCCII", "MMCCIII", "MMCCIV", "MMCCV", "MMCCVI", "MMCCVII", "MMCCVIII", "MMCCIX", "MMCCX", "MMCCXI", "MMCCXII", "MMCCXIII", "MMCCXIV", "MMCCXV", "MMCCXVI", "MMCCXVII", "MMCCXVIII", "MMCCXIX", "MMCCXX", "MMCCXXI", "MMCCXXII", "MMCCXXIII", "MMCCXXIV", "MMCCXXV", "MMCCXXVI", "MMCCXXVII", "MMCCXXVIII", "MMCCXXIX", "MMCCXXX", "MMCCXXXI", "MMCCXXXII", "MMCCXXXIII", "MMCCXXXIV", "MMCCXXXV", "MMCCXXXVI", "MMCCXXXVII", "MMCCXXXVIII", "MMCCXXXIX", "MMCCXL", "MMCCXLI", "MMCCXLII", "MMCCXLIII", "MMCCXLIV", "MMCCXLV", "MMCCXLVI", "MMCCXLVII", "MMCCXLVIII", "MMCCXLIX", "MMCCL", "MMCCLI", "MMCCLII", "MMCCLIII", "MMCCLIV", "MMCCLV", "MMCCLVI", "MMCCLVII", "MMCCLVIII", "MMCCLIX", "MMCCLX", "MMCCLXI", "MMCCLXII", "MMCCLXIII", "MMCCLXIV", "MMCCLXV", "MMCCLXVI", "MMCCLXVII", "MMCCLXVIII", "MMCCLXIX", "MMCCLXX", "MMCCLXXI", "MMCCLXXII", "MMCCLXXIII", "MMCCLXXIV", "MMCCLXXV", "MMCCLXXVI", "MMCCLXXVII", "MMCCLXXVIII", "MMCCLXXIX", "MMCCLXXX", "MMCCLXXXI", "MMCCLXXXII", "MMCCLXXXIII", "MMCCLXXXIV", "MMCCLXXXV", "MMCCLXXXVI", "MMCCLXXXVII", "MMCCLXXXVIII", "MMCCLXXXIX", "MMCCXC", "MMCCXCI", "MMCCXCII", "MMCCXCIII", "MMCCXCIV", "MMCCXCV", "MMCCXCVI", "MMCCXCVII", "MMCCXCVIII", "MMCCXCIX", "MMCCC", "MMCCCI", "MMCCCII", "MMCCCIII", "MMCCCIV", "MMCCCV", "MMCCCVI", "MMCCCVII", "MMCCCVIII", "MMCCCIX", "MMCCCX", "MMCCCXI", "MMCCCXII", "MMCCCXIII", "MMCCCXIV", "MMCCCXV", "MMCCCXVI", "MMCCCXVII", "MMCCCXVIII", "MMCCCXIX", "MMCCCXX", "MMCCCXXI", "MMCCCXXII", "MMCCCXXIII", "MMCCCXXIV", "MMCCCXXV", "MMCCCXXVI", "MMCCCXXVII", "MMCCCXXVIII", "MMCCCXXIX", "MMCCCXXX", "MMCCCXXXI", "MMCCCXXXII", "MMCCCXXXIII", "MMCCCXXXIV", "MMCCCXXXV", "MMCCCXXXVI", "MMCCCXXXVII", "MMCCCXXXVIII", "MMCCCXXXIX", "MMCCCXL", "MMCCCXLI", "MMCCCXLII", "MMCCCXLIII", "MMCCCXLIV", "MMCCCXLV", "MMCCCXLVI", "MMCCCXLVII", "MMCCCXLVIII", "MMCCCXLIX", "MMCCCL", "MMCCCLI", "MMCCCLII", "MMCCCLIII", "MMCCCLIV", "MMCCCLV", "MMCCCLVI", "MMCCCLVII", "MMCCCLVIII", "MMCCCLIX", "MMCCCLX", "MMCCCLXI", "MMCCCLXII", "MMCCCLXIII", "MMCCCLXIV", "MMCCCLXV", "MMCCCLXVI", "MMCCCLXVII", "MMCCCLXVIII", "MMCCCLXIX", "MMCCCLXX", "MMCCCLXXI", "MMCCCLXXII", "MMCCCLXXIII", "MMCCCLXXIV", "MMCCCLXXV", "MMCCCLXXVI", "MMCCCLXXVII", "MMCCCLXXVIII", "MMCCCLXXIX", "MMCCCLXXX", "MMCCCLXXXI", "MMCCCLXXXII", "MMCCCLXXXIII", "MMCCCLXXXIV", "MMCCCLXXXV", "MMCCCLXXXVI", "MMCCCLXXXVII", "MMCCCLXXXVIII", "MMCCCLXXXIX", "MMCCCXC", "MMCCCXCI", "MMCCCXCII", "MMCCCXCIII", "MMCCCXCIV", "MMCCCXCV", "MMCCCXCVI", "MMCCCXCVII", "MMCCCXCVIII", "MMCCCXCIX", "MMCD", "MMCDI", "MMCDII", "MMCDIII", "MMCDIV", "MMCDV", "MMCDVI", "MMCDVII", "MMCDVIII", "MMCDIX", "MMCDX", "MMCDXI", "MMCDXII", "MMCDXIII", "MMCDXIV", "MMCDXV", "MMCDXVI", "MMCDXVII", "MMCDXVIII", "MMCDXIX", "MMCDXX", "MMCDXXI", "MMCDXXII", "MMCDXXIII", "MMCDXXIV", "MMCDXXV", "MMCDXXVI", "MMCDXXVII", "MMCDXXVIII", "MMCDXXIX", "MMCDXXX", "MMCDXXXI", "MMCDXXXII", "MMCDXXXIII", "MMCDXXXIV", "MMCDXXXV", "MMCDXXXVI", "MMCDXXXVII", "MMCDXXXVIII", "MMCDXXXIX", "MMCDXL", "MMCDXLI", "MMCDXLII", "MMCDXLIII", "MMCDXLIV", "MMCDXLV", "MMCDXLVI", "MMCDXLVII", "MMCDXLVIII", "MMCDXLIX", "MMCDL", "MMCDLI", "MMCDLII", "MMCDLIII", "MMCDLIV", "MMCDLV", "MMCDLVI", "MMCDLVII", "MMCDLVIII", "MMCDLIX", "MMCDLX", "MMCDLXI", "MMCDLXII", "MMCDLXIII", "MMCDLXIV", "MMCDLXV", "MMCDLXVI", "MMCDLXVII", "MMCDLXVIII", "MMCDLXIX", "MMCDLXX", "MMCDLXXI", "MMCDLXXII", "MMCDLXXIII", "MMCDLXXIV", "MMCDLXXV", "MMCDLXXVI", "MMCDLXXVII", "MMCDLXXVIII", "MMCDLXXIX", "MMCDLXXX", "MMCDLXXXI", "MMCDLXXXII", "MMCDLXXXIII", "MMCDLXXXIV", "MMCDLXXXV", "MMCDLXXXVI", "MMCDLXXXVII", "MMCDLXXXVIII", "MMCDLXXXIX", "MMCDXC", "MMCDXCI", "MMCDXCII", "MMCDXCIII", "MMCDXCIV", "MMCDXCV", "MMCDXCVI", "MMCDXCVII", "MMCDXCVIII", "MMCDXCIX", "MMD", "MMDI", "MMDII", "MMDIII", "MMDIV", "MMDV", "MMDVI", "MMDVII", "MMDVIII", "MMDIX", "MMDX", "MMDXI", "MMDXII", "MMDXIII", "MMDXIV", "MMDXV", "MMDXVI", "MMDXVII", "MMDXVIII", "MMDXIX", "MMDXX", "MMDXXI", "MMDXXII", "MMDXXIII", "MMDXXIV", "MMDXXV", "MMDXXVI", "MMDXXVII", "MMDXXVIII", "MMDXXIX", "MMDXXX", "MMDXXXI", "MMDXXXII", "MMDXXXIII", "MMDXXXIV", "MMDXXXV", "MMDXXXVI", "MMDXXXVII", "MMDXXXVIII", "MMDXXXIX", "MMDXL", "MMDXLI", "MMDXLII", "MMDXLIII", "MMDXLIV", "MMDXLV", "MMDXLVI", "MMDXLVII", "MMDXLVIII", "MMDXLIX", "MMDL", "MMDLI", "MMDLII", "MMDLIII", "MMDLIV", "MMDLV", "MMDLVI", "MMDLVII", "MMDLVIII", "MMDLIX", "MMDLX", "MMDLXI", "MMDLXII", "MMDLXIII", "MMDLXIV", "MMDLXV", "MMDLXVI", "MMDLXVII", "MMDLXVIII", "MMDLXIX", "MMDLXX", "MMDLXXI", "MMDLXXII", "MMDLXXIII", "MMDLXXIV", "MMDLXXV", "MMDLXXVI", "MMDLXXVII", "MMDLXXVIII", "MMDLXXIX", "MMDLXXX", "MMDLXXXI", "MMDLXXXII", "MMDLXXXIII", "MMDLXXXIV", "MMDLXXXV", "MMDLXXXVI", "MMDLXXXVII", "MMDLXXXVIII", "MMDLXXXIX", "MMDXC", "MMDXCI", "MMDXCII", "MMDXCIII", "MMDXCIV", "MMDXCV", "MMDXCVI", "MMDXCVII", "MMDXCVIII", "MMDXCIX", "MMDC", "MMDCI", "MMDCII", "MMDCIII", "MMDCIV", "MMDCV", "MMDCVI", "MMDCVII", "MMDCVIII", "MMDCIX", "MMDCX", "MMDCXI", "MMDCXII", "MMDCXIII", "MMDCXIV", "MMDCXV", "MMDCXVI", "MMDCXVII", "MMDCXVIII", "MMDCXIX", "MMDCXX", "MMDCXXI", "MMDCXXII", "MMDCXXIII", "MMDCXXIV", "MMDCXXV", "MMDCXXVI", "MMDCXXVII", "MMDCXXVIII", "MMDCXXIX", "MMDCXXX", "MMDCXXXI", "MMDCXXXII", "MMDCXXXIII", "MMDCXXXIV", "MMDCXXXV", "MMDCXXXVI", "MMDCXXXVII", "MMDCXXXVIII", "MMDCXXXIX", "MMDCXL", "MMDCXLI", "MMDCXLII", "MMDCXLIII", "MMDCXLIV", "MMDCXLV", "MMDCXLVI", "MMDCXLVII", "MMDCXLVIII", "MMDCXLIX", "MMDCL", "MMDCLI", "MMDCLII", "MMDCLIII", "MMDCLIV", "MMDCLV", "MMDCLVI", "MMDCLVII", "MMDCLVIII", "MMDCLIX", "MMDCLX", "MMDCLXI", "MMDCLXII", "MMDCLXIII", "MMDCLXIV", "MMDCLXV", "MMDCLXVI", "MMDCLXVII", "MMDCLXVIII", "MMDCLXIX", "MMDCLXX", "MMDCLXXI", "MMDCLXXII", "MMDCLXXIII", "MMDCLXXIV", "MMDCLXXV", "MMDCLXXVI", "MMDCLXXVII", "MMDCLXXVIII", "MMDCLXXIX", "MMDCLXXX", "MMDCLXXXI", "MMDCLXXXII", "MMDCLXXXIII", "MMDCLXXXIV", "MMDCLXXXV", "MMDCLXXXVI", "MMDCLXXXVII", "MMDCLXXXVIII", "MMDCLXXXIX", "MMDCXC", "MMDCXCI", "MMDCXCII", "MMDCXCIII", "MMDCXCIV", "MMDCXCV", "MMDCXCVI", "MMDCXCVII", "MMDCXCVIII", "MMDCXCIX", "MMDCC", "MMDCCI", "MMDCCII", "MMDCCIII", "MMDCCIV", "MMDCCV", "MMDCCVI", "MMDCCVII", "MMDCCVIII", "MMDCCIX", "MMDCCX", "MMDCCXI", "MMDCCXII", "MMDCCXIII", "MMDCCXIV", "MMDCCXV", "MMDCCXVI", "MMDCCXVII", "MMDCCXVIII", "MMDCCXIX", "MMDCCXX", "MMDCCXXI", "MMDCCXXII", "MMDCCXXIII", "MMDCCXXIV", "MMDCCXXV", "MMDCCXXVI", "MMDCCXXVII", "MMDCCXXVIII", "MMDCCXXIX", "MMDCCXXX", "MMDCCXXXI", "MMDCCXXXII", "MMDCCXXXIII", "MMDCCXXXIV", "MMDCCXXXV", "MMDCCXXXVI", "MMDCCXXXVII", "MMDCCXXXVIII", "MMDCCXXXIX", "MMDCCXL", "MMDCCXLI", "MMDCCXLII", "MMDCCXLIII", "MMDCCXLIV", "MMDCCXLV", "MMDCCXLVI", "MMDCCXLVII", "MMDCCXLVIII", "MMDCCXLIX", "MMDCCL", "MMDCCLI", "MMDCCLII", "MMDCCLIII", "MMDCCLIV", "MMDCCLV", "MMDCCLVI", "MMDCCLVII", "MMDCCLVIII", "MMDCCLIX", "MMDCCLX", "MMDCCLXI", "MMDCCLXII", "MMDCCLXIII", "MMDCCLXIV", "MMDCCLXV", "MMDCCLXVI", "MMDCCLXVII", "MMDCCLXVIII", "MMDCCLXIX", "MMDCCLXX", "MMDCCLXXI", "MMDCCLXXII", "MMDCCLXXIII", "MMDCCLXXIV", "MMDCCLXXV", "MMDCCLXXVI", "MMDCCLXXVII", "MMDCCLXXVIII", "MMDCCLXXIX", "MMDCCLXXX", "MMDCCLXXXI", "MMDCCLXXXII", "MMDCCLXXXIII", "MMDCCLXXXIV", "MMDCCLXXXV", "MMDCCLXXXVI", "MMDCCLXXXVII", "MMDCCLXXXVIII", "MMDCCLXXXIX", "MMDCCXC", "MMDCCXCI", "MMDCCXCII", "MMDCCXCIII", "MMDCCXCIV", "MMDCCXCV", "MMDCCXCVI", "MMDCCXCVII", "MMDCCXCVIII", "MMDCCXCIX", "MMDCCC", "MMDCCCI", "MMDCCCII", "MMDCCCIII", "MMDCCCIV", "MMDCCCV", "MMDCCCVI", "MMDCCCVII", "MMDCCCVIII", "MMDCCCIX", "MMDCCCX", "MMDCCCXI", "MMDCCCXII", "MMDCCCXIII", "MMDCCCXIV", "MMDCCCXV", "MMDCCCXVI", "MMDCCCXVII", "MMDCCCXVIII", "MMDCCCXIX", "MMDCCCXX", "MMDCCCXXI", "MMDCCCXXII", "MMDCCCXXIII", "MMDCCCXXIV", "MMDCCCXXV", "MMDCCCXXVI", "MMDCCCXXVII", "MMDCCCXXVIII", "MMDCCCXXIX", "MMDCCCXXX", "MMDCCCXXXI", "MMDCCCXXXII", "MMDCCCXXXIII", "MMDCCCXXXIV", "MMDCCCXXXV", "MMDCCCXXXVI", "MMDCCCXXXVII", "MMDCCCXXXVIII", "MMDCCCXXXIX", "MMDCCCXL", "MMDCCCXLI", "MMDCCCXLII", "MMDCCCXLIII", "MMDCCCXLIV", "MMDCCCXLV", "MMDCCCXLVI", "MMDCCCXLVII", "MMDCCCXLVIII", "MMDCCCXLIX", "MMDCCCL", "MMDCCCLI", "MMDCCCLII", "MMDCCCLIII", "MMDCCCLIV", "MMDCCCLV", "MMDCCCLVI", "MMDCCCLVII", "MMDCCCLVIII", "MMDCCCLIX", "MMDCCCLX", "MMDCCCLXI", "MMDCCCLXII", "MMDCCCLXIII", "MMDCCCLXIV", "MMDCCCLXV", "MMDCCCLXVI", "MMDCCCLXVII", "MMDCCCLXVIII", "MMDCCCLXIX", "MMDCCCLXX", "MMDCCCLXXI", "MMDCCCLXXII", "MMDCCCLXXIII", "MMDCCCLXXIV", "MMDCCCLXXV", "MMDCCCLXXVI", "MMDCCCLXXVII", "MMDCCCLXXVIII", "MMDCCCLXXIX", "MMDCCCLXXX", "MMDCCCLXXXI", "MMDCCCLXXXII", "MMDCCCLXXXIII", "MMDCCCLXXXIV", "MMDCCCLXXXV", "MMDCCCLXXXVI", "MMDCCCLXXXVII", "MMDCCCLXXXVIII", "MMDCCCLXXXIX", "MMDCCCXC", "MMDCCCXCI", "MMDCCCXCII", "MMDCCCXCIII", "MMDCCCXCIV", "MMDCCCXCV", "MMDCCCXCVI", "MMDCCCXCVII", "MMDCCCXCVIII", "MMDCCCXCIX", "MMCM", "MMCMI", "MMCMII", "MMCMIII", "MMCMIV", "MMCMV", "MMCMVI", "MMCMVII", "MMCMVIII", "MMCMIX", "MMCMX", "MMCMXI", "MMCMXII", "MMCMXIII", "MMCMXIV", "MMCMXV", "MMCMXVI", "MMCMXVII", "MMCMXVIII", "MMCMXIX", "MMCMXX", "MMCMXXI", "MMCMXXII", "MMCMXXIII", "MMCMXXIV", "MMCMXXV", "MMCMXXVI", "MMCMXXVII", "MMCMXXVIII", "MMCMXXIX", "MMCMXXX", "MMCMXXXI", "MMCMXXXII", "MMCMXXXIII", "MMCMXXXIV", "MMCMXXXV", "MMCMXXXVI", "MMCMXXXVII", "MMCMXXXVIII", "MMCMXXXIX", "MMCMXL", "MMCMXLI", "MMCMXLII", "MMCMXLIII", "MMCMXLIV", "MMCMXLV", "MMCMXLVI", "MMCMXLVII", "MMCMXLVIII", "MMCMXLIX", "MMCML", "MMCMLI", "MMCMLII", "MMCMLIII", "MMCMLIV", "MMCMLV", "MMCMLVI", "MMCMLVII", "MMCMLVIII", "MMCMLIX", "MMCMLX", "MMCMLXI", "MMCMLXII", "MMCMLXIII", "MMCMLXIV", "MMCMLXV", "MMCMLXVI", "MMCMLXVII", "MMCMLXVIII", "MMCMLXIX", "MMCMLXX", "MMCMLXXI", "MMCMLXXII", "MMCMLXXIII", "MMCMLXXIV", "MMCMLXXV", "MMCMLXXVI", "MMCMLXXVII", "MMCMLXXVIII", "MMCMLXXIX", "MMCMLXXX", "MMCMLXXXI", "MMCMLXXXII", "MMCMLXXXIII", "MMCMLXXXIV", "MMCMLXXXV", "MMCMLXXXVI", "MMCMLXXXVII", "MMCMLXXXVIII", "MMCMLXXXIX", "MMCMXC", "MMCMXCI", "MMCMXCII", "MMCMXCIII", "MMCMXCIV", "MMCMXCV", "MMCMXCVI", "MMCMXCVII", "MMCMXCVIII", "MMCMXCIX", "MMM", "MMMI", "MMMII", "MMMIII", "MMMIV", "MMMV", "MMMVI", "MMMVII", "MMMVIII", "MMMIX", "MMMX", "MMMXI", "MMMXII", "MMMXIII", "MMMXIV", "MMMXV", "MMMXVI", "MMMXVII", "MMMXVIII", "MMMXIX", "MMMXX", "MMMXXI", "MMMXXII", "MMMXXIII", "MMMXXIV", "MMMXXV", "MMMXXVI", "MMMXXVII", "MMMXXVIII", "MMMXXIX", "MMMXXX", "MMMXXXI", "MMMXXXII", "MMMXXXIII", "MMMXXXIV", "MMMXXXV", "MMMXXXVI", "MMMXXXVII", "MMMXXXVIII", "MMMXXXIX", "MMMXL", "MMMXLI", "MMMXLII", "MMMXLIII", "MMMXLIV", "MMMXLV", "MMMXLVI", "MMMXLVII", "MMMXLVIII", "MMMXLIX", "MMML", "MMMLI", "MMMLII", "MMMLIII", "MMMLIV", "MMMLV", "MMMLVI", "MMMLVII", "MMMLVIII", "MMMLIX", "MMMLX", "MMMLXI", "MMMLXII", "MMMLXIII", "MMMLXIV", "MMMLXV", "MMMLXVI", "MMMLXVII", "MMMLXVIII", "MMMLXIX", "MMMLXX", "MMMLXXI", "MMMLXXII", "MMMLXXIII", "MMMLXXIV", "MMMLXXV", "MMMLXXVI", "MMMLXXVII", "MMMLXXVIII", "MMMLXXIX", "MMMLXXX", "MMMLXXXI", "MMMLXXXII", "MMMLXXXIII", "MMMLXXXIV", "MMMLXXXV", "MMMLXXXVI", "MMMLXXXVII", "MMMLXXXVIII", "MMMLXXXIX", "MMMXC", "MMMXCI", "MMMXCII", "MMMXCIII", "MMMXCIV", "MMMXCV", "MMMXCVI", "MMMXCVII", "MMMXCVIII", "MMMXCIX", "MMMC", "MMMCI", "MMMCII", "MMMCIII", "MMMCIV", "MMMCV", "MMMCVI", "MMMCVII", "MMMCVIII", "MMMCIX", "MMMCX", "MMMCXI", "MMMCXII", "MMMCXIII", "MMMCXIV", "MMMCXV", "MMMCXVI", "MMMCXVII", "MMMCXVIII", "MMMCXIX", "MMMCXX", "MMMCXXI", "MMMCXXII", "MMMCXXIII", "MMMCXXIV", "MMMCXXV", "MMMCXXVI", "MMMCXXVII", "MMMCXXVIII", "MMMCXXIX", "MMMCXXX", "MMMCXXXI", "MMMCXXXII", "MMMCXXXIII", "MMMCXXXIV", "MMMCXXXV", "MMMCXXXVI", "MMMCXXXVII", "MMMCXXXVIII", "MMMCXXXIX", "MMMCXL", "MMMCXLI", "MMMCXLII", "MMMCXLIII", "MMMCXLIV", "MMMCXLV", "MMMCXLVI", "MMMCXLVII", "MMMCXLVIII", "MMMCXLIX", "MMMCL", "MMMCLI", "MMMCLII", "MMMCLIII", "MMMCLIV", "MMMCLV", "MMMCLVI", "MMMCLVII", "MMMCLVIII", "MMMCLIX", "MMMCLX", "MMMCLXI", "MMMCLXII", "MMMCLXIII", "MMMCLXIV", "MMMCLXV", "MMMCLXVI", "MMMCLXVII", "MMMCLXVIII", "MMMCLXIX", "MMMCLXX", "MMMCLXXI", "MMMCLXXII", "MMMCLXXIII", "MMMCLXXIV", "MMMCLXXV", "MMMCLXXVI", "MMMCLXXVII", "MMMCLXXVIII", "MMMCLXXIX", "MMMCLXXX", "MMMCLXXXI", "MMMCLXXXII", "MMMCLXXXIII", "MMMCLXXXIV", "MMMCLXXXV", "MMMCLXXXVI", "MMMCLXXXVII", "MMMCLXXXVIII", "MMMCLXXXIX", "MMMCXC", "MMMCXCI", "MMMCXCII", "MMMCXCIII", "MMMCXCIV", "MMMCXCV", "MMMCXCVI", "MMMCXCVII", "MMMCXCVIII", "MMMCXCIX", "MMMCC", "MMMCCI", "MMMCCII", "MMMCCIII", "MMMCCIV", "MMMCCV", "MMMCCVI", "MMMCCVII", "MMMCCVIII", "MMMCCIX", "MMMCCX", "MMMCCXI", "MMMCCXII", "MMMCCXIII", "MMMCCXIV", "MMMCCXV", "MMMCCXVI", "MMMCCXVII", "MMMCCXVIII", "MMMCCXIX", "MMMCCXX", "MMMCCXXI", "MMMCCXXII", "MMMCCXXIII", "MMMCCXXIV", "MMMCCXXV", "MMMCCXXVI", "MMMCCXXVII", "MMMCCXXVIII", "MMMCCXXIX", "MMMCCXXX", "MMMCCXXXI", "MMMCCXXXII", "MMMCCXXXIII", "MMMCCXXXIV", "MMMCCXXXV", "MMMCCXXXVI", "MMMCCXXXVII", "MMMCCXXXVIII", "MMMCCXXXIX", "MMMCCXL", "MMMCCXLI", "MMMCCXLII", "MMMCCXLIII", "MMMCCXLIV", "MMMCCXLV", "MMMCCXLVI", "MMMCCXLVII", "MMMCCXLVIII", "MMMCCXLIX", "MMMCCL", "MMMCCLI", "MMMCCLII", "MMMCCLIII", "MMMCCLIV", "MMMCCLV", "MMMCCLVI", "MMMCCLVII", "MMMCCLVIII", "MMMCCLIX", "MMMCCLX", "MMMCCLXI", "MMMCCLXII", "MMMCCLXIII", "MMMCCLXIV", "MMMCCLXV", "MMMCCLXVI", "MMMCCLXVII", "MMMCCLXVIII", "MMMCCLXIX", "MMMCCLXX", "MMMCCLXXI", "MMMCCLXXII", "MMMCCLXXIII", "MMMCCLXXIV", "MMMCCLXXV", "MMMCCLXXVI", "MMMCCLXXVII", "MMMCCLXXVIII", "MMMCCLXXIX", "MMMCCLXXX", "MMMCCLXXXI", "MMMCCLXXXII", "MMMCCLXXXIII", "MMMCCLXXXIV", "MMMCCLXXXV", "MMMCCLXXXVI", "MMMCCLXXXVII", "MMMCCLXXXVIII", "MMMCCLXXXIX", "MMMCCXC", "MMMCCXCI", "MMMCCXCII", "MMMCCXCIII", "MMMCCXCIV", "MMMCCXCV", "MMMCCXCVI", "MMMCCXCVII", "MMMCCXCVIII", "MMMCCXCIX", "MMMCCC", "MMMCCCI", "MMMCCCII", "MMMCCCIII", "MMMCCCIV", "MMMCCCV", "MMMCCCVI", "MMMCCCVII", "MMMCCCVIII", "MMMCCCIX", "MMMCCCX", "MMMCCCXI", "MMMCCCXII", "MMMCCCXIII", "MMMCCCXIV", "MMMCCCXV", "MMMCCCXVI", "MMMCCCXVII", "MMMCCCXVIII", "MMMCCCXIX", "MMMCCCXX", "MMMCCCXXI", "MMMCCCXXII", "MMMCCCXXIII", "MMMCCCXXIV", "MMMCCCXXV", "MMMCCCXXVI", "MMMCCCXXVII", "MMMCCCXXVIII", "MMMCCCXXIX", "MMMCCCXXX", "MMMCCCXXXI", "MMMCCCXXXII", "MMMCCCXXXIII", "MMMCCCXXXIV", "MMMCCCXXXV", "MMMCCCXXXVI", "MMMCCCXXXVII", "MMMCCCXXXVIII", "MMMCCCXXXIX", "MMMCCCXL", "MMMCCCXLI", "MMMCCCXLII", "MMMCCCXLIII", "MMMCCCXLIV", "MMMCCCXLV", "MMMCCCXLVI", "MMMCCCXLVII", "MMMCCCXLVIII", "MMMCCCXLIX", "MMMCCCL", "MMMCCCLI", "MMMCCCLII", "MMMCCCLIII", "MMMCCCLIV", "MMMCCCLV", "MMMCCCLVI", "MMMCCCLVII", "MMMCCCLVIII", "MMMCCCLIX", "MMMCCCLX", "MMMCCCLXI", "MMMCCCLXII", "MMMCCCLXIII", "MMMCCCLXIV", "MMMCCCLXV", "MMMCCCLXVI", "MMMCCCLXVII", "MMMCCCLXVIII", "MMMCCCLXIX", "MMMCCCLXX", "MMMCCCLXXI", "MMMCCCLXXII", "MMMCCCLXXIII", "MMMCCCLXXIV", "MMMCCCLXXV", "MMMCCCLXXVI", "MMMCCCLXXVII", "MMMCCCLXXVIII", "MMMCCCLXXIX", "MMMCCCLXXX", "MMMCCCLXXXI", "MMMCCCLXXXII", "MMMCCCLXXXIII", "MMMCCCLXXXIV", "MMMCCCLXXXV", "MMMCCCLXXXVI", "MMMCCCLXXXVII", "MMMCCCLXXXVIII", "MMMCCCLXXXIX", "MMMCCCXC", "MMMCCCXCI", "MMMCCCXCII", "MMMCCCXCIII", "MMMCCCXCIV", "MMMCCCXCV", "MMMCCCXCVI", "MMMCCCXCVII", "MMMCCCXCVIII", "MMMCCCXCIX", "MMMCD", "MMMCDI", "MMMCDII", "MMMCDIII", "MMMCDIV", "MMMCDV", "MMMCDVI", "MMMCDVII", "MMMCDVIII", "MMMCDIX", "MMMCDX", "MMMCDXI", "MMMCDXII", "MMMCDXIII", "MMMCDXIV", "MMMCDXV", "MMMCDXVI", "MMMCDXVII", "MMMCDXVIII", "MMMCDXIX", "MMMCDXX", "MMMCDXXI", "MMMCDXXII", "MMMCDXXIII", "MMMCDXXIV", "MMMCDXXV", "MMMCDXXVI", "MMMCDXXVII", "MMMCDXXVIII", "MMMCDXXIX", "MMMCDXXX", "MMMCDXXXI", "MMMCDXXXII", "MMMCDXXXIII", "MMMCDXXXIV", "MMMCDXXXV", "MMMCDXXXVI", "MMMCDXXXVII", "MMMCDXXXVIII", "MMMCDXXXIX", "MMMCDXL", "MMMCDXLI", "MMMCDXLII", "MMMCDXLIII", "MMMCDXLIV", "MMMCDXLV", "MMMCDXLVI", "MMMCDXLVII", "MMMCDXLVIII", "MMMCDXLIX", "MMMCDL", "MMMCDLI", "MMMCDLII", "MMMCDLIII", "MMMCDLIV", "MMMCDLV", "MMMCDLVI", "MMMCDLVII", "MMMCDLVIII", "MMMCDLIX", "MMMCDLX", "MMMCDLXI", "MMMCDLXII", "MMMCDLXIII", "MMMCDLXIV", "MMMCDLXV", "MMMCDLXVI", "MMMCDLXVII", "MMMCDLXVIII", "MMMCDLXIX", "MMMCDLXX", "MMMCDLXXI", "MMMCDLXXII", "MMMCDLXXIII", "MMMCDLXXIV", "MMMCDLXXV", "MMMCDLXXVI", "MMMCDLXXVII", "MMMCDLXXVIII", "MMMCDLXXIX", "MMMCDLXXX", "MMMCDLXXXI", "MMMCDLXXXII", "MMMCDLXXXIII", "MMMCDLXXXIV", "MMMCDLXXXV", "MMMCDLXXXVI", "MMMCDLXXXVII", "MMMCDLXXXVIII", "MMMCDLXXXIX", "MMMCDXC", "MMMCDXCI", "MMMCDXCII", "MMMCDXCIII", "MMMCDXCIV", "MMMCDXCV", "MMMCDXCVI", "MMMCDXCVII", "MMMCDXCVIII", "MMMCDXCIX", "MMMD", "MMMDI", "MMMDII", "MMMDIII", "MMMDIV", "MMMDV", "MMMDVI", "MMMDVII", "MMMDVIII", "MMMDIX", "MMMDX", "MMMDXI", "MMMDXII", "MMMDXIII", "MMMDXIV", "MMMDXV", "MMMDXVI", "MMMDXVII", "MMMDXVIII", "MMMDXIX", "MMMDXX", "MMMDXXI", "MMMDXXII", "MMMDXXIII", "MMMDXXIV", "MMMDXXV", "MMMDXXVI", "MMMDXXVII", "MMMDXXVIII", "MMMDXXIX", "MMMDXXX", "MMMDXXXI", "MMMDXXXII", "MMMDXXXIII", "MMMDXXXIV", "MMMDXXXV", "MMMDXXXVI", "MMMDXXXVII", "MMMDXXXVIII", "MMMDXXXIX", "MMMDXL", "MMMDXLI", "MMMDXLII", "MMMDXLIII", "MMMDXLIV", "MMMDXLV", "MMMDXLVI", "MMMDXLVII", "MMMDXLVIII", "MMMDXLIX", "MMMDL", "MMMDLI", "MMMDLII", "MMMDLIII", "MMMDLIV", "MMMDLV", "MMMDLVI", "MMMDLVII", "MMMDLVIII", "MMMDLIX", "MMMDLX", "MMMDLXI", "MMMDLXII", "MMMDLXIII", "MMMDLXIV", "MMMDLXV", "MMMDLXVI", "MMMDLXVII", "MMMDLXVIII", "MMMDLXIX", "MMMDLXX", "MMMDLXXI", "MMMDLXXII", "MMMDLXXIII", "MMMDLXXIV", "MMMDLXXV", "MMMDLXXVI", "MMMDLXXVII", "MMMDLXXVIII", "MMMDLXXIX", "MMMDLXXX", "MMMDLXXXI", "MMMDLXXXII", "MMMDLXXXIII", "MMMDLXXXIV", "MMMDLXXXV", "MMMDLXXXVI", "MMMDLXXXVII", "MMMDLXXXVIII", "MMMDLXXXIX", "MMMDXC", "MMMDXCI", "MMMDXCII", "MMMDXCIII", "MMMDXCIV", "MMMDXCV", "MMMDXCVI", "MMMDXCVII", "MMMDXCVIII", "MMMDXCIX", "MMMDC", "MMMDCI", "MMMDCII", "MMMDCIII", "MMMDCIV", "MMMDCV", "MMMDCVI", "MMMDCVII", "MMMDCVIII", "MMMDCIX", "MMMDCX", "MMMDCXI", "MMMDCXII", "MMMDCXIII", "MMMDCXIV", "MMMDCXV", "MMMDCXVI", "MMMDCXVII", "MMMDCXVIII", "MMMDCXIX", "MMMDCXX", "MMMDCXXI", "MMMDCXXII", "MMMDCXXIII", "MMMDCXXIV", "MMMDCXXV", "MMMDCXXVI", "MMMDCXXVII", "MMMDCXXVIII", "MMMDCXXIX", "MMMDCXXX", "MMMDCXXXI", "MMMDCXXXII", "MMMDCXXXIII", "MMMDCXXXIV", "MMMDCXXXV", "MMMDCXXXVI", "MMMDCXXXVII", "MMMDCXXXVIII", "MMMDCXXXIX", "MMMDCXL", "MMMDCXLI", "MMMDCXLII", "MMMDCXLIII", "MMMDCXLIV", "MMMDCXLV", "MMMDCXLVI", "MMMDCXLVII", "MMMDCXLVIII", "MMMDCXLIX", "MMMDCL", "MMMDCLI", "MMMDCLII", "MMMDCLIII", "MMMDCLIV", "MMMDCLV", "MMMDCLVI", "MMMDCLVII", "MMMDCLVIII", "MMMDCLIX", "MMMDCLX", "MMMDCLXI", "MMMDCLXII", "MMMDCLXIII", "MMMDCLXIV", "MMMDCLXV", "MMMDCLXVI", "MMMDCLXVII", "MMMDCLXVIII", "MMMDCLXIX", "MMMDCLXX", "MMMDCLXXI", "MMMDCLXXII", "MMMDCLXXIII", "MMMDCLXXIV", "MMMDCLXXV", "MMMDCLXXVI", "MMMDCLXXVII", "MMMDCLXXVIII", "MMMDCLXXIX", "MMMDCLXXX", "MMMDCLXXXI", "MMMDCLXXXII", "MMMDCLXXXIII", "MMMDCLXXXIV", "MMMDCLXXXV", "MMMDCLXXXVI", "MMMDCLXXXVII", "MMMDCLXXXVIII", "MMMDCLXXXIX", "MMMDCXC", "MMMDCXCI", "MMMDCXCII", "MMMDCXCIII", "MMMDCXCIV", "MMMDCXCV", "MMMDCXCVI", "MMMDCXCVII", "MMMDCXCVIII", "MMMDCXCIX", "MMMDCC", "MMMDCCI", "MMMDCCII", "MMMDCCIII", "MMMDCCIV", "MMMDCCV", "MMMDCCVI", "MMMDCCVII", "MMMDCCVIII", "MMMDCCIX", "MMMDCCX", "MMMDCCXI", "MMMDCCXII", "MMMDCCXIII", "MMMDCCXIV", "MMMDCCXV", "MMMDCCXVI", "MMMDCCXVII", "MMMDCCXVIII", "MMMDCCXIX", "MMMDCCXX", "MMMDCCXXI", "MMMDCCXXII", "MMMDCCXXIII", "MMMDCCXXIV", "MMMDCCXXV", "MMMDCCXXVI", "MMMDCCXXVII", "MMMDCCXXVIII", "MMMDCCXXIX", "MMMDCCXXX", "MMMDCCXXXI", "MMMDCCXXXII", "MMMDCCXXXIII", "MMMDCCXXXIV", "MMMDCCXXXV", "MMMDCCXXXVI", "MMMDCCXXXVII", "MMMDCCXXXVIII", "MMMDCCXXXIX", "MMMDCCXL", "MMMDCCXLI", "MMMDCCXLII", "MMMDCCXLIII", "MMMDCCXLIV", "MMMDCCXLV", "MMMDCCXLVI", "MMMDCCXLVII", "MMMDCCXLVIII", "MMMDCCXLIX", "MMMDCCL", "MMMDCCLI", "MMMDCCLII", "MMMDCCLIII", "MMMDCCLIV", "MMMDCCLV", "MMMDCCLVI", "MMMDCCLVII", "MMMDCCLVIII", "MMMDCCLIX", "MMMDCCLX", "MMMDCCLXI", "MMMDCCLXII", "MMMDCCLXIII", "MMMDCCLXIV", "MMMDCCLXV", "MMMDCCLXVI", "MMMDCCLXVII", "MMMDCCLXVIII", "MMMDCCLXIX", "MMMDCCLXX", "MMMDCCLXXI", "MMMDCCLXXII", "MMMDCCLXXIII", "MMMDCCLXXIV", "MMMDCCLXXV", "MMMDCCLXXVI", "MMMDCCLXXVII", "MMMDCCLXXVIII", "MMMDCCLXXIX", "MMMDCCLXXX", "MMMDCCLXXXI", "MMMDCCLXXXII", "MMMDCCLXXXIII", "MMMDCCLXXXIV", "MMMDCCLXXXV", "MMMDCCLXXXVI", "MMMDCCLXXXVII", "MMMDCCLXXXVIII", "MMMDCCLXXXIX", "MMMDCCXC", "MMMDCCXCI", "MMMDCCXCII", "MMMDCCXCIII", "MMMDCCXCIV", "MMMDCCXCV", "MMMDCCXCVI", "MMMDCCXCVII", "MMMDCCXCVIII", "MMMDCCXCIX", "MMMDCCC", "MMMDCCCI", "MMMDCCCII", "MMMDCCCIII", "MMMDCCCIV", "MMMDCCCV", "MMMDCCCVI", "MMMDCCCVII", "MMMDCCCVIII", "MMMDCCCIX", "MMMDCCCX", "MMMDCCCXI", "MMMDCCCXII", "MMMDCCCXIII", "MMMDCCCXIV", "MMMDCCCXV", "MMMDCCCXVI", "MMMDCCCXVII", "MMMDCCCXVIII", "MMMDCCCXIX", "MMMDCCCXX", "MMMDCCCXXI", "MMMDCCCXXII", "MMMDCCCXXIII", "MMMDCCCXXIV", "MMMDCCCXXV", "MMMDCCCXXVI", "MMMDCCCXXVII", "MMMDCCCXXVIII", "MMMDCCCXXIX", "MMMDCCCXXX", "MMMDCCCXXXI", "MMMDCCCXXXII", "MMMDCCCXXXIII", "MMMDCCCXXXIV", "MMMDCCCXXXV", "MMMDCCCXXXVI", "MMMDCCCXXXVII", "MMMDCCCXXXVIII", "MMMDCCCXXXIX", "MMMDCCCXL", "MMMDCCCXLI", "MMMDCCCXLII", "MMMDCCCXLIII", "MMMDCCCXLIV", "MMMDCCCXLV", "MMMDCCCXLVI", "MMMDCCCXLVII", "MMMDCCCXLVIII", "MMMDCCCXLIX", "MMMDCCCL", "MMMDCCCLI", "MMMDCCCLII", "MMMDCCCLIII", "MMMDCCCLIV", "MMMDCCCLV", "MMMDCCCLVI", "MMMDCCCLVII", "MMMDCCCLVIII", "MMMDCCCLIX", "MMMDCCCLX", "MMMDCCCLXI", "MMMDCCCLXII", "MMMDCCCLXIII", "MMMDCCCLXIV", "MMMDCCCLXV", "MMMDCCCLXVI", "MMMDCCCLXVII", "MMMDCCCLXVIII", "MMMDCCCLXIX", "MMMDCCCLXX", "MMMDCCCLXXI", "MMMDCCCLXXII", "MMMDCCCLXXIII", "MMMDCCCLXXIV", "MMMDCCCLXXV", "MMMDCCCLXXVI", "MMMDCCCLXXVII", "MMMDCCCLXXVIII", "MMMDCCCLXXIX", "MMMDCCCLXXX", "MMMDCCCLXXXI", "MMMDCCCLXXXII", "MMMDCCCLXXXIII", "MMMDCCCLXXXIV", "MMMDCCCLXXXV", "MMMDCCCLXXXVI", "MMMDCCCLXXXVII", "MMMDCCCLXXXVIII", "MMMDCCCLXXXIX", "MMMDCCCXC", "MMMDCCCXCI", "MMMDCCCXCII", "MMMDCCCXCIII", "MMMDCCCXCIV", "MMMDCCCXCV", "MMMDCCCXCVI", "MMMDCCCXCVII", "MMMDCCCXCVIII", "MMMDCCCXCIX", "MMMCM", "MMMCMI", "MMMCMII", "MMMCMIII", "MMMCMIV", "MMMCMV", "MMMCMVI", "MMMCMVII", "MMMCMVIII", "MMMCMIX", "MMMCMX", "MMMCMXI", "MMMCMXII", "MMMCMXIII", "MMMCMXIV", "MMMCMXV", "MMMCMXVI", "MMMCMXVII", "MMMCMXVIII", "MMMCMXIX", "MMMCMXX", "MMMCMXXI", "MMMCMXXII", "MMMCMXXIII", "MMMCMXXIV", "MMMCMXXV", "MMMCMXXVI", "MMMCMXXVII", "MMMCMXXVIII", "MMMCMXXIX", "MMMCMXXX", "MMMCMXXXI", "MMMCMXXXII", "MMMCMXXXIII", "MMMCMXXXIV", "MMMCMXXXV", "MMMCMXXXVI", "MMMCMXXXVII", "MMMCMXXXVIII", "MMMCMXXXIX", "MMMCMXL", "MMMCMXLI", "MMMCMXLII", "MMMCMXLIII", "MMMCMXLIV", "MMMCMXLV", "MMMCMXLVI", "MMMCMXLVII", "MMMCMXLVIII", "MMMCMXLIX", "MMMCML", "MMMCMLI", "MMMCMLII", "MMMCMLIII", "MMMCMLIV", "MMMCMLV", "MMMCMLVI", "MMMCMLVII", "MMMCMLVIII", "MMMCMLIX", "MMMCMLX", "MMMCMLXI", "MMMCMLXII", "MMMCMLXIII", "MMMCMLXIV", "MMMCMLXV", "MMMCMLXVI", "MMMCMLXVII", "MMMCMLXVIII", "MMMCMLXIX", "MMMCMLXX", "MMMCMLXXI", "MMMCMLXXII", "MMMCMLXXIII", "MMMCMLXXIV", "MMMCMLXXV", "MMMCMLXXVI", "MMMCMLXXVII", "MMMCMLXXVIII", "MMMCMLXXIX", "MMMCMLXXX", "MMMCMLXXXI", "MMMCMLXXXII", "MMMCMLXXXIII", "MMMCMLXXXIV", "MMMCMLXXXV", "MMMCMLXXXVI", "MMMCMLXXXVII", "MMMCMLXXXVIII", "MMMCMLXXXIX", "MMMCMXC", "MMMCMXCI", "MMMCMXCII", "MMMCMXCIII", "MMMCMXCIV", "MMMCMXCV", "MMMCMXCVI", "MMMCMXCVII", "MMMCMXCVIII", "MMMCMXCIX" }; const std::array<string, 4000> cheat_arr{ "","I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX", "XXI", "XXII", "XXIII", "XXIV", "XXV", "XXVI", "XXVII", "XXVIII", "XXIX", "XXX", "XXXI", "XXXII", "XXXIII", "XXXIV", "XXXV", "XXXVI", "XXXVII", "XXXVIII", "XXXIX", "XL", "XLI", "XLII", "XLIII", "XLIV", "XLV", "XLVI", "XLVII", "XLVIII", "XLIX", "L", "LI", "LII", "LIII", "LIV", "LV", "LVI", "LVII", "LVIII", "LIX", "LX", "LXI", "LXII", "LXIII", "LXIV", "LXV", "LXVI", "LXVII", "LXVIII", "LXIX", "LXX", "LXXI", "LXXII", "LXXIII", "LXXIV", "LXXV", "LXXVI", "LXXVII", "LXXVIII", "LXXIX", "LXXX", "LXXXI", "LXXXII", "LXXXIII", "LXXXIV", "LXXXV", "LXXXVI", "LXXXVII", "LXXXVIII", "LXXXIX", "XC", "XCI", "XCII", "XCIII", "XCIV", "XCV", "XCVI", "XCVII", "XCVIII", "XCIX", "C", "CI", "CII", "CIII", "CIV", "CV", "CVI", "CVII", "CVIII", "CIX", "CX", "CXI", "CXII", "CXIII", "CXIV", "CXV", "CXVI", "CXVII", "CXVIII", "CXIX", "CXX", "CXXI", "CXXII", "CXXIII", "CXXIV", "CXXV", "CXXVI", "CXXVII", "CXXVIII", "CXXIX", "CXXX", "CXXXI", "CXXXII", "CXXXIII", "CXXXIV", "CXXXV", "CXXXVI", "CXXXVII", "CXXXVIII", "CXXXIX", "CXL", "CXLI", "CXLII", "CXLIII", "CXLIV", "CXLV", "CXLVI", "CXLVII", "CXLVIII", "CXLIX", "CL", "CLI", "CLII", "CLIII", "CLIV", "CLV", "CLVI", "CLVII", "CLVIII", "CLIX", "CLX", "CLXI", "CLXII", "CLXIII", "CLXIV", "CLXV", "CLXVI", "CLXVII", "CLXVIII", "CLXIX", "CLXX", "CLXXI", "CLXXII", "CLXXIII", "CLXXIV", "CLXXV", "CLXXVI", "CLXXVII", "CLXXVIII", "CLXXIX", "CLXXX", "CLXXXI", "CLXXXII", "CLXXXIII", "CLXXXIV", "CLXXXV", "CLXXXVI", "CLXXXVII", "CLXXXVIII", "CLXXXIX", "CXC", "CXCI", "CXCII", "CXCIII", "CXCIV", "CXCV", "CXCVI", "CXCVII", "CXCVIII", "CXCIX", "CC", "CCI", "CCII", "CCIII", "CCIV", "CCV", "CCVI", "CCVII", "CCVIII", "CCIX", "CCX", "CCXI", "CCXII", "CCXIII", "CCXIV", "CCXV", "CCXVI", "CCXVII", "CCXVIII", "CCXIX", "CCXX", "CCXXI", "CCXXII", "CCXXIII", "CCXXIV", "CCXXV", "CCXXVI", "CCXXVII", "CCXXVIII", "CCXXIX", "CCXXX", "CCXXXI", "CCXXXII", "CCXXXIII", "CCXXXIV", "CCXXXV", "CCXXXVI", "CCXXXVII", "CCXXXVIII", "CCXXXIX", "CCXL", "CCXLI", "CCXLII", "CCXLIII", "CCXLIV", "CCXLV", "CCXLVI", "CCXLVII", "CCXLVIII", "CCXLIX", "CCL", "CCLI", "CCLII", "CCLIII", "CCLIV", "CCLV", "CCLVI", "CCLVII", "CCLVIII", "CCLIX", "CCLX", "CCLXI", "CCLXII", "CCLXIII", "CCLXIV", "CCLXV", "CCLXVI", "CCLXVII", "CCLXVIII", "CCLXIX", "CCLXX", "CCLXXI", "CCLXXII", "CCLXXIII", "CCLXXIV", "CCLXXV", "CCLXXVI", "CCLXXVII", "CCLXXVIII", "CCLXXIX", "CCLXXX", "CCLXXXI", "CCLXXXII", "CCLXXXIII", "CCLXXXIV", "CCLXXXV", "CCLXXXVI", "CCLXXXVII", "CCLXXXVIII", "CCLXXXIX", "CCXC", "CCXCI", "CCXCII", "CCXCIII", "CCXCIV", "CCXCV", "CCXCVI", "CCXCVII", "CCXCVIII", "CCXCIX", "CCC", "CCCI", "CCCII", "CCCIII", "CCCIV", "CCCV", "CCCVI", "CCCVII", "CCCVIII", "CCCIX", "CCCX", "CCCXI", "CCCXII", "CCCXIII", "CCCXIV", "CCCXV", "CCCXVI", "CCCXVII", "CCCXVIII", "CCCXIX", "CCCXX", "CCCXXI", "CCCXXII", "CCCXXIII", "CCCXXIV", "CCCXXV", "CCCXXVI", "CCCXXVII", "CCCXXVIII", "CCCXXIX", "CCCXXX", "CCCXXXI", "CCCXXXII", "CCCXXXIII", "CCCXXXIV", "CCCXXXV", "CCCXXXVI", "CCCXXXVII", "CCCXXXVIII", "CCCXXXIX", "CCCXL", "CCCXLI", "CCCXLII", "CCCXLIII", "CCCXLIV", "CCCXLV", "CCCXLVI", "CCCXLVII", "CCCXLVIII", "CCCXLIX", "CCCL", "CCCLI", "CCCLII", "CCCLIII", "CCCLIV", "CCCLV", "CCCLVI", "CCCLVII", "CCCLVIII", "CCCLIX", "CCCLX", "CCCLXI", "CCCLXII", "CCCLXIII", "CCCLXIV", "CCCLXV", "CCCLXVI", "CCCLXVII", "CCCLXVIII", "CCCLXIX", "CCCLXX", "CCCLXXI", "CCCLXXII", "CCCLXXIII", "CCCLXXIV", "CCCLXXV", "CCCLXXVI", "CCCLXXVII", "CCCLXXVIII", "CCCLXXIX", "CCCLXXX", "CCCLXXXI", "CCCLXXXII", "CCCLXXXIII", "CCCLXXXIV", "CCCLXXXV", "CCCLXXXVI", "CCCLXXXVII", "CCCLXXXVIII", "CCCLXXXIX", "CCCXC", "CCCXCI", "CCCXCII", "CCCXCIII", "CCCXCIV", "CCCXCV", "CCCXCVI", "CCCXCVII", "CCCXCVIII", "CCCXCIX", "CD", "CDI", "CDII", "CDIII", "CDIV", "CDV", "CDVI", "CDVII", "CDVIII", "CDIX", "CDX", "CDXI", "CDXII", "CDXIII", "CDXIV", "CDXV", "CDXVI", "CDXVII", "CDXVIII", "CDXIX", "CDXX", "CDXXI", "CDXXII", "CDXXIII", "CDXXIV", "CDXXV", "CDXXVI", "CDXXVII", "CDXXVIII", "CDXXIX", "CDXXX", "CDXXXI", "CDXXXII", "CDXXXIII", "CDXXXIV", "CDXXXV", "CDXXXVI", "CDXXXVII", "CDXXXVIII", "CDXXXIX", "CDXL", "CDXLI", "CDXLII", "CDXLIII", "CDXLIV", "CDXLV", "CDXLVI", "CDXLVII", "CDXLVIII", "CDXLIX", "CDL", "CDLI", "CDLII", "CDLIII", "CDLIV", "CDLV", "CDLVI", "CDLVII", "CDLVIII", "CDLIX", "CDLX", "CDLXI", "CDLXII", "CDLXIII", "CDLXIV", "CDLXV", "CDLXVI", "CDLXVII", "CDLXVIII", "CDLXIX", "CDLXX", "CDLXXI", "CDLXXII", "CDLXXIII", "CDLXXIV", "CDLXXV", "CDLXXVI", "CDLXXVII", "CDLXXVIII", "CDLXXIX", "CDLXXX", "CDLXXXI", "CDLXXXII", "CDLXXXIII", "CDLXXXIV", "CDLXXXV", "CDLXXXVI", "CDLXXXVII", "CDLXXXVIII", "CDLXXXIX", "CDXC", "CDXCI", "CDXCII", "CDXCIII", "CDXCIV", "CDXCV", "CDXCVI", "CDXCVII", "CDXCVIII", "CDXCIX", "D", "DI", "DII", "DIII", "DIV", "DV", "DVI", "DVII", "DVIII", "DIX", "DX", "DXI", "DXII", "DXIII", "DXIV", "DXV", "DXVI", "DXVII", "DXVIII", "DXIX", "DXX", "DXXI", "DXXII", "DXXIII", "DXXIV", "DXXV", "DXXVI", "DXXVII", "DXXVIII", "DXXIX", "DXXX", "DXXXI", "DXXXII", "DXXXIII", "DXXXIV", "DXXXV", "DXXXVI", "DXXXVII", "DXXXVIII", "DXXXIX", "DXL", "DXLI", "DXLII", "DXLIII", "DXLIV", "DXLV", "DXLVI", "DXLVII", "DXLVIII", "DXLIX", "DL", "DLI", "DLII", "DLIII", "DLIV", "DLV", "DLVI", "DLVII", "DLVIII", "DLIX", "DLX", "DLXI", "DLXII", "DLXIII", "DLXIV", "DLXV", "DLXVI", "DLXVII", "DLXVIII", "DLXIX", "DLXX", "DLXXI", "DLXXII", "DLXXIII", "DLXXIV", "DLXXV", "DLXXVI", "DLXXVII", "DLXXVIII", "DLXXIX", "DLXXX", "DLXXXI", "DLXXXII", "DLXXXIII", "DLXXXIV", "DLXXXV", "DLXXXVI", "DLXXXVII", "DLXXXVIII", "DLXXXIX", "DXC", "DXCI", "DXCII", "DXCIII", "DXCIV", "DXCV", "DXCVI", "DXCVII", "DXCVIII", "DXCIX", "DC", "DCI", "DCII", "DCIII", "DCIV", "DCV", "DCVI", "DCVII", "DCVIII", "DCIX", "DCX", "DCXI", "DCXII", "DCXIII", "DCXIV", "DCXV", "DCXVI", "DCXVII", "DCXVIII", "DCXIX", "DCXX", "DCXXI", "DCXXII", "DCXXIII", "DCXXIV", "DCXXV", "DCXXVI", "DCXXVII", "DCXXVIII", "DCXXIX", "DCXXX", "DCXXXI", "DCXXXII", "DCXXXIII", "DCXXXIV", "DCXXXV", "DCXXXVI", "DCXXXVII", "DCXXXVIII", "DCXXXIX", "DCXL", "DCXLI", "DCXLII", "DCXLIII", "DCXLIV", "DCXLV", "DCXLVI", "DCXLVII", "DCXLVIII", "DCXLIX", "DCL", "DCLI", "DCLII", "DCLIII", "DCLIV", "DCLV", "DCLVI", "DCLVII", "DCLVIII", "DCLIX", "DCLX", "DCLXI", "DCLXII", "DCLXIII", "DCLXIV", "DCLXV", "DCLXVI", "DCLXVII", "DCLXVIII", "DCLXIX", "DCLXX", "DCLXXI", "DCLXXII", "DCLXXIII", "DCLXXIV", "DCLXXV", "DCLXXVI", "DCLXXVII", "DCLXXVIII", "DCLXXIX", "DCLXXX", "DCLXXXI", "DCLXXXII", "DCLXXXIII", "DCLXXXIV", "DCLXXXV", "DCLXXXVI", "DCLXXXVII", "DCLXXXVIII", "DCLXXXIX", "DCXC", "DCXCI", "DCXCII", "DCXCIII", "DCXCIV", "DCXCV", "DCXCVI", "DCXCVII", "DCXCVIII", "DCXCIX", "DCC", "DCCI", "DCCII", "DCCIII", "DCCIV", "DCCV", "DCCVI", "DCCVII", "DCCVIII", "DCCIX", "DCCX", "DCCXI", "DCCXII", "DCCXIII", "DCCXIV", "DCCXV", "DCCXVI", "DCCXVII", "DCCXVIII", "DCCXIX", "DCCXX", "DCCXXI", "DCCXXII", "DCCXXIII", "DCCXXIV", "DCCXXV", "DCCXXVI", "DCCXXVII", "DCCXXVIII", "DCCXXIX", "DCCXXX", "DCCXXXI", "DCCXXXII", "DCCXXXIII", "DCCXXXIV", "DCCXXXV", "DCCXXXVI", "DCCXXXVII", "DCCXXXVIII", "DCCXXXIX", "DCCXL", "DCCXLI", "DCCXLII", "DCCXLIII", "DCCXLIV", "DCCXLV", "DCCXLVI", "DCCXLVII", "DCCXLVIII", "DCCXLIX", "DCCL", "DCCLI", "DCCLII", "DCCLIII", "DCCLIV", "DCCLV", "DCCLVI", "DCCLVII", "DCCLVIII", "DCCLIX", "DCCLX", "DCCLXI", "DCCLXII", "DCCLXIII", "DCCLXIV", "DCCLXV", "DCCLXVI", "DCCLXVII", "DCCLXVIII", "DCCLXIX", "DCCLXX", "DCCLXXI", "DCCLXXII", "DCCLXXIII", "DCCLXXIV", "DCCLXXV", "DCCLXXVI", "DCCLXXVII", "DCCLXXVIII", "DCCLXXIX", "DCCLXXX", "DCCLXXXI", "DCCLXXXII", "DCCLXXXIII", "DCCLXXXIV", "DCCLXXXV", "DCCLXXXVI", "DCCLXXXVII", "DCCLXXXVIII", "DCCLXXXIX", "DCCXC", "DCCXCI", "DCCXCII", "DCCXCIII", "DCCXCIV", "DCCXCV", "DCCXCVI", "DCCXCVII", "DCCXCVIII", "DCCXCIX", "DCCC", "DCCCI", "DCCCII", "DCCCIII", "DCCCIV", "DCCCV", "DCCCVI", "DCCCVII", "DCCCVIII", "DCCCIX", "DCCCX", "DCCCXI", "DCCCXII", "DCCCXIII", "DCCCXIV", "DCCCXV", "DCCCXVI", "DCCCXVII", "DCCCXVIII", "DCCCXIX", "DCCCXX", "DCCCXXI", "DCCCXXII", "DCCCXXIII", "DCCCXXIV", "DCCCXXV", "DCCCXXVI", "DCCCXXVII", "DCCCXXVIII", "DCCCXXIX", "DCCCXXX", "DCCCXXXI", "DCCCXXXII", "DCCCXXXIII", "DCCCXXXIV", "DCCCXXXV", "DCCCXXXVI", "DCCCXXXVII", "DCCCXXXVIII", "DCCCXXXIX", "DCCCXL", "DCCCXLI", "DCCCXLII", "DCCCXLIII", "DCCCXLIV", "DCCCXLV", "DCCCXLVI", "DCCCXLVII", "DCCCXLVIII", "DCCCXLIX", "DCCCL", "DCCCLI", "DCCCLII", "DCCCLIII", "DCCCLIV", "DCCCLV", "DCCCLVI", "DCCCLVII", "DCCCLVIII", "DCCCLIX", "DCCCLX", "DCCCLXI", "DCCCLXII", "DCCCLXIII", "DCCCLXIV", "DCCCLXV", "DCCCLXVI", "DCCCLXVII", "DCCCLXVIII", "DCCCLXIX", "DCCCLXX", "DCCCLXXI", "DCCCLXXII", "DCCCLXXIII", "DCCCLXXIV", "DCCCLXXV", "DCCCLXXVI", "DCCCLXXVII", "DCCCLXXVIII", "DCCCLXXIX", "DCCCLXXX", "DCCCLXXXI", "DCCCLXXXII", "DCCCLXXXIII", "DCCCLXXXIV", "DCCCLXXXV", "DCCCLXXXVI", "DCCCLXXXVII", "DCCCLXXXVIII", "DCCCLXXXIX", "DCCCXC", "DCCCXCI", "DCCCXCII", "DCCCXCIII", "DCCCXCIV", "DCCCXCV", "DCCCXCVI", "DCCCXCVII", "DCCCXCVIII", "DCCCXCIX", "CM", "CMI", "CMII", "CMIII", "CMIV", "CMV", "CMVI", "CMVII", "CMVIII", "CMIX", "CMX", "CMXI", "CMXII", "CMXIII", "CMXIV", "CMXV", "CMXVI", "CMXVII", "CMXVIII", "CMXIX", "CMXX", "CMXXI", "CMXXII", "CMXXIII", "CMXXIV", "CMXXV", "CMXXVI", "CMXXVII", "CMXXVIII", "CMXXIX", "CMXXX", "CMXXXI", "CMXXXII", "CMXXXIII", "CMXXXIV", "CMXXXV", "CMXXXVI", "CMXXXVII", "CMXXXVIII", "CMXXXIX", "CMXL", "CMXLI", "CMXLII", "CMXLIII", "CMXLIV", "CMXLV", "CMXLVI", "CMXLVII", "CMXLVIII", "CMXLIX", "CML", "CMLI", "CMLII", "CMLIII", "CMLIV", "CMLV", "CMLVI", "CMLVII", "CMLVIII", "CMLIX", "CMLX", "CMLXI", "CMLXII", "CMLXIII", "CMLXIV", "CMLXV", "CMLXVI", "CMLXVII", "CMLXVIII", "CMLXIX", "CMLXX", "CMLXXI", "CMLXXII", "CMLXXIII", "CMLXXIV", "CMLXXV", "CMLXXVI", "CMLXXVII", "CMLXXVIII", "CMLXXIX", "CMLXXX", "CMLXXXI", "CMLXXXII", "CMLXXXIII", "CMLXXXIV", "CMLXXXV", "CMLXXXVI", "CMLXXXVII", "CMLXXXVIII", "CMLXXXIX", "CMXC", "CMXCI", "CMXCII", "CMXCIII", "CMXCIV", "CMXCV", "CMXCVI", "CMXCVII", "CMXCVIII", "CMXCIX", "M", "MI", "MII", "MIII", "MIV", "MV", "MVI", "MVII", "MVIII", "MIX", "MX", "MXI", "MXII", "MXIII", "MXIV", "MXV", "MXVI", "MXVII", "MXVIII", "MXIX", "MXX", "MXXI", "MXXII", "MXXIII", "MXXIV", "MXXV", "MXXVI", "MXXVII", "MXXVIII", "MXXIX", "MXXX", "MXXXI", "MXXXII", "MXXXIII", "MXXXIV", "MXXXV", "MXXXVI", "MXXXVII", "MXXXVIII", "MXXXIX", "MXL", "MXLI", "MXLII", "MXLIII", "MXLIV", "MXLV", "MXLVI", "MXLVII", "MXLVIII", "MXLIX", "ML", "MLI", "MLII", "MLIII", "MLIV", "MLV", "MLVI", "MLVII", "MLVIII", "MLIX", "MLX", "MLXI", "MLXII", "MLXIII", "MLXIV", "MLXV", "MLXVI", "MLXVII", "MLXVIII", "MLXIX", "MLXX", "MLXXI", "MLXXII", "MLXXIII", "MLXXIV", "MLXXV", "MLXXVI", "MLXXVII", "MLXXVIII", "MLXXIX", "MLXXX", "MLXXXI", "MLXXXII", "MLXXXIII", "MLXXXIV", "MLXXXV", "MLXXXVI", "MLXXXVII", "MLXXXVIII", "MLXXXIX", "MXC", "MXCI", "MXCII", "MXCIII", "MXCIV", "MXCV", "MXCVI", "MXCVII", "MXCVIII", "MXCIX", "MC", "MCI", "MCII", "MCIII", "MCIV", "MCV", "MCVI", "MCVII", "MCVIII", "MCIX", "MCX", "MCXI", "MCXII", "MCXIII", "MCXIV", "MCXV", "MCXVI", "MCXVII", "MCXVIII", "MCXIX", "MCXX", "MCXXI", "MCXXII", "MCXXIII", "MCXXIV", "MCXXV", "MCXXVI", "MCXXVII", "MCXXVIII", "MCXXIX", "MCXXX", "MCXXXI", "MCXXXII", "MCXXXIII", "MCXXXIV", "MCXXXV", "MCXXXVI", "MCXXXVII", "MCXXXVIII", "MCXXXIX", "MCXL", "MCXLI", "MCXLII", "MCXLIII", "MCXLIV", "MCXLV", "MCXLVI", "MCXLVII", "MCXLVIII", "MCXLIX", "MCL", "MCLI", "MCLII", "MCLIII", "MCLIV", "MCLV", "MCLVI", "MCLVII", "MCLVIII", "MCLIX", "MCLX", "MCLXI", "MCLXII", "MCLXIII", "MCLXIV", "MCLXV", "MCLXVI", "MCLXVII", "MCLXVIII", "MCLXIX", "MCLXX", "MCLXXI", "MCLXXII", "MCLXXIII", "MCLXXIV", "MCLXXV", "MCLXXVI", "MCLXXVII", "MCLXXVIII", "MCLXXIX", "MCLXXX", "MCLXXXI", "MCLXXXII", "MCLXXXIII", "MCLXXXIV", "MCLXXXV", "MCLXXXVI", "MCLXXXVII", "MCLXXXVIII", "MCLXXXIX", "MCXC", "MCXCI", "MCXCII", "MCXCIII", "MCXCIV", "MCXCV", "MCXCVI", "MCXCVII", "MCXCVIII", "MCXCIX", "MCC", "MCCI", "MCCII", "MCCIII", "MCCIV", "MCCV", "MCCVI", "MCCVII", "MCCVIII", "MCCIX", "MCCX", "MCCXI", "MCCXII", "MCCXIII", "MCCXIV", "MCCXV", "MCCXVI", "MCCXVII", "MCCXVIII", "MCCXIX", "MCCXX", "MCCXXI", "MCCXXII", "MCCXXIII", "MCCXXIV", "MCCXXV", "MCCXXVI", "MCCXXVII", "MCCXXVIII", "MCCXXIX", "MCCXXX", "MCCXXXI", "MCCXXXII", "MCCXXXIII", "MCCXXXIV", "MCCXXXV", "MCCXXXVI", "MCCXXXVII", "MCCXXXVIII", "MCCXXXIX", "MCCXL", "MCCXLI", "MCCXLII", "MCCXLIII", "MCCXLIV", "MCCXLV", "MCCXLVI", "MCCXLVII", "MCCXLVIII", "MCCXLIX", "MCCL", "MCCLI", "MCCLII", "MCCLIII", "MCCLIV", "MCCLV", "MCCLVI", "MCCLVII", "MCCLVIII", "MCCLIX", "MCCLX", "MCCLXI", "MCCLXII", "MCCLXIII", "MCCLXIV", "MCCLXV", "MCCLXVI", "MCCLXVII", "MCCLXVIII", "MCCLXIX", "MCCLXX", "MCCLXXI", "MCCLXXII", "MCCLXXIII", "MCCLXXIV", "MCCLXXV", "MCCLXXVI", "MCCLXXVII", "MCCLXXVIII", "MCCLXXIX", "MCCLXXX", "MCCLXXXI", "MCCLXXXII", "MCCLXXXIII", "MCCLXXXIV", "MCCLXXXV", "MCCLXXXVI", "MCCLXXXVII", "MCCLXXXVIII", "MCCLXXXIX", "MCCXC", "MCCXCI", "MCCXCII", "MCCXCIII", "MCCXCIV", "MCCXCV", "MCCXCVI", "MCCXCVII", "MCCXCVIII", "MCCXCIX", "MCCC", "MCCCI", "MCCCII", "MCCCIII", "MCCCIV", "MCCCV", "MCCCVI", "MCCCVII", "MCCCVIII", "MCCCIX", "MCCCX", "MCCCXI", "MCCCXII", "MCCCXIII", "MCCCXIV", "MCCCXV", "MCCCXVI", "MCCCXVII", "MCCCXVIII", "MCCCXIX", "MCCCXX", "MCCCXXI", "MCCCXXII", "MCCCXXIII", "MCCCXXIV", "MCCCXXV", "MCCCXXVI", "MCCCXXVII", "MCCCXXVIII", "MCCCXXIX", "MCCCXXX", "MCCCXXXI", "MCCCXXXII", "MCCCXXXIII", "MCCCXXXIV", "MCCCXXXV", "MCCCXXXVI", "MCCCXXXVII", "MCCCXXXVIII", "MCCCXXXIX", "MCCCXL", "MCCCXLI", "MCCCXLII", "MCCCXLIII", "MCCCXLIV", "MCCCXLV", "MCCCXLVI", "MCCCXLVII", "MCCCXLVIII", "MCCCXLIX", "MCCCL", "MCCCLI", "MCCCLII", "MCCCLIII", "MCCCLIV", "MCCCLV", "MCCCLVI", "MCCCLVII", "MCCCLVIII", "MCCCLIX", "MCCCLX", "MCCCLXI", "MCCCLXII", "MCCCLXIII", "MCCCLXIV", "MCCCLXV", "MCCCLXVI", "MCCCLXVII", "MCCCLXVIII", "MCCCLXIX", "MCCCLXX", "MCCCLXXI", "MCCCLXXII", "MCCCLXXIII", "MCCCLXXIV", "MCCCLXXV", "MCCCLXXVI", "MCCCLXXVII", "MCCCLXXVIII", "MCCCLXXIX", "MCCCLXXX", "MCCCLXXXI", "MCCCLXXXII", "MCCCLXXXIII", "MCCCLXXXIV", "MCCCLXXXV", "MCCCLXXXVI", "MCCCLXXXVII", "MCCCLXXXVIII", "MCCCLXXXIX", "MCCCXC", "MCCCXCI", "MCCCXCII", "MCCCXCIII", "MCCCXCIV", "MCCCXCV", "MCCCXCVI", "MCCCXCVII", "MCCCXCVIII", "MCCCXCIX", "MCD", "MCDI", "MCDII", "MCDIII", "MCDIV", "MCDV", "MCDVI", "MCDVII", "MCDVIII", "MCDIX", "MCDX", "MCDXI", "MCDXII", "MCDXIII", "MCDXIV", "MCDXV", "MCDXVI", "MCDXVII", "MCDXVIII", "MCDXIX", "MCDXX", "MCDXXI", "MCDXXII", "MCDXXIII", "MCDXXIV", "MCDXXV", "MCDXXVI", "MCDXXVII", "MCDXXVIII", "MCDXXIX", "MCDXXX", "MCDXXXI", "MCDXXXII", "MCDXXXIII", "MCDXXXIV", "MCDXXXV", "MCDXXXVI", "MCDXXXVII", "MCDXXXVIII", "MCDXXXIX", "MCDXL", "MCDXLI", "MCDXLII", "MCDXLIII", "MCDXLIV", "MCDXLV", "MCDXLVI", "MCDXLVII", "MCDXLVIII", "MCDXLIX", "MCDL", "MCDLI", "MCDLII", "MCDLIII", "MCDLIV", "MCDLV", "MCDLVI", "MCDLVII", "MCDLVIII", "MCDLIX", "MCDLX", "MCDLXI", "MCDLXII", "MCDLXIII", "MCDLXIV", "MCDLXV", "MCDLXVI", "MCDLXVII", "MCDLXVIII", "MCDLXIX", "MCDLXX", "MCDLXXI", "MCDLXXII", "MCDLXXIII", "MCDLXXIV", "MCDLXXV", "MCDLXXVI", "MCDLXXVII", "MCDLXXVIII", "MCDLXXIX", "MCDLXXX", "MCDLXXXI", "MCDLXXXII", "MCDLXXXIII", "MCDLXXXIV", "MCDLXXXV", "MCDLXXXVI", "MCDLXXXVII", "MCDLXXXVIII", "MCDLXXXIX", "MCDXC", "MCDXCI", "MCDXCII", "MCDXCIII", "MCDXCIV", "MCDXCV", "MCDXCVI", "MCDXCVII", "MCDXCVIII", "MCDXCIX", "MD", "MDI", "MDII", "MDIII", "MDIV", "MDV", "MDVI", "MDVII", "MDVIII", "MDIX", "MDX", "MDXI", "MDXII", "MDXIII", "MDXIV", "MDXV", "MDXVI", "MDXVII", "MDXVIII", "MDXIX", "MDXX", "MDXXI", "MDXXII", "MDXXIII", "MDXXIV", "MDXXV", "MDXXVI", "MDXXVII", "MDXXVIII", "MDXXIX", "MDXXX", "MDXXXI", "MDXXXII", "MDXXXIII", "MDXXXIV", "MDXXXV", "MDXXXVI", "MDXXXVII", "MDXXXVIII", "MDXXXIX", "MDXL", "MDXLI", "MDXLII", "MDXLIII", "MDXLIV", "MDXLV", "MDXLVI", "MDXLVII", "MDXLVIII", "MDXLIX", "MDL", "MDLI", "MDLII", "MDLIII", "MDLIV", "MDLV", "MDLVI", "MDLVII", "MDLVIII", "MDLIX", "MDLX", "MDLXI", "MDLXII", "MDLXIII", "MDLXIV", "MDLXV", "MDLXVI", "MDLXVII", "MDLXVIII", "MDLXIX", "MDLXX", "MDLXXI", "MDLXXII", "MDLXXIII", "MDLXXIV", "MDLXXV", "MDLXXVI", "MDLXXVII", "MDLXXVIII", "MDLXXIX", "MDLXXX", "MDLXXXI", "MDLXXXII", "MDLXXXIII", "MDLXXXIV", "MDLXXXV", "MDLXXXVI", "MDLXXXVII", "MDLXXXVIII", "MDLXXXIX", "MDXC", "MDXCI", "MDXCII", "MDXCIII", "MDXCIV", "MDXCV", "MDXCVI", "MDXCVII", "MDXCVIII", "MDXCIX", "MDC", "MDCI", "MDCII", "MDCIII", "MDCIV", "MDCV", "MDCVI", "MDCVII", "MDCVIII", "MDCIX", "MDCX", "MDCXI", "MDCXII", "MDCXIII", "MDCXIV", "MDCXV", "MDCXVI", "MDCXVII", "MDCXVIII", "MDCXIX", "MDCXX", "MDCXXI", "MDCXXII", "MDCXXIII", "MDCXXIV", "MDCXXV", "MDCXXVI", "MDCXXVII", "MDCXXVIII", "MDCXXIX", "MDCXXX", "MDCXXXI", "MDCXXXII", "MDCXXXIII", "MDCXXXIV", "MDCXXXV", "MDCXXXVI", "MDCXXXVII", "MDCXXXVIII", "MDCXXXIX", "MDCXL", "MDCXLI", "MDCXLII", "MDCXLIII", "MDCXLIV", "MDCXLV", "MDCXLVI", "MDCXLVII", "MDCXLVIII", "MDCXLIX", "MDCL", "MDCLI", "MDCLII", "MDCLIII", "MDCLIV", "MDCLV", "MDCLVI", "MDCLVII", "MDCLVIII", "MDCLIX", "MDCLX", "MDCLXI", "MDCLXII", "MDCLXIII", "MDCLXIV", "MDCLXV", "MDCLXVI", "MDCLXVII", "MDCLXVIII", "MDCLXIX", "MDCLXX", "MDCLXXI", "MDCLXXII", "MDCLXXIII", "MDCLXXIV", "MDCLXXV", "MDCLXXVI", "MDCLXXVII", "MDCLXXVIII", "MDCLXXIX", "MDCLXXX", "MDCLXXXI", "MDCLXXXII", "MDCLXXXIII", "MDCLXXXIV", "MDCLXXXV", "MDCLXXXVI", "MDCLXXXVII", "MDCLXXXVIII", "MDCLXXXIX", "MDCXC", "MDCXCI", "MDCXCII", "MDCXCIII", "MDCXCIV", "MDCXCV", "MDCXCVI", "MDCXCVII", "MDCXCVIII", "MDCXCIX", "MDCC", "MDCCI", "MDCCII", "MDCCIII", "MDCCIV", "MDCCV", "MDCCVI", "MDCCVII", "MDCCVIII", "MDCCIX", "MDCCX", "MDCCXI", "MDCCXII", "MDCCXIII", "MDCCXIV", "MDCCXV", "MDCCXVI", "MDCCXVII", "MDCCXVIII", "MDCCXIX", "MDCCXX", "MDCCXXI", "MDCCXXII", "MDCCXXIII", "MDCCXXIV", "MDCCXXV", "MDCCXXVI", "MDCCXXVII", "MDCCXXVIII", "MDCCXXIX", "MDCCXXX", "MDCCXXXI", "MDCCXXXII", "MDCCXXXIII", "MDCCXXXIV", "MDCCXXXV", "MDCCXXXVI", "MDCCXXXVII", "MDCCXXXVIII", "MDCCXXXIX", "MDCCXL", "MDCCXLI", "MDCCXLII", "MDCCXLIII", "MDCCXLIV", "MDCCXLV", "MDCCXLVI", "MDCCXLVII", "MDCCXLVIII", "MDCCXLIX", "MDCCL", "MDCCLI", "MDCCLII", "MDCCLIII", "MDCCLIV", "MDCCLV", "MDCCLVI", "MDCCLVII", "MDCCLVIII", "MDCCLIX", "MDCCLX", "MDCCLXI", "MDCCLXII", "MDCCLXIII", "MDCCLXIV", "MDCCLXV", "MDCCLXVI", "MDCCLXVII", "MDCCLXVIII", "MDCCLXIX", "MDCCLXX", "MDCCLXXI", "MDCCLXXII", "MDCCLXXIII", "MDCCLXXIV", "MDCCLXXV", "MDCCLXXVI", "MDCCLXXVII", "MDCCLXXVIII", "MDCCLXXIX", "MDCCLXXX", "MDCCLXXXI", "MDCCLXXXII", "MDCCLXXXIII", "MDCCLXXXIV", "MDCCLXXXV", "MDCCLXXXVI", "MDCCLXXXVII", "MDCCLXXXVIII", "MDCCLXXXIX", "MDCCXC", "MDCCXCI", "MDCCXCII", "MDCCXCIII", "MDCCXCIV", "MDCCXCV", "MDCCXCVI", "MDCCXCVII", "MDCCXCVIII", "MDCCXCIX", "MDCCC", "MDCCCI", "MDCCCII", "MDCCCIII", "MDCCCIV", "MDCCCV", "MDCCCVI", "MDCCCVII", "MDCCCVIII", "MDCCCIX", "MDCCCX", "MDCCCXI", "MDCCCXII", "MDCCCXIII", "MDCCCXIV", "MDCCCXV", "MDCCCXVI", "MDCCCXVII", "MDCCCXVIII", "MDCCCXIX", "MDCCCXX", "MDCCCXXI", "MDCCCXXII", "MDCCCXXIII", "MDCCCXXIV", "MDCCCXXV", "MDCCCXXVI", "MDCCCXXVII", "MDCCCXXVIII", "MDCCCXXIX", "MDCCCXXX", "MDCCCXXXI", "MDCCCXXXII", "MDCCCXXXIII", "MDCCCXXXIV", "MDCCCXXXV", "MDCCCXXXVI", "MDCCCXXXVII", "MDCCCXXXVIII", "MDCCCXXXIX", "MDCCCXL", "MDCCCXLI", "MDCCCXLII", "MDCCCXLIII", "MDCCCXLIV", "MDCCCXLV", "MDCCCXLVI", "MDCCCXLVII", "MDCCCXLVIII", "MDCCCXLIX", "MDCCCL", "MDCCCLI", "MDCCCLII", "MDCCCLIII", "MDCCCLIV", "MDCCCLV", "MDCCCLVI", "MDCCCLVII", "MDCCCLVIII", "MDCCCLIX", "MDCCCLX", "MDCCCLXI", "MDCCCLXII", "MDCCCLXIII", "MDCCCLXIV", "MDCCCLXV", "MDCCCLXVI", "MDCCCLXVII", "MDCCCLXVIII", "MDCCCLXIX", "MDCCCLXX", "MDCCCLXXI", "MDCCCLXXII", "MDCCCLXXIII", "MDCCCLXXIV", "MDCCCLXXV", "MDCCCLXXVI", "MDCCCLXXVII", "MDCCCLXXVIII", "MDCCCLXXIX", "MDCCCLXXX", "MDCCCLXXXI", "MDCCCLXXXII", "MDCCCLXXXIII", "MDCCCLXXXIV", "MDCCCLXXXV", "MDCCCLXXXVI", "MDCCCLXXXVII", "MDCCCLXXXVIII", "MDCCCLXXXIX", "MDCCCXC", "MDCCCXCI", "MDCCCXCII", "MDCCCXCIII", "MDCCCXCIV", "MDCCCXCV", "MDCCCXCVI", "MDCCCXCVII", "MDCCCXCVIII", "MDCCCXCIX", "MCM", "MCMI", "MCMII", "MCMIII", "MCMIV", "MCMV", "MCMVI", "MCMVII", "MCMVIII", "MCMIX", "MCMX", "MCMXI", "MCMXII", "MCMXIII", "MCMXIV", "MCMXV", "MCMXVI", "MCMXVII", "MCMXVIII", "MCMXIX", "MCMXX", "MCMXXI", "MCMXXII", "MCMXXIII", "MCMXXIV", "MCMXXV", "MCMXXVI", "MCMXXVII", "MCMXXVIII", "MCMXXIX", "MCMXXX", "MCMXXXI", "MCMXXXII", "MCMXXXIII", "MCMXXXIV", "MCMXXXV", "MCMXXXVI", "MCMXXXVII", "MCMXXXVIII", "MCMXXXIX", "MCMXL", "MCMXLI", "MCMXLII", "MCMXLIII", "MCMXLIV", "MCMXLV", "MCMXLVI", "MCMXLVII", "MCMXLVIII", "MCMXLIX", "MCML", "MCMLI", "MCMLII", "MCMLIII", "MCMLIV", "MCMLV", "MCMLVI", "MCMLVII", "MCMLVIII", "MCMLIX", "MCMLX", "MCMLXI", "MCMLXII", "MCMLXIII", "MCMLXIV", "MCMLXV", "MCMLXVI", "MCMLXVII", "MCMLXVIII", "MCMLXIX", "MCMLXX", "MCMLXXI", "MCMLXXII", "MCMLXXIII", "MCMLXXIV", "MCMLXXV", "MCMLXXVI", "MCMLXXVII", "MCMLXXVIII", "MCMLXXIX", "MCMLXXX", "MCMLXXXI", "MCMLXXXII", "MCMLXXXIII", "MCMLXXXIV", "MCMLXXXV", "MCMLXXXVI", "MCMLXXXVII", "MCMLXXXVIII", "MCMLXXXIX", "MCMXC", "MCMXCI", "MCMXCII", "MCMXCIII", "MCMXCIV", "MCMXCV", "MCMXCVI", "MCMXCVII", "MCMXCVIII", "MCMXCIX", "MM", "MMI", "MMII", "MMIII", "MMIV", "MMV", "MMVI", "MMVII", "MMVIII", "MMIX", "MMX", "MMXI", "MMXII", "MMXIII", "MMXIV", "MMXV", "MMXVI", "MMXVII", "MMXVIII", "MMXIX", "MMXX", "MMXXI", "MMXXII", "MMXXIII", "MMXXIV", "MMXXV", "MMXXVI", "MMXXVII", "MMXXVIII", "MMXXIX", "MMXXX", "MMXXXI", "MMXXXII", "MMXXXIII", "MMXXXIV", "MMXXXV", "MMXXXVI", "MMXXXVII", "MMXXXVIII", "MMXXXIX", "MMXL", "MMXLI", "MMXLII", "MMXLIII", "MMXLIV", "MMXLV", "MMXLVI", "MMXLVII", "MMXLVIII", "MMXLIX", "MML", "MMLI", "MMLII", "MMLIII", "MMLIV", "MMLV", "MMLVI", "MMLVII", "MMLVIII", "MMLIX", "MMLX", "MMLXI", "MMLXII", "MMLXIII", "MMLXIV", "MMLXV", "MMLXVI", "MMLXVII", "MMLXVIII", "MMLXIX", "MMLXX", "MMLXXI", "MMLXXII", "MMLXXIII", "MMLXXIV", "MMLXXV", "MMLXXVI", "MMLXXVII", "MMLXXVIII", "MMLXXIX", "MMLXXX", "MMLXXXI", "MMLXXXII", "MMLXXXIII", "MMLXXXIV", "MMLXXXV", "MMLXXXVI", "MMLXXXVII", "MMLXXXVIII", "MMLXXXIX", "MMXC", "MMXCI", "MMXCII", "MMXCIII", "MMXCIV", "MMXCV", "MMXCVI", "MMXCVII", "MMXCVIII", "MMXCIX", "MMC", "MMCI", "MMCII", "MMCIII", "MMCIV", "MMCV", "MMCVI", "MMCVII", "MMCVIII", "MMCIX", "MMCX", "MMCXI", "MMCXII", "MMCXIII", "MMCXIV", "MMCXV", "MMCXVI", "MMCXVII", "MMCXVIII", "MMCXIX", "MMCXX", "MMCXXI", "MMCXXII", "MMCXXIII", "MMCXXIV", "MMCXXV", "MMCXXVI", "MMCXXVII", "MMCXXVIII", "MMCXXIX", "MMCXXX", "MMCXXXI", "MMCXXXII", "MMCXXXIII", "MMCXXXIV", "MMCXXXV", "MMCXXXVI", "MMCXXXVII", "MMCXXXVIII", "MMCXXXIX", "MMCXL", "MMCXLI", "MMCXLII", "MMCXLIII", "MMCXLIV", "MMCXLV", "MMCXLVI", "MMCXLVII", "MMCXLVIII", "MMCXLIX", "MMCL", "MMCLI", "MMCLII", "MMCLIII", "MMCLIV", "MMCLV", "MMCLVI", "MMCLVII", "MMCLVIII", "MMCLIX", "MMCLX", "MMCLXI", "MMCLXII", "MMCLXIII", "MMCLXIV", "MMCLXV", "MMCLXVI", "MMCLXVII", "MMCLXVIII", "MMCLXIX", "MMCLXX", "MMCLXXI", "MMCLXXII", "MMCLXXIII", "MMCLXXIV", "MMCLXXV", "MMCLXXVI", "MMCLXXVII", "MMCLXXVIII", "MMCLXXIX", "MMCLXXX", "MMCLXXXI", "MMCLXXXII", "MMCLXXXIII", "MMCLXXXIV", "MMCLXXXV", "MMCLXXXVI", "MMCLXXXVII", "MMCLXXXVIII", "MMCLXXXIX", "MMCXC", "MMCXCI", "MMCXCII", "MMCXCIII", "MMCXCIV", "MMCXCV", "MMCXCVI", "MMCXCVII", "MMCXCVIII", "MMCXCIX", "MMCC", "MMCCI", "MMCCII", "MMCCIII", "MMCCIV", "MMCCV", "MMCCVI", "MMCCVII", "MMCCVIII", "MMCCIX", "MMCCX", "MMCCXI", "MMCCXII", "MMCCXIII", "MMCCXIV", "MMCCXV", "MMCCXVI", "MMCCXVII", "MMCCXVIII", "MMCCXIX", "MMCCXX", "MMCCXXI", "MMCCXXII", "MMCCXXIII", "MMCCXXIV", "MMCCXXV", "MMCCXXVI", "MMCCXXVII", "MMCCXXVIII", "MMCCXXIX", "MMCCXXX", "MMCCXXXI", "MMCCXXXII", "MMCCXXXIII", "MMCCXXXIV", "MMCCXXXV", "MMCCXXXVI", "MMCCXXXVII", "MMCCXXXVIII", "MMCCXXXIX", "MMCCXL", "MMCCXLI", "MMCCXLII", "MMCCXLIII", "MMCCXLIV", "MMCCXLV", "MMCCXLVI", "MMCCXLVII", "MMCCXLVIII", "MMCCXLIX", "MMCCL", "MMCCLI", "MMCCLII", "MMCCLIII", "MMCCLIV", "MMCCLV", "MMCCLVI", "MMCCLVII", "MMCCLVIII", "MMCCLIX", "MMCCLX", "MMCCLXI", "MMCCLXII", "MMCCLXIII", "MMCCLXIV", "MMCCLXV", "MMCCLXVI", "MMCCLXVII", "MMCCLXVIII", "MMCCLXIX", "MMCCLXX", "MMCCLXXI", "MMCCLXXII", "MMCCLXXIII", "MMCCLXXIV", "MMCCLXXV", "MMCCLXXVI", "MMCCLXXVII", "MMCCLXXVIII", "MMCCLXXIX", "MMCCLXXX", "MMCCLXXXI", "MMCCLXXXII", "MMCCLXXXIII", "MMCCLXXXIV", "MMCCLXXXV", "MMCCLXXXVI", "MMCCLXXXVII", "MMCCLXXXVIII", "MMCCLXXXIX", "MMCCXC", "MMCCXCI", "MMCCXCII", "MMCCXCIII", "MMCCXCIV", "MMCCXCV", "MMCCXCVI", "MMCCXCVII", "MMCCXCVIII", "MMCCXCIX", "MMCCC", "MMCCCI", "MMCCCII", "MMCCCIII", "MMCCCIV", "MMCCCV", "MMCCCVI", "MMCCCVII", "MMCCCVIII", "MMCCCIX", "MMCCCX", "MMCCCXI", "MMCCCXII", "MMCCCXIII", "MMCCCXIV", "MMCCCXV", "MMCCCXVI", "MMCCCXVII", "MMCCCXVIII", "MMCCCXIX", "MMCCCXX", "MMCCCXXI", "MMCCCXXII", "MMCCCXXIII", "MMCCCXXIV", "MMCCCXXV", "MMCCCXXVI", "MMCCCXXVII", "MMCCCXXVIII", "MMCCCXXIX", "MMCCCXXX", "MMCCCXXXI", "MMCCCXXXII", "MMCCCXXXIII", "MMCCCXXXIV", "MMCCCXXXV", "MMCCCXXXVI", "MMCCCXXXVII", "MMCCCXXXVIII", "MMCCCXXXIX", "MMCCCXL", "MMCCCXLI", "MMCCCXLII", "MMCCCXLIII", "MMCCCXLIV", "MMCCCXLV", "MMCCCXLVI", "MMCCCXLVII", "MMCCCXLVIII", "MMCCCXLIX", "MMCCCL", "MMCCCLI", "MMCCCLII", "MMCCCLIII", "MMCCCLIV", "MMCCCLV", "MMCCCLVI", "MMCCCLVII", "MMCCCLVIII", "MMCCCLIX", "MMCCCLX", "MMCCCLXI", "MMCCCLXII", "MMCCCLXIII", "MMCCCLXIV", "MMCCCLXV", "MMCCCLXVI", "MMCCCLXVII", "MMCCCLXVIII", "MMCCCLXIX", "MMCCCLXX", "MMCCCLXXI", "MMCCCLXXII", "MMCCCLXXIII", "MMCCCLXXIV", "MMCCCLXXV", "MMCCCLXXVI", "MMCCCLXXVII", "MMCCCLXXVIII", "MMCCCLXXIX", "MMCCCLXXX", "MMCCCLXXXI", "MMCCCLXXXII", "MMCCCLXXXIII", "MMCCCLXXXIV", "MMCCCLXXXV", "MMCCCLXXXVI", "MMCCCLXXXVII", "MMCCCLXXXVIII", "MMCCCLXXXIX", "MMCCCXC", "MMCCCXCI", "MMCCCXCII", "MMCCCXCIII", "MMCCCXCIV", "MMCCCXCV", "MMCCCXCVI", "MMCCCXCVII", "MMCCCXCVIII", "MMCCCXCIX", "MMCD", "MMCDI", "MMCDII", "MMCDIII", "MMCDIV", "MMCDV", "MMCDVI", "MMCDVII", "MMCDVIII", "MMCDIX", "MMCDX", "MMCDXI", "MMCDXII", "MMCDXIII", "MMCDXIV", "MMCDXV", "MMCDXVI", "MMCDXVII", "MMCDXVIII", "MMCDXIX", "MMCDXX", "MMCDXXI", "MMCDXXII", "MMCDXXIII", "MMCDXXIV", "MMCDXXV", "MMCDXXVI", "MMCDXXVII", "MMCDXXVIII", "MMCDXXIX", "MMCDXXX", "MMCDXXXI", "MMCDXXXII", "MMCDXXXIII", "MMCDXXXIV", "MMCDXXXV", "MMCDXXXVI", "MMCDXXXVII", "MMCDXXXVIII", "MMCDXXXIX", "MMCDXL", "MMCDXLI", "MMCDXLII", "MMCDXLIII", "MMCDXLIV", "MMCDXLV", "MMCDXLVI", "MMCDXLVII", "MMCDXLVIII", "MMCDXLIX", "MMCDL", "MMCDLI", "MMCDLII", "MMCDLIII", "MMCDLIV", "MMCDLV", "MMCDLVI", "MMCDLVII", "MMCDLVIII", "MMCDLIX", "MMCDLX", "MMCDLXI", "MMCDLXII", "MMCDLXIII", "MMCDLXIV", "MMCDLXV", "MMCDLXVI", "MMCDLXVII", "MMCDLXVIII", "MMCDLXIX", "MMCDLXX", "MMCDLXXI", "MMCDLXXII", "MMCDLXXIII", "MMCDLXXIV", "MMCDLXXV", "MMCDLXXVI", "MMCDLXXVII", "MMCDLXXVIII", "MMCDLXXIX", "MMCDLXXX", "MMCDLXXXI", "MMCDLXXXII", "MMCDLXXXIII", "MMCDLXXXIV", "MMCDLXXXV", "MMCDLXXXVI", "MMCDLXXXVII", "MMCDLXXXVIII", "MMCDLXXXIX", "MMCDXC", "MMCDXCI", "MMCDXCII", "MMCDXCIII", "MMCDXCIV", "MMCDXCV", "MMCDXCVI", "MMCDXCVII", "MMCDXCVIII", "MMCDXCIX", "MMD", "MMDI", "MMDII", "MMDIII", "MMDIV", "MMDV", "MMDVI", "MMDVII", "MMDVIII", "MMDIX", "MMDX", "MMDXI", "MMDXII", "MMDXIII", "MMDXIV", "MMDXV", "MMDXVI", "MMDXVII", "MMDXVIII", "MMDXIX", "MMDXX", "MMDXXI", "MMDXXII", "MMDXXIII", "MMDXXIV", "MMDXXV", "MMDXXVI", "MMDXXVII", "MMDXXVIII", "MMDXXIX", "MMDXXX", "MMDXXXI", "MMDXXXII", "MMDXXXIII", "MMDXXXIV", "MMDXXXV", "MMDXXXVI", "MMDXXXVII", "MMDXXXVIII", "MMDXXXIX", "MMDXL", "MMDXLI", "MMDXLII", "MMDXLIII", "MMDXLIV", "MMDXLV", "MMDXLVI", "MMDXLVII", "MMDXLVIII", "MMDXLIX", "MMDL", "MMDLI", "MMDLII", "MMDLIII", "MMDLIV", "MMDLV", "MMDLVI", "MMDLVII", "MMDLVIII", "MMDLIX", "MMDLX", "MMDLXI", "MMDLXII", "MMDLXIII", "MMDLXIV", "MMDLXV", "MMDLXVI", "MMDLXVII", "MMDLXVIII", "MMDLXIX", "MMDLXX", "MMDLXXI", "MMDLXXII", "MMDLXXIII", "MMDLXXIV", "MMDLXXV", "MMDLXXVI", "MMDLXXVII", "MMDLXXVIII", "MMDLXXIX", "MMDLXXX", "MMDLXXXI", "MMDLXXXII", "MMDLXXXIII", "MMDLXXXIV", "MMDLXXXV", "MMDLXXXVI", "MMDLXXXVII", "MMDLXXXVIII", "MMDLXXXIX", "MMDXC", "MMDXCI", "MMDXCII", "MMDXCIII", "MMDXCIV", "MMDXCV", "MMDXCVI", "MMDXCVII", "MMDXCVIII", "MMDXCIX", "MMDC", "MMDCI", "MMDCII", "MMDCIII", "MMDCIV", "MMDCV", "MMDCVI", "MMDCVII", "MMDCVIII", "MMDCIX", "MMDCX", "MMDCXI", "MMDCXII", "MMDCXIII", "MMDCXIV", "MMDCXV", "MMDCXVI", "MMDCXVII", "MMDCXVIII", "MMDCXIX", "MMDCXX", "MMDCXXI", "MMDCXXII", "MMDCXXIII", "MMDCXXIV", "MMDCXXV", "MMDCXXVI", "MMDCXXVII", "MMDCXXVIII", "MMDCXXIX", "MMDCXXX", "MMDCXXXI", "MMDCXXXII", "MMDCXXXIII", "MMDCXXXIV", "MMDCXXXV", "MMDCXXXVI", "MMDCXXXVII", "MMDCXXXVIII", "MMDCXXXIX", "MMDCXL", "MMDCXLI", "MMDCXLII", "MMDCXLIII", "MMDCXLIV", "MMDCXLV", "MMDCXLVI", "MMDCXLVII", "MMDCXLVIII", "MMDCXLIX", "MMDCL", "MMDCLI", "MMDCLII", "MMDCLIII", "MMDCLIV", "MMDCLV", "MMDCLVI", "MMDCLVII", "MMDCLVIII", "MMDCLIX", "MMDCLX", "MMDCLXI", "MMDCLXII", "MMDCLXIII", "MMDCLXIV", "MMDCLXV", "MMDCLXVI", "MMDCLXVII", "MMDCLXVIII", "MMDCLXIX", "MMDCLXX", "MMDCLXXI", "MMDCLXXII", "MMDCLXXIII", "MMDCLXXIV", "MMDCLXXV", "MMDCLXXVI", "MMDCLXXVII", "MMDCLXXVIII", "MMDCLXXIX", "MMDCLXXX", "MMDCLXXXI", "MMDCLXXXII", "MMDCLXXXIII", "MMDCLXXXIV", "MMDCLXXXV", "MMDCLXXXVI", "MMDCLXXXVII", "MMDCLXXXVIII", "MMDCLXXXIX", "MMDCXC", "MMDCXCI", "MMDCXCII", "MMDCXCIII", "MMDCXCIV", "MMDCXCV", "MMDCXCVI", "MMDCXCVII", "MMDCXCVIII", "MMDCXCIX", "MMDCC", "MMDCCI", "MMDCCII", "MMDCCIII", "MMDCCIV", "MMDCCV", "MMDCCVI", "MMDCCVII", "MMDCCVIII", "MMDCCIX", "MMDCCX", "MMDCCXI", "MMDCCXII", "MMDCCXIII", "MMDCCXIV", "MMDCCXV", "MMDCCXVI", "MMDCCXVII", "MMDCCXVIII", "MMDCCXIX", "MMDCCXX", "MMDCCXXI", "MMDCCXXII", "MMDCCXXIII", "MMDCCXXIV", "MMDCCXXV", "MMDCCXXVI", "MMDCCXXVII", "MMDCCXXVIII", "MMDCCXXIX", "MMDCCXXX", "MMDCCXXXI", "MMDCCXXXII", "MMDCCXXXIII", "MMDCCXXXIV", "MMDCCXXXV", "MMDCCXXXVI", "MMDCCXXXVII", "MMDCCXXXVIII", "MMDCCXXXIX", "MMDCCXL", "MMDCCXLI", "MMDCCXLII", "MMDCCXLIII", "MMDCCXLIV", "MMDCCXLV", "MMDCCXLVI", "MMDCCXLVII", "MMDCCXLVIII", "MMDCCXLIX", "MMDCCL", "MMDCCLI", "MMDCCLII", "MMDCCLIII", "MMDCCLIV", "MMDCCLV", "MMDCCLVI", "MMDCCLVII", "MMDCCLVIII", "MMDCCLIX", "MMDCCLX", "MMDCCLXI", "MMDCCLXII", "MMDCCLXIII", "MMDCCLXIV", "MMDCCLXV", "MMDCCLXVI", "MMDCCLXVII", "MMDCCLXVIII", "MMDCCLXIX", "MMDCCLXX", "MMDCCLXXI", "MMDCCLXXII", "MMDCCLXXIII", "MMDCCLXXIV", "MMDCCLXXV", "MMDCCLXXVI", "MMDCCLXXVII", "MMDCCLXXVIII", "MMDCCLXXIX", "MMDCCLXXX", "MMDCCLXXXI", "MMDCCLXXXII", "MMDCCLXXXIII", "MMDCCLXXXIV", "MMDCCLXXXV", "MMDCCLXXXVI", "MMDCCLXXXVII", "MMDCCLXXXVIII", "MMDCCLXXXIX", "MMDCCXC", "MMDCCXCI", "MMDCCXCII", "MMDCCXCIII", "MMDCCXCIV", "MMDCCXCV", "MMDCCXCVI", "MMDCCXCVII", "MMDCCXCVIII", "MMDCCXCIX", "MMDCCC", "MMDCCCI", "MMDCCCII", "MMDCCCIII", "MMDCCCIV", "MMDCCCV", "MMDCCCVI", "MMDCCCVII", "MMDCCCVIII", "MMDCCCIX", "MMDCCCX", "MMDCCCXI", "MMDCCCXII", "MMDCCCXIII", "MMDCCCXIV", "MMDCCCXV", "MMDCCCXVI", "MMDCCCXVII", "MMDCCCXVIII", "MMDCCCXIX", "MMDCCCXX", "MMDCCCXXI", "MMDCCCXXII", "MMDCCCXXIII", "MMDCCCXXIV", "MMDCCCXXV", "MMDCCCXXVI", "MMDCCCXXVII", "MMDCCCXXVIII", "MMDCCCXXIX", "MMDCCCXXX", "MMDCCCXXXI", "MMDCCCXXXII", "MMDCCCXXXIII", "MMDCCCXXXIV", "MMDCCCXXXV", "MMDCCCXXXVI", "MMDCCCXXXVII", "MMDCCCXXXVIII", "MMDCCCXXXIX", "MMDCCCXL", "MMDCCCXLI", "MMDCCCXLII", "MMDCCCXLIII", "MMDCCCXLIV", "MMDCCCXLV", "MMDCCCXLVI", "MMDCCCXLVII", "MMDCCCXLVIII", "MMDCCCXLIX", "MMDCCCL", "MMDCCCLI", "MMDCCCLII", "MMDCCCLIII", "MMDCCCLIV", "MMDCCCLV", "MMDCCCLVI", "MMDCCCLVII", "MMDCCCLVIII", "MMDCCCLIX", "MMDCCCLX", "MMDCCCLXI", "MMDCCCLXII", "MMDCCCLXIII", "MMDCCCLXIV", "MMDCCCLXV", "MMDCCCLXVI", "MMDCCCLXVII", "MMDCCCLXVIII", "MMDCCCLXIX", "MMDCCCLXX", "MMDCCCLXXI", "MMDCCCLXXII", "MMDCCCLXXIII", "MMDCCCLXXIV", "MMDCCCLXXV", "MMDCCCLXXVI", "MMDCCCLXXVII", "MMDCCCLXXVIII", "MMDCCCLXXIX", "MMDCCCLXXX", "MMDCCCLXXXI", "MMDCCCLXXXII", "MMDCCCLXXXIII", "MMDCCCLXXXIV", "MMDCCCLXXXV", "MMDCCCLXXXVI", "MMDCCCLXXXVII", "MMDCCCLXXXVIII", "MMDCCCLXXXIX", "MMDCCCXC", "MMDCCCXCI", "MMDCCCXCII", "MMDCCCXCIII", "MMDCCCXCIV", "MMDCCCXCV", "MMDCCCXCVI", "MMDCCCXCVII", "MMDCCCXCVIII", "MMDCCCXCIX", "MMCM", "MMCMI", "MMCMII", "MMCMIII", "MMCMIV", "MMCMV", "MMCMVI", "MMCMVII", "MMCMVIII", "MMCMIX", "MMCMX", "MMCMXI", "MMCMXII", "MMCMXIII", "MMCMXIV", "MMCMXV", "MMCMXVI", "MMCMXVII", "MMCMXVIII", "MMCMXIX", "MMCMXX", "MMCMXXI", "MMCMXXII", "MMCMXXIII", "MMCMXXIV", "MMCMXXV", "MMCMXXVI", "MMCMXXVII", "MMCMXXVIII", "MMCMXXIX", "MMCMXXX", "MMCMXXXI", "MMCMXXXII", "MMCMXXXIII", "MMCMXXXIV", "MMCMXXXV", "MMCMXXXVI", "MMCMXXXVII", "MMCMXXXVIII", "MMCMXXXIX", "MMCMXL", "MMCMXLI", "MMCMXLII", "MMCMXLIII", "MMCMXLIV", "MMCMXLV", "MMCMXLVI", "MMCMXLVII", "MMCMXLVIII", "MMCMXLIX", "MMCML", "MMCMLI", "MMCMLII", "MMCMLIII", "MMCMLIV", "MMCMLV", "MMCMLVI", "MMCMLVII", "MMCMLVIII", "MMCMLIX", "MMCMLX", "MMCMLXI", "MMCMLXII", "MMCMLXIII", "MMCMLXIV", "MMCMLXV", "MMCMLXVI", "MMCMLXVII", "MMCMLXVIII", "MMCMLXIX", "MMCMLXX", "MMCMLXXI", "MMCMLXXII", "MMCMLXXIII", "MMCMLXXIV", "MMCMLXXV", "MMCMLXXVI", "MMCMLXXVII", "MMCMLXXVIII", "MMCMLXXIX", "MMCMLXXX", "MMCMLXXXI", "MMCMLXXXII", "MMCMLXXXIII", "MMCMLXXXIV", "MMCMLXXXV", "MMCMLXXXVI", "MMCMLXXXVII", "MMCMLXXXVIII", "MMCMLXXXIX", "MMCMXC", "MMCMXCI", "MMCMXCII", "MMCMXCIII", "MMCMXCIV", "MMCMXCV", "MMCMXCVI", "MMCMXCVII", "MMCMXCVIII", "MMCMXCIX", "MMM", "MMMI", "MMMII", "MMMIII", "MMMIV", "MMMV", "MMMVI", "MMMVII", "MMMVIII", "MMMIX", "MMMX", "MMMXI", "MMMXII", "MMMXIII", "MMMXIV", "MMMXV", "MMMXVI", "MMMXVII", "MMMXVIII", "MMMXIX", "MMMXX", "MMMXXI", "MMMXXII", "MMMXXIII", "MMMXXIV", "MMMXXV", "MMMXXVI", "MMMXXVII", "MMMXXVIII", "MMMXXIX", "MMMXXX", "MMMXXXI", "MMMXXXII", "MMMXXXIII", "MMMXXXIV", "MMMXXXV", "MMMXXXVI", "MMMXXXVII", "MMMXXXVIII", "MMMXXXIX", "MMMXL", "MMMXLI", "MMMXLII", "MMMXLIII", "MMMXLIV", "MMMXLV", "MMMXLVI", "MMMXLVII", "MMMXLVIII", "MMMXLIX", "MMML", "MMMLI", "MMMLII", "MMMLIII", "MMMLIV", "MMMLV", "MMMLVI", "MMMLVII", "MMMLVIII", "MMMLIX", "MMMLX", "MMMLXI", "MMMLXII", "MMMLXIII", "MMMLXIV", "MMMLXV", "MMMLXVI", "MMMLXVII", "MMMLXVIII", "MMMLXIX", "MMMLXX", "MMMLXXI", "MMMLXXII", "MMMLXXIII", "MMMLXXIV", "MMMLXXV", "MMMLXXVI", "MMMLXXVII", "MMMLXXVIII", "MMMLXXIX", "MMMLXXX", "MMMLXXXI", "MMMLXXXII", "MMMLXXXIII", "MMMLXXXIV", "MMMLXXXV", "MMMLXXXVI", "MMMLXXXVII", "MMMLXXXVIII", "MMMLXXXIX", "MMMXC", "MMMXCI", "MMMXCII", "MMMXCIII", "MMMXCIV", "MMMXCV", "MMMXCVI", "MMMXCVII", "MMMXCVIII", "MMMXCIX", "MMMC", "MMMCI", "MMMCII", "MMMCIII", "MMMCIV", "MMMCV", "MMMCVI", "MMMCVII", "MMMCVIII", "MMMCIX", "MMMCX", "MMMCXI", "MMMCXII", "MMMCXIII", "MMMCXIV", "MMMCXV", "MMMCXVI", "MMMCXVII", "MMMCXVIII", "MMMCXIX", "MMMCXX", "MMMCXXI", "MMMCXXII", "MMMCXXIII", "MMMCXXIV", "MMMCXXV", "MMMCXXVI", "MMMCXXVII", "MMMCXXVIII", "MMMCXXIX", "MMMCXXX", "MMMCXXXI", "MMMCXXXII", "MMMCXXXIII", "MMMCXXXIV", "MMMCXXXV", "MMMCXXXVI", "MMMCXXXVII", "MMMCXXXVIII", "MMMCXXXIX", "MMMCXL", "MMMCXLI", "MMMCXLII", "MMMCXLIII", "MMMCXLIV", "MMMCXLV", "MMMCXLVI", "MMMCXLVII", "MMMCXLVIII", "MMMCXLIX", "MMMCL", "MMMCLI", "MMMCLII", "MMMCLIII", "MMMCLIV", "MMMCLV", "MMMCLVI", "MMMCLVII", "MMMCLVIII", "MMMCLIX", "MMMCLX", "MMMCLXI", "MMMCLXII", "MMMCLXIII", "MMMCLXIV", "MMMCLXV", "MMMCLXVI", "MMMCLXVII", "MMMCLXVIII", "MMMCLXIX", "MMMCLXX", "MMMCLXXI", "MMMCLXXII", "MMMCLXXIII", "MMMCLXXIV", "MMMCLXXV", "MMMCLXXVI", "MMMCLXXVII", "MMMCLXXVIII", "MMMCLXXIX", "MMMCLXXX", "MMMCLXXXI", "MMMCLXXXII", "MMMCLXXXIII", "MMMCLXXXIV", "MMMCLXXXV", "MMMCLXXXVI", "MMMCLXXXVII", "MMMCLXXXVIII", "MMMCLXXXIX", "MMMCXC", "MMMCXCI", "MMMCXCII", "MMMCXCIII", "MMMCXCIV", "MMMCXCV", "MMMCXCVI", "MMMCXCVII", "MMMCXCVIII", "MMMCXCIX", "MMMCC", "MMMCCI", "MMMCCII", "MMMCCIII", "MMMCCIV", "MMMCCV", "MMMCCVI", "MMMCCVII", "MMMCCVIII", "MMMCCIX", "MMMCCX", "MMMCCXI", "MMMCCXII", "MMMCCXIII", "MMMCCXIV", "MMMCCXV", "MMMCCXVI", "MMMCCXVII", "MMMCCXVIII", "MMMCCXIX", "MMMCCXX", "MMMCCXXI", "MMMCCXXII", "MMMCCXXIII", "MMMCCXXIV", "MMMCCXXV", "MMMCCXXVI", "MMMCCXXVII", "MMMCCXXVIII", "MMMCCXXIX", "MMMCCXXX", "MMMCCXXXI", "MMMCCXXXII", "MMMCCXXXIII", "MMMCCXXXIV", "MMMCCXXXV", "MMMCCXXXVI", "MMMCCXXXVII", "MMMCCXXXVIII", "MMMCCXXXIX", "MMMCCXL", "MMMCCXLI", "MMMCCXLII", "MMMCCXLIII", "MMMCCXLIV", "MMMCCXLV", "MMMCCXLVI", "MMMCCXLVII", "MMMCCXLVIII", "MMMCCXLIX", "MMMCCL", "MMMCCLI", "MMMCCLII", "MMMCCLIII", "MMMCCLIV", "MMMCCLV", "MMMCCLVI", "MMMCCLVII", "MMMCCLVIII", "MMMCCLIX", "MMMCCLX", "MMMCCLXI", "MMMCCLXII", "MMMCCLXIII", "MMMCCLXIV", "MMMCCLXV", "MMMCCLXVI", "MMMCCLXVII", "MMMCCLXVIII", "MMMCCLXIX", "MMMCCLXX", "MMMCCLXXI", "MMMCCLXXII", "MMMCCLXXIII", "MMMCCLXXIV", "MMMCCLXXV", "MMMCCLXXVI", "MMMCCLXXVII", "MMMCCLXXVIII", "MMMCCLXXIX", "MMMCCLXXX", "MMMCCLXXXI", "MMMCCLXXXII", "MMMCCLXXXIII", "MMMCCLXXXIV", "MMMCCLXXXV", "MMMCCLXXXVI", "MMMCCLXXXVII", "MMMCCLXXXVIII", "MMMCCLXXXIX", "MMMCCXC", "MMMCCXCI", "MMMCCXCII", "MMMCCXCIII", "MMMCCXCIV", "MMMCCXCV", "MMMCCXCVI", "MMMCCXCVII", "MMMCCXCVIII", "MMMCCXCIX", "MMMCCC", "MMMCCCI", "MMMCCCII", "MMMCCCIII", "MMMCCCIV", "MMMCCCV", "MMMCCCVI", "MMMCCCVII", "MMMCCCVIII", "MMMCCCIX", "MMMCCCX", "MMMCCCXI", "MMMCCCXII", "MMMCCCXIII", "MMMCCCXIV", "MMMCCCXV", "MMMCCCXVI", "MMMCCCXVII", "MMMCCCXVIII", "MMMCCCXIX", "MMMCCCXX", "MMMCCCXXI", "MMMCCCXXII", "MMMCCCXXIII", "MMMCCCXXIV", "MMMCCCXXV", "MMMCCCXXVI", "MMMCCCXXVII", "MMMCCCXXVIII", "MMMCCCXXIX", "MMMCCCXXX", "MMMCCCXXXI", "MMMCCCXXXII", "MMMCCCXXXIII", "MMMCCCXXXIV", "MMMCCCXXXV", "MMMCCCXXXVI", "MMMCCCXXXVII", "MMMCCCXXXVIII", "MMMCCCXXXIX", "MMMCCCXL", "MMMCCCXLI", "MMMCCCXLII", "MMMCCCXLIII", "MMMCCCXLIV", "MMMCCCXLV", "MMMCCCXLVI", "MMMCCCXLVII", "MMMCCCXLVIII", "MMMCCCXLIX", "MMMCCCL", "MMMCCCLI", "MMMCCCLII", "MMMCCCLIII", "MMMCCCLIV", "MMMCCCLV", "MMMCCCLVI", "MMMCCCLVII", "MMMCCCLVIII", "MMMCCCLIX", "MMMCCCLX", "MMMCCCLXI", "MMMCCCLXII", "MMMCCCLXIII", "MMMCCCLXIV", "MMMCCCLXV", "MMMCCCLXVI", "MMMCCCLXVII", "MMMCCCLXVIII", "MMMCCCLXIX", "MMMCCCLXX", "MMMCCCLXXI", "MMMCCCLXXII", "MMMCCCLXXIII", "MMMCCCLXXIV", "MMMCCCLXXV", "MMMCCCLXXVI", "MMMCCCLXXVII", "MMMCCCLXXVIII", "MMMCCCLXXIX", "MMMCCCLXXX", "MMMCCCLXXXI", "MMMCCCLXXXII", "MMMCCCLXXXIII", "MMMCCCLXXXIV", "MMMCCCLXXXV", "MMMCCCLXXXVI", "MMMCCCLXXXVII", "MMMCCCLXXXVIII", "MMMCCCLXXXIX", "MMMCCCXC", "MMMCCCXCI", "MMMCCCXCII", "MMMCCCXCIII", "MMMCCCXCIV", "MMMCCCXCV", "MMMCCCXCVI", "MMMCCCXCVII", "MMMCCCXCVIII", "MMMCCCXCIX", "MMMCD", "MMMCDI", "MMMCDII", "MMMCDIII", "MMMCDIV", "MMMCDV", "MMMCDVI", "MMMCDVII", "MMMCDVIII", "MMMCDIX", "MMMCDX", "MMMCDXI", "MMMCDXII", "MMMCDXIII", "MMMCDXIV", "MMMCDXV", "MMMCDXVI", "MMMCDXVII", "MMMCDXVIII", "MMMCDXIX", "MMMCDXX", "MMMCDXXI", "MMMCDXXII", "MMMCDXXIII", "MMMCDXXIV", "MMMCDXXV", "MMMCDXXVI", "MMMCDXXVII", "MMMCDXXVIII", "MMMCDXXIX", "MMMCDXXX", "MMMCDXXXI", "MMMCDXXXII", "MMMCDXXXIII", "MMMCDXXXIV", "MMMCDXXXV", "MMMCDXXXVI", "MMMCDXXXVII", "MMMCDXXXVIII", "MMMCDXXXIX", "MMMCDXL", "MMMCDXLI", "MMMCDXLII", "MMMCDXLIII", "MMMCDXLIV", "MMMCDXLV", "MMMCDXLVI", "MMMCDXLVII", "MMMCDXLVIII", "MMMCDXLIX", "MMMCDL", "MMMCDLI", "MMMCDLII", "MMMCDLIII", "MMMCDLIV", "MMMCDLV", "MMMCDLVI", "MMMCDLVII", "MMMCDLVIII", "MMMCDLIX", "MMMCDLX", "MMMCDLXI", "MMMCDLXII", "MMMCDLXIII", "MMMCDLXIV", "MMMCDLXV", "MMMCDLXVI", "MMMCDLXVII", "MMMCDLXVIII", "MMMCDLXIX", "MMMCDLXX", "MMMCDLXXI", "MMMCDLXXII", "MMMCDLXXIII", "MMMCDLXXIV", "MMMCDLXXV", "MMMCDLXXVI", "MMMCDLXXVII", "MMMCDLXXVIII", "MMMCDLXXIX", "MMMCDLXXX", "MMMCDLXXXI", "MMMCDLXXXII", "MMMCDLXXXIII", "MMMCDLXXXIV", "MMMCDLXXXV", "MMMCDLXXXVI", "MMMCDLXXXVII", "MMMCDLXXXVIII", "MMMCDLXXXIX", "MMMCDXC", "MMMCDXCI", "MMMCDXCII", "MMMCDXCIII", "MMMCDXCIV", "MMMCDXCV", "MMMCDXCVI", "MMMCDXCVII", "MMMCDXCVIII", "MMMCDXCIX", "MMMD", "MMMDI", "MMMDII", "MMMDIII", "MMMDIV", "MMMDV", "MMMDVI", "MMMDVII", "MMMDVIII", "MMMDIX", "MMMDX", "MMMDXI", "MMMDXII", "MMMDXIII", "MMMDXIV", "MMMDXV", "MMMDXVI", "MMMDXVII", "MMMDXVIII", "MMMDXIX", "MMMDXX", "MMMDXXI", "MMMDXXII", "MMMDXXIII", "MMMDXXIV", "MMMDXXV", "MMMDXXVI", "MMMDXXVII", "MMMDXXVIII", "MMMDXXIX", "MMMDXXX", "MMMDXXXI", "MMMDXXXII", "MMMDXXXIII", "MMMDXXXIV", "MMMDXXXV", "MMMDXXXVI", "MMMDXXXVII", "MMMDXXXVIII", "MMMDXXXIX", "MMMDXL", "MMMDXLI", "MMMDXLII", "MMMDXLIII", "MMMDXLIV", "MMMDXLV", "MMMDXLVI", "MMMDXLVII", "MMMDXLVIII", "MMMDXLIX", "MMMDL", "MMMDLI", "MMMDLII", "MMMDLIII", "MMMDLIV", "MMMDLV", "MMMDLVI", "MMMDLVII", "MMMDLVIII", "MMMDLIX", "MMMDLX", "MMMDLXI", "MMMDLXII", "MMMDLXIII", "MMMDLXIV", "MMMDLXV", "MMMDLXVI", "MMMDLXVII", "MMMDLXVIII", "MMMDLXIX", "MMMDLXX", "MMMDLXXI", "MMMDLXXII", "MMMDLXXIII", "MMMDLXXIV", "MMMDLXXV", "MMMDLXXVI", "MMMDLXXVII", "MMMDLXXVIII", "MMMDLXXIX", "MMMDLXXX", "MMMDLXXXI", "MMMDLXXXII", "MMMDLXXXIII", "MMMDLXXXIV", "MMMDLXXXV", "MMMDLXXXVI", "MMMDLXXXVII", "MMMDLXXXVIII", "MMMDLXXXIX", "MMMDXC", "MMMDXCI", "MMMDXCII", "MMMDXCIII", "MMMDXCIV", "MMMDXCV", "MMMDXCVI", "MMMDXCVII", "MMMDXCVIII", "MMMDXCIX", "MMMDC", "MMMDCI", "MMMDCII", "MMMDCIII", "MMMDCIV", "MMMDCV", "MMMDCVI", "MMMDCVII", "MMMDCVIII", "MMMDCIX", "MMMDCX", "MMMDCXI", "MMMDCXII", "MMMDCXIII", "MMMDCXIV", "MMMDCXV", "MMMDCXVI", "MMMDCXVII", "MMMDCXVIII", "MMMDCXIX", "MMMDCXX", "MMMDCXXI", "MMMDCXXII", "MMMDCXXIII", "MMMDCXXIV", "MMMDCXXV", "MMMDCXXVI", "MMMDCXXVII", "MMMDCXXVIII", "MMMDCXXIX", "MMMDCXXX", "MMMDCXXXI", "MMMDCXXXII", "MMMDCXXXIII", "MMMDCXXXIV", "MMMDCXXXV", "MMMDCXXXVI", "MMMDCXXXVII", "MMMDCXXXVIII", "MMMDCXXXIX", "MMMDCXL", "MMMDCXLI", "MMMDCXLII", "MMMDCXLIII", "MMMDCXLIV", "MMMDCXLV", "MMMDCXLVI", "MMMDCXLVII", "MMMDCXLVIII", "MMMDCXLIX", "MMMDCL", "MMMDCLI", "MMMDCLII", "MMMDCLIII", "MMMDCLIV", "MMMDCLV", "MMMDCLVI", "MMMDCLVII", "MMMDCLVIII", "MMMDCLIX", "MMMDCLX", "MMMDCLXI", "MMMDCLXII", "MMMDCLXIII", "MMMDCLXIV", "MMMDCLXV", "MMMDCLXVI", "MMMDCLXVII", "MMMDCLXVIII", "MMMDCLXIX", "MMMDCLXX", "MMMDCLXXI", "MMMDCLXXII", "MMMDCLXXIII", "MMMDCLXXIV", "MMMDCLXXV", "MMMDCLXXVI", "MMMDCLXXVII", "MMMDCLXXVIII", "MMMDCLXXIX", "MMMDCLXXX", "MMMDCLXXXI", "MMMDCLXXXII", "MMMDCLXXXIII", "MMMDCLXXXIV", "MMMDCLXXXV", "MMMDCLXXXVI", "MMMDCLXXXVII", "MMMDCLXXXVIII", "MMMDCLXXXIX", "MMMDCXC", "MMMDCXCI", "MMMDCXCII", "MMMDCXCIII", "MMMDCXCIV", "MMMDCXCV", "MMMDCXCVI", "MMMDCXCVII", "MMMDCXCVIII", "MMMDCXCIX", "MMMDCC", "MMMDCCI", "MMMDCCII", "MMMDCCIII", "MMMDCCIV", "MMMDCCV", "MMMDCCVI", "MMMDCCVII", "MMMDCCVIII", "MMMDCCIX", "MMMDCCX", "MMMDCCXI", "MMMDCCXII", "MMMDCCXIII", "MMMDCCXIV", "MMMDCCXV", "MMMDCCXVI", "MMMDCCXVII", "MMMDCCXVIII", "MMMDCCXIX", "MMMDCCXX", "MMMDCCXXI", "MMMDCCXXII", "MMMDCCXXIII", "MMMDCCXXIV", "MMMDCCXXV", "MMMDCCXXVI", "MMMDCCXXVII", "MMMDCCXXVIII", "MMMDCCXXIX", "MMMDCCXXX", "MMMDCCXXXI", "MMMDCCXXXII", "MMMDCCXXXIII", "MMMDCCXXXIV", "MMMDCCXXXV", "MMMDCCXXXVI", "MMMDCCXXXVII", "MMMDCCXXXVIII", "MMMDCCXXXIX", "MMMDCCXL", "MMMDCCXLI", "MMMDCCXLII", "MMMDCCXLIII", "MMMDCCXLIV", "MMMDCCXLV", "MMMDCCXLVI", "MMMDCCXLVII", "MMMDCCXLVIII", "MMMDCCXLIX", "MMMDCCL", "MMMDCCLI", "MMMDCCLII", "MMMDCCLIII", "MMMDCCLIV", "MMMDCCLV", "MMMDCCLVI", "MMMDCCLVII", "MMMDCCLVIII", "MMMDCCLIX", "MMMDCCLX", "MMMDCCLXI", "MMMDCCLXII", "MMMDCCLXIII", "MMMDCCLXIV", "MMMDCCLXV", "MMMDCCLXVI", "MMMDCCLXVII", "MMMDCCLXVIII", "MMMDCCLXIX", "MMMDCCLXX", "MMMDCCLXXI", "MMMDCCLXXII", "MMMDCCLXXIII", "MMMDCCLXXIV", "MMMDCCLXXV", "MMMDCCLXXVI", "MMMDCCLXXVII", "MMMDCCLXXVIII", "MMMDCCLXXIX", "MMMDCCLXXX", "MMMDCCLXXXI", "MMMDCCLXXXII", "MMMDCCLXXXIII", "MMMDCCLXXXIV", "MMMDCCLXXXV", "MMMDCCLXXXVI", "MMMDCCLXXXVII", "MMMDCCLXXXVIII", "MMMDCCLXXXIX", "MMMDCCXC", "MMMDCCXCI", "MMMDCCXCII", "MMMDCCXCIII", "MMMDCCXCIV", "MMMDCCXCV", "MMMDCCXCVI", "MMMDCCXCVII", "MMMDCCXCVIII", "MMMDCCXCIX", "MMMDCCC", "MMMDCCCI", "MMMDCCCII", "MMMDCCCIII", "MMMDCCCIV", "MMMDCCCV", "MMMDCCCVI", "MMMDCCCVII", "MMMDCCCVIII", "MMMDCCCIX", "MMMDCCCX", "MMMDCCCXI", "MMMDCCCXII", "MMMDCCCXIII", "MMMDCCCXIV", "MMMDCCCXV", "MMMDCCCXVI", "MMMDCCCXVII", "MMMDCCCXVIII", "MMMDCCCXIX", "MMMDCCCXX", "MMMDCCCXXI", "MMMDCCCXXII", "MMMDCCCXXIII", "MMMDCCCXXIV", "MMMDCCCXXV", "MMMDCCCXXVI", "MMMDCCCXXVII", "MMMDCCCXXVIII", "MMMDCCCXXIX", "MMMDCCCXXX", "MMMDCCCXXXI", "MMMDCCCXXXII", "MMMDCCCXXXIII", "MMMDCCCXXXIV", "MMMDCCCXXXV", "MMMDCCCXXXVI", "MMMDCCCXXXVII", "MMMDCCCXXXVIII", "MMMDCCCXXXIX", "MMMDCCCXL", "MMMDCCCXLI", "MMMDCCCXLII", "MMMDCCCXLIII", "MMMDCCCXLIV", "MMMDCCCXLV", "MMMDCCCXLVI", "MMMDCCCXLVII", "MMMDCCCXLVIII", "MMMDCCCXLIX", "MMMDCCCL", "MMMDCCCLI", "MMMDCCCLII", "MMMDCCCLIII", "MMMDCCCLIV", "MMMDCCCLV", "MMMDCCCLVI", "MMMDCCCLVII", "MMMDCCCLVIII", "MMMDCCCLIX", "MMMDCCCLX", "MMMDCCCLXI", "MMMDCCCLXII", "MMMDCCCLXIII", "MMMDCCCLXIV", "MMMDCCCLXV", "MMMDCCCLXVI", "MMMDCCCLXVII", "MMMDCCCLXVIII", "MMMDCCCLXIX", "MMMDCCCLXX", "MMMDCCCLXXI", "MMMDCCCLXXII", "MMMDCCCLXXIII", "MMMDCCCLXXIV", "MMMDCCCLXXV", "MMMDCCCLXXVI", "MMMDCCCLXXVII", "MMMDCCCLXXVIII", "MMMDCCCLXXIX", "MMMDCCCLXXX", "MMMDCCCLXXXI", "MMMDCCCLXXXII", "MMMDCCCLXXXIII", "MMMDCCCLXXXIV", "MMMDCCCLXXXV", "MMMDCCCLXXXVI", "MMMDCCCLXXXVII", "MMMDCCCLXXXVIII", "MMMDCCCLXXXIX", "MMMDCCCXC", "MMMDCCCXCI", "MMMDCCCXCII", "MMMDCCCXCIII", "MMMDCCCXCIV", "MMMDCCCXCV", "MMMDCCCXCVI", "MMMDCCCXCVII", "MMMDCCCXCVIII", "MMMDCCCXCIX", "MMMCM", "MMMCMI", "MMMCMII", "MMMCMIII", "MMMCMIV", "MMMCMV", "MMMCMVI", "MMMCMVII", "MMMCMVIII", "MMMCMIX", "MMMCMX", "MMMCMXI", "MMMCMXII", "MMMCMXIII", "MMMCMXIV", "MMMCMXV", "MMMCMXVI", "MMMCMXVII", "MMMCMXVIII", "MMMCMXIX", "MMMCMXX", "MMMCMXXI", "MMMCMXXII", "MMMCMXXIII", "MMMCMXXIV", "MMMCMXXV", "MMMCMXXVI", "MMMCMXXVII", "MMMCMXXVIII", "MMMCMXXIX", "MMMCMXXX", "MMMCMXXXI", "MMMCMXXXII", "MMMCMXXXIII", "MMMCMXXXIV", "MMMCMXXXV", "MMMCMXXXVI", "MMMCMXXXVII", "MMMCMXXXVIII", "MMMCMXXXIX", "MMMCMXL", "MMMCMXLI", "MMMCMXLII", "MMMCMXLIII", "MMMCMXLIV", "MMMCMXLV", "MMMCMXLVI", "MMMCMXLVII", "MMMCMXLVIII", "MMMCMXLIX", "MMMCML", "MMMCMLI", "MMMCMLII", "MMMCMLIII", "MMMCMLIV", "MMMCMLV", "MMMCMLVI", "MMMCMLVII", "MMMCMLVIII", "MMMCMLIX", "MMMCMLX", "MMMCMLXI", "MMMCMLXII", "MMMCMLXIII", "MMMCMLXIV", "MMMCMLXV", "MMMCMLXVI", "MMMCMLXVII", "MMMCMLXVIII", "MMMCMLXIX", "MMMCMLXX", "MMMCMLXXI", "MMMCMLXXII", "MMMCMLXXIII", "MMMCMLXXIV", "MMMCMLXXV", "MMMCMLXXVI", "MMMCMLXXVII", "MMMCMLXXVIII", "MMMCMLXXIX", "MMMCMLXXX", "MMMCMLXXXI", "MMMCMLXXXII", "MMMCMLXXXIII", "MMMCMLXXXIV", "MMMCMLXXXV", "MMMCMLXXXVI", "MMMCMLXXXVII", "MMMCMLXXXVIII", "MMMCMLXXXIX", "MMMCMXC", "MMMCMXCI", "MMMCMXCII", "MMMCMXCIII", "MMMCMXCIV", "MMMCMXCV", "MMMCMXCVI", "MMMCMXCVII", "MMMCMXCVIII", "MMMCMXCIX" }; class Solution { public: string intToRoman(int num) { return cheat_chart[num]; } }; class Solution00 { public: string intToRoman(int num) { string str_rtn; str_rtn.append(OneDigitIntToRaman<'M', '?', '?'>(num / 1000)); str_rtn.append(OneDigitIntToRaman<'C', 'D', 'M'>((num / 100) % 10)); str_rtn.append(OneDigitIntToRaman<'X', 'L', 'C'>((num / 10) % 10)); str_rtn += OneDigitIntToRaman<'I', 'V', 'X'>(num % 10); return str_rtn; } private: template <char ONE, char FIVE, char TEN> string OneDigitIntToRaman(int num) { assert(0 <= num && num < 10); char rtn_val[][5] = {{}, {ONE}, {ONE, ONE}, {ONE, ONE, ONE}, {ONE, FIVE}, {FIVE}, {FIVE, ONE}, {FIVE, ONE, ONE}, {FIVE, ONE, ONE, ONE}, {ONE, TEN}}; return rtn_val[num]; } }; int main00(void) { Solution sln; string rtn = sln.intToRoman(10); assert(rtn == "X"); rtn = sln.intToRoman(58); assert(rtn == "LVIII"); rtn = sln.intToRoman(1994); assert(rtn == "MCMXCIV"); return 0; } int main(int argc, char const *argv[]) { // Solution sln; // std::ofstream file("out.file"); // for (int i = 1; i < 4000; ++i) { // file << "\"" << sln.intToRoman(i) << "\", "; // if(i%100==0) file<<'\n'; // } // Solution sln; // Solution00 sln0; // for (int i = 1; i < 4000; ++i) { // assert(sln.intToRoman(i) == sln0.intToRoman(i)); // } size_t max = 0; for (const auto &str : cheat_arr) { if (max < str.size()) max = str.size(); } return 0; }
543.716763
1,498
0.648331
LuciusKyle
4d297430a48c4e706fb72fb72a3f98aebcd32ae8
16,035
cpp
C++
FGUI/widgets/form.cpp
Jacckii/fgui
668d80b00c8c3e7908f5f67dd42260fe04ac01e4
[ "MIT" ]
null
null
null
FGUI/widgets/form.cpp
Jacckii/fgui
668d80b00c8c3e7908f5f67dd42260fe04ac01e4
[ "MIT" ]
null
null
null
FGUI/widgets/form.cpp
Jacckii/fgui
668d80b00c8c3e7908f5f67dd42260fe04ac01e4
[ "MIT" ]
null
null
null
// // FGUI - feature rich graphical user interface // // library includes #include "form.hpp" #include "groupbox.hpp" namespace FGUI { void CForm::Render() { // handle input system FGUI::INPUT.PullInput(); if (FGUI::INPUT.GetKeyPress(GetKey())) { // toggle main form on and off SetState(!GetState()); } // if the user toggles the main form if (GetState()) { // update main form Update(); // handle main form movement Movement(); // populate main form geometry Geometry(); } // iterate over child forms for (const std::shared_ptr<FGUI::CForm>& childs : m_prgpForms) { if (FGUI::INPUT.GetKeyPress(childs->GetKey())) { // toggle child forms on and off childs->SetState(!childs->GetState()); } // if the user toggles a child form if (childs->GetState()) { // update child forms childs->Update(); // handle child forms movement childs->Movement(); // populate child forms geometry childs->Geometry(); } } } void CForm::SetState(bool onoff) { m_bIsOpened = onoff; } bool CForm::GetState() { return m_bIsOpened; } void CForm::AddForm(std::shared_ptr<FGUI::CForm> form) { if (!form) { return; } // populate the form container m_prgpForms.emplace_back(form); } void CForm::AddTab(std::shared_ptr<FGUI::CTabs> tab) { if (!tab) { return; } // select the current tab being added (in case the form doesn't select one for us) if (!m_prgpTabs.size()) { m_pSelectedTab = tab; } // set parent form tab->m_pParentForm = std::dynamic_pointer_cast<FGUI::CForm>(shared_from_this()); // populate the tab container m_prgpTabs.emplace_back(tab); } void CForm::AddCallback(std::function<void()> callback) { m_fnctCallback = callback; } void CForm::SetKey(unsigned int key_code) { m_iKey = key_code; } void CForm::SetPosition(unsigned int x, unsigned int y) { m_ptPosition.m_iX = x; m_ptPosition.m_iY = y; } void CForm::SetSize(unsigned int width, unsigned int height) { m_dmSize.m_iWidth = width; m_dmSize.m_iHeight = height; } void CForm::SetSize(FGUI::DIMENSION size) { m_dmSize.m_iWidth = size.m_iWidth; m_dmSize.m_iHeight = size.m_iHeight; } void CForm::SetTitle(std::string title) { m_strTitle = title; } void CForm::SetFlags(int flags) { m_nFlags = flags; } int CForm::GetKey() { return m_iKey; } std::string CForm::GetTitle() { return m_strTitle; } void CForm::SetFont(std::string family, int size, bool bold, int flags) { FGUI::RENDER.CreateFont(m_ulFont, family, size, flags, bold); } void CForm::SetFont(FGUI::WIDGET_FONT font) { FGUI::RENDER.CreateFont(m_ulFont, font.m_strFamily, font.m_iSize, font.m_nFlags, font.m_bBold); } FGUI::AREA CForm::GetWidgetArea() { // NOTE: if you plan to change the form design, make sure to edit this as well. (this is the area where widgets will be drawned) return { m_ptPosition.m_iX + 10, m_ptPosition.m_iY + 75, m_dmSize.m_iWidth, m_dmSize.m_iHeight }; } void CForm::SetFocusedWidget(std::shared_ptr<FGUI::CWidgets> widget) { m_pFocusedWidget = widget; if (widget) { m_bIsFocusingOnWidget = true; } else { m_bIsFocusingOnWidget = false; } } std::shared_ptr<FGUI::CWidgets> CForm::GetFocusedWidget() { return m_pFocusedWidget; } FGUI::FONT CForm::GetFont() { return m_ulFont; } bool CForm::GetFlags(FGUI::WIDGET_FLAG flags) { if (m_nFlags & static_cast<int>(flags)) { return true; } return false; } FGUI::POINT CForm::GetPosition() { return m_ptPosition; } FGUI::DIMENSION CForm::GetSize() { return m_dmSize; } void CForm::Geometry() { // form body FGUI::RENDER.Rectangle(m_ptPosition.m_iX, m_ptPosition.m_iY, m_dmSize.m_iWidth, m_dmSize.m_iHeight, { 45, 45, 45 }); FGUI::RENDER.Rectangle(m_ptPosition.m_iX + 1, m_ptPosition.m_iY + 31, m_dmSize.m_iWidth - 2, (m_dmSize.m_iHeight - 30) - 2, { 245, 245, 245 }); // form title FGUI::RENDER.Text(m_ptPosition.m_iX + 10, m_ptPosition.m_iY + 10, m_ulFont, { 255, 255, 255 }, m_strTitle); // widget area FGUI::RENDER.Outline(m_ptPosition.m_iX + 10, (m_ptPosition.m_iY + 31) + 20 + 25, m_dmSize.m_iWidth - 20, (m_dmSize.m_iHeight - 31) - 60, { 195, 195, 195 }); // if the window has a function if (m_fnctCallback) { // invoke function m_fnctCallback(); } // don't proceed if the form doesn't have any tabs if (m_prgpTabs.empty()) { return; } // tab buttons for (std::size_t i = 0; i < m_prgpTabs.size(); i++) { // tab button area FGUI::AREA arTabRegion = { (m_ptPosition.m_iX + 10) + (static_cast<int>(i) * 113), (m_ptPosition.m_iY + 31) + 20, 110, 25 }; if (FGUI::INPUT.IsCursorInArea(arTabRegion)) { if (FGUI::INPUT.GetKeyPress(MOUSE_1)) { // select tab m_pSelectedTab = m_prgpTabs[i]; } // unfocus widget m_pFocusedWidget = nullptr; } // draw the buttons according to the tab state if (m_pSelectedTab == m_prgpTabs[i]) { FGUI::RENDER.Rectangle(arTabRegion.m_iLeft, arTabRegion.m_iTop - 5, arTabRegion.m_iRight, arTabRegion.m_iBottom + 5, { 45, 45, 45 }); FGUI::RENDER.Text(arTabRegion.m_iLeft + 20, arTabRegion.m_iTop + (arTabRegion.m_iBottom / 2) - 5, m_prgpTabs[i]->GetFont(), { 255, 255, 255 }, m_prgpTabs[i]->GetTitle()); } else { FGUI::RENDER.Rectangle(arTabRegion.m_iLeft, arTabRegion.m_iTop, arTabRegion.m_iRight, arTabRegion.m_iBottom, { 45, 45, 45 }); FGUI::RENDER.Text(arTabRegion.m_iLeft + 20, arTabRegion.m_iTop + (arTabRegion.m_iBottom / 2) - 5, m_prgpTabs[i]->GetFont(), { 220, 220, 220 }, m_prgpTabs[i]->GetTitle()); } } // if the user selects a tab if (m_pSelectedTab) { // this will tell the form to skip focused elements (so it can be drawned after all others) bool bSkipWidget = false; // this will hold the skipped element std::shared_ptr<FGUI::CWidgets> pWidgetToSkip = nullptr; // if the form is focusing on a widget if (m_bIsFocusingOnWidget) { if (m_pFocusedWidget) { // assign the widget that will be skipped pWidgetToSkip = m_pFocusedWidget; // tell the form to skip this widget bSkipWidget = true; } } // if the tab doesn't have any widgets, don't proceed if (m_pSelectedTab->m_prgpWidgets.empty()) { return; } // iterate over the rest of the widgets for (const std::shared_ptr<FGUI::CWidgets>& pWidgets : m_pSelectedTab->m_prgpWidgets) { // if the menu is having a widget skiped if (bSkipWidget) { // check if the widget inside this iteration is not the one that will be skipped if (pWidgetToSkip == pWidgets) { continue; } } // check if widgets are unlocked (able to be drawned) if (pWidgets && pWidgets->GetFlags(WIDGET_FLAG::DRAWABLE) && pWidgets->IsUnlocked()) { // found groupbox std::shared_ptr<FGUI::CGroupBox> pFoundGroupBox = nullptr; if (pWidgets->GetType() != static_cast<int>(WIDGET_TYPE::GROUPBOX)) { pFoundGroupBox = pWidgets->m_pParentGroupBox ? std::reinterpret_pointer_cast<FGUI::CGroupBox>(pWidgets->m_pParentGroupBox) : nullptr; } if (pFoundGroupBox) { // check if the groupbox has scrollbars enabled if (pFoundGroupBox->GetScrollbarState()) { // check if the skipped widgets are inside the boundaries of the groupbox if ((pWidgets->GetAbsolutePosition().m_iY + pWidgets->GetSize().m_iHeight) <= (pFoundGroupBox->GetAbsolutePosition().m_iY + pFoundGroupBox->GetSize().m_iHeight) && (pWidgets->GetAbsolutePosition().m_iY >= pFoundGroupBox->GetAbsolutePosition().m_iY)) { // draw other skipped widgets pWidgets->Geometry(); } } else { // draw other widgets pWidgets->Geometry(); } } else if (pWidgets->GetType() == static_cast<int>(WIDGET_TYPE::GROUPBOX) || pWidgets->GetType() == static_cast<int>(WIDGET_TYPE::COLORLIST) || pWidgets->GetType() == static_cast<int>(WIDGET_TYPE::IMAGE)) { // draw widgets that needs to be outside of a groupbox pWidgets->Geometry(); } } } // now the form can draw skipped widgets if (bSkipWidget) { if (pWidgetToSkip && pWidgetToSkip->GetFlags(WIDGET_FLAG::DRAWABLE) && pWidgetToSkip->IsUnlocked()) { // found groupbox std::shared_ptr<FGUI::CGroupBox> pFoundGroupBox = nullptr; if (pWidgetToSkip->GetType() != static_cast<int>(WIDGET_TYPE::GROUPBOX)) { pFoundGroupBox = pWidgetToSkip->m_pParentGroupBox ? std::reinterpret_pointer_cast<FGUI::CGroupBox>(pWidgetToSkip->m_pParentGroupBox) : nullptr; } if (pFoundGroupBox) { // check if the groupbox has scrollbars enabled if (pFoundGroupBox->GetScrollbarState()) { // check if the skipped widgets are inside the boundaries of the groupbox if ((pWidgetToSkip->GetAbsolutePosition().m_iY + pWidgetToSkip->GetSize().m_iHeight) <= (pFoundGroupBox->GetAbsolutePosition().m_iY + pFoundGroupBox->GetSize().m_iHeight) && (pWidgetToSkip->GetAbsolutePosition().m_iY >= pFoundGroupBox->GetAbsolutePosition().m_iY)) { // draw other skipped widgets pWidgetToSkip->Geometry(); } } else { // draw other skipped widgets pWidgetToSkip->Geometry(); } } else if (pWidgetToSkip->GetType() == static_cast<int>(WIDGET_TYPE::GROUPBOX) || pWidgetToSkip->GetType() == static_cast<int>(WIDGET_TYPE::COLORLIST)) { // draw widgets that needs to be outside of a groupbox pWidgetToSkip->Geometry(); } } } } } void CForm::Update() { // don't do updates while the form is closed if (!m_bIsOpened) { return; } // form flags if (GetFlags(WIDGET_FLAG::FULLSCREEN)) { // change form size SetSize(FGUI::RENDER.GetScreenSize()); } // check if the form received a click bool bCheckWidgetClicks = false; if (FGUI::INPUT.GetKeyPress(MOUSE_1)) { // grab screen size FGUI::DIMENSION dmScreenSize = FGUI::RENDER.GetScreenSize(); // get "clickable" area (you can limit this to the form boundaries instead of using the entire screen.) FGUI::AREA arClickableRegion = { m_ptPosition.m_iX, m_ptPosition.m_iY, dmScreenSize.m_iWidth, dmScreenSize.m_iHeight }; if (FGUI::INPUT.IsCursorInArea(arClickableRegion)) { // tell the form that it had received a click bCheckWidgetClicks = true; } } // if the form doesn't have a tab selected, don't proceed if (!m_pSelectedTab) { return; } // if the tab doesn't have any widgets, don't proceed if (m_pSelectedTab->m_prgpWidgets.empty()) { return; } // this will tell the form to skip focused elements (so it can be drawned after all other's) bool bSkipWidget = false; // this will hold the skipped element std::shared_ptr<FGUI::CWidgets> pWidgetToSkip = nullptr; // handle updates on the focused widget first if (m_bIsFocusingOnWidget) { if (m_pFocusedWidget) { // check if the focused widget is unlocked if (m_pFocusedWidget->IsUnlocked()) { // tell the form to skip this widget bSkipWidget = true; // assign the widget that will be skipped pWidgetToSkip = m_pFocusedWidget; // get focused widget area FGUI::AREA arFocusedWidgetRegion = { pWidgetToSkip->GetAbsolutePosition().m_iX, pWidgetToSkip->GetAbsolutePosition().m_iY, pWidgetToSkip->GetSize().m_iWidth, pWidgetToSkip->GetSize().m_iHeight }; // update focused widget pWidgetToSkip->Update(); // check if the focused widget can be clicked if (pWidgetToSkip->GetFlags(WIDGET_FLAG::CLICKABLE) && FGUI::INPUT.IsCursorInArea(arFocusedWidgetRegion) && bCheckWidgetClicks) { // handle input of focused widgets pWidgetToSkip->Input(); // unfocus this widget SetFocusedWidget(nullptr); // tell the form to look for another click bCheckWidgetClicks = false; } } } } // iterate over the rest of the widgets for (const std::shared_ptr<FGUI::CWidgets>& pWidgets : m_pSelectedTab->m_prgpWidgets) { // check if the widgets are unlocked first if (pWidgets->IsUnlocked()) { // if the menu is having a widget skiped if (bSkipWidget) { // check if the widget inside this iteration is not the one that will be skipped if (pWidgetToSkip == pWidgets) { continue; } } // found groupbox std::shared_ptr<FGUI::CGroupBox> pFoundGroupBox = nullptr; if (pWidgets->GetType() != static_cast<int>(WIDGET_TYPE::GROUPBOX)) { pFoundGroupBox = pWidgets->m_pParentGroupBox ? std::reinterpret_pointer_cast<FGUI::CGroupBox>(pWidgets->m_pParentGroupBox) : nullptr; } // get the widget area FGUI::AREA arWidgetRegion = { pWidgets->GetAbsolutePosition().m_iX, pWidgets->GetAbsolutePosition().m_iY, pWidgets->GetSize().m_iWidth, pWidgets->GetSize().m_iHeight }; if (pFoundGroupBox) { // check if the groupbox has scrollbars enabled if (pFoundGroupBox->GetScrollbarState()) { // check if the skipped widgets are inside the boundaries of the groupbox if ((pWidgets->GetAbsolutePosition().m_iY + pWidgets->GetSize().m_iHeight) <= (pFoundGroupBox->GetAbsolutePosition().m_iY + pFoundGroupBox->GetSize().m_iHeight) && (pWidgets->GetAbsolutePosition().m_iY >= pFoundGroupBox->GetAbsolutePosition().m_iY)) { // update widgets pWidgets->Update(); // check if the widget can be clicked if (pWidgets->GetFlags(WIDGET_FLAG::CLICKABLE) && FGUI::INPUT.IsCursorInArea(arWidgetRegion) && bCheckWidgetClicks) { // handle widget input pWidgets->Input(); // tell the form to look for another click bCheckWidgetClicks = false; // focus widget if (pWidgets->GetFlags(WIDGET_FLAG::FOCUSABLE)) { SetFocusedWidget(pWidgets); } else { SetFocusedWidget(nullptr); } } } } else { // update widgets pWidgets->Update(); // check if the widget can be clicked if (pWidgets->GetFlags(WIDGET_FLAG::CLICKABLE) && FGUI::INPUT.IsCursorInArea(arWidgetRegion) && bCheckWidgetClicks) { // handle widget input pWidgets->Input(); // tell the form to look for another click bCheckWidgetClicks = false; // focus widget if (pWidgets->GetFlags(WIDGET_FLAG::FOCUSABLE)) { SetFocusedWidget(pWidgets); } else { SetFocusedWidget(nullptr); } } } } else if (pWidgets->GetType() == static_cast<int>(WIDGET_TYPE::GROUPBOX) || pWidgets->GetType() == static_cast<int>(WIDGET_TYPE::COLORLIST)) { // update widgets outside a groupbox pWidgets->Update(); // check if the widgets can be clicked if (pWidgets->GetFlags(WIDGET_FLAG::CLICKABLE) && FGUI::INPUT.IsCursorInArea(arWidgetRegion) && bCheckWidgetClicks) { // handle input pWidgets->Input(); // tell the form to look for another click bCheckWidgetClicks = false; } } } } } void CForm::Movement() { // don't handle movement while the form is closed if (!m_bIsOpened) { return; } // form draggable area FGUI::AREA arDraggableArea = { m_ptPosition.m_iX, m_ptPosition.m_iY, m_dmSize.m_iWidth, 30 }; if (FGUI::INPUT.IsCursorInArea(arDraggableArea)) { if (FGUI::INPUT.GetKeyPress(MOUSE_1)) { // drag form m_bIsDragging = true; } } // if the user started dragging the form if (m_bIsDragging) { // get cursor position delta FGUI::POINT ptCursorPosDelta = FGUI::INPUT.GetCursorPosDelta(); // move form m_ptPosition.m_iX += ptCursorPosDelta.m_iX; m_ptPosition.m_iY += ptCursorPosDelta.m_iY; } if (FGUI::INPUT.GetKeyRelease(MOUSE_1)) { m_bIsDragging = false; } } } // namespace FGUI
26.115635
207
0.65488
Jacckii
4d2a1af1df214bd2662ea9af9f4330368f286590
5,329
cpp
C++
src/clReflectScan/Main.cpp
chip5441/clReflect
d366cced2fff9aefcfc5ec6a0c97ed6c827263eb
[ "MIT" ]
null
null
null
src/clReflectScan/Main.cpp
chip5441/clReflect
d366cced2fff9aefcfc5ec6a0c97ed6c827263eb
[ "MIT" ]
1
2020-02-22T09:59:21.000Z
2020-02-22T09:59:21.000Z
src/clReflectScan/Main.cpp
chip5441/clReflect
d366cced2fff9aefcfc5ec6a0c97ed6c827263eb
[ "MIT" ]
null
null
null
// // =============================================================================== // clReflect // ------------------------------------------------------------------------------- // Copyright (c) 2011-2012 Don Williamson & clReflect Authors (see AUTHORS file) // Released under MIT License (see LICENSE file) // =============================================================================== // #include "ClangFrontend.h" #include "ASTConsumer.h" #include "ReflectionSpecs.h" #include "clReflectCore/Arguments.h" #include "clReflectCore/Logging.h" #include "clReflectCore/Database.h" #include "clReflectCore/DatabaseTextSerialiser.h" #include "clReflectCore/DatabaseBinarySerialiser.h" #include "clang/AST/ASTContext.h" #include <stdio.h> #include <time.h> namespace { bool FileExists(const char* filename) { // For now, just try to open the file FILE* fp = fopen(filename, "r"); if (fp == 0) { return false; } fclose(fp); return true; } bool EndsWith(const std::string& str, const std::string& end) { return str.rfind(end) == str.length() - end.length(); } void WriteIncludedHeaders(const ClangParser& ast_parser, const char* outputfile, const char* input_filename) { std::vector< std::pair<ClangParser::HeaderType, std::string> > header_files; ast_parser.GetIncludedFiles(header_files); FILE* fp = fopen(outputfile, "wt"); // Print to output, noting that the source file will also be in the list for (size_t i = 0; i < header_files.size(); i++) { if (header_files[i].second != input_filename) { fprintf(fp, "%c %s", (header_files[i].first==ClangParser::HeaderType_User) ? 'u' : ( (header_files[i].first==ClangParser::HeaderType_System) ? 's' : 'e'), header_files[i].second.c_str()); fprintf(fp, "\n"); } } fclose(fp); } void WriteDatabase(const cldb::Database& db, const std::string& filename) { if (EndsWith(filename, ".csv")) { cldb::WriteTextDatabase(filename.c_str(), db); } else { cldb::WriteBinaryDatabase(filename.c_str(), db); } } void TestDBReadWrite(const cldb::Database& db) { cldb::WriteTextDatabase("output.csv", db); cldb::WriteBinaryDatabase("output.bin", db); cldb::Database indb_text; cldb::ReadTextDatabase("output.csv", indb_text); cldb::WriteTextDatabase("output2.csv", indb_text); cldb::Database indb_bin; cldb::ReadBinaryDatabase("output.bin", indb_bin); cldb::WriteBinaryDatabase("output2.bin", indb_bin); } } int main(int argc, const char* argv[]) { float start = clock(); LOG_TO_STDOUT(main, ALL); // Leave early if there aren't enough arguments Arguments args(argc, argv); if (args.Count() < 2) { LOG(main, ERROR, "Not enough arguments\n"); return 1; } // Does the input file exist? const char* input_filename = argv[1]; if (!FileExists(input_filename)) { LOG(main, ERROR, "Couldn't find the input file %s\n", input_filename); return 1; } float prologue = clock(); // Parse the AST ClangParser parser(args); if (!parser.ParseAST(input_filename)) { LOG(main, ERROR, "Errors parsing the AST\n"); return 1; } float parsing = clock(); // Gather reflection specs for the translation unit clang::ASTContext& ast_context = parser.GetASTContext(); std::string spec_log = args.GetProperty("-spec_log"); ReflectionSpecs reflection_specs(args.Have("-reflect_specs_all"), spec_log); reflection_specs.Gather(ast_context.getTranslationUnitDecl()); float specs = clock(); // On the second pass, build the reflection database cldb::Database db; db.AddBaseTypePrimitives(); std::string ast_log = args.GetProperty("-ast_log"); ASTConsumer ast_consumer(ast_context, db, reflection_specs, ast_log); ast_consumer.WalkTranlationUnit(ast_context.getTranslationUnitDecl()); float build = clock(); // Add all the container specs const ReflectionSpecContainer::MapType& container_specs = reflection_specs.GetContainerSpecs(); for (ReflectionSpecContainer::MapType::const_iterator i = container_specs.begin(); i != container_specs.end(); ++i) { const ReflectionSpecContainer& c = i->second; db.AddContainerInfo(i->first, c.read_iterator_type, c.write_iterator_type, c.has_key); } // Write included header files if requested std::string output_headers = args.GetProperty("-output_headers"); if (output_headers!="") WriteIncludedHeaders(parser, output_headers.c_str(), input_filename); // Write to a text/binary database depending upon extension std::string output = args.GetProperty("-output"); if (output != "") WriteDatabase(db, output); float dbwrite = clock(); if (args.Have("-test_db")) TestDBReadWrite(db); float end = clock(); // Print some rough profiling info if (args.Have("-timing")) { printf("Prologue: %.3f\n", (prologue - start) / CLOCKS_PER_SEC); printf("Parsing: %.3f\n", (parsing - prologue) / CLOCKS_PER_SEC); printf("Specs: %.3f\n", (specs - parsing) / CLOCKS_PER_SEC); printf("Building: %.3f\n", (build - specs) / CLOCKS_PER_SEC); printf("Database: %.3f\n", (dbwrite - build) / CLOCKS_PER_SEC); printf("Total time: %.3f\n", (end - start) / CLOCKS_PER_SEC); } return 0; }
28.497326
139
0.64346
chip5441
4d2d672703c5773c83494c90ace77bba3c193a79
4,527
hpp
C++
include/Mahi/Gui/Transform.hpp
1over/mahi-gui
a460f831d06746eb0e83555305a3eab174ee85b9
[ "MIT" ]
358
2020-03-22T05:30:25.000Z
2022-03-29T13:20:18.000Z
include/Mahi/Gui/Transform.hpp
1over/mahi-gui
a460f831d06746eb0e83555305a3eab174ee85b9
[ "MIT" ]
32
2020-03-25T13:16:28.000Z
2022-02-07T21:58:41.000Z
include/Mahi/Gui/Transform.hpp
1over/mahi-gui
a460f831d06746eb0e83555305a3eab174ee85b9
[ "MIT" ]
64
2020-03-22T16:56:59.000Z
2022-03-19T13:50:18.000Z
// MIT License // // Copyright (c) 2020 Mechatronics and Haptic Interfaces Lab - Rice University // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // Author(s): Evan Pezent (epezent@rice.edu) // // Adapted from: SFML - Simple and Fast Multimedia Library (license at bottom) #pragma once #include <Mahi/Gui/Rect.hpp> #include <Mahi/Gui/Vec2.hpp> namespace mahi { namespace gui { /// Encapsulates a 3x3 transformation matrix class Transform { public: /// Default constructor Transform(); /// Construct a transform from a 3x3 matrix Transform(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22); /// Return the transform as a 4x4 matrix compatible with OpenGL const float* matrix() const; /// Return the inverse of the transform Transform inverse() const; /// Transform a 2D point Vec2 transform(float x, float y) const; /// Transform a 2D point Vec2 transform(const Vec2& point) const; /// Transform a rectangle Rect transform(const Rect& rectangle) const; /// Combine the current transform with another one Transform& combine(const Transform& transform); /// Combine the current transform with a translation Transform& translate(float x, float y); /// Combine the current transform with a translation Transform& translate(const Vec2& offset); /// Combine the current transform with a rotation Transform& rotate(float angle); /// Combine the current transform with a rotation Transform& rotate(float angle, float centerX, float centerY); /// Combine the current transform with a rotation Transform& rotate(float angle, const Vec2& center); /// Combine the current transform with a scaling Transform& scale(float scaleX, float scaleY); /// Combine the current transform with a scaling Transform& scale(float scaleX, float scaleY, float centerX, float centerY); /// Combine the current transform with a scaling Transform& scale(const Vec2& factors); /// Combine the current transform with a scaling Transform& scale(const Vec2& factors, const Vec2& center); public: static const Transform Identity; ///< The identity transform private: float m_matrix[16]; ///< 4x4 matrix defining the transformation }; /// Equivalent to calling Transform(left).combine(right). Transform operator*(const Transform& left, const Transform& right); /// Equivalent to calling left.combine(right). Transform& operator*=(Transform& left, const Transform& right); /// Equivalent to calling left.transform(right). Vec2 operator*(const Transform& left, const Vec2& right); /// Performs an element-wise comparison of the elements of the /// left transform with the elements of the right transform. bool operator==(const Transform& left, const Transform& right); /// Equivalent to !(left == right). bool operator!=(const Transform& left, const Transform& right); } // namespace gui } // namespace mahi // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org) // // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the use of this // software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it freely, // subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; // you must not claim that you wrote the original software. // If you use this software in a product, an acknowledgment // in the product documentation would be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, // and must not be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution.
41.916667
91
0.726972
1over
4d2de854dd84ca179d07c01cb4c557641fbd48ce
1,125
cpp
C++
N0413-Arithmetic-Slices/solution1.cpp
loyio/leetcode
366393c29a434a621592ef6674a45795a3086184
[ "CC0-1.0" ]
null
null
null
N0413-Arithmetic-Slices/solution1.cpp
loyio/leetcode
366393c29a434a621592ef6674a45795a3086184
[ "CC0-1.0" ]
null
null
null
N0413-Arithmetic-Slices/solution1.cpp
loyio/leetcode
366393c29a434a621592ef6674a45795a3086184
[ "CC0-1.0" ]
2
2022-01-25T05:31:31.000Z
2022-02-26T07:22:23.000Z
// // main.cpp // LeetCode-Solution // // Created by Loyio Hex on 3/3/22. // #include <iostream> #include <chrono> #include <vector> using namespace std; using namespace std::chrono; class Solution { public: int numberOfArithmeticSlices(vector<int>& nums) { int len = nums.size(); if (len == 1) { return 0; } int d = nums[0] - nums[1]; int t = 0, ans = 0; for (int i = 2; i < len; ++i) { if (nums[i - 1] - nums[i] == d) { ++t; } else { d = nums[i - 1] - nums[i]; t = 0; } ans += t; } return ans; } }; int main(int argc, const char * argv[]) { auto start = high_resolution_clock::now(); // Main Start vector<int> nums = {1,2,3,4}; Solution solution; cout << solution.numberOfArithmeticSlices(nums); // Main End auto stop = high_resolution_clock::now(); auto duration = duration_cast<microseconds>(stop - start); cout << endl << "Runnig time : " << duration.count() << "ms;" << endl; return 0; }
21.226415
74
0.503111
loyio
4d320cb4168e07c288fbf2ffe2ffa85908102660
3,339
cpp
C++
src/SSAO/GBuffer.cpp
fqhd/Sokuban
1b41fb6c6e7c865447824eaffce0dff8c7efafa4
[ "MIT" ]
1
2021-11-17T07:52:45.000Z
2021-11-17T07:52:45.000Z
src/SSAO/GBuffer.cpp
fqhd/Sokuban
1b41fb6c6e7c865447824eaffce0dff8c7efafa4
[ "MIT" ]
null
null
null
src/SSAO/GBuffer.cpp
fqhd/Sokuban
1b41fb6c6e7c865447824eaffce0dff8c7efafa4
[ "MIT" ]
null
null
null
#include "GBuffer.hpp" void GBuffer::init(unsigned int width, unsigned int height){ glGenFramebuffers(1, &m_fboID); glBindFramebuffer(GL_FRAMEBUFFER, m_fboID); // - position color buffer glGenTextures(1, &m_positionTextureID); glBindTexture(GL_TEXTURE_2D, m_positionTextureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGB, GL_FLOAT, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_positionTextureID, 0); glBindTexture(GL_TEXTURE_2D, 0); // - normal color buffer glGenTextures(1, &m_normalTextureID); glBindTexture(GL_TEXTURE_2D, m_normalTextureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGB, GL_FLOAT, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, m_normalTextureID, 0); glBindTexture(GL_TEXTURE_2D, 0); // - color + specular color buffer glGenTextures(1, &m_albedoTextureID); glBindTexture(GL_TEXTURE_2D, m_albedoTextureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, m_albedoTextureID, 0); glBindTexture(GL_TEXTURE_2D, 0); // - tell OpenGL which color attachments we'll use (of this framebuffer) for rendering unsigned int attachments[3] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; glDrawBuffers(3, attachments); //Depth buffer glGenRenderbuffers(1, &m_rboID); glBindRenderbuffer(GL_RENDERBUFFER, m_rboID); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rboID); glBindRenderbuffer(GL_RENDERBUFFER, 0); if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){ Utils::log("GBuffer: Failed to create Geomtry Buffer"); } glBindFramebuffer(GL_FRAMEBUFFER, 0); } void GBuffer::clear(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void GBuffer::bind(){ glBindFramebuffer(GL_FRAMEBUFFER, m_fboID); } void GBuffer::unbind(){ glBindFramebuffer(GL_FRAMEBUFFER, 0); } void GBuffer::destroy(){ glDeleteTextures(1, &m_positionTextureID); glDeleteTextures(1, &m_albedoTextureID); glDeleteTextures(1, &m_normalTextureID); glDeleteRenderbuffers(1, &m_rboID); glDeleteFramebuffers(1, &m_fboID); } GLuint GBuffer::getPositionTextureID(){ return m_positionTextureID; } GLuint GBuffer::getNormalTextureID(){ return m_normalTextureID; } GLuint GBuffer::getAlbedoTextureID(){ return m_albedoTextureID; }
37.1
105
0.758311
fqhd
4d323d3d506b5e0b8fc0f332ea46f44510846f2b
589
cc
C++
src/graphics/lib/magma/src/magma_util/platform/linux/linux_platform_port.cc
allansrc/fuchsia
a2c235b33fc4305044d496354a08775f30cdcf37
[ "BSD-2-Clause" ]
210
2019-02-05T12:45:09.000Z
2022-03-28T07:59:06.000Z
src/graphics/lib/magma/src/magma_util/platform/linux/linux_platform_port.cc
allansrc/fuchsia
a2c235b33fc4305044d496354a08775f30cdcf37
[ "BSD-2-Clause" ]
56
2021-06-03T03:16:25.000Z
2022-03-20T01:07:44.000Z
src/graphics/lib/magma/src/magma_util/platform/linux/linux_platform_port.cc
allansrc/fuchsia
a2c235b33fc4305044d496354a08775f30cdcf37
[ "BSD-2-Clause" ]
73
2019-03-06T18:55:23.000Z
2022-03-26T12:04:51.000Z
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "magma_util/macros.h" #include "platform_port.h" namespace magma { class LinuxPlatformPort : public PlatformPort { public: void Close() override {} Status Wait(uint64_t* key_out, uint64_t timeout_ms) override { return DRET(MAGMA_STATUS_UNIMPLEMENTED); } }; std::unique_ptr<PlatformPort> PlatformPort::Create() { return DRETP(nullptr, "PlatformPort::Create not supported"); } } // namespace magma
24.541667
73
0.743633
allansrc
2ec0117ea59b42bc7d14cf7d64aef029254fcde2
12,084
cpp
C++
runtime/qrt/internal_compiler/xacc_internal_compiler.cpp
vetter/qcor
6f86835737277a26071593bb10dd8627c29d74a3
[ "BSD-3-Clause" ]
59
2019-08-22T18:40:38.000Z
2022-03-09T04:12:42.000Z
runtime/qrt/internal_compiler/xacc_internal_compiler.cpp
vetter/qcor
6f86835737277a26071593bb10dd8627c29d74a3
[ "BSD-3-Clause" ]
137
2019-09-13T15:50:18.000Z
2021-12-06T14:19:46.000Z
runtime/qrt/internal_compiler/xacc_internal_compiler.cpp
vetter/qcor
6f86835737277a26071593bb10dd8627c29d74a3
[ "BSD-3-Clause" ]
26
2019-07-08T17:30:35.000Z
2021-12-03T16:24:12.000Z
/******************************************************************************* * Copyright (c) 2018-, UT-Battelle, LLC. * All rights reserved. This program and the accompanying materials * are made available under the terms of the MIT License * which accompanies this distribution. * * Contributors: * Alexander J. McCaskey - initial API and implementation * Thien Nguyen - implementation *******************************************************************************/ #include "xacc_internal_compiler.hpp" #include "Instruction.hpp" #include "Utils.hpp" #include "heterogeneous.hpp" #include "config_file_parser.hpp" #include "xacc.hpp" #include "xacc_service.hpp" #include "InstructionIterator.hpp" #include <CompositeInstruction.hpp> #include <stdlib.h> // Need to finalize the QuantumRuntime #include "qrt.hpp" namespace xacc { namespace internal_compiler { std::shared_ptr<Accelerator> qpu = nullptr; std::shared_ptr<CompositeInstruction> lastCompiled = nullptr; bool __execute = true; std::vector<HeterogeneousMap> current_runtime_arguments = {}; void __set_verbose(bool v) { xacc::set_verbose(v); } void compiler_InitializeXACC(const char *qpu_backend, const std::vector<std::string> cmd_line_args) { if (!xacc::isInitialized()) { xacc::Initialize(cmd_line_args); xacc::external::load_external_language_plugins(); auto at_exit = []() { if (quantum::qrt_impl) quantum::qrt_impl->finalize(); xacc::Finalize(); }; atexit(at_exit); } setAccelerator(qpu_backend); } void compiler_InitializeXACC(const char *qpu_backend, int shots) { if (!xacc::isInitialized()) { xacc::Initialize(); xacc::external::load_external_language_plugins(); auto at_exit = []() { if (quantum::qrt_impl) quantum::qrt_impl->finalize(); xacc::Finalize(); }; atexit(at_exit); } setAccelerator(qpu_backend, shots); } auto process_qpu_backend_str = [](const std::string &qpu_backend_str) -> std::pair<std::string, HeterogeneousMap> { bool has_extra_config = qpu_backend_str.find("[") != std::string::npos; auto qpu_name = (has_extra_config) ? qpu_backend_str.substr(0, qpu_backend_str.find_first_of("[")) : qpu_backend_str; HeterogeneousMap options; if (has_extra_config) { auto first = qpu_backend_str.find_first_of("["); auto second = qpu_backend_str.find_first_of("]"); auto qpu_config = qpu_backend_str.substr(first + 1, second - first - 1); auto key_values = split(qpu_config, ','); for (auto key_value : key_values) { auto tmp = split(key_value, ':'); auto key = tmp[0]; auto value = tmp[1]; if (key == "qcor_qpu_config") { // If the config is provided in a file: // We could check for file extension here to // determine a parsing plugin. // Currently, we only support a simple key-value format (INI like). // e.g. // String like config: // name=XACC // Boolean configs // true_val=true // false_val=false // Array/vector configs // array=[1,2,3] // array_double=[1.0,2.0,3.0] auto parser = xacc::getService<ConfigFileParsingUtil>("ini"); options = parser->parse(value); } else { // check if int first, then double, // finally just throw it in as a string try { auto i = std::stoi(value); options.insert(key, i); } catch (std::exception &e) { try { auto d = std::stod(value); options.insert(key, d); } catch (std::exception &e) { options.insert(key, value); } } } } } return std::make_pair(qpu_name, options); }; void setAccelerator(const char *qpu_backend) { if (qpu) { if (qpu_backend != qpu->name()) { const auto [qpu_name, config] = process_qpu_backend_str(qpu_backend); qpu = xacc::getAccelerator(qpu_name, config); } } else { const auto [qpu_name, config] = process_qpu_backend_str(qpu_backend); qpu = xacc::getAccelerator(qpu_name, config); } } void setAccelerator(const char *qpu_backend, int shots) { if (qpu) { if (qpu_backend != qpu->name()) { auto [qpu_name, config] = process_qpu_backend_str(qpu_backend); config.insert("shots", shots); qpu = xacc::getAccelerator(qpu_backend, config); } } else { auto [qpu_name, config] = process_qpu_backend_str(qpu_backend); config.insert("shots", shots); qpu = xacc::getAccelerator(qpu_backend, {std::make_pair("shots", shots)}); } } std::shared_ptr<Accelerator> get_qpu() { return qpu; } std::shared_ptr<CompositeInstruction> getLastCompiled() { return lastCompiled; } // Map kernel source string representing a single // kernel function to a single CompositeInstruction (src to IR) std::shared_ptr<CompositeInstruction> compile(const char *compiler_name, const char *kernel_src) { auto compiler = xacc::getCompiler(compiler_name); auto IR = compiler->compile(kernel_src, qpu); auto program = IR->getComposites()[0]; lastCompiled = program; return program; } std::shared_ptr<CompositeInstruction> getCompiled(const char *kernel_name) { return xacc::hasCompiled(kernel_name) ? xacc::getCompiled(kernel_name) : nullptr; } // Run quantum compilation routines on IR void optimize(std::shared_ptr<CompositeInstruction> program, const OptLevel opt) { xacc::info("[InternalCompiler] Pre-optimization, circuit has " + std::to_string(program->nInstructions()) + " instructions."); if (opt == DEFAULT) { auto optimizer = xacc::getIRTransformation("circuit-optimizer"); optimizer->apply(program, qpu); } else { xacc::error("Other Optimization Levels not yet supported."); } xacc::info("[InternalCompiler] Post-optimization, circuit has " + std::to_string(program->nInstructions()) + " instructions."); } void execute(AcceleratorBuffer *buffer, std::vector<std::shared_ptr<CompositeInstruction>> programs) { qpu->execute(xacc::as_shared_ptr(buffer), programs); } // Execute on the specified QPU, persisting results to // the provided buffer. void execute(AcceleratorBuffer *buffer, std::shared_ptr<CompositeInstruction> program, double *parameters) { std::shared_ptr<CompositeInstruction> program_as_shared; if (parameters) { std::vector<double> values(parameters, parameters + program->nVariables()); program = program->operator()(values); } auto buffer_as_shared = std::shared_ptr<AcceleratorBuffer>( buffer, xacc::empty_delete<AcceleratorBuffer>()); qpu->execute(buffer_as_shared, program); } void execute(AcceleratorBuffer **buffers, const int nBuffers, std::shared_ptr<CompositeInstruction> program, double *parameters) { // Should take vector of buffers, and we collapse them // into a single unified buffer for execution, then set the // measurement counts accordingly in postprocessing. std::vector<AcceleratorBuffer *> bvec(buffers, buffers + nBuffers); std::vector<std::string> buffer_names; for (auto &a : bvec) buffer_names.push_back(a->name()); // Do we have any unknown ancilla bits? std::vector<std::string> possible_extra_buffers; int possible_size = -1; InstructionIterator it(program); while (it.hasNext()) { auto &next = *it.next(); auto bnames = next.getBufferNames(); for (auto &bb : bnames) { if (!xacc::container::contains(buffer_names, bb) && !xacc::container::contains(possible_extra_buffers, bb)) { // we have an unknown buffer with name bb, need to figure out its size // too possible_extra_buffers.push_back(bb); } } } for (auto &possible_buffer : possible_extra_buffers) { std::set<std::size_t> sizes; InstructionIterator it2(program); while (it2.hasNext()) { auto &next = *it2.next(); for (auto &bit : next.bits()) { sizes.insert(bit); } } auto size = *std::max_element(sizes.begin(), sizes.end()); auto extra = qalloc(size); extra->setName(possible_buffer); xacc::debug("[xacc_internal_compiler] Adding extra buffer " + possible_buffer + " of size " + std::to_string(size)); bvec.push_back(extra.get()); } // Merge the buffers. Keep track of buffer_name to shift in // all bit indices operating on that buffer_name, a map of // buffer names to the buffer ptr, and start a map to collect // buffer names to measurement counts int global_reg_size = 0; std::map<std::string, int> shift_map; std::vector<std::string> shift_map_names; std::vector<int> shift_map_shifts; std::map<std::string, AcceleratorBuffer *> buf_map; std::map<std::string, std::map<std::string, int>> buf_counts; for (auto &b : bvec) { shift_map.insert({b->name(), global_reg_size}); shift_map_names.push_back(b->name()); shift_map_shifts.push_back(global_reg_size); buf_map.insert({b->name(), b}); buf_counts.insert({b->name(), {}}); global_reg_size += b->size(); } xacc::debug("[xacc_internal_compiler] Creating register of size " + std::to_string(global_reg_size)); auto tmp = xacc::qalloc(global_reg_size); // Update Program bit indices based on new global // qubit register InstructionIterator iter(program); while (iter.hasNext()) { auto &next = *iter.next(); std::vector<std::size_t> newBits; int counter = 0; for (auto &b : next.bits()) { auto buffer_name = next.getBufferName(counter); auto shift = shift_map[buffer_name]; newBits.push_back(b + shift); counter++; } next.setBits(newBits); // FIXME Update buffer_names here too std::vector<std::string> unified_buf_names; for (int j = 0; j < next.nRequiredBits(); j++) { unified_buf_names.push_back("q"); } next.setBufferNames(unified_buf_names); } std::vector<std::size_t> measure_idxs; InstructionIterator iter2(program); while (iter2.hasNext()) { auto &next = *iter2.next(); if (next.name() == "Measure") { measure_idxs.push_back(next.bits()[0]); } } // Now execute using the global merged register execute(tmp.get(), program, parameters); // Take bit strings and map to buffer individual bit strings for (auto &kv : tmp->getMeasurementCounts()) { auto bitstring = kv.first; // Some backends return bitstring of size = number of measures // instead of size = global_reg_size, adjust if so if (bitstring.size() == measure_idxs.size()) { std::string tmps = ""; for (int j = 0; j < global_reg_size; j++) tmps += "0"; for (int j = 0; j < measure_idxs.size(); j++) { tmps[measure_idxs[j]] = bitstring[j]; } bitstring = tmps; } // The following processing the bit string assuming LSB if (qpu->getBitOrder() == Accelerator::BitOrder::MSB) { std::reverse(bitstring.begin(), bitstring.end()); } for (int j = 0; j < shift_map_names.size(); j++) { auto shift = shift_map_shifts[j]; auto buff_name = shift_map_names[j]; auto buffer = buf_map[buff_name]; auto buffer_bitstring = bitstring.substr(shift, buffer->size()); if (qpu->getBitOrder() == Accelerator::BitOrder::MSB) { std::reverse(buffer_bitstring.begin(), buffer_bitstring.end()); } if (buf_counts[buff_name].count(buffer_bitstring)) { buf_counts[buff_name][buffer_bitstring] += kv.second; } else { buf_counts[buff_name].insert({buffer_bitstring, kv.second}); } } } for (auto &b : bvec) { b->setMeasurements(buf_counts[b->name()]); b->addExtraInfo("endianness", qpu->getBitOrder() == Accelerator::BitOrder::LSB ? "lsb" : "msb"); } } } // namespace internal_compiler } // namespace xacc
33.566667
81
0.638613
vetter
2ec02fda5fe7db14036fea086c6c492bcfbc1353
1,017
cpp
C++
programs/chapter_10/old/example_10_0/modules/pir/pir.cpp
epernia/arm_book
ffdd17618c2c7372cef338fc743f517bf6f0f42b
[ "BSD-3-Clause" ]
2
2021-05-03T17:21:37.000Z
2021-06-08T08:32:07.000Z
programs/chapter_10/old/example_10_0/modules/pir/pir.cpp
epernia/arm_book
ffdd17618c2c7372cef338fc743f517bf6f0f42b
[ "BSD-3-Clause" ]
null
null
null
programs/chapter_10/old/example_10_0/modules/pir/pir.cpp
epernia/arm_book
ffdd17618c2c7372cef338fc743f517bf6f0f42b
[ "BSD-3-Clause" ]
2
2020-10-14T19:06:24.000Z
2021-06-08T08:32:09.000Z
//=====[Libraries]============================================================= #include "mbed.h" #include "pir.h" //=====[Declaration of private defines]====================================== //=====[Declaration of private data types]===================================== //=====[Declaration and initialization of public global objects]=============== InterruptIn pir(PC_3); DigitalOut pirOutput(PF_3); //=====[Declaration of external public global variables]======================= //=====[Declaration and initialization of public global variables]============= //=====[Declaration and initialization of private global variables]============ //=====[Declarations (prototypes) of private functions]======================== void pirUpdate(); //=====[Implementations of public functions]=================================== void pirSensorInit() { pir.rise(&pirUpdate); } void pirUpdate() { pirOutput = !pirOutput; } //=====[Implementations of private functions]==================================
26.076923
79
0.496559
epernia
2ec12e9175f0a442ed2324081911c226e60a13f4
4,563
cpp
C++
src/hir_expand/erased_types.cpp
bjorn3/mrustc
01f73e7894119405ab3f92b6191f044e491c9062
[ "MIT" ]
1,706
2015-01-18T11:01:10.000Z
2022-03-31T00:31:54.000Z
src/hir_expand/erased_types.cpp
bjorn3/mrustc
01f73e7894119405ab3f92b6191f044e491c9062
[ "MIT" ]
215
2015-03-26T10:31:36.000Z
2022-03-13T02:04:13.000Z
src/hir_expand/erased_types.cpp
bjorn3/mrustc
01f73e7894119405ab3f92b6191f044e491c9062
[ "MIT" ]
114
2015-03-26T10:29:02.000Z
2022-03-21T20:59:37.000Z
/* * MRustC - Rust Compiler * - By John Hodge (Mutabah/thePowersGang) * * hir_expand/erased_types.cpp * - HIR Expansion - Replace `impl Trait` with the real type */ #include <hir/visitor.hpp> #include <hir/expr.hpp> #include <hir_typeck/static.hpp> #include <algorithm> #include "main_bindings.hpp" namespace { class ExprVisitor_Extract: public ::HIR::ExprVisitorDef { const StaticTraitResolve& m_resolve; public: ExprVisitor_Extract(const StaticTraitResolve& resolve): m_resolve(resolve) { } void visit_root(::HIR::ExprPtr& root) { root->visit(*this); visit_type(root->m_res_type); for(auto& ty : root.m_bindings) visit_type(ty); for(auto& ty : root.m_erased_types) visit_type(ty); } void visit_node_ptr(::std::unique_ptr< ::HIR::ExprNode>& node_ptr) override { assert(node_ptr); node_ptr->visit(*this); visit_type(node_ptr->m_res_type); } void visit_type(::HIR::TypeRef& ty) override { static Span sp; if( ty.data().is_ErasedType() ) { TRACE_FUNCTION_FR(ty, ty); const auto& e = ty.data().as_ErasedType(); MonomorphState monomorph_cb; auto val = m_resolve.get_value(sp, e.m_origin, monomorph_cb); const auto& fcn = *val.as_Function(); const auto& erased_types = fcn.m_code.m_erased_types; ASSERT_BUG(sp, e.m_index < erased_types.size(), "Erased type index out of range for " << e.m_origin << " - " << e.m_index << " >= " << erased_types.size()); const auto& tpl = erased_types[e.m_index]; auto new_ty = monomorph_cb.monomorph_type(sp, tpl); m_resolve.expand_associated_types(sp, new_ty); DEBUG("> " << ty << " => " << new_ty); ty = mv$(new_ty); // Recurse (TODO: Cleanly prevent infinite recursion - TRACE_FUNCTION does crude prevention) visit_type(ty); } else { ::HIR::ExprVisitorDef::visit_type(ty); } } }; class OuterVisitor: public ::HIR::Visitor { StaticTraitResolve m_resolve; const ::HIR::ItemPath* m_fcn_path = nullptr; public: OuterVisitor(const ::HIR::Crate& crate): m_resolve(crate) {} void visit_expr(::HIR::ExprPtr& exp) override { if( exp ) { ExprVisitor_Extract ev(m_resolve); ev.visit_root( exp ); } } void visit_function(::HIR::ItemPath p, ::HIR::Function& fcn) override { m_fcn_path = &p; ::HIR::Visitor::visit_function(p, fcn); m_fcn_path = nullptr; } }; class OuterVisitor_Fixup: public ::HIR::Visitor { StaticTraitResolve m_resolve; public: OuterVisitor_Fixup(const ::HIR::Crate& crate): m_resolve(crate) {} void visit_type(::HIR::TypeRef& ty) override { static const Span sp; if( ty.data().is_ErasedType() ) { const auto& e = ty.data().as_ErasedType(); TRACE_FUNCTION_FR(ty, ty); MonomorphState monomorph_cb; auto val = m_resolve.get_value(sp, e.m_origin, monomorph_cb); const auto& fcn = *val.as_Function(); const auto& erased_types = fcn.m_code.m_erased_types; ASSERT_BUG(sp, e.m_index < erased_types.size(), "Erased type index out of range for " << e.m_origin << " - " << e.m_index << " >= " << erased_types.size()); const auto& tpl = erased_types[e.m_index]; auto new_ty = monomorph_cb.monomorph_type(sp, tpl); DEBUG("> " << ty << " => " << new_ty); ty = mv$(new_ty); // Recurse (TODO: Cleanly prevent infinite recursion - TRACE_FUNCTION does crude prevention) visit_type(ty); } else { ::HIR::Visitor::visit_type(ty); } } }; } void HIR_Expand_ErasedType(::HIR::Crate& crate) { OuterVisitor ov(crate); ov.visit_crate( crate ); OuterVisitor_Fixup ov_fix(crate); ov_fix.visit_crate(crate); }
30.218543
172
0.526846
bjorn3
2ec2130a3012d5f534b52827cbebfd8040e4ea68
3,624
cxx
C++
reflow/dtls_wrapper/DtlsFactory.cxx
dulton/reSipServer
ac4241df81c1e3eef2e678271ffef4dda1fc6747
[ "Apache-2.0" ]
1
2019-04-15T14:10:58.000Z
2019-04-15T14:10:58.000Z
reflow/dtls_wrapper/DtlsFactory.cxx
dulton/reSipServer
ac4241df81c1e3eef2e678271ffef4dda1fc6747
[ "Apache-2.0" ]
null
null
null
reflow/dtls_wrapper/DtlsFactory.cxx
dulton/reSipServer
ac4241df81c1e3eef2e678271ffef4dda1fc6747
[ "Apache-2.0" ]
2
2019-10-31T09:11:09.000Z
2021-09-17T01:00:49.000Z
#ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef USE_SSL #include <cassert> #include <iostream> #include <rutil/ssl/OpenSSLInit.hxx> #include <openssl/e_os2.h> #include <openssl/rand.h> #include <openssl/err.h> #include <openssl/crypto.h> #include <openssl/ssl.h> #include "DtlsFactory.hxx" #include "DtlsSocket.hxx" using namespace dtls; const char* DtlsFactory::DefaultSrtpProfile = "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32"; DtlsFactory::DtlsFactory(std::auto_ptr<DtlsTimerContext> tc,X509 *cert, EVP_PKEY *privkey): mTimerContext(tc), mCert(cert) { int r; mContext=SSL_CTX_new(DTLSv1_method()); assert(mContext); r=SSL_CTX_use_certificate(mContext, cert); assert(r==1); r=SSL_CTX_use_PrivateKey(mContext, privkey); assert(r==1); // Set SRTP profiles r=SSL_CTX_set_tlsext_use_srtp(mContext, DefaultSrtpProfile); assert(r==0); } DtlsFactory::~DtlsFactory() { SSL_CTX_free(mContext); } DtlsSocket* DtlsFactory::createClient(std::auto_ptr<DtlsSocketContext> context) { return new DtlsSocket(context,this,DtlsSocket::Client); } DtlsSocket* DtlsFactory::createServer(std::auto_ptr<DtlsSocketContext> context) { return new DtlsSocket(context,this,DtlsSocket::Server); } void DtlsFactory::getMyCertFingerprint(char *fingerprint) { DtlsSocket::computeFingerprint(mCert,fingerprint); } void DtlsFactory::setSrtpProfiles(const char *str) { int r; r=SSL_CTX_set_tlsext_use_srtp(mContext,str); assert(r==0); } void DtlsFactory::setCipherSuites(const char *str) { int r; r=SSL_CTX_set_cipher_list(mContext,str); assert(r==1); } DtlsFactory::PacketType DtlsFactory::demuxPacket(const unsigned char *data, unsigned int len) { assert(len>=1); if((data[0]==0) || (data[0]==1)) return stun; if((data[0]>=128) && (data[0]<=191)) return rtp; if((data[0]>=20) && (data[0]<=64)) return dtls; return unknown; } #endif //USE_SSL /* ==================================================================== Copyright (c) 2007-2008, Eric Rescorla and Derek MacDonald 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. None of the contributors names 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. ==================================================================== */
26.452555
94
0.715232
dulton
2ec329002a0f52f0f7939833605fed1fad4d4a0d
2,485
cpp
C++
test/op/Conv2DBackPropTest.cpp
z415073783/MNN
62c5ca47964407508a5fa802582e648fc75eb0d9
[ "Apache-2.0" ]
null
null
null
test/op/Conv2DBackPropTest.cpp
z415073783/MNN
62c5ca47964407508a5fa802582e648fc75eb0d9
[ "Apache-2.0" ]
1
2021-09-07T09:13:03.000Z
2021-09-07T09:13:03.000Z
test/op/Conv2DBackPropTest.cpp
z415073783/MNN
62c5ca47964407508a5fa802582e648fc75eb0d9
[ "Apache-2.0" ]
1
2020-03-10T02:17:47.000Z
2020-03-10T02:17:47.000Z
// // Conv2DBackPropTest.cpp // MNNTests // // Created by MNN on 2019/9/26. // Copyright © 2018, Alibaba Group Holding Limited // #include "MNNTestSuite.h" #include "Expr.hpp" #include "ExprCreator.hpp" #include "TestUtils.h" using namespace MNN::Express; class Conv2DBackPropTest : public MNNTestCase{ virtual ~Conv2DBackPropTest() = default; virtual bool run(){ const float inputGradData[] = { 1., 1., 1., 1., 1., 1., 1., 1., 1 }; // 1x1x3x3 auto inputGrad = _Const(inputGradData, {1, 1, 3, 3}, NCHW); inputGrad = _Convert(inputGrad, NC4HW4); const float weightData[] = { 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; // 1x3x3x3 auto weight = _Const(weightData, {1,3,3,3}, NCHW); auto bias = _Const(0., {1}, NCHW); auto outputGrad = _Deconv(weight, bias, inputGrad); outputGrad = _Convert(outputGrad, NCHW); auto outputGradDim = outputGrad->getInfo()->dim; const int outSize = outputGrad->getInfo()->size; if(outputGrad->getInfo()->size != outSize){ return false; } const std::vector<int> expectedDim = {1,3,5,5}; if(!checkVector<int>(outputGradDim.data(), expectedDim.data(), 4, 0)){ MNN_ERROR("Conv2DBackProp shape test failed!\n"); return false; } const float expectedOutputGrad[] = { 1., 2., 3., 2., 1., 2., 4., 6., 4., 2., 3., 6., 9., 6., 3., 2., 4., 6., 4., 2., 1., 2., 3., 2., 1., 1., 2., 3., 2., 1., 2., 4., 6., 4., 2., 3., 6., 9., 6., 3., 2., 4., 6., 4., 2., 1., 2., 3., 2., 1., 1., 2., 3., 2., 1., 2., 4., 6., 4., 2., 3., 6., 9., 6., 3., 2., 4., 6., 4., 2., 1., 2., 3., 2., 1.}; auto outputGradData = outputGrad->readMap<float>(); if(!checkVector<float>(outputGradData, expectedOutputGrad, outSize, 0.01)){ MNN_ERROR("Conv2DBackProp test failed!\n"); return false; } return true; } }; MNNTestSuiteRegister(Conv2DBackPropTest, "op/Conv2DBackPropTest");
28.895349
83
0.452314
z415073783
2ec774cda8bc0c4968f2af8f7889a45a276a657f
1,307
hpp
C++
lib/src/audio/summer.hpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
182
2019-04-19T12:38:30.000Z
2022-03-20T16:48:20.000Z
lib/src/audio/summer.hpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
107
2019-04-23T10:49:35.000Z
2022-03-02T18:12:28.000Z
lib/src/audio/summer.hpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
59
2019-06-04T11:27:25.000Z
2022-03-17T23:49:49.000Z
// Copyright (c) 2012-2017 VideoStitch SAS // Copyright (c) 2018 stitchEm // // A class to sum audio blocks #pragma once #include "libvideostitch/audioBlock.hpp" #include <sstream> namespace VideoStitch { namespace Audio { Status sum(std::vector<AudioBlock> &blocks, AudioBlock &output) { ChannelLayout layout = blocks.begin()->getLayout(); size_t nbSamples = blocks.begin()->numSamples(); for (const AudioBlock &block : blocks) { if (block.getLayout() != layout) { std::stringstream errMsg; errMsg << "Cannot sum blocks with different layouts: expected \"" << getStringFromChannelLayout(layout) << "\" got \"" << getStringFromChannelLayout(block.getLayout()) << "\""; return {Origin::AudioPipeline, ErrType::AlgorithmFailure, errMsg.str()}; } if (block.numSamples() != nbSamples) { std::stringstream errMsg; errMsg << "Cannot sum blocks with different size: expected " << nbSamples << " got " << block.numSamples(); return {Origin::AudioPipeline, ErrType::AlgorithmFailure, errMsg.str()}; } } output.setChannelLayout(layout); output.resize(nbSamples); output.assign(nbSamples, 0.); for (AudioBlock &block : blocks) { output += block; } return Status::OK(); } } // namespace Audio } // namespace VideoStitch
30.395349
113
0.671002
tlalexander
2ecb094e1ba006a1f49447c6b506ef888ebad477
417
cpp
C++
codeforces/Codeforces_Round_535_Div3/1108C.cpp
juseongkr/BOJ
8f10a2bf9a7d695455493fbe7423347a8b648416
[ "Apache-2.0" ]
7
2020-02-03T10:00:19.000Z
2021-11-16T11:03:57.000Z
codeforces/Codeforces_Round_535_Div3/1108C.cpp
juseongkr/Algorithm-training
8f10a2bf9a7d695455493fbe7423347a8b648416
[ "Apache-2.0" ]
1
2021-01-03T06:58:24.000Z
2021-01-03T06:58:24.000Z
codeforces/Codeforces_Round_535_Div3/1108C.cpp
juseongkr/Algorithm-training
8f10a2bf9a7d695455493fbe7423347a8b648416
[ "Apache-2.0" ]
1
2020-01-22T14:34:03.000Z
2020-01-22T14:34:03.000Z
#include <iostream> using namespace std; int n; string s; string p[6] = {"RGB", "RBG", "BRG", "BGR", "GBR", "GRB"}; int main() { cin >> n >> s; int ans = 1e9+7, idx = 0; for (int i=0; i<6; ++i) { int cnt = 0; for (int j=0; j<n; ++j) if (s[j] != p[i][j%3]) cnt++; if (cnt < ans) { ans = cnt; idx = i; } } cout << ans << '\n'; for (int i=0; i<n; ++i) cout << p[idx][i%3]; return 0; }
13.9
57
0.453237
juseongkr
2ecb0e9f2302503b0c1a8944fbdaf30fe9cc14b5
7,820
cpp
C++
moai/src/zlcore/ZLFile.cpp
jjimenezg93/ai-pathfinding
e32ae8be30d3df21c7e64be987134049b585f1e6
[ "MIT" ]
null
null
null
moai/src/zlcore/ZLFile.cpp
jjimenezg93/ai-pathfinding
e32ae8be30d3df21c7e64be987134049b585f1e6
[ "MIT" ]
null
null
null
moai/src/zlcore/ZLFile.cpp
jjimenezg93/ai-pathfinding
e32ae8be30d3df21c7e64be987134049b585f1e6
[ "MIT" ]
null
null
null
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #include "pch.h" #ifdef NACL #include "NaClFile.h" #endif #include <zlcore/zl_util.h> #include <zlcore/ZLFile.h> #include <zlcore/ZLFileSystem.h> #include <zlcore/ZLVirtualPath.h> #include <zlcore/ZLZipStream.h> #ifdef MOAI_COMPILER_MSVC #include <Share.h> #endif using namespace std; //================================================================// // ZLFile //================================================================// //----------------------------------------------------------------// void ZLFile::ClearError () { if ( !this->mIsZip ) { clearerr ( this->mPtr.mFile ); } } //----------------------------------------------------------------// int ZLFile::Close () { int result = 0; if ( this->mIsZip ) { if ( this->mPtr.mZip ) { delete this->mPtr.mZip; this->mPtr.mZip = 0; } } else if ( this->mPtr.mFile ) { result = fclose ( this->mPtr.mFile ); this->mPtr.mFile = 0; } return result; } //----------------------------------------------------------------// int ZLFile::CloseProcess () { FILE* stdFile = 0; if ( !this->mIsZip ) { stdFile = this->mPtr.mFile; this->mPtr.mFile = 0; } #ifdef MOAI_OS_WINDOWS return _pclose ( stdFile ); #else return pclose ( stdFile ); #endif } //----------------------------------------------------------------// int ZLFile::Flush () { if ( !this->mIsZip ) { return fflush ( this->mPtr.mFile ); } return 0; } //----------------------------------------------------------------// int ZLFile::GetChar () { int result = EOF; if ( this->mIsZip ) { char c; result = ( int )this->mPtr.mZip->Read ( &c, 1 ); if ( result == 1 ) { result = c; } } else { result = fgetc ( this->mPtr.mFile ); } return result; } //----------------------------------------------------------------// int ZLFile::GetError () { return ( this->mIsZip ) ? 0 : ferror ( this->mPtr.mFile ); // TODO: error flag for zip file } //----------------------------------------------------------------// int ZLFile::GetFileNum () { // TODO: if ( !this->mIsZip ) { return fileno ( this->mPtr.mFile ); } return -1; } //----------------------------------------------------------------// int ZLFile::GetPos ( fpos_t* position ) { (( void )position ); assert ( 0 ); // not implemented return -1; } //----------------------------------------------------------------// char* ZLFile::GetString ( char* string, int length ) { int i = 0; int c = 0; if ( this->mIsZip ) { if ( length <= 1 ) return 0; do { c = this->GetChar (); if ( c == ( int )EOF || c == ( int )NULL ) break; string [ i++ ] = ( char )c; if ( i >= length ) return 0; } while ( c && ( c != '\n' )); if ( i == 0 ) { return 0; } string [ i ] = 0; return string; } return fgets ( string, length, this->mPtr.mFile ); } //----------------------------------------------------------------// int ZLFile::IsEOF () { return ( this->mIsZip ) ? this->mPtr.mZip->IsAtEnd () : feof ( this->mPtr.mFile ); } //----------------------------------------------------------------// int ZLFile::Open ( const char* filename, const char* mode ) { ZLVirtualPath* mount; string abspath = ZLFileSystem::Get ().GetAbsoluteFilePath ( filename ); filename = abspath.c_str (); mount = ZLFileSystem::Get ().FindBestVirtualPath ( filename ); if ( mount ) { if ( mode [ 0 ] == 'r' ) { ZLZipStream* zipStream = 0; filename = mount->GetLocalPath ( filename ); if ( filename ) { zipStream = ZLZipStream::Open ( mount->mArchive, filename ); } if ( zipStream ) { this->mIsZip = 1; this->mPtr.mZip = zipStream; return 0; } } } else { #ifdef MOAI_COMPILER_MSVC FILE* stdFile = 0; stdFile = _fsopen ( filename, mode, _SH_DENYNO ); #else FILE* stdFile = fopen ( filename, mode ); #endif if ( stdFile ) { this->mPtr.mFile = stdFile; return 0; } } return -1; } //----------------------------------------------------------------// int ZLFile::OpenProcess ( const char *command, const char *mode ) { FILE* stdFile = 0; #ifdef MOAI_OS_WINDOWS stdFile = _popen ( command, mode ); #else stdFile = popen ( command, mode ); #endif if ( stdFile ) { this->mPtr.mFile = stdFile; return 0; } return -1; } //----------------------------------------------------------------// int ZLFile::OpenTemp () { this->mPtr.mFile = tmpfile (); return this->mPtr.mFile ? 0 : -1; } //----------------------------------------------------------------// int ZLFile::PutChar ( int c ) { if ( !this->mIsZip ) { return fputc ( c, this->mPtr.mFile ); } return EOF; } //----------------------------------------------------------------// int ZLFile::PutString ( const char* string ) { if ( !this->mIsZip ) { return fputs ( string, this->mPtr.mFile ); } return EOF; } //----------------------------------------------------------------// size_t ZLFile::Read ( void* buffer, size_t size, size_t count ) { if ( this->mIsZip ) { size_t result = ( size_t )this->mPtr.mZip->Read ( buffer, size * count ); return ( size_t )( result / size ); } return fread ( buffer, size, count, this->mPtr.mFile ); } //----------------------------------------------------------------// int ZLFile::Reopen ( const char* filename, const char* mode ) { if ( this->mIsZip ) { this->Close (); return this->Open ( filename, mode ); } else { FILE* stdFile = freopen ( filename, mode, this->mPtr.mFile ); if ( stdFile ) { this->mPtr.mFile = stdFile; return 0; } } return -1; } //----------------------------------------------------------------// int ZLFile::Seek ( long offset, int origin ) { return ( this->mIsZip ) ? this->mPtr.mZip->Seek ( offset, origin ) : fseek ( this->mPtr.mFile, offset, origin ); } //----------------------------------------------------------------// void ZLFile::SetFile ( FILE* file ) { this->Flush (); this->mPtr.mFile = file; this->mIsZip = false; } //----------------------------------------------------------------// int ZLFile::SetPos ( const fpos_t * pos ) { (( void )pos ); assert ( 0 ); // not implemented return -1; } //----------------------------------------------------------------// long ZLFile::Tell () { return ( this->mIsZip ) ? ( long )this->mPtr.mZip->Tell () : ftell ( this->mPtr.mFile ); } //----------------------------------------------------------------// size_t ZLFile::Write ( const void* data, size_t size, size_t count ) { if ( !this->mIsZip ) { return fwrite ( data, size, count, this->mPtr.mFile ); } return 0; } //----------------------------------------------------------------// void ZLFile::SetBuf ( char* buffer ) { if ( !this->mIsZip ) { setbuf ( this->mPtr.mFile, buffer ); } } //----------------------------------------------------------------// int ZLFile::SetVBuf ( char* buffer, int mode, size_t size ) { if ( !this->mIsZip ) { setvbuf ( this->mPtr.mFile, buffer, mode, size ); } return 0; } //----------------------------------------------------------------// int ZLFile::UnGetChar ( int character ) { if ( this->mIsZip ) { return this->mPtr.mZip->UnGetChar (( char )character ) ? EOF : 0; } return ungetc ( character, this->mPtr.mFile ); } //----------------------------------------------------------------// int ZLFile::VarPrintf ( const char* format, va_list arg ) { if ( !this->mIsZip ) { return vfprintf ( this->mPtr.mFile, format, arg ); } return -1; } //----------------------------------------------------------------// ZLFile::ZLFile () : mIsZip ( false ) { this->mPtr.mFile = 0; this->mPtr.mZip = 0; } //----------------------------------------------------------------// ZLFile::~ZLFile () { this->Close (); }
21.966292
113
0.438491
jjimenezg93