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
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
sequencelengths
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
sequencelengths
1
9
max_issues_count
int64
1
48.5k
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
sequencelengths
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
80bd855e82392e09fc83f2c2ad73beb0cbcd3730
9,648
cpp
C++
src/test/fixtures.cpp
KuroGuo/firo
dbce40b3c7edb21fbebb014e6fe7ab700e649b6f
[ "MIT" ]
null
null
null
src/test/fixtures.cpp
KuroGuo/firo
dbce40b3c7edb21fbebb014e6fe7ab700e649b6f
[ "MIT" ]
null
null
null
src/test/fixtures.cpp
KuroGuo/firo
dbce40b3c7edb21fbebb014e6fe7ab700e649b6f
[ "MIT" ]
null
null
null
#include "util.h" #include "clientversion.h" #include "primitives/transaction.h" #include "random.h" #include "sync.h" #include "utilstrencodings.h" #include "utilmoneystr.h" #include "test/test_bitcoin.h" #include <stdint.h> #include <vector> #include <iostream> #include "chainparams.h" #include "consensus/consensus.h" #include "consensus/validation.h" #include "key.h" #include "sigma/openssl_context.h" #include "validation.h" #include "miner.h" #include "pubkey.h" #include "random.h" #include "txdb.h" #include "txmempool.h" #include "ui_interface.h" #include "rpc/server.h" #include "rpc/register.h" #include "test/testutil.h" #include "test/fixtures.h" #include "wallet/db.h" #include "wallet/wallet.h" #include <boost/filesystem.hpp> #include <boost/test/unit_test.hpp> #include <boost/thread.hpp> #include "sigma.h" #include "lelantus.h" ZerocoinTestingSetupBase::ZerocoinTestingSetupBase(): TestingSetup(CBaseChainParams::REGTEST, "1") { // Crean sigma state, just in case someone forgot to do so. sigma::CSigmaState *sigmaState = sigma::CSigmaState::GetState(); sigmaState->Reset(); }; ZerocoinTestingSetupBase::~ZerocoinTestingSetupBase() { // Clean sigma state after us. sigma::CSigmaState *sigmaState = sigma::CSigmaState::GetState(); sigmaState->Reset(); } CBlock ZerocoinTestingSetupBase::CreateBlock(const CScript& scriptPubKey) { const CChainParams& chainparams = Params(); std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey); CBlock block = pblocktemplate->block; // IncrementExtraNonce creates a valid coinbase and merkleRoot unsigned int extraNonce = 0; IncrementExtraNonce(&block, chainActive.Tip(), extraNonce); while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())){ ++block.nNonce; } return block; } bool ZerocoinTestingSetupBase::ProcessBlock(const CBlock &block) { const CChainParams& chainparams = Params(); return ProcessNewBlock(chainparams, std::make_shared<const CBlock>(block), true, NULL); } // Create a new block with just given transactions, coinbase paying to // scriptPubKey, and try to add it to the current chain. CBlock ZerocoinTestingSetupBase::CreateAndProcessBlock(const CScript& scriptPubKey) { CBlock block = CreateBlock(scriptPubKey); BOOST_CHECK_MESSAGE(ProcessBlock(block), "Processing block failed"); return block; } void ZerocoinTestingSetupBase::CreateAndProcessEmptyBlocks(size_t block_numbers, const CScript& script) { while (block_numbers--) { CreateAndProcessBlock(script); } } ZerocoinTestingSetup200::ZerocoinTestingSetup200() { BOOST_CHECK(pwalletMain->GetKeyFromPool(pubkey)); std::string strAddress = CBitcoinAddress(pubkey.GetID()).ToString(); pwalletMain->SetAddressBook(CBitcoinAddress(strAddress).Get(), "", ( "receive")); //Mine 200 blocks so that we have funds for creating mints and we are over these limits: //mBlockHeightConstants["ZC_V1_5_STARTING_BLOCK"] = 150; //mBlockHeightConstants["ZC_CHECK_BUG_FIXED_AT_BLOCK"] = 140; // Since sigma V3 implementation also over consensus.nMintV3SigmaStartBlock = 180; scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG; for (int i = 0; i < 200; i++) { CBlock b = CreateAndProcessBlock(scriptPubKey); coinbaseTxns.push_back(*b.vtx[0]); LOCK(cs_main); { LOCK(pwalletMain->cs_wallet); pwalletMain->AddToWalletIfInvolvingMe(*b.vtx[0], chainActive.Tip(), 0, true); } } } ZerocoinTestingSetup109::ZerocoinTestingSetup109() { CPubKey newKey; BOOST_CHECK(pwalletMain->GetKeyFromPool(newKey)); std::string strAddress = CBitcoinAddress(newKey.GetID()).ToString(); pwalletMain->SetAddressBook(CBitcoinAddress(strAddress).Get(), "", ( "receive")); scriptPubKey = CScript() << ToByteVector(newKey/*coinbaseKey.GetPubKey()*/) << OP_CHECKSIG; for (int i = 0; i < 109; i++) { CBlock b = CreateAndProcessBlock(scriptPubKey); coinbaseTxns.push_back(*b.vtx[0]); LOCK(cs_main); { LOCK(pwalletMain->cs_wallet); pwalletMain->AddToWalletIfInvolvingMe(*b.vtx[0], chainActive.Tip(), 0, true); } } } MtpMalformedTestingSetup::MtpMalformedTestingSetup() { CPubKey newKey; BOOST_CHECK(pwalletMain->GetKeyFromPool(newKey)); std::string strAddress = CBitcoinAddress(newKey.GetID()).ToString(); pwalletMain->SetAddressBook(CBitcoinAddress(strAddress).Get(), "", ( "receive")); scriptPubKey = CScript() << ToByteVector(newKey/*coinbaseKey.GetPubKey()*/) << OP_CHECKSIG; bool mtp = false; CBlock b; for (int i = 0; i < 150; i++) { b = CreateAndProcessBlock(scriptPubKey, mtp); coinbaseTxns.push_back(*b.vtx[0]); LOCK(cs_main); { LOCK(pwalletMain->cs_wallet); pwalletMain->AddToWalletIfInvolvingMe(*b.vtx[0], chainActive.Tip(), 0, true); } } } CBlock MtpMalformedTestingSetup::CreateBlock( const CScript& scriptPubKeyMtpMalformed, bool mtp = false) { const CChainParams& chainparams = Params(); std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKeyMtpMalformed); CBlock block = pblocktemplate->block; // IncrementExtraNonce creates a valid coinbase and merkleRoot unsigned int extraNonce = 0; IncrementExtraNonce(&block, chainActive.Tip(), extraNonce); while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())){ ++block.nNonce; } if(mtp) { while (!CheckMerkleTreeProof(block, chainparams.GetConsensus())){ block.mtpHashValue = mtp::hash(block, Params().GetConsensus().powLimit); } } else { while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())){ ++block.nNonce; } } //delete pblocktemplate; return block; } // Create a new block with just given transactions, coinbase paying to // scriptPubKeyMtpMalformed, and try to add it to the current chain. CBlock MtpMalformedTestingSetup::CreateAndProcessBlock( const CScript& scriptPubKeyMtpMalformed, bool mtp = false) { CBlock block = CreateBlock(scriptPubKeyMtpMalformed, mtp); BOOST_CHECK_MESSAGE(ProcessBlock(block), "Processing block failed"); return block; } LelantusTestingSetup::LelantusTestingSetup() : params(lelantus::Params::get_default()) { CPubKey key; { LOCK(pwalletMain->cs_wallet); key = pwalletMain->GenerateNewKey(); } script = GetScriptForDestination(key.GetID()); } CBlockIndex* LelantusTestingSetup::GenerateBlock(std::vector<CMutableTransaction> const &txns, CScript *script) { auto last = chainActive.Tip(); CreateAndProcessBlock(txns, script ? *script : this->script); auto block = chainActive.Tip(); if (block != last) { pwalletMain->ScanForWalletTransactions(block, true); } return block != last ? block : nullptr; } void LelantusTestingSetup::GenerateBlocks(size_t blocks, CScript *script) { while (blocks--) { GenerateBlock({}, script); } } std::vector<lelantus::PrivateCoin> LelantusTestingSetup::GenerateMints( std::vector<CAmount> const &amounts) { auto const &p = lelantus::Params::get_default(); std::vector<lelantus::PrivateCoin> coins; for (auto a : amounts) { std::vector<unsigned char> k(32); GetRandBytes(k.data(), k.size()); secp256k1_pubkey pubkey; if (!secp256k1_ec_pubkey_create(OpenSSLContext::get_context(), &pubkey, k.data())) { throw std::runtime_error("Fail to create public key"); } auto serial = lelantus::PrivateCoin::serialNumberFromSerializedPublicKey( OpenSSLContext::get_context(), &pubkey); Scalar randomness; randomness.randomize(); coins.emplace_back(p, serial, a, randomness, k, 0); } return coins; } std::vector<CHDMint> LelantusTestingSetup::GenerateMints( std::vector<CAmount> const &amounts, std::vector<CMutableTransaction> &txs) { std::vector<lelantus::PrivateCoin> coins; return GenerateMints(amounts, txs, coins); } std::vector<CHDMint> LelantusTestingSetup::GenerateMints( std::vector<CAmount> const &amounts, std::vector<CMutableTransaction> &txs, std::vector<lelantus::PrivateCoin> &coins) { std::vector<CHDMint> hdMints; CWalletDB walletdb(pwalletMain->strWalletFile); for (auto a : amounts) { std::vector<std::pair<CWalletTx, CAmount>> wtxAndFee; std::vector<CHDMint> mints; auto result = pwalletMain->MintAndStoreLelantus(a, wtxAndFee, mints); if (result != "") { throw std::runtime_error(_("Fail to generate mints, ") + result); } for(auto itr : wtxAndFee) txs.emplace_back(itr.first); hdMints.insert(hdMints.end(), mints.begin(), mints.end()); } return hdMints; } CPubKey LelantusTestingSetup::GenerateAddress() { LOCK(pwalletMain->cs_wallet); return pwalletMain->GenerateNewKey(); } LelantusTestingSetup::~LelantusTestingSetup() { lelantus::CLelantusState::GetState()->Reset(); }
31.42671
122
0.671953
KuroGuo
80be77e6041f1ac2db954c1ec238a0dc33252bf1
3,186
cpp
C++
Gui/VtkVis/VtkCompositeThresholdFilter.cpp
WenjieXu/ogs
0cd1b72ec824833bf949a8bbce073c82158ee443
[ "BSD-4-Clause" ]
1
2021-11-21T17:29:38.000Z
2021-11-21T17:29:38.000Z
Gui/VtkVis/VtkCompositeThresholdFilter.cpp
WenjieXu/ogs
0cd1b72ec824833bf949a8bbce073c82158ee443
[ "BSD-4-Clause" ]
null
null
null
Gui/VtkVis/VtkCompositeThresholdFilter.cpp
WenjieXu/ogs
0cd1b72ec824833bf949a8bbce073c82158ee443
[ "BSD-4-Clause" ]
null
null
null
/** * \file * \author Lars Bilke * \date 2010-10-25 * \brief Implementation of the VtkCompositeThresholdFilter class. * * \copyright * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.org/project/license * */ // ** INCLUDES ** #include "VtkCompositeThresholdFilter.h" #include <vtkCellData.h> #include <vtkThreshold.h> #include <vtkUnstructuredGrid.h> #include <vtkIntArray.h> #include <vtkSmartPointer.h> #include <limits> VtkCompositeThresholdFilter::VtkCompositeThresholdFilter( vtkAlgorithm* inputAlgorithm ) : VtkCompositeFilter(inputAlgorithm) { this->init(); } VtkCompositeThresholdFilter::~VtkCompositeThresholdFilter() { } void VtkCompositeThresholdFilter::init() { // Set meta information about input and output data types this->_inputDataObjectType = VTK_DATA_SET; this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID; // Because this is the only filter here we cannot use vtkSmartPointer vtkThreshold* threshold = vtkThreshold::New(); threshold->SetInputConnection(_inputAlgorithm->GetOutputPort()); // Sets a filter property which will be user editable threshold->SetSelectedComponent(0); // Setting the threshold to min / max values to ensure that the whole data // is first processed. This is needed for correct lookup table generation. const double dMin = std::numeric_limits<double>::lowest(); const double dMax = std::numeric_limits<double>::max(); threshold->ThresholdBetween(dMin, dMax); // Create a list for the ThresholdBetween (vector) property. QList<QVariant> thresholdRangeList; // Insert the values (same values as above) thresholdRangeList.push_back(dMin); thresholdRangeList.push_back(dMax); // Put that list in the property map (*_algorithmUserVectorProperties)["Range"] = thresholdRangeList; // Make a new entry in the property map for the SelectedComponent property (*_algorithmUserProperties)["Selected Component"] = 0; // Must all scalars match the criterium threshold->SetAllScalars(1); (*_algorithmUserProperties)["Evaluate all points"] = true; // The threshold filter is last one and so it is also the _outputAlgorithm _outputAlgorithm = threshold; } void VtkCompositeThresholdFilter::SetUserProperty( QString name, QVariant value ) { VtkAlgorithmProperties::SetUserProperty(name, value); // Use the same name as in init() if (name.compare("Selected Component") == 0) // Set the property on the algorithm static_cast<vtkThreshold*>(_outputAlgorithm)->SetSelectedComponent(value.toInt()); else if (name.compare("Evaluate all points") == 0) static_cast<vtkThreshold*>(_outputAlgorithm)->SetAllScalars(value.toBool()); } void VtkCompositeThresholdFilter::SetUserVectorProperty( QString name, QList<QVariant> values ) { VtkAlgorithmProperties::SetUserVectorProperty(name, values); // Use the same name as in init() if (name.compare("Range") == 0) // Set the vector property on the algorithm static_cast<vtkThreshold*>(_outputAlgorithm)->ThresholdBetween( values[0].toDouble(), values[1].toDouble()); }
33.1875
95
0.752982
WenjieXu
80c24b7d826a1b034e18ffa62ce8661006267914
5,300
cpp
C++
PersistentDSU.cpp
RohitTheBoss007/CodeforcesSolutions
4025270fb22a6c5c5276569b42e839f35b9ce09b
[ "MIT" ]
2
2020-06-15T09:20:26.000Z
2020-10-01T19:24:07.000Z
PersistentDSU.cpp
RohitTheBoss007/Coding-Algorithms
4025270fb22a6c5c5276569b42e839f35b9ce09b
[ "MIT" ]
null
null
null
PersistentDSU.cpp
RohitTheBoss007/Coding-Algorithms
4025270fb22a6c5c5276569b42e839f35b9ce09b
[ "MIT" ]
null
null
null
// Problem: Persistent UnionFind (https://judge.yosupo.jp/problem/persistent_unionfind) // Contest: Library Checker // Time: 2020-12-16 23:45:07 // 私に忍び寄るのをやめてください、ありがとう #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ll long long #define int long long #define mod 1000000007 //998244353 #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define f(i,n) for(ll i=0;i<n;i++) #define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i) #define nl "\n" #define trace(x) cerr<<#x<<": "<<x<<" "<<endl #define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl #define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl #define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl #define x first #define y second #define vc vector #define pb push_back #define ar array #define all(a) (a).begin(), (a).end() #define rall(x) (x).rbegin(), (x).rend() #define ms(v,n,x) fill(v,v+n,x); #define init(c,a) memset(c,a,sizeof(c)) #define pll pair<ll,ll> #define mll map<ll,ll> #define sll set<ll> #define vll vector<ll> #define vpll vector<pll> #define inf 9e18 #define cases ll T;cin>>T;while(T--) #define BLOCK 500 //const double PI = 3.141592653589793238460; template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } typedef std::complex<double> Complex; typedef std::valarray<Complex> CArray; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} // void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); template< typename T, int LOG > struct PersistentArray { struct Node { T data; Node *child[1 << LOG] = {}; Node() {} Node(const T &data) : data(data) {} }; Node *root; PersistentArray() : root(nullptr) {} T get(Node *t, int k) { if(k == 0) return t->data; return get(t->child[k & ((1 << LOG) - 1)], k >> LOG); } T get(const int &k) { return get(root, k); } pair< Node *, T * > mutable_get(Node *t, int k) { t = t ? new Node(*t) : new Node(); if(k == 0) return {t, &t->data}; auto p = mutable_get(t->child[k & ((1 << LOG) - 1)], k >> LOG); t->child[k & ((1 << LOG) - 1)] = p.first; return {t, p.second}; } T *mutable_get(const int &k) { auto ret = mutable_get(root, k); root = ret.first; return ret.second; } Node *build(Node *t, const T &data, int k) { if(!t) t = new Node(); if(k == 0) { t->data = data; return t; } auto p = build(t->child[k & ((1 << LOG) - 1)], data, k >> LOG); t->child[k & ((1 << LOG) - 1)] = p; return t; } void build(const vector< T > &v) { root = nullptr; for(int i = 0; i < v.size(); i++) { root = build(root, v[i], i); } } }; /* * @brief Persistent-Union-Find(永続Union-Find) */ struct PersistentUnionFind { PersistentArray< int, 3 > data; PersistentUnionFind() {} PersistentUnionFind(int sz) { data.build(vector< int >(sz, -1)); } int find(int k) { int p = data.get(k); return p >= 0 ? find(p) : k; } int size(int k) { return (-data.get(find(k))); } bool unite(int x, int y) { x = find(x); y = find(y); if(x == y) return false; auto u = data.get(x); auto v = data.get(y); if(u < v) { auto a = data.mutable_get(x); *a += v; auto b = data.mutable_get(y); *b = x; } else { auto a = data.mutable_get(y); *a += u; auto b = data.mutable_get(x); *b = y; } return true; } }; int32_t main() { fast cout << fixed << setprecision(12); ll n,q; cin>>n>>q; vc<PersistentUnionFind> uf(q+1); uf[0]= PersistentUnionFind(n); fore(i,1,q){ ll t,k,u,v; cin>>t>>k>>u>>v;k++; if(t==0){ uf[i]=uf[k]; uf[i].unite(u,v); } else{ if(uf[k].find(u)==uf[k].find(v))cout<<1<<nl; else cout<<0<<nl; } } return 0; }
25.603865
118
0.558113
RohitTheBoss007
80c5a2a27d50f3aa69dc4866d2f39309eece010a
3,440
hpp
C++
include/tao/json/events/debug.hpp
mallexxx/json
da7ae64ef1af13949a9983a92fddac44390c4951
[ "BSD-3-Clause", "Apache-2.0", "MIT" ]
null
null
null
include/tao/json/events/debug.hpp
mallexxx/json
da7ae64ef1af13949a9983a92fddac44390c4951
[ "BSD-3-Clause", "Apache-2.0", "MIT" ]
null
null
null
include/tao/json/events/debug.hpp
mallexxx/json
da7ae64ef1af13949a9983a92fddac44390c4951
[ "BSD-3-Clause", "Apache-2.0", "MIT" ]
null
null
null
// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/json/ #ifndef TAO_JSON_EVENTS_DEBUG_HPP #define TAO_JSON_EVENTS_DEBUG_HPP #include <cmath> #include <cstddef> #include <cstdint> #include <ostream> #include <string> #include "../binary_view.hpp" #include "../external/ryu.hpp" #include "../internal/escape.hpp" #include "../internal/hexdump.hpp" namespace tao { namespace json { namespace events { // Events consumer that writes the events to a stream for debug purposes. class debug { private: std::ostream& os; public: explicit debug( std::ostream& in_os ) noexcept : os( in_os ) { } void null() { os << "null\n"; } void boolean( const bool v ) { if( v ) { os << "boolean: true\n"; } else { os << "boolean: false\n"; } } void number( const std::int64_t v ) { os << "std::int64_t: " << v << '\n'; } void number( const std::uint64_t v ) { os << "std::uint64_t: " << v << '\n'; } void number( const double v ) { os << "double: "; if( !std::isfinite( v ) ) { os << v; } else { ryu::d2s_stream( os, v ); } os << '\n'; } void string( const std::string_view v ) { os << "string: \""; internal::escape( os, v ); os << "\"\n"; } void binary( const tao::binary_view v ) { os << "binary: "; internal::hexdump( os, v ); os << '\n'; } void begin_array() { os << "begin array\n"; } void begin_array( const std::size_t size ) { os << "begin array " << size << '\n'; } void element() { os << "element\n"; } void end_array() { os << "end array\n"; } void end_array( const std::size_t size ) { os << "end array " << size << '\n'; } void begin_object() { os << "begin object\n"; } void begin_object( const std::size_t size ) { os << "begin object " << size << '\n'; } void key( const std::string_view v ) { os << "key: \""; internal::escape( os, v ); os << "\"\n"; } void member() { os << "member\n"; } void end_object() { os << "end object\n"; } void end_object( const std::size_t size ) { os << "end object " << size << '\n'; } }; } // namespace events } // namespace json } // namespace tao #endif
22.193548
82
0.371802
mallexxx
80c73e13996af716a05b3761f690bd9a902903d4
9,090
cpp
C++
src/translation_unit_base.cpp
achreto/fm-translation-framework
a46afcc43f94c8a224f32fcad988a830689a9256
[ "MIT" ]
null
null
null
src/translation_unit_base.cpp
achreto/fm-translation-framework
a46afcc43f94c8a224f32fcad988a830689a9256
[ "MIT" ]
null
null
null
src/translation_unit_base.cpp
achreto/fm-translation-framework
a46afcc43f94c8a224f32fcad988a830689a9256
[ "MIT" ]
null
null
null
/** * Translation Unit Base class implementation * * SPDX-License-Identifier: MIT * * Copyright (C) 2022, Reto Achermann (The University of British Columbia) */ #include "pv/PVBusMaster.h" #include "pv/PVAccessWidth.h" #include <framework/translation_unit_base.hpp> #include <framework/interface_base.hpp> #include <framework/logging.hpp> /* * ------------------------------------------------------------------------------------------- * Reset * ------------------------------------------------------------------------------------------- */ void TranslationUnitBase::reset(void) { Logging::info("resetting translation unit '%s'", this->_name.c_str()); this->get_state()->reset(); this->get_interface()->reset(); Logging::info("reset completed"); } void TranslationUnitBase::set_reset(bool signal_level) { } /* * ------------------------------------------------------------------------------------------- * Printing Functionality * ------------------------------------------------------------------------------------------- */ // prints the global state std::ostream &TranslationUnitBase::print_global_state(std::ostream &os) { return os; } // prints the translation steps for an address std::ostream &TranslationUnitBase::print_translation(std::ostream &os, lvaddr_t addr) { return os; } /* * ------------------------------------------------------------------------------------------------- * Configuration Space * ------------------------------------------------------------------------------------------------- */ pv::Tx_Result TranslationUnitBase::control_read(pv::ReadTransaction tx) { access_mode_t mode; uint64_t value; Logging::debug("TranslationUnit::control_read([%lx..%lx])", tx.getAddress(), tx.getAddressEndIncl()); // we want only to support aligned accesses to the configuration space if (!tx.isAligned()) { Logging::info("TranslationUnit::control_read(): unaligned data access."); return pv::Tx_Result(pv::Tx_Data::TX_ALIGNMENTABORT); } if (tx.isNonSecure()) { if (tx.isPrivileged()) { mode = ACCESS_MODE_NOSEC_READ; } else { mode = ACCESS_MODE_USER_READ; } } else { mode = ACCESS_MODE_SEC_READ; } auto iface = this->get_interface(); bool r = iface->handle_register_read(tx.getAddress(), tx.getTransactionByteSize(), mode, &value); if (!r) { Logging::debug("TranslationUnit::control_write(): read failed."); return pv::Tx_Result(pv::Tx_Data::TX_TRANSFAULT); } switch (tx.getTransactionByteSize()) { case 1: { return tx.setReturnData8(value); } case 2: { // XXX: work around,as the following statement somehow causes issues... // return tx.setReturnData16(value); *static_cast<uint16_t *>(tx.referenceDataValue()) = value; return pv::Tx_Result(pv::Tx_Data::TX_OK); } case 4: { return tx.setReturnData32(value); } case 8: { return tx.setReturnData64(value); } default: return pv::Tx_Result(pv::Tx_Data::TX_ALIGNMENTABORT); } } pv::Tx_Result TranslationUnitBase::control_write(pv::WriteTransaction tx) { access_mode_t mode; uint64_t value; Logging::debug("TranslationUnitBase::control_write([%lx..%lx])", tx.getAddress(), tx.getAddressEndIncl()); // we want only to support aligned accesses to the configuration space if (!tx.isAligned()) { Logging::debug("TranslationUnitBase::control_write(): unaligned data access."); return pv::Tx_Result(pv::Tx_Data::TX_ALIGNMENTABORT); } if (tx.isNonSecure()) { if (tx.isPrivileged()) { mode = ACCESS_MODE_NOSEC_READ; } else { mode = ACCESS_MODE_USER_READ; } } else { mode = ACCESS_MODE_SEC_READ; } switch (tx.getTransactionByteSize()) { case 1: value = tx.getData8(); break; case 2: value = tx.getData16(); break; case 4: value = tx.getData32(); break; case 8: value = tx.getData64(); break; default: Logging::info("TranslationUnitBase::control_write(): unsupported transaction size."); return pv::Tx_Result(pv::Tx_Data::TX_ALIGNMENTABORT); } auto iface = this->get_interface(); bool r = iface->handle_register_write(tx.getAddress(), tx.getTransactionByteSize(), mode, value); if (!r) { Logging::debug("TranslationUnitBase::control_write(): write failed."); return pv::Tx_Result(pv::Tx_Data::TX_TRANSFAULT); } return pv::Tx_Result(pv::Tx_Data::TX_OK); } pv::Tx_Result TranslationUnitBase::control_debug_read(pv::ReadTransaction tx) { Logging::debug("TranslationUnitBase::control_debug_read([%lx..%lx])", tx.getAddress(), tx.getAddressEndIncl()); return this->control_read(tx); } pv::Tx_Result TranslationUnitBase::control_debug_write(pv::WriteTransaction tx) { Logging::debug("TranslationUnitBase::control_debug_write([%lx..%lx])", tx.getAddress(), tx.getAddressEndIncl()); return this->control_write(tx); } /* * ------------------------------------------------------------------------------------------- * Translations * ------------------------------------------------------------------------------------------- */ #include "pv/RemapRequest.h" #define BASE_PAGE_SIZE 4096 /// basic translate functionality. This doesn't change anything in the remap request /// the specific translation unit needs to override this function to provide the actual /// remapping/translatino function here. unsigned TranslationUnitBase::handle_remap(pv::RemapRequest &req, unsigned *unpredictable) { Logging::debug("TranslationUnitBase::handle_remap()"); lpaddr_t addr = req.getOriginalTransactionAddress(); size_t size = 1; // can we get the size somehow? // check the supported ranges if (addr < this->_inaddr_range_min || addr + size > this->_inaddr_range_max) { Logging::error("TranslationUnitBase::handle_remap - request 0x%lx out of supported range " "0x%lx..0x%lx", addr, this->_inaddr_range_min, this->_inaddr_range_max); return 1; } const pv::TransactionAttributes *attr = req.getTransactionAttributes(); access_mode_t mode; if (attr->isNormalWorld()) { if (attr->isPrivileged()) { if (req.isRead()) { mode = ACCESS_MODE_NOSEC_READ; } else { mode = ACCESS_MODE_NOSEC_WRITE; } } else { if (req.isRead()) { mode = ACCESS_MODE_USER_READ; } else { mode = ACCESS_MODE_USER_WRITE; } } } else { if (req.isRead()) { mode = ACCESS_MODE_SEC_READ; } else { mode = ACCESS_MODE_SEC_WRITE; } } // set the translation to be valid only once, to get retriggered req.setOnceOnly(); lpaddr_t dst; bool r = this->do_translate(addr, size, mode, &dst); if (!r) { Logging::info("TranslationUnitBase::handle_remap() - translation failed"); return 1; } Logging::debug("TranslationUnitBase::handle_remap() - translated 0x%lx -> 0x%lx", addr, dst); // set the remap base req.setRemapPageBase(dst & ~(BASE_PAGE_SIZE - 1)); return 0; } DVM::error_response_t TranslationUnitBase::handle_dvm_msg(DVM::Message *msg, bool ptw) { return DVM::error_response_t(DVM::error_response_t::ok); } /* * ------------------------------------------------------------------------------------------- * Translation table walk * ------------------------------------------------------------------------------------------- */ bool TranslationUnitBase::translation_table_walk(lpaddr_t addr, uint8_t width, uint64_t *data) { pv::AccessWidth access_width; Logging::debug("TranslationUnitBase::translation_table_walk(0x%lx, %u)", addr, width); if (this->_ttw_pvbus == nullptr) { Logging::error("TranslationUnitBase::translation_table_walk - no page walker set!"); return false; } if (width == 64) { access_width = pv::ACCESS_64_BITS; } else if (width == 32) { access_width = pv::ACCESS_32_BITS; } else { return false; } // setup the buffer descriptor pv::RandomContextTransactionGenerator::buffer_t bt = pv::RandomContextTransactionGenerator::buffer_t(access_width, data, 1); // setup the transaction attributes pv::TransactionAttributes ta = pv::TransactionAttributes(); ta.setPTW(true); // a new ACE request pv::ACERequest req = pv::ACERequest(); // do the translaction pv::Tx_Result res = this->_ttw_pvbus->read(&ta, &req, (pv::bus_addr_t)addr, &bt); // return success return res.isOK(); }
30.199336
100
0.562376
achreto
80c7e24023da4a49c724c3ff8c1fd74df3d9528b
5,459
cpp
C++
cppLib/code/dep/G3D/source/UprightFrame.cpp
DrYaling/ProcedureContentGenerationForUnity
3c4f1e70b01e4fe2b9f847324b60b15016b9a740
[ "MIT" ]
3
2019-05-14T07:19:59.000Z
2019-05-14T08:08:25.000Z
cppLib/code/dep/G3D/source/UprightFrame.cpp
DrYaling/ProcedureContentGenerationForUnity
3c4f1e70b01e4fe2b9f847324b60b15016b9a740
[ "MIT" ]
null
null
null
cppLib/code/dep/G3D/source/UprightFrame.cpp
DrYaling/ProcedureContentGenerationForUnity
3c4f1e70b01e4fe2b9f847324b60b15016b9a740
[ "MIT" ]
1
2018-08-08T07:39:16.000Z
2018-08-08T07:39:16.000Z
/** \file UprightFrame.cpp \maintainer Morgan McGuire, http://graphics.cs.williams.edu */ #include "G3D/UprightFrame.h" #include "G3D/BinaryInput.h" #include "G3D/BinaryOutput.h" namespace G3D { UprightFrame::UprightFrame(const CoordinateFrame& cframe) { Vector3 look = cframe.lookVector(); yaw = (float)(G3D::pi() + atan2(look.x, look.z)); pitch = asin(look.y); translation = cframe.translation; } UprightFrame::UprightFrame(const Any& any) { any.verifyName("UprightFrame"); any.verifyType(Any::TABLE); translation = any["translation"]; pitch = any["pitch"]; yaw = any["yaw"]; } Any UprightFrame::toAny() const { Any any(Any::TABLE, "UprightFrame"); any["translation"] = translation; any["pitch"] = pitch; any["yaw"] = yaw; return any; } UprightFrame& UprightFrame::operator=(const Any& any) { *this = UprightFrame(any); return *this; } CoordinateFrame UprightFrame::toCoordinateFrame() const { CoordinateFrame cframe; Matrix3 P(Matrix3::fromAxisAngle(Vector3::unitX(), pitch)); Matrix3 Y(Matrix3::fromAxisAngle(Vector3::unitY(), yaw)); cframe.rotation = Y * P; cframe.translation = translation; return cframe; } UprightFrame UprightFrame::operator+(const UprightFrame& other) const { return UprightFrame(translation + other.translation, pitch + other.pitch, yaw + other.yaw); } UprightFrame UprightFrame::operator*(const float k) const { return UprightFrame(translation * k, pitch * k, yaw * k); } void UprightFrame::unwrapYaw(UprightFrame* a, int N) { // Use the first point to establish the wrapping convention for (int i = 1; i < N; ++i) { const float prev = a[i - 1].yaw; float& cur = a[i].yaw; // No two angles should be more than pi (i.e., 180-degrees) apart. if (abs(cur - prev) > G3D::pi()) { // These angles must have wrapped at zero, causing them // to be interpolated the long way. // Find canonical [0, 2pi] versions of these numbers float p = (float)wrap(prev, twoPi()); float c = (float)wrap(cur, twoPi()); // Find the difference -pi < diff < pi between the current and previous values float diff = c - p; if (diff < -G3D::pi()) { diff += (float)twoPi(); } else if (diff > G3D::pi()) { diff -= (float)twoPi(); } // Offset the current from the previous by the difference // between them. cur = prev + diff; } } } void UprightFrame::serialize(class BinaryOutput& b) const { translation.serialize(b); b.writeFloat32(pitch); b.writeFloat32(yaw); } void UprightFrame::deserialize(class BinaryInput& b) { translation.deserialize(b); pitch = b.readFloat32(); yaw = b.readFloat32(); } /////////////////////////////////////////////////////////////////////////////////////////// UprightSpline::UprightSpline() : Spline<UprightFrame>() { } UprightSpline::UprightSpline(const Any& any) { any.verifyName("UprightSpline"); any.verifyType(Any::TABLE); extrapolationMode = any["extrapolationMode"]; const Any& controlsAny = any["control"]; controlsAny.verifyType(Any::ARRAY); control.resize(controlsAny.length()); for (int controlIndex = 0; controlIndex < control.length(); ++controlIndex) { control[controlIndex] = controlsAny[controlIndex]; } const Any& timesAny = any["time"]; timesAny.verifyType(Any::ARRAY); time.resize(timesAny.length()); for (int timeIndex = 0; timeIndex < time.length(); ++timeIndex) { time[timeIndex] = timesAny[timeIndex]; } } Any UprightSpline::toAny(const std::string& myName) const { Any any(Any::TABLE, myName); any["extrapolationMode"] = extrapolationMode; Any controlsAny(Any::ARRAY); for (int controlIndex = 0; controlIndex < control.length(); ++controlIndex) { controlsAny.append(control[controlIndex]); } any["control"] = controlsAny; Any timesAny(Any::ARRAY); for (int timeIndex = 0; timeIndex < time.length(); ++timeIndex) { timesAny.append(Any(time[timeIndex])); } any["time"] = timesAny; return any; } Any UprightSpline::toAny() const { return toAny("UprightSpline"); } UprightSpline& UprightSpline::operator=(const Any& any) { *this = UprightSpline(any); return *this; } void UprightSpline::serialize(class BinaryOutput& b) const { b.writeInt32(extrapolationMode); b.writeInt32(control.size()); for (int i = 0; i < control.size(); ++i) { control[i].serialize(b); } b.writeInt32(time.size()); for (int i = 0; i < time.size(); ++i) { b.writeFloat32(time[i]); } } void UprightSpline::deserialize(class BinaryInput& b) { extrapolationMode = SplineExtrapolationMode(b.readInt32()); control.resize(b.readInt32()); for (int i = 0; i < control.size(); ++i) { control[i].deserialize(b); } if (b.hasMore()) { time.resize(b.readInt32()); for (int i = 0; i < time.size(); ++i) { time[i] = b.readFloat32(); } debugAssert(time.size() == control.size()); } else { // Import legacy path time.resize(control.size()); for (int i = 0; i < time.size(); ++i) { time[i] = (float)i; } } } }
25.390698
95
0.599744
DrYaling
80c7ebb1fcac1999f8ba5ef57dd73c1c11ecc57f
68,985
cpp
C++
src/drivers/mcr3.cpp
pierrelouys/PSP-MAME4ALL
54374b0579b7e2377f015ac155d8f519addfaa1a
[ "Unlicense" ]
1
2021-01-25T20:16:33.000Z
2021-01-25T20:16:33.000Z
src/drivers/mcr3.cpp
pierrelouys/PSP-MAME4ALL
54374b0579b7e2377f015ac155d8f519addfaa1a
[ "Unlicense" ]
1
2021-05-24T20:28:35.000Z
2021-05-25T14:44:54.000Z
src/drivers/mcr3.cpp
PSP-Archive/PSP-MAME4ALL
54374b0579b7e2377f015ac155d8f519addfaa1a
[ "Unlicense" ]
null
null
null
/*************************************************************************** MCR/III memory map (preliminary) 0000-3fff ROM 0 4000-7fff ROM 1 8000-cfff ROM 2 c000-dfff ROM 3 e000-e7ff RAM e800-e9ff spriteram f000-f7ff tiles f800-f8ff palette ram IN0 bit 0 : left coin bit 1 : right coin bit 2 : 1 player bit 3 : 2 player bit 4 : ? bit 5 : tilt bit 6 : ? bit 7 : service IN1,IN2 joystick, sometimes spinner IN3 Usually dipswitches. Most game configuration is really done by holding down the service key (F2) during the startup self-test. IN4 extra inputs; also used to control sound for external boards The MCR/III games used a plethora of sound boards; all of them seem to do roughly the same thing. We have: * Chip Squeak Deluxe (CSD) - used for music on Spy Hunter * Turbo Chip Squeak (TCS) - used for all sound effects on Sarge * Sounds Good (SG) - used for all sound effects on Rampage and Xenophobe * Squawk & Talk (SNT) - used for speech on Discs of Tron Known issues: * Destruction Derby has no sound * Destruction Derby player 3 and 4 steering wheels are not properly muxed ***************************************************************************/ #include "driver.h" #include "vidhrdw/generic.h" #include "machine/6821pia.h" void mcr3_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); void mcr3_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); void mcr3_videoram_w(int offset,int data); void mcr3_paletteram_w(int offset,int data); void rampage_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); void spyhunt_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); int spyhunt_vh_start(void); void spyhunt_vh_stop(void); void spyhunt_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); extern unsigned char *spyhunt_alpharam; extern int spyhunt_alpharam_size; int crater_vh_start(void); void mcr_init_machine(void); int mcr_interrupt(void); int dotron_interrupt(void); extern int mcr_loadnvram; void mcr_writeport(int port,int value); int mcr_readport(int port); void mcr_soundstatus_w (int offset,int data); int mcr_soundlatch_r (int offset); void mcr_pia_1_w (int offset, int data); int mcr_pia_1_r (int offset); int destderb_port_r(int offset); void spyhunt_init_machine(void); int spyhunt_port_1_r(int offset); int spyhunt_port_2_r(int offset); void spyhunt_writeport(int port,int value); void rampage_init_machine(void); void rampage_writeport(int port,int value); void maxrpm_writeport(int port,int value); int maxrpm_IN1_r(int offset); int maxrpm_IN2_r(int offset); void sarge_init_machine(void); int sarge_IN1_r(int offset); int sarge_IN2_r(int offset); void sarge_writeport(int port,int value); int dotron_vh_start(void); void dotron_vh_stop(void); int dotron_IN2_r(int offset); void dotron_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); void dotron_init_machine(void); void dotron_writeport(int port,int value); void crater_writeport(int port,int value); /*************************************************************************** Memory maps ***************************************************************************/ static struct MemoryReadAddress readmem[] = { { 0x0000, 0xdfff, MRA_ROM }, { 0xe000, 0xe9ff, MRA_RAM }, { 0xf000, 0xf7ff, MRA_RAM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress writemem[] = { { 0xe000, 0xe7ff, MWA_RAM }, { 0x0000, 0xdfff, MWA_ROM }, { 0xe800, 0xe9ff, MWA_RAM, &spriteram, &spriteram_size }, { 0xf000, 0xf7ff, mcr3_videoram_w, &videoram, &videoram_size }, { 0xf800, 0xf8ff, mcr3_paletteram_w, &paletteram }, { -1 } /* end of table */ }; static struct MemoryReadAddress rampage_readmem[] = { { 0x0000, 0xdfff, MRA_ROM }, { 0xe000, 0xebff, MRA_RAM }, { 0xf000, 0xf7ff, MRA_RAM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress rampage_writemem[] = { { 0xe000, 0xe7ff, MWA_RAM }, { 0x0000, 0xdfff, MWA_ROM }, { 0xe800, 0xebff, MWA_RAM, &spriteram, &spriteram_size }, { 0xf000, 0xf7ff, mcr3_videoram_w, &videoram, &videoram_size }, { 0xec00, 0xecff, mcr3_paletteram_w, &paletteram }, { -1 } /* end of table */ }; static struct MemoryReadAddress spyhunt_readmem[] = { { 0x0000, 0xdfff, MRA_ROM }, { 0xe000, 0xebff, MRA_RAM }, { 0xf000, 0xffff, MRA_RAM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress spyhunt_writemem[] = { { 0xf000, 0xf7ff, MWA_RAM }, { 0xe800, 0xebff, MWA_RAM, &spyhunt_alpharam, &spyhunt_alpharam_size }, { 0xe000, 0xe7ff, videoram_w, &videoram, &videoram_size }, { 0xf800, 0xf9ff, MWA_RAM, &spriteram, &spriteram_size }, { 0xfa00, 0xfaff, mcr3_paletteram_w, &paletteram }, { 0x0000, 0xdfff, MWA_ROM }, { -1 } /* end of table */ }; static struct MemoryReadAddress sound_readmem[] = { { 0x8000, 0x83ff, MRA_RAM }, { 0x9000, 0x9003, mcr_soundlatch_r }, { 0xa001, 0xa001, AY8910_read_port_0_r }, { 0xb001, 0xb001, AY8910_read_port_1_r }, { 0xf000, 0xf000, input_port_5_r }, { 0xe000, 0xe000, MRA_NOP }, { 0x0000, 0x3fff, MRA_ROM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress sound_writemem[] = { { 0x8000, 0x83ff, MWA_RAM }, { 0xa000, 0xa000, AY8910_control_port_0_w }, { 0xa002, 0xa002, AY8910_write_port_0_w }, { 0xb000, 0xb000, AY8910_control_port_1_w }, { 0xb002, 0xb002, AY8910_write_port_1_w }, { 0xc000, 0xc000, mcr_soundstatus_w }, { 0xe000, 0xe000, MWA_NOP }, { 0x0000, 0x3fff, MWA_ROM }, { -1 } /* end of table */ }; static struct MemoryReadAddress timber_sound_readmem[] = { { 0x3000, 0x3fff, MRA_RAM }, { 0x8000, 0x83ff, MRA_RAM }, { 0x9000, 0x9003, mcr_soundlatch_r }, { 0xa001, 0xa001, AY8910_read_port_0_r }, { 0xb001, 0xb001, AY8910_read_port_1_r }, { 0xf000, 0xf000, input_port_5_r }, { 0xe000, 0xe000, MRA_NOP }, { 0x0000, 0x2fff, MRA_ROM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress timber_sound_writemem[] = { { 0x3000, 0x3fff, MWA_RAM }, { 0x8000, 0x83ff, MWA_RAM }, { 0xa000, 0xa000, AY8910_control_port_0_w }, { 0xa002, 0xa002, AY8910_write_port_0_w }, { 0xb000, 0xb000, AY8910_control_port_1_w }, { 0xb002, 0xb002, AY8910_write_port_1_w }, { 0xc000, 0xc000, mcr_soundstatus_w }, { 0xe000, 0xe000, MWA_NOP }, { 0x0000, 0x2fff, MWA_ROM }, { -1 } /* end of table */ }; static struct MemoryReadAddress csd_readmem[] = { { 0x000000, 0x007fff, MRA_ROM }, { 0x018000, 0x018007, mcr_pia_1_r }, { 0x01c000, 0x01cfff, MRA_BANK1 }, { -1 } /* end of table */ }; static struct MemoryWriteAddress csd_writemem[] = { { 0x000000, 0x007fff, MWA_ROM }, { 0x018000, 0x018007, mcr_pia_1_w }, { 0x01c000, 0x01cfff, MWA_BANK1 }, { -1 } /* end of table */ }; static struct MemoryReadAddress sg_readmem[] = { { 0x000000, 0x01ffff, MRA_ROM }, { 0x060000, 0x060007, mcr_pia_1_r }, { 0x070000, 0x070fff, MRA_BANK1 }, { -1 } /* end of table */ }; static struct MemoryWriteAddress sg_writemem[] = { { 0x000000, 0x01ffff, MWA_ROM }, { 0x060000, 0x060007, mcr_pia_1_w }, { 0x070000, 0x070fff, MWA_BANK1 }, { -1 } /* end of table */ }; static struct MemoryReadAddress snt_readmem[] = { { 0x0000, 0x007f, MRA_RAM }, { 0x0080, 0x0083, pia_1_r }, { 0x0090, 0x0093, pia_2_r }, { 0xd000, 0xffff, MRA_ROM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress snt_writemem[] = { { 0x0000, 0x007f, MWA_RAM }, { 0x0080, 0x0083, pia_1_w }, { 0x0090, 0x0093, pia_2_w }, { 0xd000, 0xffff, MWA_ROM }, { -1 } /* end of table */ }; static struct MemoryReadAddress tcs_readmem[] = { { 0x0000, 0x03ff, MRA_RAM }, { 0x6000, 0x6003, pia_1_r }, { 0xc000, 0xffff, MRA_ROM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress tcs_writemem[] = { { 0x0000, 0x03ff, MWA_RAM }, { 0x6000, 0x6003, pia_1_w }, { 0xc000, 0xffff, MWA_ROM }, { -1 } /* end of table */ }; /*************************************************************************** Input port definitions ***************************************************************************/ INPUT_PORTS_START( tapper_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x80, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN2 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN3 -- dipswitches */ PORT_DIPNAME( 0x04, 0x04, "Demo Sounds", IP_KEY_NONE ) PORT_DIPSETTING( 0x04, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_DIPNAME( 0x40, 0x40, "Cabinet", IP_KEY_NONE ) PORT_DIPSETTING( 0x40, "Upright" ) PORT_DIPSETTING( 0x00, "Cocktail" ) PORT_BIT( 0xbb, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN4 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END INPUT_PORTS_START( dotron_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x80, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_START /* IN1 */ #ifdef GP2X PORT_ANALOGX( 0xff, 0x00, IPT_DIAL | IPF_REVERSE, 5, 0, 0, 0, 0, 0, OSD_JOY_FIRE5, OSD_JOY_FIRE6, 16 ) #else PORT_ANALOGX( 0xff, 0x00, IPT_DIAL | IPF_REVERSE, 50, 0, 0, 0, OSD_KEY_Z, OSD_KEY_X, 0, 0, 4 ) #endif PORT_START /* IN2 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_BUTTON3, "Aim Down", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0 ) PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON4, "Aim Up", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) /* we default to Environmental otherwise speech is disabled */ PORT_DIPNAME( 0x80, 0x00, "Cabinet", IP_KEY_NONE ) PORT_DIPSETTING( 0x80, "Upright" ) PORT_DIPSETTING( 0x00, "Environmental" ) PORT_START /* IN3 -- dipswitches */ PORT_DIPNAME( 0x01, 0x01, "Coin Meters", IP_KEY_NONE ) PORT_DIPSETTING( 0x01, "1" ) PORT_DIPSETTING( 0x00, "2" ) PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN4 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* fake port to make aiming up & down easier */ PORT_ANALOG ( 0xff, 0x00, IPT_TRACKBALL_Y, 100, 0, 0, 0 ) INPUT_PORTS_END INPUT_PORTS_START( destderb_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BITX( 0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x20, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN1 -- the high 6 bits contain the sterring wheel value */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) PORT_ANALOG ( 0xfc, 0x00, IPT_DIAL | IPF_REVERSE, 50, 0, 0, 0 ) PORT_START /* IN2 -- the high 6 bits contain the sterring wheel value */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) PORT_ANALOG ( 0xfc, 0x00, IPT_DIAL | IPF_REVERSE, 50, 0, 0, 0 ) PORT_START /* IN3 -- dipswitches */ PORT_DIPNAME( 0x01, 0x01, "Cabinet", IP_KEY_NONE ) PORT_DIPSETTING( 0x01, "2P Upright" ) PORT_DIPSETTING( 0x00, "4P Upright" ) PORT_DIPNAME( 0x02, 0x02, "Difficulty", IP_KEY_NONE ) PORT_DIPSETTING( 0x02, "Normal" ) PORT_DIPSETTING( 0x00, "Harder" ) PORT_DIPNAME( 0x04, 0x04, "Free Play", IP_KEY_NONE ) PORT_DIPSETTING( 0x04, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_DIPNAME( 0x08, 0x08, "Reward Screen", IP_KEY_NONE ) PORT_DIPSETTING( 0x08, "Expanded" ) PORT_DIPSETTING( 0x00, "Limited" ) PORT_DIPNAME( 0x30, 0x30, "Coinage", IP_KEY_NONE ) PORT_DIPSETTING( 0x20, "2 Coins/1 Credit" ) PORT_DIPSETTING( 0x00, "2 Coins/2 Credits" ) PORT_DIPSETTING( 0x30, "1 Coin/1 Credit" ) PORT_DIPSETTING( 0x10, "1 Coin/2 Credits" ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN4 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN4 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START3 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START4 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER4 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER4 ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END INPUT_PORTS_START( timber_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x80, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER1 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER1 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN2 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER2 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN3 -- dipswitches */ PORT_DIPNAME( 0x04, 0x04, "Demo Sounds", IP_KEY_NONE ) PORT_DIPSETTING( 0x04, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_BIT( 0xfb, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN4 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END INPUT_PORTS_START( rampage_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_TILT ) PORT_BITX( 0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x20, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER1 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN2 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN3 -- dipswitches */ PORT_DIPNAME( 0x03, 0x03, "Difficulty", IP_KEY_NONE ) PORT_DIPSETTING( 0x02, "Easy" ) PORT_DIPSETTING( 0x03, "Normal" ) PORT_DIPSETTING( 0x01, "Hard" ) PORT_DIPSETTING( 0x00, "Free Play" ) PORT_DIPNAME( 0x04, 0x04, "Score Option", IP_KEY_NONE ) PORT_DIPSETTING( 0x04, "Keep score when continuing" ) PORT_DIPSETTING( 0x00, "Lose score when continuing" ) PORT_DIPNAME( 0x08, 0x08, "Coin A", IP_KEY_NONE ) PORT_DIPSETTING( 0x00, "2 Coins/1 Credit" ) PORT_DIPSETTING( 0x08, "1 Coin/1 Credit" ) PORT_DIPNAME( 0x70, 0x70, "Coin B", IP_KEY_NONE ) PORT_DIPSETTING( 0x00, "3 Coins/1 Credit" ) PORT_DIPSETTING( 0x10, "2 Coins/1 Credit" ) PORT_DIPSETTING( 0x70, "1 Coin/1 Credit" ) PORT_DIPSETTING( 0x60, "1 Coin/2 Credits" ) PORT_DIPSETTING( 0x50, "1 Coin/3 Credits" ) PORT_DIPSETTING( 0x40, "1 Coin/4 Credits" ) PORT_DIPSETTING( 0x30, "1 Coin/5 Credits" ) PORT_DIPSETTING( 0x20, "1 Coin/6 Credits" ) PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Advance", OSD_KEY_F1, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x80, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_START /* IN4 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER3 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER3 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER3 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER3 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END INPUT_PORTS_START( maxrpm_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x80, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_START /* IN1 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN2 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 ) PORT_START /* IN3 -- dipswitches */ PORT_DIPNAME( 0x08, 0x08, "Free Play", IP_KEY_NONE ) PORT_DIPSETTING( 0x08, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_DIPNAME( 0x30, 0x30, "Coinage", IP_KEY_NONE ) PORT_DIPSETTING( 0x20, "2 Coins/1 Credit" ) PORT_DIPSETTING( 0x30, "1 Coin/1 Credit" ) PORT_DIPSETTING( 0x10, "1 Coin/2 Credits" ) /* 0x00 says 2 Coins/2 Credits in service mode, but gives 1 Coin/1 Credit */ PORT_BIT( 0xc7, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN4 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* new fake for acceleration */ PORT_ANALOGX( 0xff, 0x30, IPT_AD_STICK_Y | IPF_PLAYER2, 100, 0, 0x30, 0xff, OSD_KEY_UP, OSD_KEY_DOWN, IPT_JOYSTICK_UP, IPT_JOYSTICK_DOWN, 1 ) PORT_START /* new fake for acceleration */ PORT_ANALOGX( 0xff, 0x30, IPT_AD_STICK_Y | IPF_PLAYER1, 100, 0, 0x30, 0xff, OSD_KEY_UP, OSD_KEY_DOWN, IPT_JOYSTICK_UP, IPT_JOYSTICK_DOWN, 1 ) PORT_START /* new fake for steering */ PORT_ANALOGX( 0xff, 0x74, IPT_AD_STICK_X | IPF_PLAYER2 | IPF_REVERSE, 80, 0, 0x34, 0xb4, OSD_KEY_LEFT, OSD_KEY_RIGHT, IPT_JOYSTICK_LEFT, IPT_JOYSTICK_RIGHT, 2 ) PORT_START /* new fake for steering */ PORT_ANALOGX( 0xff, 0x74, IPT_AD_STICK_X | IPF_PLAYER1 | IPF_REVERSE, 80, 0, 0x34, 0xb4, OSD_KEY_LEFT, OSD_KEY_RIGHT, IPT_JOYSTICK_LEFT, IPT_JOYSTICK_RIGHT, 2 ) PORT_START /* fake for shifting */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END INPUT_PORTS_START( sarge_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_TILT ) PORT_BITX( 0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x20, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP | IPF_2WAY | IPF_PLAYER1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN | IPF_2WAY | IPF_PLAYER1 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP | IPF_2WAY | IPF_PLAYER1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN | IPF_2WAY | IPF_PLAYER1 ) PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) PORT_START /* IN2 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP | IPF_2WAY | IPF_PLAYER2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN | IPF_2WAY | IPF_PLAYER2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP | IPF_2WAY | IPF_PLAYER2 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN | IPF_2WAY | IPF_PLAYER2 ) PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) PORT_START /* IN3 -- dipswitches */ PORT_DIPNAME( 0x08, 0x08, "Free Play", IP_KEY_NONE ) PORT_DIPSETTING( 0x08, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_DIPNAME( 0x30, 0x30, "Coinage", IP_KEY_NONE ) PORT_DIPSETTING( 0x20, "2 Coins/1 Credit" ) PORT_DIPSETTING( 0x30, "1 Coin/1 Credit" ) PORT_DIPSETTING( 0x10, "1 Coin/2 Credits" ) /* 0x00 says 2 Coins/2 Credits in service mode, but gives 1 Coin/1 Credit */ PORT_BIT( 0xc7, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN4 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* fake port for single joystick control */ /* This fake port is handled via sarge_IN1_r and sarge_IN2_r */ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER1 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER1 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER1 ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER1 ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER2 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | /* IPF_CHEAT |*/ IPF_PLAYER2 ) INPUT_PORTS_END INPUT_PORTS_START( spyhunt_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BITX( 0x10, IP_ACTIVE_LOW, IPT_BUTTON6 | IPF_TOGGLE, "Gear Shift", OSD_KEY_ENTER, IP_JOY_DEFAULT, 0 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_KEY_NONE, 0 ) PORT_DIPSETTING( 0x80, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_START /* IN1 -- various buttons, low 5 bits */ PORT_BITX( 0x01, IP_ACTIVE_LOW, IPT_BUTTON4, "Oil Slick", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0 ) PORT_BITX( 0x02, IP_ACTIVE_LOW, IPT_BUTTON5, "Missiles", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0 ) PORT_BITX( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3, "Weapon Truck", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0 ) PORT_BITX( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2, "Smoke Screen", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0 ) PORT_BITX( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1, "Machine Guns", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0 ) PORT_BIT( 0x60, IP_ACTIVE_HIGH, IPT_UNUSED ) /* CSD status bits */ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN2 -- actually not used at all, but read as a trakport */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START /* IN3 -- dipswitches -- low 4 bits only */ PORT_DIPNAME( 0x01, 0x01, "Game Timer", IP_KEY_NONE ) PORT_DIPSETTING( 0x00, "1:00" ) PORT_DIPSETTING( 0x01, "1:30" ) PORT_DIPNAME( 0x02, 0x02, "Demo Sounds", IP_KEY_NONE ) PORT_DIPSETTING( 0x02, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN4 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* new fake for acceleration */ PORT_ANALOGX( 0xff, 0x30, IPT_AD_STICK_Y | IPF_REVERSE, 100, 0, 0x30, 0xff, OSD_KEY_UP, OSD_KEY_DOWN, OSD_JOY_UP, OSD_JOY_DOWN, 1 ) PORT_START /* new fake for steering */ PORT_ANALOGX( 0xff, 0x74, IPT_AD_STICK_X | IPF_CENTER, 80, 0, 0x34, 0xb4, OSD_KEY_LEFT, OSD_KEY_RIGHT, OSD_JOY_LEFT, OSD_JOY_RIGHT, 2 ) INPUT_PORTS_END INPUT_PORTS_START( crater_input_ports ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 ) PORT_DIPSETTING( 0x80, "Off" ) PORT_DIPSETTING( 0x00, "On" ) PORT_START /* IN1 */ PORT_ANALOGX( 0xff, 0x00, IPT_DIAL | IPF_REVERSE, 25, 0, 0, 0, OSD_KEY_Z, OSD_KEY_X, 0, 0, 4 ) PORT_START /* IN2 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* IN3 -- dipswitches */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* IN4 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* AIN0 */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END static struct IOReadPort readport[] = { { 0x00, 0x00, input_port_0_r }, { 0x01, 0x01, input_port_1_r }, { 0x02, 0x02, input_port_2_r }, { 0x03, 0x03, input_port_3_r }, { 0x04, 0x04, input_port_4_r }, { 0x05, 0xff, mcr_readport }, { -1 } }; static struct IOReadPort dt_readport[] = { { 0x00, 0x00, input_port_0_r }, { 0x01, 0x01, input_port_1_r }, { 0x02, 0x02, dotron_IN2_r }, { 0x03, 0x03, input_port_3_r }, { 0x04, 0x04, input_port_4_r }, { 0x05, 0xff, mcr_readport }, { -1 } }; static struct IOReadPort destderb_readport[] = { { 0x00, 0x00, input_port_0_r }, { 0x01, 0x02, destderb_port_r }, { 0x03, 0x03, input_port_3_r }, { 0x04, 0x04, input_port_4_r }, { 0x05, 0xff, mcr_readport }, { -1 } }; static struct IOReadPort maxrpm_readport[] = { { 0x00, 0x00, input_port_0_r }, { 0x01, 0x01, maxrpm_IN1_r }, { 0x02, 0x02, maxrpm_IN2_r }, { 0x03, 0x03, input_port_3_r }, { 0x04, 0x04, input_port_4_r }, { 0x05, 0xff, mcr_readport }, { -1 } }; static struct IOReadPort sarge_readport[] = { { 0x00, 0x00, input_port_0_r }, { 0x01, 0x01, sarge_IN1_r }, { 0x02, 0x02, sarge_IN2_r }, { 0x03, 0x03, input_port_3_r }, { 0x04, 0x04, input_port_4_r }, { 0x05, 0xff, mcr_readport }, { -1 } }; static struct IOReadPort spyhunt_readport[] = { { 0x00, 0x00, input_port_0_r }, { 0x01, 0x01, spyhunt_port_1_r }, { 0x02, 0x02, spyhunt_port_2_r }, { 0x03, 0x03, input_port_3_r }, { 0x04, 0x04, input_port_4_r }, { 0x05, 0xff, mcr_readport }, { -1 } }; static struct IOWritePort writeport[] = { { 0, 0xff, mcr_writeport }, { -1 } /* end of table */ }; static struct IOWritePort sh_writeport[] = { { 0, 0xff, spyhunt_writeport }, { -1 } /* end of table */ }; static struct IOWritePort cr_writeport[] = { { 0, 0xff, crater_writeport }, { -1 } /* end of table */ }; static struct IOWritePort rm_writeport[] = { { 0, 0xff, rampage_writeport }, { -1 } /* end of table */ }; static struct IOWritePort mr_writeport[] = { { 0, 0xff, maxrpm_writeport }, { -1 } /* end of table */ }; static struct IOWritePort sa_writeport[] = { { 0, 0xff, sarge_writeport }, { -1 } /* end of table */ }; static struct IOWritePort dt_writeport[] = { { 0, 0xff, dotron_writeport }, { -1 } /* end of table */ }; /*************************************************************************** Graphics layouts ***************************************************************************/ /* generic character layouts */ /* note that characters are half the resolution of sprites in each direction, so we generate them at double size */ /* 1024 characters; used by tapper, timber, rampage */ static struct GfxLayout mcr3_charlayout_1024 = { 16, 16, 1024, 4, { 1024*16*8, 1024*16*8+1, 0, 1 }, { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14 }, { 0, 0, 2*8, 2*8, 4*8, 4*8, 6*8, 6*8, 8*8, 8*8, 10*8, 10*8, 12*8, 12*8, 14*8, 14*8 }, 16*8 }; /* 512 characters; used by dotron, destderb */ static struct GfxLayout mcr3_charlayout_512 = { 16, 16, 512, 4, { 512*16*8, 512*16*8+1, 0, 1 }, { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14 }, { 0, 0, 2*8, 2*8, 4*8, 4*8, 6*8, 6*8, 8*8, 8*8, 10*8, 10*8, 12*8, 12*8, 14*8, 14*8 }, 16*8 }; /* generic sprite layouts */ /* 512 sprites; used by rampage */ #define X (512*128*8) #define Y (2*X) #define Z (3*X) static struct GfxLayout mcr3_spritelayout_512 = { 32,32, 512, 4, { 0, 1, 2, 3 }, { Z+0, Z+4, Y+0, Y+4, X+0, X+4, 0, 4, Z+8, Z+12, Y+8, Y+12, X+8, X+12, 8, 12, Z+16, Z+20, Y+16, Y+20, X+16, X+20, 16, 20, Z+24, Z+28, Y+24, Y+28, X+24, X+28, 24, 28 }, { 0, 32, 32*2, 32*3, 32*4, 32*5, 32*6, 32*7, 32*8, 32*9, 32*10, 32*11, 32*12, 32*13, 32*14, 32*15, 32*16, 32*17, 32*18, 32*19, 32*20, 32*21, 32*22, 32*23, 32*24, 32*25, 32*26, 32*27, 32*28, 32*29, 32*30, 32*31 }, 128*8 }; #undef X #undef Y #undef Z /* 256 sprites; used by tapper, timber, destderb, spyhunt */ #define X (256*128*8) #define Y (2*X) #define Z (3*X) static struct GfxLayout mcr3_spritelayout_256 = { 32,32, 256, 4, { 0, 1, 2, 3 }, { Z+0, Z+4, Y+0, Y+4, X+0, X+4, 0, 4, Z+8, Z+12, Y+8, Y+12, X+8, X+12, 8, 12, Z+16, Z+20, Y+16, Y+20, X+16, X+20, 16, 20, Z+24, Z+28, Y+24, Y+28, X+24, X+28, 24, 28 }, { 0, 32, 32*2, 32*3, 32*4, 32*5, 32*6, 32*7, 32*8, 32*9, 32*10, 32*11, 32*12, 32*13, 32*14, 32*15, 32*16, 32*17, 32*18, 32*19, 32*20, 32*21, 32*22, 32*23, 32*24, 32*25, 32*26, 32*27, 32*28, 32*29, 32*30, 32*31 }, 128*8 }; #undef X #undef Y #undef Z /* 128 sprites; used by dotron */ #define X (128*128*8) #define Y (2*X) #define Z (3*X) static struct GfxLayout mcr3_spritelayout_128 = { 32,32, 128, 4, { 0, 1, 2, 3 }, { Z+0, Z+4, Y+0, Y+4, X+0, X+4, 0, 4, Z+8, Z+12, Y+8, Y+12, X+8, X+12, 8, 12, Z+16, Z+20, Y+16, Y+20, X+16, X+20, 16, 20, Z+24, Z+28, Y+24, Y+28, X+24, X+28, 24, 28 }, { 0, 32, 32*2, 32*3, 32*4, 32*5, 32*6, 32*7, 32*8, 32*9, 32*10, 32*11, 32*12, 32*13, 32*14, 32*15, 32*16, 32*17, 32*18, 32*19, 32*20, 32*21, 32*22, 32*23, 32*24, 32*25, 32*26, 32*27, 32*28, 32*29, 32*30, 32*31 }, 128*8 }; #undef X #undef Y #undef Z /***************************** spyhunt layouts **********************************/ /* 128 32x16 characters; used by spyhunt */ static struct GfxLayout spyhunt_charlayout_128 = { 32, 32, /* we pixel double and split in half */ 128, 4, { 0, 1, 128*128*8, 128*128*8+1 }, { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30 }, { 0, 0, 8*8, 8*8, 16*8, 16*8, 24*8, 24*8, 32*8, 32*8, 40*8, 40*8, 48*8, 48*8, 56*8, 56*8, 64*8, 64*8, 72*8, 72*8, 80*8, 80*8, 88*8, 88*8, 96*8, 96*8, 104*8, 104*8, 112*8, 112*8, 120*8, 120*8 }, 128*8 }; /* of course, Spy Hunter just *had* to be different than everyone else... */ static struct GfxLayout spyhunt_alphalayout = { 16, 16, 256, 2, { 0, 1 }, { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14 }, { 0, 0, 2*8, 2*8, 4*8, 4*8, 6*8, 6*8, 8*8, 8*8, 10*8, 10*8, 12*8, 12*8, 14*8, 14*8 }, 16*8 }; static struct GfxDecodeInfo tapper_gfxdecodeinfo[] = { { 1, 0x0000, &mcr3_charlayout_1024, 0, 4 }, { 1, 0x8000, &mcr3_spritelayout_256, 0, 4 }, { -1 } /* end of array */ }; static struct GfxDecodeInfo dotron_gfxdecodeinfo[] = { { 1, 0x0000, &mcr3_charlayout_512, 0, 4 }, { 1, 0x4000, &mcr3_spritelayout_128, 0, 4 }, { -1 } /* end of array */ }; static struct GfxDecodeInfo destderb_gfxdecodeinfo[] = { { 1, 0x0000, &mcr3_charlayout_512, 0, 4 }, { 1, 0x4000, &mcr3_spritelayout_256, 0, 4 }, { -1 } /* end of array */ }; static struct GfxDecodeInfo timber_gfxdecodeinfo[] = { { 1, 0x0000, &mcr3_charlayout_1024, 0, 4 }, { 1, 0x8000, &mcr3_spritelayout_256, 0, 4 }, { -1 } /* end of array */ }; static struct GfxDecodeInfo rampage_gfxdecodeinfo[] = { { 1, 0x0000, &mcr3_charlayout_1024, 0, 4 }, { 1, 0x8000, &mcr3_spritelayout_512, 0, 4 }, { -1 } /* end of array */ }; static struct GfxDecodeInfo sarge_gfxdecodeinfo[] = { { 1, 0x0000, &mcr3_charlayout_512, 0, 4 }, { 1, 0x4000, &mcr3_spritelayout_256, 0, 4 }, { -1 } /* end of array */ }; static struct GfxDecodeInfo spyhunt_gfxdecodeinfo[] = { { 1, 0x0000, &spyhunt_charlayout_128, 1*16, 1 }, /* top half */ { 1, 0x0004, &spyhunt_charlayout_128, 1*16, 1 }, /* bottom half */ { 1, 0x8000, &mcr3_spritelayout_256, 0*16, 1 }, { 1, 0x28000, &spyhunt_alphalayout, 8*16, 1 }, { -1 } /* end of array */ }; static struct GfxDecodeInfo crater_gfxdecodeinfo[] = { { 1, 0x0000, &spyhunt_charlayout_128, 3*16, 1 }, /* top half */ { 1, 0x0004, &spyhunt_charlayout_128, 3*16, 1 }, /* bottom half */ { 1, 0x8000, &mcr3_spritelayout_256, 0*16, 4 }, { 1, 0x28000, &spyhunt_alphalayout, 8*16, 1 }, { -1 } /* end of array */ }; /*************************************************************************** Sound interfaces ***************************************************************************/ static struct AY8910interface ay8910_interface = { 2, /* 2 chips */ 2000000, /* 2 MHz ?? */ { 255, 255 }, { 0 }, { 0 }, { 0 }, { 0 } }; static struct DACinterface dac_interface = { 1, { 255 } }; static struct TMS5220interface tms5220_interface = { 640000, 192, 0 }; /*************************************************************************** Machine drivers ***************************************************************************/ static struct MachineDriver tapper_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, readmem,writemem,readport,writeport, mcr_interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, /* 2 Mhz */ 2, sound_readmem,sound_writemem,0,0, interrupt,26 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU has enough interrupts to handle synchronization */ mcr_init_machine, /* video hardware */ 32*16, 30*16, { 0, 32*16-1, 0, 30*16-1 }, tapper_gfxdecodeinfo, 8*16, 8*16, mcr3_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY|VIDEO_MODIFIES_PALETTE, 0, generic_vh_start, generic_vh_stop, mcr3_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &ay8910_interface } } }; static struct MachineDriver dotron_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, readmem,writemem,dt_readport,dt_writeport, dotron_interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, /* 2 Mhz */ 2, sound_readmem,sound_writemem,0,0, interrupt,26 }, { CPU_M6802 | CPU_AUDIO_CPU, 3580000/4, /* .8 Mhz */ 3, snt_readmem,snt_writemem,0,0, ignore_interrupt,1 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU has enough interrupts to handle synchronization */ dotron_init_machine, /* video hardware */ /* 32*16, 30*16, { 0, 32*16-1, 0, 30*16-1 }, - MAB 09/30/98, changed the screen size for the backdrop */ 800, 600, { 0, 800-1, 0, 600-1 }, dotron_gfxdecodeinfo, 254, 4*16, /* The extra colors are for the backdrop */ mcr3_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY|VIDEO_MODIFIES_PALETTE, 0, dotron_vh_start, dotron_vh_stop, dotron_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &ay8910_interface }, { SOUND_TMS5220, &tms5220_interface } } }; static struct MachineDriver destderb_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, readmem,writemem,destderb_readport,writeport, mcr_interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, /* 2 Mhz */ 2, sound_readmem,sound_writemem,0,0, interrupt,26 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU has enough interrupts to handle synchronization */ mcr_init_machine, /* video hardware */ 32*16, 30*16, { 0, 32*16-1, 0, 30*16-1 }, destderb_gfxdecodeinfo, 8*16, 8*16, mcr3_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY|VIDEO_MODIFIES_PALETTE, 0, generic_vh_start, generic_vh_stop, mcr3_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &ay8910_interface } } }; static struct MachineDriver timber_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, readmem,writemem,readport,writeport, mcr_interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, /* 2 Mhz */ 2, timber_sound_readmem,timber_sound_writemem,0,0, interrupt,26 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU has enough interrupts to handle synchronization */ mcr_init_machine, /* video hardware */ 32*16, 30*16, { 0, 32*16-1, 0, 30*16-1 }, timber_gfxdecodeinfo, 8*16, 8*16, mcr3_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY|VIDEO_MODIFIES_PALETTE, 0, generic_vh_start, generic_vh_stop, mcr3_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &ay8910_interface } } }; static struct MachineDriver rampage_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, rampage_readmem,rampage_writemem,readport,rm_writeport, mcr_interrupt,1 }, { CPU_M68000 | CPU_AUDIO_CPU, 7500000, /* 7.5 Mhz */ 2, sg_readmem,sg_writemem,0,0, ignore_interrupt,1 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU synchronization is done via timers */ rampage_init_machine, /* video hardware */ 32*16, 30*16, { 0, 32*16-1, 0, 30*16-1 }, rampage_gfxdecodeinfo, 8*16, 8*16, mcr3_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY|VIDEO_MODIFIES_PALETTE, 0, generic_vh_start, generic_vh_stop, rampage_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_DAC, &dac_interface } } }; static struct MachineDriver maxrpm_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, rampage_readmem,rampage_writemem,maxrpm_readport,mr_writeport, mcr_interrupt,1 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU synchronization is done via timers */ rampage_init_machine, /* video hardware */ 32*16, 30*16, { 0, 32*16-1, 0, 30*16-1 }, rampage_gfxdecodeinfo, 8*16, 8*16, mcr3_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY|VIDEO_MODIFIES_PALETTE, 0, generic_vh_start, generic_vh_stop, rampage_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_DAC, &dac_interface } } }; static struct MachineDriver sarge_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, rampage_readmem,rampage_writemem,sarge_readport,sa_writeport, mcr_interrupt,1 }, { CPU_M6809 | CPU_AUDIO_CPU, 2250000, /* 2.25 Mhz??? */ 2, tcs_readmem,tcs_writemem,0,0, ignore_interrupt,1 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU synchronization is done via timers */ sarge_init_machine, /* video hardware */ 32*16, 30*16, { 0, 32*16-1, 0, 30*16-1 }, sarge_gfxdecodeinfo, 8*16, 8*16, mcr3_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_SUPPORTS_DIRTY|VIDEO_MODIFIES_PALETTE, 0, generic_vh_start, generic_vh_stop, rampage_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_DAC, &dac_interface } } }; static struct MachineDriver spyhunt_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, spyhunt_readmem,spyhunt_writemem,spyhunt_readport,sh_writeport, mcr_interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, /* 2 Mhz */ 2, sound_readmem,sound_writemem,0,0, interrupt,26 }, { CPU_M68000 | CPU_AUDIO_CPU, 7500000, /* Actually 7.5 Mhz, but the 68000 emulator isn't accurate */ 3, csd_readmem,csd_writemem,0,0, ignore_interrupt,1 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU has enough interrupts to handle synchronization */ spyhunt_init_machine, /* video hardware */ 31*16, 30*16, { 0, 31*16-1, 0, 30*16-1 }, spyhunt_gfxdecodeinfo, 8*16+4, 8*16+4, spyhunt_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_MODIFIES_PALETTE, 0, spyhunt_vh_start, spyhunt_vh_stop, spyhunt_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &ay8910_interface }, { SOUND_DAC, &dac_interface } } }; static struct MachineDriver crater_machine_driver = { /* basic machine hardware */ { { CPU_Z80, 5000000, /* 5 Mhz */ 0, spyhunt_readmem,spyhunt_writemem,readport,cr_writeport, mcr_interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 2000000, /* 2 Mhz */ 2, sound_readmem,sound_writemem,0,0, interrupt,26 } }, 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, /* 1 CPU slice per frame - sound CPU has enough interrupts to handle synchronization */ mcr_init_machine, /* video hardware */ 30*16, 30*16, { 0, 30*16-1, 0, 30*16-1 }, crater_gfxdecodeinfo, 8*16+4, 8*16+4, spyhunt_vh_convert_color_prom, VIDEO_TYPE_RASTER|VIDEO_MODIFIES_PALETTE, 0, crater_vh_start, spyhunt_vh_stop, spyhunt_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &ay8910_interface } } }; /*************************************************************************** High score save/load ***************************************************************************/ static int mcr3_hiload(int addr, int len) { unsigned char *RAM = Machine->memory_region[0]; /* see if it's okay to load */ if (mcr_loadnvram) { void *f; f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0); if (f) { osd_fread(f,&RAM[addr],len); osd_fclose (f); } return 1; } else return 0; /* we can't load the hi scores yet */ } static void mcr3_hisave(int addr, int len) { unsigned char *RAM = Machine->memory_region[0]; void *f; f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1); if (f) { osd_fwrite(f,&RAM[addr],len); osd_fclose (f); } } static int tapper_hiload(void) { return mcr3_hiload(0xe000, 0x9d); } static void tapper_hisave(void) { mcr3_hisave(0xe000, 0x9d); } static int dotron_hiload(void) { return mcr3_hiload(0xe543, 0xac); } static void dotron_hisave(void) { mcr3_hisave(0xe543, 0xac); } static int destderb_hiload(void) { return mcr3_hiload(0xe4e6, 0x153); } static void destderb_hisave(void) { mcr3_hisave(0xe4e6, 0x153); } static int timber_hiload(void) { return mcr3_hiload(0xe000, 0x9f); } static void timber_hisave(void) { mcr3_hisave(0xe000, 0x9f); } static int rampage_hiload(void) { return mcr3_hiload(0xe631, 0x3f); } static void rampage_hisave(void) { mcr3_hisave(0xe631, 0x3f); } static int spyhunt_hiload(void) { return mcr3_hiload(0xf42b, 0xfb); } static void spyhunt_hisave(void) { mcr3_hisave(0xf42b, 0xfb); } static int crater_hiload(void) { return mcr3_hiload(0xf5fb, 0xa3); } static void crater_hisave(void) { mcr3_hisave(0xf5fb, 0xa3); } /*************************************************************************** ROM decoding ***************************************************************************/ static void spyhunt_decode (void) { unsigned char *RAM = Machine->memory_region[0]; /* some versions of rom 11d have the top and bottom 8k swapped; to enable us to work with either a correct set or a swapped set (both of which pass the checksum!), we swap them here */ if (RAM[0xa000] != 0x0c) { int i; unsigned char temp; for (i = 0;i < 0x2000;i++) { temp = RAM[0xa000 + i]; RAM[0xa000 + i] = RAM[0xc000 + i]; RAM[0xc000 + i] = temp; } } } /*************************************************************************** Game driver(s) ***************************************************************************/ ROM_START( tapper_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "tappg0.bin", 0x0000, 0x4000, 0x127171d1 ) ROM_LOAD( "tappg1.bin", 0x4000, 0x4000, 0x9d6a47f7 ) ROM_LOAD( "tappg2.bin", 0x8000, 0x4000, 0x3a1f8778 ) ROM_LOAD( "tappg3.bin", 0xc000, 0x2000, 0xe8dcdaa4 ) ROM_REGION_DISPOSE(0x28000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "tapbg1.bin", 0x00000, 0x4000, 0x2a30238c ) ROM_LOAD( "tapbg0.bin", 0x04000, 0x4000, 0x394ab576 ) ROM_LOAD( "tapfg7.bin", 0x08000, 0x4000, 0x070b4c81 ) ROM_LOAD( "tapfg6.bin", 0x0c000, 0x4000, 0xa37aef36 ) ROM_LOAD( "tapfg5.bin", 0x10000, 0x4000, 0x800f7c8a ) ROM_LOAD( "tapfg4.bin", 0x14000, 0x4000, 0x32674ee6 ) ROM_LOAD( "tapfg3.bin", 0x18000, 0x4000, 0x818fffd4 ) ROM_LOAD( "tapfg2.bin", 0x1c000, 0x4000, 0x67e37690 ) ROM_LOAD( "tapfg1.bin", 0x20000, 0x4000, 0x32509011 ) ROM_LOAD( "tapfg0.bin", 0x24000, 0x4000, 0x8412c808 ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "tapsnda7.bin", 0x0000, 0x1000, 0x0e8bb9d5 ) ROM_LOAD( "tapsnda8.bin", 0x1000, 0x1000, 0x0cf0e29b ) ROM_LOAD( "tapsnda9.bin", 0x2000, 0x1000, 0x31eb6dc6 ) ROM_LOAD( "tapsda10.bin", 0x3000, 0x1000, 0x01a9be6a ) ROM_END ROM_START( sutapper_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "5791", 0x0000, 0x4000, 0x87119cc4 ) ROM_LOAD( "5792", 0x4000, 0x4000, 0x4c23ad89 ) ROM_LOAD( "5793", 0x8000, 0x4000, 0xfecbf683 ) ROM_LOAD( "5794", 0xc000, 0x2000, 0x5bdc1916 ) ROM_REGION_DISPOSE(0x28000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "5790", 0x00000, 0x4000, 0xac1558c1 ) ROM_LOAD( "5789", 0x04000, 0x4000, 0xfa66cab5 ) ROM_LOAD( "5801", 0x08000, 0x4000, 0xd70defa7 ) ROM_LOAD( "5802", 0x0c000, 0x4000, 0xd4f114b9 ) ROM_LOAD( "5799", 0x10000, 0x4000, 0x02c69432 ) ROM_LOAD( "5800", 0x14000, 0x4000, 0xebf1f948 ) ROM_LOAD( "5797", 0x18000, 0x4000, 0xf10a1d05 ) ROM_LOAD( "5798", 0x1c000, 0x4000, 0x614990cd ) ROM_LOAD( "5795", 0x20000, 0x4000, 0x5d987c92 ) ROM_LOAD( "5796", 0x24000, 0x4000, 0xde5700b4 ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "5788", 0x0000, 0x1000, 0x5c1d0982 ) ROM_LOAD( "5787", 0x1000, 0x1000, 0x09e74ed8 ) ROM_LOAD( "5786", 0x2000, 0x1000, 0xc3e98284 ) ROM_LOAD( "5785", 0x3000, 0x1000, 0xced2fd47 ) ROM_END ROM_START( rbtapper_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "rbtpg0.bin", 0x0000, 0x4000, 0x20b9adf4 ) ROM_LOAD( "rbtpg1.bin", 0x4000, 0x4000, 0x87e616c2 ) ROM_LOAD( "rbtpg2.bin", 0x8000, 0x4000, 0x0b332c97 ) ROM_LOAD( "rbtpg3.bin", 0xc000, 0x2000, 0x698c06f2 ) ROM_REGION_DISPOSE(0x28000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "rbtbg1.bin", 0x00000, 0x4000, 0x44dfa483 ) ROM_LOAD( "rbtbg0.bin", 0x04000, 0x4000, 0x510b13de ) ROM_LOAD( "rbtfg7.bin", 0x08000, 0x4000, 0x8dbf0c36 ) ROM_LOAD( "rbtfg6.bin", 0x0c000, 0x4000, 0x441201a0 ) ROM_LOAD( "rbtfg5.bin", 0x10000, 0x4000, 0x9eeca46e ) ROM_LOAD( "rbtfg4.bin", 0x14000, 0x4000, 0x8c79e7d7 ) ROM_LOAD( "rbtfg3.bin", 0x18000, 0x4000, 0x3e725e77 ) ROM_LOAD( "rbtfg2.bin", 0x1c000, 0x4000, 0x4ee8b624 ) ROM_LOAD( "rbtfg1.bin", 0x20000, 0x4000, 0x1c0b8791 ) ROM_LOAD( "rbtfg0.bin", 0x24000, 0x4000, 0xe99f6018 ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "rbtsnda7.bin", 0x0000, 0x1000, 0x5c1d0982 ) ROM_LOAD( "rbtsnda8.bin", 0x1000, 0x1000, 0x09e74ed8 ) ROM_LOAD( "rbtsnda9.bin", 0x2000, 0x1000, 0xc3e98284 ) ROM_LOAD( "rbtsda10.bin", 0x3000, 0x1000, 0xced2fd47 ) ROM_END struct GameDriver tapper_driver = { __FILE__, 0, "tapper", "Tapper (Budweiser)", "1983", "Bally Midway", "Christopher Kirmse\nAaron Giles\nNicola Salmoria", 0, &tapper_machine_driver, 0, tapper_rom, 0, 0, 0, 0, /* sound_prom */ tapper_input_ports, 0, 0,0, ORIENTATION_DEFAULT, tapper_hiload, tapper_hisave }; struct GameDriver sutapper_driver = { __FILE__, &tapper_driver, "sutapper", "Tapper (Suntory)", "1983", "Bally Midway", "Christopher Kirmse\nAaron Giles\nNicola Salmoria", 0, &tapper_machine_driver, 0, sutapper_rom, 0, 0, 0, 0, /* sound_prom */ tapper_input_ports, 0, 0,0, ORIENTATION_DEFAULT, tapper_hiload, tapper_hisave }; struct GameDriver rbtapper_driver = { __FILE__, &tapper_driver, "rbtapper", "Tapper (Root Beer)", "1984", "Bally Midway", "Christopher Kirmse\nAaron Giles\nNicola Salmoria", 0, &tapper_machine_driver, 0, rbtapper_rom, 0, 0, 0, 0, /* sound_prom */ tapper_input_ports, 0, 0,0, ORIENTATION_DEFAULT, tapper_hiload, tapper_hisave }; ROM_START( dotron_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "loc-pg0.1c", 0x0000, 0x4000, 0xba0da15f ) ROM_LOAD( "loc-pg1.2c", 0x4000, 0x4000, 0xdc300191 ) ROM_LOAD( "loc-pg2.3c", 0x8000, 0x4000, 0xab0b3800 ) ROM_LOAD( "loc-pg1.4c", 0xc000, 0x2000, 0xf98c9f8e ) ROM_REGION_DISPOSE(0x14000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "loc-bg2.6f", 0x00000, 0x2000, 0x40167124 ) ROM_LOAD( "loc-bg1.5f", 0x02000, 0x2000, 0xbb2d7a5d ) ROM_LOAD( "loc-a.cp0", 0x04000, 0x2000, 0xb35f5374 ) ROM_LOAD( "loc-b.cp9", 0x06000, 0x2000, 0x565a5c48 ) ROM_LOAD( "loc-c.cp8", 0x08000, 0x2000, 0xef45d146 ) ROM_LOAD( "loc-d.cp7", 0x0a000, 0x2000, 0x5e8a3ef3 ) ROM_LOAD( "loc-e.cp6", 0x0c000, 0x2000, 0xce957f1a ) ROM_LOAD( "loc-f.cp5", 0x0e000, 0x2000, 0xd26053ce ) ROM_LOAD( "loc-g.cp4", 0x10000, 0x2000, 0x57a2b1ff ) ROM_LOAD( "loc-h.cp3", 0x12000, 0x2000, 0x3bb4d475 ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "sound0.a7", 0x0000, 0x1000, 0x6d39bf19 ) ROM_LOAD( "sound1.a8", 0x1000, 0x1000, 0xac872e1d ) ROM_LOAD( "sound2.a9", 0x2000, 0x1000, 0xe8ef6519 ) ROM_LOAD( "sound3.a10", 0x3000, 0x1000, 0x6b5aeb02 ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "pre.u3", 0xd000, 0x1000, 0xc3d0f762 ) ROM_LOAD( "pre.u4", 0xe000, 0x1000, 0x7ca79b43 ) ROM_LOAD( "pre.u5", 0xf000, 0x1000, 0x24e9618e ) ROM_END ROM_START( dotrone_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "loc-cpu1", 0x0000, 0x4000, 0xeee31b8c ) ROM_LOAD( "loc-cpu2", 0x4000, 0x4000, 0x75ba6ad3 ) ROM_LOAD( "loc-cpu3", 0x8000, 0x4000, 0x94bb1a0e ) ROM_LOAD( "loc-cpu4", 0xc000, 0x2000, 0xc137383c ) ROM_REGION_DISPOSE(0x14000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "loc-bg2.6f", 0x00000, 0x2000, 0x40167124 ) ROM_LOAD( "loc-bg1.5f", 0x02000, 0x2000, 0xbb2d7a5d ) ROM_LOAD( "loc-a.cp0", 0x04000, 0x2000, 0xb35f5374 ) ROM_LOAD( "loc-b.cp9", 0x06000, 0x2000, 0x565a5c48 ) ROM_LOAD( "loc-c.cp8", 0x08000, 0x2000, 0xef45d146 ) ROM_LOAD( "loc-d.cp7", 0x0a000, 0x2000, 0x5e8a3ef3 ) ROM_LOAD( "loc-e.cp6", 0x0c000, 0x2000, 0xce957f1a ) ROM_LOAD( "loc-f.cp5", 0x0e000, 0x2000, 0xd26053ce ) ROM_LOAD( "loc-g.cp4", 0x10000, 0x2000, 0x57a2b1ff ) ROM_LOAD( "loc-h.cp3", 0x12000, 0x2000, 0x3bb4d475 ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "loc-a", 0x0000, 0x1000, 0x2de6a8a8 ) ROM_LOAD( "loc-b", 0x1000, 0x1000, 0x4097663e ) ROM_LOAD( "loc-c", 0x2000, 0x1000, 0xf576b9e7 ) ROM_LOAD( "loc-d", 0x3000, 0x1000, 0x74b0059e ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "pre.u3", 0xd000, 0x1000, 0xc3d0f762 ) ROM_LOAD( "pre.u4", 0xe000, 0x1000, 0x7ca79b43 ) ROM_LOAD( "pre.u5", 0xf000, 0x1000, 0x24e9618e ) ROM_END struct GameDriver dotron_driver = { __FILE__, 0, "dotron", "Discs of Tron (Upright)", "1983", "Bally Midway", "Christopher Kirmse\nAaron Giles\nNicola Salmoria\nAlan J. McCormick (speech info)\nMathis Rosenhauer(backdrop support)\nMike Balfour(backdrop support)\nBrandon Kirkpatrick (backdrop)", 0, &dotron_machine_driver, 0, dotron_rom, 0, 0, 0, 0, /* sound_prom */ dotron_input_ports, 0, 0,0, ORIENTATION_FLIP_X, dotron_hiload, dotron_hisave }; struct GameDriver dotrone_driver = { __FILE__, &dotron_driver, "dotrone", "Discs of Tron (Environmental)", "1983", "Bally Midway", "Christopher Kirmse\nAaron Giles\nNicola Salmoria\nAlan J. McCormick (speech info)\nMathis Rosenhauer(backdrop support)\nMike Balfour(backdrop support)\nBrandon Kirkpatrick (backdrop)", 0, &dotron_machine_driver, 0, dotrone_rom, 0, 0, 0, 0, /* sound_prom */ dotron_input_ports, 0, 0,0, ORIENTATION_FLIP_X, dotron_hiload, dotron_hisave }; ROM_START( destderb_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "dd_pro", 0x0000, 0x4000, 0x8781b367 ) ROM_LOAD( "dd_pro1", 0x4000, 0x4000, 0x4c713bfe ) ROM_LOAD( "dd_pro2", 0x8000, 0x4000, 0xc2cbd2a4 ) ROM_REGION_DISPOSE(0x24000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "dd_bg0.6f", 0x00000, 0x2000, 0xcf80be19 ) ROM_LOAD( "dd_bg1.5f", 0x02000, 0x2000, 0x4e173e52 ) ROM_LOAD( "dd_fg-3.a10", 0x04000, 0x4000, 0x801d9b86 ) ROM_LOAD( "dd_fg-7.a9", 0x08000, 0x4000, 0x0ec3f60a ) ROM_LOAD( "dd_fg-2.a8", 0x0c000, 0x4000, 0x6cab7b95 ) ROM_LOAD( "dd_fg-6.a7", 0x10000, 0x4000, 0xabfb9a8b ) ROM_LOAD( "dd_fg-1.a6", 0x14000, 0x4000, 0x70259651 ) ROM_LOAD( "dd_fg-5.a5", 0x18000, 0x4000, 0x5fe99007 ) ROM_LOAD( "dd_fg-0.a4", 0x1c000, 0x4000, 0xe57a4de6 ) ROM_LOAD( "dd_fg-4.a3", 0x20000, 0x4000, 0x55aa667f ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "dd_ssio.a7", 0x0000, 0x1000, 0xc95cf31e ) ROM_LOAD( "dd_ssio.a8", 0x1000, 0x1000, 0x12aaa48e ) ROM_END struct GameDriver destderb_driver = { __FILE__, 0, "destderb", "Demolition Derby", "1984", "Bally Midway", "Christopher Kirmse\nAaron Giles\nNicola Salmoria\nBrad Oliver", 0, &destderb_machine_driver, 0, destderb_rom, 0, 0, 0, 0, /* sound_prom */ destderb_input_ports, 0, 0,0, ORIENTATION_DEFAULT, destderb_hiload, destderb_hisave }; ROM_START( timber_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "timpg0.bin", 0x0000, 0x4000, 0x377032ab ) ROM_LOAD( "timpg1.bin", 0x4000, 0x4000, 0xfd772836 ) ROM_LOAD( "timpg2.bin", 0x8000, 0x4000, 0x632989f9 ) ROM_LOAD( "timpg3.bin", 0xc000, 0x2000, 0xdae8a0dc ) ROM_REGION_DISPOSE(0x28000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "timbg1.bin", 0x00000, 0x4000, 0xb1cb2651 ) ROM_LOAD( "timbg0.bin", 0x04000, 0x4000, 0x2ae352c4 ) ROM_LOAD( "timfg7.bin", 0x08000, 0x4000, 0xd9c27475 ) ROM_LOAD( "timfg6.bin", 0x0c000, 0x4000, 0x244778e8 ) ROM_LOAD( "timfg5.bin", 0x10000, 0x4000, 0xeb636216 ) ROM_LOAD( "timfg4.bin", 0x14000, 0x4000, 0xb7105eb7 ) ROM_LOAD( "timfg3.bin", 0x18000, 0x4000, 0x37c03272 ) ROM_LOAD( "timfg2.bin", 0x1c000, 0x4000, 0xe2c2885c ) ROM_LOAD( "timfg1.bin", 0x20000, 0x4000, 0x81de4a73 ) ROM_LOAD( "timfg0.bin", 0x24000, 0x4000, 0x7f3a4f59 ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "tima7.bin", 0x0000, 0x1000, 0xc615dc3e ) ROM_LOAD( "tima8.bin", 0x1000, 0x1000, 0x83841c87 ) ROM_LOAD( "tima9.bin", 0x2000, 0x1000, 0x22bcdcd3 ) ROM_END struct GameDriver timber_driver = { __FILE__, 0, "timber", "Timber", "1984", "Bally Midway", "Christopher Kirmse\nAaron Giles\nNicola Salmoria\nBrad Oliver", 0, &timber_machine_driver, 0, timber_rom, 0, 0, 0, 0, /* sound_prom */ timber_input_ports, 0, 0,0, ORIENTATION_DEFAULT, timber_hiload, timber_hisave }; ROM_START( rampage_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "pro-0.rv3", 0x0000, 0x8000, 0x2f7ca03c ) ROM_LOAD( "pro-1.rv3", 0x8000, 0x8000, 0xd89bd9a4 ) ROM_REGION_DISPOSE(0x48000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "bg-0", 0x00000, 0x04000, 0xc0d8b7a5 ) ROM_LOAD( "bg-1", 0x04000, 0x04000, 0x2f6e3aa1 ) ROM_LOAD( "fg-3", 0x08000, 0x10000, 0x81e1de40 ) ROM_LOAD( "fg-2", 0x18000, 0x10000, 0x9489f714 ) ROM_LOAD( "fg-1", 0x28000, 0x10000, 0x8728532b ) ROM_LOAD( "fg-0", 0x38000, 0x10000, 0x0974be5d ) ROM_REGION(0x20000) /* 128k for the Sounds Good board */ ROM_LOAD_EVEN( "ramp_u7.snd", 0x00000, 0x8000, 0xcffd7fa5 ) ROM_LOAD_ODD ( "ramp_u17.snd", 0x00000, 0x8000, 0xe92c596b ) ROM_LOAD_EVEN( "ramp_u8.snd", 0x10000, 0x8000, 0x11f787e4 ) ROM_LOAD_ODD ( "ramp_u18.snd", 0x10000, 0x8000, 0x6b8bf5e1 ) ROM_END void rampage_rom_decode (void) { int i; /* Rampage tile graphics are inverted */ for (i = 0; i < 0x8000; i++) Machine->memory_region[1][i] ^= 0xff; } struct GameDriver rampage_driver = { __FILE__, 0, "rampage", "Rampage", "1986", "Bally Midway", "Aaron Giles\nChristopher Kirmse\nNicola Salmoria\nBrad Oliver", 0, &rampage_machine_driver, 0, rampage_rom, rampage_rom_decode, 0, 0, 0, /* sound_prom */ rampage_input_ports, 0, 0,0, ORIENTATION_DEFAULT, rampage_hiload, rampage_hisave }; ROM_START( powerdrv_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "pdrv3b.bin", 0x0000, 0x8000, 0xd870b704 ) ROM_LOAD( "pdrv5b.bin", 0x8000, 0x8000, 0xfa0544ad ) ROM_REGION_DISPOSE(0x48000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "pdrv15a.bin", 0x00000, 0x04000, 0xb858b5a8 ) ROM_LOAD( "pdrv14b.bin", 0x04000, 0x04000, 0x12ee7fc2 ) ROM_LOAD( "pdrv4e.bin", 0x08000, 0x10000, 0xde400335 ) ROM_LOAD( "pdrv5e.bin", 0x18000, 0x10000, 0x4cb4780e ) ROM_LOAD( "pdrv6e.bin", 0x28000, 0x10000, 0x1a1f7f81 ) ROM_LOAD( "pdrv8e.bin", 0x38000, 0x10000, 0xdd3a2adc ) ROM_REGION(0x20000) /* 128k for the Sounds Good board */ ROM_LOAD_EVEN( "pdsndu7.bin", 0x00000, 0x8000, 0x78713e78 ) ROM_LOAD_ODD ( "pdsndu17.bin", 0x00000, 0x8000, 0xc41de6e4 ) ROM_LOAD_EVEN( "pdsndu8.bin", 0x10000, 0x8000, 0x15714036 ) ROM_LOAD_ODD ( "pdsndu18.bin", 0x10000, 0x8000, 0xcae14c70 ) ROM_END struct GameDriver powerdrv_driver = { __FILE__, 0, "powerdrv", "Power Drive", "????", "Bally Midway", "Aaron Giles\nChristopher Kirmse\nNicola Salmoria\nBrad Oliver", 0, &rampage_machine_driver, 0, powerdrv_rom, rampage_rom_decode, 0, 0, 0, /* sound_prom */ rampage_input_ports, 0, 0,0, ORIENTATION_DEFAULT, 0, 0 }; ROM_START( maxrpm_rom ) ROM_REGION(0x12000) /* 64k for code */ ROM_LOAD( "pro.0", 0x00000, 0x8000, 0x3f9ec35f ) ROM_LOAD( "pro.1", 0x08000, 0x6000, 0xf628bb30 ) ROM_CONTINUE( 0x10000, 0x2000 ) /* unused? but there seems to be stuff in here */ /* loading it at e000 causes rogue sprites to appear on screen */ ROM_REGION_DISPOSE(0x48000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "bg-0", 0x00000, 0x4000, 0xe3fb693a ) ROM_LOAD( "bg-1", 0x04000, 0x4000, 0x50d1db6c ) ROM_LOAD( "fg-3", 0x08000, 0x8000, 0x9ae3eb52 ) ROM_LOAD( "fg-2", 0x18000, 0x8000, 0x38be8505 ) ROM_LOAD( "fg-1", 0x28000, 0x8000, 0xe54b7f2a ) ROM_LOAD( "fg-0", 0x38000, 0x8000, 0x1d1435c1 ) ROM_END struct GameDriver maxrpm_driver = { __FILE__, 0, "maxrpm", "Max RPM", "1986", "Bally Midway", "Aaron Giles\nChristopher Kirmse\nNicola Salmoria\nBrad Oliver", 0, &maxrpm_machine_driver, 0, maxrpm_rom, rampage_rom_decode, 0, 0, 0, /* sound_prom */ maxrpm_input_ports, 0, 0,0, ORIENTATION_DEFAULT, rampage_hiload, rampage_hisave }; ROM_START( sarge_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "cpu_3b.bin", 0x0000, 0x8000, 0xda31a58f ) ROM_LOAD( "cpu_5b.bin", 0x8000, 0x8000, 0x6800e746 ) ROM_REGION_DISPOSE(0x24000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "til_15a.bin", 0x00000, 0x2000, 0x685001b8 ) ROM_LOAD( "til_14b.bin", 0x02000, 0x2000, 0x8449eb45 ) ROM_LOAD( "spr_4e.bin", 0x04000, 0x8000, 0xc382267d ) ROM_LOAD( "spr_5e.bin", 0x0c000, 0x8000, 0xc832375c ) ROM_LOAD( "spr_6e.bin", 0x14000, 0x8000, 0x7cc6fb28 ) ROM_LOAD( "spr_8e.bin", 0x1c000, 0x8000, 0x93fac29d ) ROM_REGION(0x10000) /* 64k for the Turbo Cheap Squeak */ ROM_LOAD( "tcs_u5.bin", 0xc000, 0x2000, 0xa894ef8a ) ROM_LOAD( "tcs_u4.bin", 0xe000, 0x2000, 0x6ca6faf3 ) ROM_END void sarge_rom_decode (void) { int i; /* Sarge tile graphics are inverted */ for (i = 0; i < 0x4000; i++) Machine->memory_region[1][i] ^= 0xff; } struct GameDriver sarge_driver = { __FILE__, 0, "sarge", "Sarge", "1985", "Bally Midway", "Aaron Giles\nChristopher Kirmse\nNicola Salmoria\nBrad Oliver", 0, &sarge_machine_driver, 0, sarge_rom, sarge_rom_decode, 0, 0, 0, /* sound_prom */ sarge_input_ports, 0, 0,0, ORIENTATION_DEFAULT, 0, 0 }; ROM_START( spyhunt_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "cpu_pg0.6d", 0x0000, 0x2000, 0x1721b88f ) ROM_LOAD( "cpu_pg1.7d", 0x2000, 0x2000, 0x909d044f ) ROM_LOAD( "cpu_pg2.8d", 0x4000, 0x2000, 0xafeeb8bd ) ROM_LOAD( "cpu_pg3.9d", 0x6000, 0x2000, 0x5e744381 ) ROM_LOAD( "cpu_pg4.10d", 0x8000, 0x2000, 0xa3033c15 ) ROM_LOAD( "cpu_pg5.11d", 0xA000, 0x4000, 0x88aa1e99 ) ROM_REGION_DISPOSE(0x29000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "cpu_bg2.5a", 0x0000, 0x2000, 0xba0fd626 ) ROM_LOAD( "cpu_bg3.6a", 0x2000, 0x2000, 0x7b482d61 ) ROM_LOAD( "cpu_bg0.3a", 0x4000, 0x2000, 0xdea34fed ) ROM_LOAD( "cpu_bg1.4a", 0x6000, 0x2000, 0x8f64525f ) ROM_LOAD( "vid_6fg.a2", 0x8000, 0x4000, 0x8cb8a066 ) ROM_LOAD( "vid_7fg.a1", 0xc000, 0x4000, 0x940fe17e ) ROM_LOAD( "vid_4fg.a4", 0x10000, 0x4000, 0x7ca4941b ) ROM_LOAD( "vid_5fg.a3", 0x14000, 0x4000, 0x2d9fbcec ) ROM_LOAD( "vid_2fg.a6", 0x18000, 0x4000, 0x62c8bfa5 ) ROM_LOAD( "vid_3fg.a5", 0x1c000, 0x4000, 0xb894934d ) ROM_LOAD( "vid_0fg.a8", 0x20000, 0x4000, 0x292c5466 ) ROM_LOAD( "vid_1fg.a7", 0x24000, 0x4000, 0x9fe286ec ) ROM_LOAD( "cpu_alph.10g", 0x28000, 0x1000, 0x936dc87f ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "snd_0sd.a8", 0x0000, 0x1000, 0xc95cf31e ) ROM_LOAD( "snd_1sd.a7", 0x1000, 0x1000, 0x12aaa48e ) ROM_REGION(0x8000) /* 32k for the Chip Squeak Deluxe */ ROM_LOAD_EVEN( "csd_u7a.u7", 0x00000, 0x2000, 0x6e689fe7 ) ROM_LOAD_ODD ( "csd_u17b.u17", 0x00000, 0x2000, 0x0d9ddce6 ) ROM_LOAD_EVEN( "csd_u8c.u8", 0x04000, 0x2000, 0x35563cd0 ) ROM_LOAD_ODD ( "csd_u18d.u18", 0x04000, 0x2000, 0x63d3f5b1 ) ROM_END struct GameDriver spyhunt_driver = { __FILE__, 0, "spyhunt", "Spy Hunter", "1983", "Bally Midway", "Aaron Giles\nChristopher Kirmse\nNicola Salmoria\nBrad Oliver\nLawnmower Man", 0, &spyhunt_machine_driver, 0, spyhunt_rom, spyhunt_decode, 0, 0, 0, /* sound_prom */ spyhunt_input_ports, 0, 0,0, ORIENTATION_ROTATE_90, spyhunt_hiload, spyhunt_hisave }; ROM_START( crater_rom ) ROM_REGION(0x10000) /* 64k for code */ ROM_LOAD( "crcpu.6d", 0x0000, 0x2000, 0xad31f127 ) ROM_LOAD( "crcpu.7d", 0x2000, 0x2000, 0x3743c78f ) ROM_LOAD( "crcpu.8d", 0x4000, 0x2000, 0xc95f9088 ) ROM_LOAD( "crcpu.9d", 0x6000, 0x2000, 0xa03c4b11 ) ROM_LOAD( "crcpu.10d", 0x8000, 0x2000, 0x44ae4cbd ) ROM_REGION_DISPOSE(0x29000) /* temporary space for graphics (disposed after conversion) */ ROM_LOAD( "crcpu.5a", 0x00000, 0x2000, 0x2fe4a6e1 ) ROM_LOAD( "crcpu.6a", 0x02000, 0x2000, 0xd0659042 ) ROM_LOAD( "crcpu.3a", 0x04000, 0x2000, 0x9d73504a ) ROM_LOAD( "crcpu.4a", 0x06000, 0x2000, 0x42a47dff ) ROM_LOAD( "crvid.a9", 0x08000, 0x4000, 0x811f152d ) ROM_LOAD( "crvid.a10", 0x0c000, 0x4000, 0x7a22d6bc ) ROM_LOAD( "crvid.a7", 0x10000, 0x4000, 0x9fa307d5 ) ROM_LOAD( "crvid.a8", 0x14000, 0x4000, 0x4b913498 ) ROM_LOAD( "crvid.a5", 0x18000, 0x4000, 0x9bdec312 ) ROM_LOAD( "crvid.a6", 0x1c000, 0x4000, 0x5bf954e0 ) ROM_LOAD( "crvid.a3", 0x20000, 0x4000, 0x2c2f5b29 ) ROM_LOAD( "crvid.a4", 0x24000, 0x4000, 0x579a8e36 ) ROM_LOAD( "crcpu.10g", 0x28000, 0x1000, 0x6fe53c8d ) ROM_REGION(0x10000) /* 64k for the audio CPU */ ROM_LOAD( "crsnd4.a7", 0x0000, 0x1000, 0xfd666cb5 ) ROM_LOAD( "crsnd1.a8", 0x1000, 0x1000, 0x90bf2c4c ) ROM_LOAD( "crsnd2.a9", 0x2000, 0x1000, 0x3b8deef1 ) ROM_LOAD( "crsnd3.a10", 0x3000, 0x1000, 0x05803453 ) ROM_END struct GameDriver crater_driver = { __FILE__, 0, "crater", "Crater Raider", "1984", "Bally Midway", "Aaron Giles\nChristopher Kirmse\nNicola Salmoria\nBrad Oliver\nLawnmower Man", 0, &crater_machine_driver, 0, crater_rom, 0, 0, 0, 0, /* sound_prom */ crater_input_ports, 0, 0,0, ORIENTATION_FLIP_X, crater_hiload, crater_hisave };
29.543897
186
0.681757
pierrelouys
80ca4c1fac04ac410563ed7d8aa939c84589ad08
7,349
cpp
C++
libs/settings/tests/unit/setting_tests.cpp
jinmannwong/ledger
f3b129c127e107603e08bb192eb695d23eb17dbc
[ "Apache-2.0" ]
null
null
null
libs/settings/tests/unit/setting_tests.cpp
jinmannwong/ledger
f3b129c127e107603e08bb192eb695d23eb17dbc
[ "Apache-2.0" ]
null
null
null
libs/settings/tests/unit/setting_tests.cpp
jinmannwong/ledger
f3b129c127e107603e08bb192eb695d23eb17dbc
[ "Apache-2.0" ]
2
2019-11-13T10:55:24.000Z
2019-11-13T11:37:09.000Z
//------------------------------------------------------------------------------ // // Copyright 2018-2019 Fetch.AI Limited // // 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 // // 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. // //------------------------------------------------------------------------------ #include "settings/setting.hpp" #include "settings/setting_collection.hpp" #include "gtest/gtest.h" #include <cstdint> #include <memory> #include <string> #include <vector> namespace { using fetch::settings::Setting; using fetch::settings::SettingCollection; TEST(SettingTests, CheckUInt32) { SettingCollection collection{}; Setting<uint32_t> setting{collection, "foo", 0, "A sample setting"}; EXPECT_EQ(setting.name(), "foo"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 0); EXPECT_EQ(setting.value(), 0u); std::istringstream iss{"401"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "foo"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 0u); EXPECT_EQ(setting.value(), 401u); } TEST(SettingTests, CheckSizet) { SettingCollection collection{}; Setting<std::size_t> setting{collection, "block-interval", 250u, "A sample setting"}; EXPECT_EQ(setting.name(), "block-interval"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 250u); EXPECT_EQ(setting.value(), 250u); std::istringstream iss{"40100"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "block-interval"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 250u); EXPECT_EQ(setting.value(), 40100u); } TEST(SettingTests, CheckDouble) { SettingCollection collection{}; Setting<double> setting{collection, "threshold", 10.0, "A sample setting"}; EXPECT_EQ(setting.name(), "threshold"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_DOUBLE_EQ(setting.default_value(), 10.0); EXPECT_DOUBLE_EQ(setting.value(), 10.0); std::istringstream iss{"3.145"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "threshold"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_DOUBLE_EQ(setting.default_value(), 10.0); EXPECT_DOUBLE_EQ(setting.value(), 3.145); } TEST(SettingTests, CheckBool) { SettingCollection collection{}; Setting<bool> setting{collection, "flag", false, "A sample setting"}; EXPECT_EQ(setting.name(), "flag"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), false); EXPECT_EQ(setting.value(), false); for (auto const &on_value : {"true", "1", "on", "enabled"}) { setting.Update(false); std::istringstream iss{on_value}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "flag"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), false); EXPECT_EQ(setting.value(), true); } for (auto const &off_value : {"false", "0", "off", "disabled"}) { setting.Update(true); std::istringstream iss{off_value}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "flag"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), false); EXPECT_EQ(setting.value(), false); } } TEST(SettingTests, CheckStringList) { using StringArray = std::vector<std::string>; SettingCollection collection{}; Setting<StringArray> setting{collection, "peers", {}, "A sample setting"}; EXPECT_EQ(setting.name(), "peers"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), StringArray{}); EXPECT_EQ(setting.value(), StringArray{}); { setting.Update(StringArray{}); std::istringstream iss{"foo"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "peers"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), StringArray{}); EXPECT_EQ(setting.value(), StringArray({"foo"})); } { setting.Update(StringArray{}); std::istringstream iss{"foo,bar,baz"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "peers"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), StringArray{}); EXPECT_EQ(setting.value(), StringArray({"foo", "bar", "baz"})); } } TEST(SettingTests, CheckUInt32Invalid) { SettingCollection collection{}; Setting<uint32_t> setting{collection, "foo", 0, "A sample setting"}; EXPECT_EQ(setting.name(), "foo"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 0); EXPECT_EQ(setting.value(), 0u); std::istringstream iss{"blah blah blah"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "foo"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 0u); EXPECT_EQ(setting.value(), 0u); } TEST(SettingTests, CheckBoolInvalid) { SettingCollection collection{}; Setting<bool> setting{collection, "flag", false, "A sample setting"}; EXPECT_EQ(setting.name(), "flag"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), false); EXPECT_EQ(setting.value(), false); for (auto const &on_value : {"blah", "please", "gogogo", "launch"}) { setting.Update(false); std::istringstream iss{on_value}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "flag"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), false); EXPECT_EQ(setting.value(), false); } } TEST(SettingTests, CheckSizetInvalid) { SettingCollection collection{}; Setting<std::size_t> setting{collection, "block-interval", 250u, "A sample setting"}; EXPECT_EQ(setting.name(), "block-interval"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 250u); EXPECT_EQ(setting.value(), 250u); std::istringstream iss{"twenty-four"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "block-interval"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_EQ(setting.default_value(), 250u); EXPECT_EQ(setting.value(), 250u); } TEST(SettingTests, CheckDoubleInvalid) { SettingCollection collection{}; Setting<double> setting{collection, "threshold", 10.0, "A sample setting"}; EXPECT_EQ(setting.name(), "threshold"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_DOUBLE_EQ(setting.default_value(), 10.0); EXPECT_DOUBLE_EQ(setting.value(), 10.0); std::istringstream iss{"very-small-number"}; setting.FromStream(iss); EXPECT_EQ(setting.name(), "threshold"); EXPECT_EQ(setting.description(), "A sample setting"); EXPECT_DOUBLE_EQ(setting.default_value(), 10.0); EXPECT_DOUBLE_EQ(setting.value(), 10.0); } } // namespace
29.753036
87
0.68608
jinmannwong
80ccef118362e7a49e597bc41752dd6e1eba9513
1,022
cpp
C++
Solutions/Construct Binary Tree from Preorder and Inorder/main.cpp
Crayzero/LeetCodeProgramming
b10ebe22c0de1501722f0f5c934c0c1902a26789
[ "MIT" ]
1
2015-04-13T10:58:30.000Z
2015-04-13T10:58:30.000Z
Solutions/Construct Binary Tree from Preorder and Inorder/main.cpp
Crayzero/LeetCodeProgramming
b10ebe22c0de1501722f0f5c934c0c1902a26789
[ "MIT" ]
null
null
null
Solutions/Construct Binary Tree from Preorder and Inorder/main.cpp
Crayzero/LeetCodeProgramming
b10ebe22c0de1501722f0f5c934c0c1902a26789
[ "MIT" ]
null
null
null
#include <iostream> #include <vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x): val(x), left(NULL), right(NULL) {} }; class Solution { public: TreeNode *buildTree(vector<int> &preorder, vector<int> &inorder) { return f(preorder, 0, preorder.size(), inorder, 0, inorder.size()); } TreeNode *f(vector<int> &preorder, int pre_start, int pre_end, vector<int> &inorder, int in_start, int in_end) { if (pre_start >= pre_end || in_start >= in_end) { return NULL; } int root_val = preorder[pre_start]; TreeNode *root = new TreeNode(root_val); int i = in_start; for(; inorder[i] != root_val; i++); int left_dis = i - in_start; root->left = f(preorder, pre_start+1, pre_start + 1 + left_dis, inorder, in_start, i); root->right = f(preorder, pre_start+1+left_dis, pre_end, inorder, i+1, in_end); return root; } }; int main() { return 0; }
29.2
116
0.605675
Crayzero
80d0dc49bf7c748cde25fa9974b35878fe8d6bde
10,047
hpp
C++
src/3rd party/boost/boost/spirit/debug/debug_node.hpp
OLR-xray/OLR-3.0
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
[ "Apache-2.0" ]
8
2016-01-25T20:18:51.000Z
2019-03-06T07:00:04.000Z
src/3rd party/boost/boost/spirit/debug/debug_node.hpp
OLR-xray/OLR-3.0
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
[ "Apache-2.0" ]
null
null
null
src/3rd party/boost/boost/spirit/debug/debug_node.hpp
OLR-xray/OLR-3.0
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
[ "Apache-2.0" ]
3
2016-02-14T01:20:43.000Z
2021-02-03T11:19:11.000Z
/*============================================================================= Spirit v1.6.0 Copyright (c) 2001-2003 Joel de Guzman Copyright (c) 2002-2003 Hartmut Kaiser Copyright (c) 2003 Gustavo Guerra http://spirit.sourceforge.net/ Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose. =============================================================================*/ #if !defined(BOOST_SPIRIT_DEBUG_NODE_HPP) #define BOOST_SPIRIT_DEBUG_NODE_HPP #if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP) #error "You must include boost/spirit/debug.hpp, not boost/spirit/debug/debug_node.hpp" #endif #if defined(BOOST_SPIRIT_DEBUG) #include <string> #include <boost/type_traits/is_convertible.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/and.hpp> #include <boost/spirit/core/primitives/primitives.hpp> // for iscntrl_ namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////////// // // Debug helper classes for rules, which ensure maximum non-intrusiveness of // the Spirit debug support // /////////////////////////////////////////////////////////////////////////////// namespace impl { struct token_printer_aux_for_chars { template<typename CharT> static void print(CharT c) { if (c == static_cast<CharT>('\a')) BOOST_SPIRIT_DEBUG_OUT << "\\a"; else if (c == static_cast<CharT>('\b')) BOOST_SPIRIT_DEBUG_OUT << "\\b"; else if (c == static_cast<CharT>('\f')) BOOST_SPIRIT_DEBUG_OUT << "\\f"; else if (c == static_cast<CharT>('\n')) BOOST_SPIRIT_DEBUG_OUT << "\\n"; else if (c == static_cast<CharT>('\r')) BOOST_SPIRIT_DEBUG_OUT << "\\r"; else if (c == static_cast<CharT>('\t')) BOOST_SPIRIT_DEBUG_OUT << "\\t"; else if (c == static_cast<CharT>('\v')) BOOST_SPIRIT_DEBUG_OUT << "\\v"; else if (iscntrl_(c)) BOOST_SPIRIT_DEBUG_OUT << "\\" << static_cast<int>(c); else BOOST_SPIRIT_DEBUG_OUT << static_cast<char>(c); } }; // for token types where the comparison with char constants wouldn't work struct token_printer_aux_for_other_types { template<typename CharT> static void print(CharT c) { BOOST_SPIRIT_DEBUG_OUT << c; } }; template <typename CharT> struct token_printer_aux : mpl::if_< mpl::and_< is_convertible<CharT, char>, is_convertible<char, CharT> >, token_printer_aux_for_chars, token_printer_aux_for_other_types >::type { }; template<typename CharT> inline void token_printer(CharT c) { #if !defined(BOOST_SPIRIT_DEBUG_TOKEN_PRINTER) token_printer_aux<CharT>::print(c); #else BOOST_SPIRIT_DEBUG_TOKEN_PRINTER(BOOST_SPIRIT_DEBUG_OUT, c); #endif } /////////////////////////////////////////////////////////////////////////////// // // Dump infos about the parsing state of a rule // /////////////////////////////////////////////////////////////////////////////// #if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES template <typename IteratorT> inline void print_node_info(bool hit, int level, bool close, std::string const& name, IteratorT first, IteratorT last) { if (!name.empty()) { for (int i = 0; i < level; ++i) BOOST_SPIRIT_DEBUG_OUT << " "; if (close) { if (hit) BOOST_SPIRIT_DEBUG_OUT << "/"; else BOOST_SPIRIT_DEBUG_OUT << "#"; } BOOST_SPIRIT_DEBUG_OUT << name << ":\t\""; IteratorT iter = first; IteratorT ilast = last; for (int j = 0; j < BOOST_SPIRIT_DEBUG_PRINT_SOME; ++j) { if (iter == ilast) break; token_printer(*iter); ++iter; } BOOST_SPIRIT_DEBUG_OUT << "\"\n"; } } #endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES #if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES template <typename ResultT> inline ResultT & print_closure_info(ResultT &hit, int level, std::string const& name) { if (!name.empty()) { for (int i = 0; i < level-1; ++i) BOOST_SPIRIT_DEBUG_OUT << " "; // for now, print out the return value only BOOST_SPIRIT_DEBUG_OUT << "^" << name << ":\t" << hit.value() << "\n"; } return hit; } #endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES } /////////////////////////////////////////////////////////////////////////////// // // Implementation note: The parser_context_linker, parser_scanner_linker and // closure_context_linker classes are wrapped by a PP constant to allow // redefinition of this classes outside of Spirit // /////////////////////////////////////////////////////////////////////////////// #if !defined(BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED) #define BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED /////////////////////////////////////////////////////////////////////////// // // parser_context_linker is a debug wrapper for the ContextT template // parameter of the rule<>, subrule<> and the grammar<> classes // /////////////////////////////////////////////////////////////////////////// template<typename ContextT> struct parser_context_linker : public ContextT { typedef ContextT base_t; template <typename ParserT> parser_context_linker(ParserT const& p) : ContextT(p) {} template <typename ParserT, typename ScannerT> void pre_parse(ParserT const& p, ScannerT &scan) { this->base_t::pre_parse(p, scan); #if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES if (trace_parser(p)) { impl::print_node_info( false, scan.get_level(), false, parser_name(p), scan.first, scan.last); } scan.get_level()++; #endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES } template <typename ResultT, typename ParserT, typename ScannerT> ResultT& post_parse(ResultT& hit, ParserT const& p, ScannerT &scan) { #if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES --scan.get_level(); if (trace_parser(p)) { impl::print_node_info( hit, scan.get_level(), true, parser_name(p), scan.first, scan.last); } #endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES return this->base_t::post_parse(hit, p, scan); } }; #endif // !defined(BOOST_SPIRIT_PARSER_CONTEXT_LINKER_DEFINED) #if !defined(BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED) #define BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED /////////////////////////////////////////////////////////////////////////////// // This class is to avoid linker problems and to ensure a real singleton // 'level' variable struct debug_support { int& get_level() { static int level = 0; return level; } }; template<typename ScannerT> struct parser_scanner_linker : public ScannerT { parser_scanner_linker(ScannerT const &scan_) : ScannerT(scan_) {} int &get_level() { return debug.get_level(); } private: debug_support debug; }; #endif // !defined(BOOST_SPIRIT_PARSER_SCANNER_LINKER_DEFINED) #if !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED) #define BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED /////////////////////////////////////////////////////////////////////////// // // closure_context_linker is a debug wrapper for the closure template // parameter of the rule<>, subrule<> and grammar classes // /////////////////////////////////////////////////////////////////////////// template<typename ContextT> struct closure_context_linker : public parser_context_linker<ContextT> { typedef parser_context_linker<ContextT> base_t; template <typename ParserT> closure_context_linker(ParserT const& p) : parser_context_linker<ContextT>(p) {} template <typename ParserT, typename ScannerT> void pre_parse(ParserT const& p, ScannerT &scan) { this->base_t::pre_parse(p, scan); } template <typename ResultT, typename ParserT, typename ScannerT> ResultT& post_parse(ResultT& hit, ParserT const& p, ScannerT &scan) { #if BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES if (hit && trace_parser(p)) { // for now, print out the return value only return impl::print_closure_info( this->base_t::post_parse(hit, p, scan), scan.get_level(), parser_name(p) ); } #endif // BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES return this->base_t::post_parse(hit, p, scan); } }; #endif // !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED) }} // namespace boost::spirit #endif // defined(BOOST_SPIRIT_DEBUG) #endif // !defined(BOOST_SPIRIT_DEBUG_NODE_HPP)
32.099042
87
0.542052
OLR-xray
80d1daf65975d4ba1be7f6e8b285cceed09f71e9
1,605
cpp
C++
logger.cpp
chenyoujie/GeoDa
87504344512bd0da2ccadfb160ecd1e918a52f06
[ "BSL-1.0" ]
null
null
null
logger.cpp
chenyoujie/GeoDa
87504344512bd0da2ccadfb160ecd1e918a52f06
[ "BSL-1.0" ]
null
null
null
logger.cpp
chenyoujie/GeoDa
87504344512bd0da2ccadfb160ecd1e918a52f06
[ "BSL-1.0" ]
null
null
null
// Copyright (c) 2005, 2006 // Seweryn Habdank-Wojewodzki // Distributed under the Boost Software License, // Version 1.0. // (copy at http://www.boost.org/LICENSE_1_0.txt) #include "logger.h" #if !defined(CLEANLOG) #define FTLOG #if !defined(DEBUG) #undef FTLOG #undef TLOG #endif //#if defined (FTLOG) //#include <fstream> //#else #include <iostream> // http://www.msobczak.com/prog/bin/nullstream.zip #include "nullstream.h" //#endif logger_t::logger_t() {} bool logger_t::is_activated = true; #if defined(TLOG) std::auto_ptr<std::ostream> logger_t::outstream_helper_ptr = std::auto_ptr<std::ostream>( new NullStream ); std::ostream * logger_t::outstream = &std::cout; #elif defined (ETLOG) std::auto_ptr<std::ostream> logger_t::outstream_helper_ptr = std::auto_ptr <std::ostream>( new NullStream ); std::ostream * logger_t::outstream = &std::cerr; #elif defined (FTLOG) //std::auto_ptr <std::ostream> logger_t::outstream_helper_ptr //= std::auto_ptr<std::ostream>( new std::ofstream ("oldlogger.txt")); //std::ostream * logger_t::outstream = outstream_helper_ptr.get(); std::auto_ptr<std::ostream> logger_t::outstream_helper_ptr = std::auto_ptr <std::ostream>( new NullStream ); std::ostream * logger_t::outstream = &std::cout; // here is a place for user defined output stream // and compiler flag #else std::auto_ptr<std::ostream> logger_t::outstream_helper_ptr = std::auto_ptr<std::ostream>( new NullStream ); std::ostream* logger_t::outstream = outstream_helper_ptr.get(); #endif logger_t & logger() { static logger_t* ans = new logger_t(); return *ans; } #endif // !CLEANLOG
24.692308
70
0.721495
chenyoujie
80d25aae65572a296eec5063154ff3838cf4b360
7,058
cpp
C++
shared/test/unit_test/helpers/bit_helpers_tests.cpp
troels/compute-runtime
3269e719a3ee7bcd97c50ec2cfe78fc8674adec0
[ "Intel", "MIT" ]
778
2017-09-29T20:02:43.000Z
2022-03-31T15:35:28.000Z
shared/test/unit_test/helpers/bit_helpers_tests.cpp
troels/compute-runtime
3269e719a3ee7bcd97c50ec2cfe78fc8674adec0
[ "Intel", "MIT" ]
478
2018-01-26T16:06:45.000Z
2022-03-30T10:19:10.000Z
shared/test/unit_test/helpers/bit_helpers_tests.cpp
troels/compute-runtime
3269e719a3ee7bcd97c50ec2cfe78fc8674adec0
[ "Intel", "MIT" ]
215
2018-01-30T08:39:32.000Z
2022-03-29T11:08:51.000Z
/* * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/helpers/bit_helpers.h" #include "gtest/gtest.h" using namespace NEO; TEST(IsBitSetTests, givenDifferentValuesWhenTestingIsBitSetThenCorrectValueIsReturned) { size_t field1 = 0; size_t field2 = 0b1; size_t field3 = 0b1000; size_t field4 = 0b1010; EXPECT_FALSE(isBitSet(field1, 0)); EXPECT_FALSE(isBitSet(field1, 1)); EXPECT_FALSE(isBitSet(field1, 2)); EXPECT_FALSE(isBitSet(field1, 3)); EXPECT_TRUE(isBitSet(field2, 0)); EXPECT_FALSE(isBitSet(field2, 1)); EXPECT_FALSE(isBitSet(field2, 2)); EXPECT_FALSE(isBitSet(field2, 3)); EXPECT_FALSE(isBitSet(field3, 0)); EXPECT_FALSE(isBitSet(field3, 1)); EXPECT_FALSE(isBitSet(field3, 2)); EXPECT_TRUE(isBitSet(field3, 3)); EXPECT_FALSE(isBitSet(field4, 0)); EXPECT_TRUE(isBitSet(field4, 1)); EXPECT_FALSE(isBitSet(field4, 2)); EXPECT_TRUE(isBitSet(field4, 3)); } TEST(IsAnyBitSetTests, givenDifferentValuesWhenTestingIsAnyBitSetThenCorrectValueIsReturned) { EXPECT_FALSE(isAnyBitSet(0, 0)); EXPECT_FALSE(isAnyBitSet(0, 0b1)); EXPECT_FALSE(isAnyBitSet(0, 0b10)); EXPECT_FALSE(isAnyBitSet(0, 0b1000)); EXPECT_FALSE(isAnyBitSet(0, 0b1010)); EXPECT_FALSE(isAnyBitSet(0, 0b1111)); EXPECT_FALSE(isAnyBitSet(0b1, 0)); EXPECT_TRUE(isAnyBitSet(0b1, 0b1)); EXPECT_FALSE(isAnyBitSet(0b1, 0b10)); EXPECT_FALSE(isAnyBitSet(0b1, 0b1000)); EXPECT_FALSE(isAnyBitSet(0b1, 0b1010)); EXPECT_TRUE(isAnyBitSet(0b1, 0b1111)); EXPECT_FALSE(isAnyBitSet(0b10, 0)); EXPECT_FALSE(isAnyBitSet(0b10, 0b1)); EXPECT_TRUE(isAnyBitSet(0b10, 0b10)); EXPECT_FALSE(isAnyBitSet(0b10, 0b1000)); EXPECT_TRUE(isAnyBitSet(0b10, 0b1010)); EXPECT_TRUE(isAnyBitSet(0b10, 0b1111)); EXPECT_FALSE(isAnyBitSet(0b1000, 0)); EXPECT_FALSE(isAnyBitSet(0b1000, 0b1)); EXPECT_FALSE(isAnyBitSet(0b1000, 0b10)); EXPECT_TRUE(isAnyBitSet(0b1000, 0b1000)); EXPECT_TRUE(isAnyBitSet(0b1000, 0b1010)); EXPECT_TRUE(isAnyBitSet(0b1000, 0b1111)); EXPECT_FALSE(isAnyBitSet(0b1010, 0)); EXPECT_FALSE(isAnyBitSet(0b1010, 0b1)); EXPECT_TRUE(isAnyBitSet(0b1010, 0b10)); EXPECT_TRUE(isAnyBitSet(0b1010, 0b1000)); EXPECT_TRUE(isAnyBitSet(0b1010, 0b1010)); EXPECT_TRUE(isAnyBitSet(0b1010, 0b1111)); EXPECT_FALSE(isAnyBitSet(0b1111, 0)); EXPECT_TRUE(isAnyBitSet(0b1111, 0b1)); EXPECT_TRUE(isAnyBitSet(0b1111, 0b10)); EXPECT_TRUE(isAnyBitSet(0b1111, 0b1000)); EXPECT_TRUE(isAnyBitSet(0b1111, 0b1010)); EXPECT_TRUE(isAnyBitSet(0b1111, 0b1111)); } TEST(IsValueSetTests, givenDifferentValuesWhenTestingIsValueSetThenCorrectValueIsReturned) { size_t field1 = 0; size_t field2 = 0b1; size_t field3 = 0b10; size_t field4 = 0b1000; size_t field5 = 0b1010; size_t field6 = 0b1111; EXPECT_FALSE(isValueSet(field1, field2)); EXPECT_FALSE(isValueSet(field1, field3)); EXPECT_FALSE(isValueSet(field1, field4)); EXPECT_FALSE(isValueSet(field1, field5)); EXPECT_FALSE(isValueSet(field1, field6)); EXPECT_TRUE(isValueSet(field2, field2)); EXPECT_FALSE(isValueSet(field2, field3)); EXPECT_FALSE(isValueSet(field2, field4)); EXPECT_FALSE(isValueSet(field2, field5)); EXPECT_FALSE(isValueSet(field2, field6)); EXPECT_FALSE(isValueSet(field3, field2)); EXPECT_TRUE(isValueSet(field3, field3)); EXPECT_FALSE(isValueSet(field3, field4)); EXPECT_FALSE(isValueSet(field3, field5)); EXPECT_FALSE(isValueSet(field3, field6)); EXPECT_FALSE(isValueSet(field4, field2)); EXPECT_FALSE(isValueSet(field4, field3)); EXPECT_TRUE(isValueSet(field4, field4)); EXPECT_FALSE(isValueSet(field4, field5)); EXPECT_FALSE(isValueSet(field4, field6)); EXPECT_FALSE(isValueSet(field5, field2)); EXPECT_TRUE(isValueSet(field5, field3)); EXPECT_TRUE(isValueSet(field5, field4)); EXPECT_TRUE(isValueSet(field5, field5)); EXPECT_FALSE(isValueSet(field5, field6)); EXPECT_TRUE(isValueSet(field6, field2)); EXPECT_TRUE(isValueSet(field6, field3)); EXPECT_TRUE(isValueSet(field6, field4)); EXPECT_TRUE(isValueSet(field6, field5)); EXPECT_TRUE(isValueSet(field6, field6)); } TEST(IsFieldValidTests, givenDifferentValuesWhenTestingIsFieldValidThenCorrectValueIsReturned) { size_t field1 = 0; size_t field2 = 0b1; size_t field3 = 0b10; size_t field4 = 0b1000; size_t field5 = 0b1010; size_t field6 = 0b1111; EXPECT_TRUE(isFieldValid(field1, field1)); EXPECT_TRUE(isFieldValid(field1, field2)); EXPECT_TRUE(isFieldValid(field1, field3)); EXPECT_TRUE(isFieldValid(field1, field4)); EXPECT_TRUE(isFieldValid(field1, field5)); EXPECT_TRUE(isFieldValid(field1, field6)); EXPECT_FALSE(isFieldValid(field2, field1)); EXPECT_TRUE(isFieldValid(field2, field2)); EXPECT_FALSE(isFieldValid(field2, field3)); EXPECT_FALSE(isFieldValid(field2, field4)); EXPECT_FALSE(isFieldValid(field2, field5)); EXPECT_TRUE(isFieldValid(field2, field6)); EXPECT_FALSE(isFieldValid(field3, field1)); EXPECT_FALSE(isFieldValid(field3, field2)); EXPECT_TRUE(isFieldValid(field3, field3)); EXPECT_FALSE(isFieldValid(field3, field4)); EXPECT_TRUE(isFieldValid(field3, field5)); EXPECT_TRUE(isFieldValid(field3, field6)); EXPECT_FALSE(isFieldValid(field4, field1)); EXPECT_FALSE(isFieldValid(field4, field2)); EXPECT_FALSE(isFieldValid(field4, field3)); EXPECT_TRUE(isFieldValid(field4, field4)); EXPECT_TRUE(isFieldValid(field4, field5)); EXPECT_TRUE(isFieldValid(field4, field6)); EXPECT_FALSE(isFieldValid(field5, field1)); EXPECT_FALSE(isFieldValid(field5, field2)); EXPECT_FALSE(isFieldValid(field5, field3)); EXPECT_FALSE(isFieldValid(field5, field4)); EXPECT_TRUE(isFieldValid(field5, field5)); EXPECT_TRUE(isFieldValid(field5, field6)); EXPECT_FALSE(isFieldValid(field6, field1)); EXPECT_FALSE(isFieldValid(field6, field2)); EXPECT_FALSE(isFieldValid(field6, field3)); EXPECT_FALSE(isFieldValid(field6, field4)); EXPECT_FALSE(isFieldValid(field6, field5)); EXPECT_TRUE(isFieldValid(field6, field6)); } TEST(SetBitsTests, givenDifferentValuesWhenTestingSetBitsThenCorrectValueIsReturned) { EXPECT_EQ(0b0u, setBits(0b0, false, 0b0)); EXPECT_EQ(0b0u, setBits(0b0, false, 0b1)); EXPECT_EQ(0b1u, setBits(0b1, false, 0b0)); EXPECT_EQ(0b0u, setBits(0b1, false, 0b1)); EXPECT_EQ(0b0u, setBits(0b0, true, 0b0)); EXPECT_EQ(0b1u, setBits(0b0, true, 0b1)); EXPECT_EQ(0b1u, setBits(0b1, true, 0b0)); EXPECT_EQ(0b1u, setBits(0b1, true, 0b1)); EXPECT_EQ(0b1010u, setBits(0b1010, false, 0b101)); EXPECT_EQ(0b1111u, setBits(0b1010, true, 0b101)); EXPECT_EQ(0b101u, setBits(0b101, false, 0b1010)); EXPECT_EQ(0b1111u, setBits(0b101, true, 0b1010)); EXPECT_EQ(0b0u, setBits(0b1010, false, 0b1010)); EXPECT_EQ(0b1010u, setBits(0b1010, true, 0b1010)); }
35.29
96
0.726693
troels
80d44a51c750cbd6805e532bfbf036a23be0346d
4,283
cpp
C++
src/qt/qtbase/tests/manual/gestures/graphicsview/gestures.cpp
power-electro/phantomjs-Gohstdriver-DIY-openshift
a571d301a9658a4c1b524d07e15658b45f8a0579
[ "BSD-3-Clause" ]
1
2020-04-30T15:47:35.000Z
2020-04-30T15:47:35.000Z
src/qt/qtbase/tests/manual/gestures/graphicsview/gestures.cpp
power-electro/phantomjs-Gohstdriver-DIY-openshift
a571d301a9658a4c1b524d07e15658b45f8a0579
[ "BSD-3-Clause" ]
null
null
null
src/qt/qtbase/tests/manual/gestures/graphicsview/gestures.cpp
power-electro/phantomjs-Gohstdriver-DIY-openshift
a571d301a9658a4c1b524d07e15658b45f8a0579
[ "BSD-3-Clause" ]
null
null
null
/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** As a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "gestures.h" #include <QTouchEvent> Qt::GestureType ThreeFingerSlideGesture::Type = Qt::CustomGesture; QGesture *ThreeFingerSlideGestureRecognizer::create(QObject *) { return new ThreeFingerSlideGesture; } QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event) { ThreeFingerSlideGesture *d = static_cast<ThreeFingerSlideGesture *>(state); QGestureRecognizer::Result result; switch (event->type()) { case QEvent::TouchBegin: result = QGestureRecognizer::MayBeGesture; case QEvent::TouchEnd: if (d->gestureFired) result = QGestureRecognizer::FinishGesture; else result = QGestureRecognizer::CancelGesture; case QEvent::TouchUpdate: if (d->state() != Qt::NoGesture) { QTouchEvent *ev = static_cast<QTouchEvent*>(event); if (ev->touchPoints().size() == 3) { d->gestureFired = true; result = QGestureRecognizer::TriggerGesture; } else { result = QGestureRecognizer::MayBeGesture; for (int i = 0; i < ev->touchPoints().size(); ++i) { const QTouchEvent::TouchPoint &pt = ev->touchPoints().at(i); const int distance = (pt.pos().toPoint() - pt.startPos().toPoint()).manhattanLength(); if (distance > 20) { result = QGestureRecognizer::CancelGesture; } } } } else { result = QGestureRecognizer::CancelGesture; } break; case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseMove: if (d->state() != Qt::NoGesture) result = QGestureRecognizer::Ignore; else result = QGestureRecognizer::CancelGesture; break; default: result = QGestureRecognizer::Ignore; break; } return result; } void ThreeFingerSlideGestureRecognizer::reset(QGesture *state) { static_cast<ThreeFingerSlideGesture *>(state)->gestureFired = false; QGestureRecognizer::reset(state); } QGesture *RotateGestureRecognizer::create(QObject *) { return new QGesture; } QGestureRecognizer::Result RotateGestureRecognizer::recognize(QGesture *, QObject *, QEvent *event) { switch (event->type()) { case QEvent::TouchBegin: case QEvent::TouchEnd: case QEvent::TouchUpdate: break; default: break; } return QGestureRecognizer::Ignore; } void RotateGestureRecognizer::reset(QGesture *state) { QGestureRecognizer::reset(state); } #include "moc_gestures.cpp"
34.540323
114
0.646276
power-electro
80d88d4fa9985eeb6a8132df0ff0bd361615a33b
1,966
hpp
C++
include/solaire/parallel/thread_pool_executor.hpp
SolaireLibrary/solaire_parallel
eed82815215e1eb60b7ca29e19720f6707966383
[ "Apache-2.0" ]
null
null
null
include/solaire/parallel/thread_pool_executor.hpp
SolaireLibrary/solaire_parallel
eed82815215e1eb60b7ca29e19720f6707966383
[ "Apache-2.0" ]
null
null
null
include/solaire/parallel/thread_pool_executor.hpp
SolaireLibrary/solaire_parallel
eed82815215e1eb60b7ca29e19720f6707966383
[ "Apache-2.0" ]
null
null
null
#ifndef SOLAIRE_PARALEL_THREAD_POOL_EXECUTOR_HPP #define SOLAIRE_PARALEL_THREAD_POOL_EXECUTOR_HPP //Copyright 2016 Adam G. Smith // //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 // //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. #include <vector> #include "solaire/parallel/task_executor.hpp" namespace solaire { class thread_pool_executor : public task_executor { private: std::thread* const mWorkerThreads; std::vector<std::function<void()>> mTasks; std::mutex mTasksLock; std::condition_variable mTaskAdded; const uint32_t mThreadCount; bool mExit; protected: // inherited from task_executor void _schedule(std::function<void()> aTask) override { mTasksLock.lock(); mTasks.push_back(aTask); mTasksLock.unlock(); mTaskAdded.notify_one(); } public: thread_pool_executor(uint32_t aThreadCount) : mWorkerThreads(new std::thread[aThreadCount]), mThreadCount(aThreadCount), mExit(false) { const auto threadFn = [this]() { while(! mExit) { std::unique_lock<std::mutex> lock(mTasksLock); mTaskAdded.wait(lock); if(! mTasks.empty()) { std::function<void()> task = mTasks.back(); mTasks.pop_back(); lock.unlock(); task(); } } }; for(uint32_t i = 0; i < aThreadCount; ++i) mWorkerThreads[i] = std::thread(threadFn); } ~thread_pool_executor() { mExit = true; mTaskAdded.notify_all(); for (uint32_t i = 0; i < mThreadCount; ++i) mWorkerThreads[i].join(); delete[] mWorkerThreads; } }; } #endif
26.931507
88
0.706002
SolaireLibrary
80d950eacccf88a798578ce38845f2308be757aa
757
hpp
C++
src/include/duckdb/planner/operator/logical_copy_to_file.hpp
RelationalAI-oss/duckdb
a4908ae17de3ac62d42633ada03077b8c3ead7a5
[ "MIT" ]
2
2020-01-07T17:19:02.000Z
2020-01-09T22:04:04.000Z
src/include/duckdb/planner/operator/logical_copy_to_file.hpp
RelationalAI-oss/duckdb
a4908ae17de3ac62d42633ada03077b8c3ead7a5
[ "MIT" ]
null
null
null
src/include/duckdb/planner/operator/logical_copy_to_file.hpp
RelationalAI-oss/duckdb
a4908ae17de3ac62d42633ada03077b8c3ead7a5
[ "MIT" ]
null
null
null
//===----------------------------------------------------------------------===// // DuckDB // // planner/operator/logical_copy_to_file.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/parser/parsed_data/copy_info.hpp" #include "duckdb/planner/logical_operator.hpp" namespace duckdb { class LogicalCopyToFile : public LogicalOperator { public: LogicalCopyToFile(unique_ptr<CopyInfo> info) : LogicalOperator(LogicalOperatorType::COPY_TO_FILE), info(move(info)) { } unique_ptr<CopyInfo> info; vector<string> names; vector<SQLType> sql_types; protected: void ResolveTypes() override { types.push_back(TypeId::BIGINT); } }; } // namespace duckdb
23.65625
80
0.569353
RelationalAI-oss
80db0115de030b7e18548330d48487d3542a06e7
3,336
cpp
C++
vnext/Desktop.UnitTests/WebSocketMocks.cpp
harinikmsft/react-native-windows
c73ecd0ffb8fb4ee5205ec610ab4b6dbc7f6ee21
[ "MIT" ]
null
null
null
vnext/Desktop.UnitTests/WebSocketMocks.cpp
harinikmsft/react-native-windows
c73ecd0ffb8fb4ee5205ec610ab4b6dbc7f6ee21
[ "MIT" ]
null
null
null
vnext/Desktop.UnitTests/WebSocketMocks.cpp
harinikmsft/react-native-windows
c73ecd0ffb8fb4ee5205ec610ab4b6dbc7f6ee21
[ "MIT" ]
null
null
null
#include "WebSocketMocks.h" using std::exception; using std::function; using std::string; namespace Microsoft::React::Test { MockWebSocketResource::~MockWebSocketResource() {} #pragma region IWebSocketResource overrides void MockWebSocketResource::Connect(const Protocols &protocols, const Options &options) noexcept /*override*/ { if (Mocks.Connect) return Mocks.Connect(protocols, options); } void MockWebSocketResource::Ping() noexcept /*override*/ { if (Mocks.Connect) return Mocks.Ping(); } void MockWebSocketResource::Send(const string &message) noexcept /*override*/ { if (Mocks.Send) return Mocks.Send(message); } void MockWebSocketResource::SendBinary(const string &message) noexcept /*override*/ { if (Mocks.SendBinary) return Mocks.SendBinary(message); } void MockWebSocketResource::Close(CloseCode code, const string &reason) noexcept /*override*/ { if (Mocks.Close) return Mocks.Close(code, reason); } IWebSocketResource::ReadyState MockWebSocketResource::GetReadyState() const noexcept /*override*/ { if (Mocks.GetReadyState) return Mocks.GetReadyState(); return ReadyState::Connecting; } void MockWebSocketResource::SetOnConnect(function<void()> &&handler) noexcept /*override*/ { if (Mocks.SetOnConnect) return SetOnConnect(std::move(handler)); m_connectHandler = std::move(handler); } void MockWebSocketResource::SetOnPing(function<void()> &&handler) noexcept /*override*/ { if (Mocks.SetOnPing) return Mocks.SetOnPing(std::move(handler)); m_pingHandler = std::move(handler); } void MockWebSocketResource::SetOnSend(function<void(size_t)> &&handler) noexcept /*override*/ { if (Mocks.SetOnSend) return Mocks.SetOnSend(std::move(handler)); m_writeHandler = std::move(handler); } void MockWebSocketResource::SetOnMessage(function<void(size_t, const string &)> &&handler) noexcept /*override*/ { if (Mocks.SetOnMessage) return Mocks.SetOnMessage(std::move(handler)); m_readHandler = std::move(handler); } void MockWebSocketResource::SetOnClose(function<void(CloseCode, const string &)> &&handler) noexcept /*override*/ { if (Mocks.SetOnClose) return Mocks.SetOnClose(std::move(handler)); m_closeHandler = std::move(handler); } void MockWebSocketResource::SetOnError(function<void(Error &&)> &&handler) noexcept /*override*/ { if (Mocks.SetOnError) return Mocks.SetOnError(std::move(handler)); m_errorHandler = std::move(handler); } #pragma endregion IWebSocketResource overrides void MockWebSocketResource::OnConnect() { if (m_connectHandler) m_connectHandler(); } void MockWebSocketResource::OnPing() { if (m_pingHandler) m_pingHandler(); } void MockWebSocketResource::OnSend(size_t size) { if (m_writeHandler) m_writeHandler(size); } void MockWebSocketResource::OnMessage(size_t size, const string &message) { if (m_readHandler) m_readHandler(size, message); } void MockWebSocketResource::OnClose(CloseCode code, const string &reason) { if (m_closeHandler) m_closeHandler(code, reason); } void MockWebSocketResource::OnError(Error &&error) { if (m_errorHandler) m_errorHandler(std::move(error)); } } // namespace Microsoft::React::Test
25.272727
114
0.711331
harinikmsft
80dbdafa854a5fc9ea6377dadef58a78acdda782
1,299
cpp
C++
level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp
8tab/compute-runtime
71bd96ad7184df83c7af04ffa8e0d6678ab26f99
[ "MIT" ]
null
null
null
level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp
8tab/compute-runtime
71bd96ad7184df83c7af04ffa8e0d6678ab26f99
[ "MIT" ]
null
null
null
level_zero/tools/source/sysman/engine/linux/os_engine_imp.cpp
8tab/compute-runtime
71bd96ad7184df83c7af04ffa8e0d6678ab26f99
[ "MIT" ]
null
null
null
/* * Copyright (C) 2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "level_zero/tools/source/sysman/engine/linux/os_engine_imp.h" namespace L0 { const std::string LinuxEngineImp::computeEngineGroupFile("engine/rcs0/name"); const std::string LinuxEngineImp::computeEngineGroupName("rcs0"); ze_result_t LinuxEngineImp::getActiveTime(uint64_t &activeTime) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } ze_result_t LinuxEngineImp::getEngineGroup(zet_engine_group_t &engineGroup) { std::string strVal; ze_result_t result = pSysfsAccess->read(computeEngineGroupFile, strVal); if (ZE_RESULT_SUCCESS != result) { return result; } if (strVal.compare(computeEngineGroupName) == 0) { engineGroup = ZET_ENGINE_GROUP_COMPUTE_ALL; } else { engineGroup = ZET_ENGINE_GROUP_ALL; return ZE_RESULT_ERROR_UNKNOWN; } return result; } LinuxEngineImp::LinuxEngineImp(OsSysman *pOsSysman) { LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman); pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess(); } OsEngine *OsEngine::create(OsSysman *pOsSysman) { LinuxEngineImp *pLinuxEngineImp = new LinuxEngineImp(pOsSysman); return static_cast<OsEngine *>(pLinuxEngineImp); } } // namespace L0
29.522727
79
0.744419
8tab
80def142bb58b6c555024ff734b0fbd06536ef52
484
cpp
C++
test/lib/BookmarkSerializer_test.cpp
alepez/bmrk
04db2646b42662b976b4f4a1a5fb414ca73df163
[ "MIT" ]
null
null
null
test/lib/BookmarkSerializer_test.cpp
alepez/bmrk
04db2646b42662b976b4f4a1a5fb414ca73df163
[ "MIT" ]
null
null
null
test/lib/BookmarkSerializer_test.cpp
alepez/bmrk
04db2646b42662b976b4f4a1a5fb414ca73df163
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> #include <BookmarkSerializer.hpp> #include "helpers.hpp" namespace bmrk { struct BookmarkSerializerTest: public testing::Test { BookmarkSerializer bs; }; TEST_F(BookmarkSerializerTest, CanSerialize) { auto bookmark = createMockBookmark( "http://pezzato.net", "one", Tags({"foo", "bar"}), "two"); std::stringstream stream; bs.serialize(&stream, bookmark); ASSERT_EQ("http://pezzato.net\none\nfoo,bar\ntwo\n", stream.str()); } } /* bmrk */
22
69
0.700413
alepez
80e2abd0223a3786643b9a2322a3e8e55291ed23
9,383
cpp
C++
drv/sd/sd_spi.cpp
yhsb2k/omef
7425b62dd4b5d0af4e320816293f69d16d39f57a
[ "MIT" ]
null
null
null
drv/sd/sd_spi.cpp
yhsb2k/omef
7425b62dd4b5d0af4e320816293f69d16d39f57a
[ "MIT" ]
null
null
null
drv/sd/sd_spi.cpp
yhsb2k/omef
7425b62dd4b5d0af4e320816293f69d16d39f57a
[ "MIT" ]
null
null
null
#include <stddef.h> #include <cstring> #include <assert.h> #include "sd_spi.hpp" #include "FreeRTOS.h" #include "task.h" using namespace drv; using namespace hal; #define WAIT_RESPONSE_CNT 10 #define TRANSMITTER_BIT 6 #define END_BIT 0 #define DATA_TOKEN_CMD17_18_24 0xFE #define DATA_TOKEN_CMD25 0xFC #define STOP_TOKEN_CMD25 0xFD #define ERR_TOKEN_MASK 0x1F /* 7, 6, 5 bits are not used */ #define ERR_TOKEN_ERR (1 << 0) #define ERR_TOKEN_CC_ERR (1 << 1) #define ERR_TOKEN_ECC_FAIL (1 << 2) #define ERR_TOKEN_OUT_OF_RANGE_ERR (1 << 3) #define ERR_TOKEN_CARD_LOCKED (1 << 4) #define DATA_RESP_MASK 0x1F /* 7, 6, 5 bits are not used */ #define DATA_RESP_START_BIT (1 << 0) /* Should be 1 */ #define DATA_RESP_END_BIT (1 << 4) /* Should be 0 */ #define DATA_RESP_ACCEPTED 0x05 /* Data accepted */ #define DATA_RESP_CRC_ERR 0x0B /* Data rejected due to a CRC erro */ #define DATA_RESP_WRITE_ERR 0x0D /* Data rejected due to a write error */ #define R1_START_BIT 0x80 #define CRC7_CID_CSD_MASK 0xFE /* crc7 table (crc8 table shifted left by 1 bit ) */ static const uint8_t crc7_table[256] = { 0x00, 0x12, 0x24, 0x36, 0x48, 0x5A, 0x6C, 0x7E, 0x90, 0x82, 0xB4, 0xA6, 0xD8, 0xCA, 0xFC, 0xEE, 0x32, 0x20, 0x16, 0x04, 0x7A, 0x68, 0x5E, 0x4C, 0xA2, 0xB0, 0x86, 0x94, 0xEA, 0xF8, 0xCE, 0xDC, 0x64, 0x76, 0x40, 0x52, 0x2C, 0x3E, 0x08, 0x1A, 0xF4, 0xE6, 0xD0, 0xC2, 0xBC, 0xAE, 0x98, 0x8A, 0x56, 0x44, 0x72, 0x60, 0x1E, 0x0C, 0x3A, 0x28, 0xC6, 0xD4, 0xE2, 0xF0, 0x8E, 0x9C, 0xAA, 0xB8, 0xC8, 0xDA, 0xEC, 0xFE, 0x80, 0x92, 0xA4, 0xB6, 0x58, 0x4A, 0x7C, 0x6E, 0x10, 0x02, 0x34, 0x26, 0xFA, 0xE8, 0xDE, 0xCC, 0xB2, 0xA0, 0x96, 0x84, 0x6A, 0x78, 0x4E, 0x58, 0x22, 0x30, 0x06, 0x14, 0xAC, 0xBE, 0x88, 0x9A, 0xE4, 0xF6, 0xC0, 0xD2, 0x3C, 0x2E, 0x18, 0x0A, 0x74, 0x66, 0x50, 0x42, 0x9E, 0x8C, 0xBA, 0xA8, 0xD6, 0xC4, 0xF2, 0xE0, 0x0E, 0x1C, 0x2A, 0x38, 0x46, 0x54, 0x62, 0x70, 0x82, 0x90, 0xA6, 0xB4, 0xCA, 0xD8, 0xEE, 0xFC, 0x12, 0x00, 0x36, 0x24, 0x5A, 0x48, 0x7E, 0x6C, 0xB0, 0xA2, 0x94, 0x86, 0xF8, 0xEA, 0xDC, 0xCE, 0x20, 0x32, 0x04, 0x16, 0x68, 0x7A, 0x4C, 0x5E, 0xE6, 0xF4, 0xC2, 0xD0, 0xAE, 0xBC, 0x8A, 0x98, 0x76, 0x64, 0x52, 0x40, 0x3E, 0x2C, 0x1A, 0x08, 0xD4, 0xC6, 0xF0, 0xE2, 0x9C, 0x8E, 0xB8, 0xAA, 0x44, 0x56, 0x60, 0x72, 0x0C, 0x1E, 0x28, 0x3A, 0x4A, 0x58, 0x6E, 0x7C, 0x02, 0x10, 0x26, 0x34, 0xDA, 0xC8, 0xFE, 0xEC, 0x92, 0x80, 0xB6, 0xA4, 0x78, 0x6A, 0x5C, 0x4E, 0x30, 0x22, 0x14, 0x06, 0xE8, 0xFA, 0xCC, 0xDE, 0xA0, 0xB2, 0x84, 0x96, 0x2E, 0x3C, 0x0A, 0x18, 0x66, 0x74, 0x42, 0x50, 0xBE, 0xAC, 0x9A, 0x88, 0xF6, 0xE4, 0xD2, 0xC0, 0x1C, 0x0E, 0x38, 0x2A, 0x54, 0x46, 0x70, 0x62, 0x8C, 0x9C, 0xA8, 0xBA, 0xC4, 0xD6, 0xE0, 0xF2 }; static const uint16_t crc16_ccitt_table[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 }; static uint8_t calc_crc7(uint8_t *buff, uint8_t size); static uint16_t calc_crc16(uint8_t *buff, uint16_t size); sd_spi::sd_spi(hal::spi &spi, hal::gpio &cs, hal::gpio *cd): sd(cd), _spi(spi), _cs(cs) { assert(_spi.cpol() == spi::CPOL_0); assert(_spi.cpha() == spi::CPHA_0); assert(_spi.bit_order() == spi::BIT_ORDER_MSB); assert(_cs.mode() == gpio::mode::DO && cs.get()); } sd_spi::~sd_spi() { } void sd_spi::select(bool is_selected) { _cs.set(is_selected ? 0 : 1); } int8_t sd_spi::init_sd() { /* Send 80 pulses without cs */ uint8_t init_buff[8]; memset(init_buff, 0xFF, sizeof(init_buff)); if(_spi.write(init_buff, sizeof(init_buff))) return RES_SPI_ERR; return RES_OK; } void sd_spi::set_speed(uint32_t speed) { _spi.baud(speed); } int8_t sd_spi::send_cmd(cmd_t cmd, uint32_t arg, resp_t resp_type, uint8_t *resp) { int8_t res; if(cmd != CMD12_STOP_TRANSMISSION) { res = wait_ready(); if(res) return res; } uint8_t cmd_buff[6]; cmd_buff[0] = (cmd | (1 << TRANSMITTER_BIT)) & ~R1_START_BIT; cmd_buff[1] = arg >> 24; cmd_buff[2] = arg >> 16; cmd_buff[3] = arg >> 8; cmd_buff[4] = arg; cmd_buff[5] = calc_crc7(cmd_buff, sizeof(cmd_buff) - 1); if(_spi.write(cmd_buff, sizeof(cmd_buff))) return RES_SPI_ERR; uint8_t retry_cnt = WAIT_RESPONSE_CNT; while(retry_cnt--) { resp[0] = 0xFF; if(_spi.read(resp, 1)) return RES_SPI_ERR; if(!(resp[0] & R1_START_BIT)) break; } if(!retry_cnt) return RES_NO_RESPONSE; switch(resp_type) { case R1: break; case R2: res = read_data(&resp[1], 16); if(res) return res; // Check the CSD or CID CRC7 (last byte): // Raw CID CRC7 always has LSB set to 1, //so fix it with CRC7_CID_CSD_MASK if(calc_crc7(&resp[1], 15) != (resp[16] & CRC7_CID_CSD_MASK)) return RES_CRC_ERR; break; case R3: case R6: case R7: memset(&resp[1], 0xFF, 4); if(_spi.read(&resp[1], 4)) return RES_SPI_ERR; } return RES_OK; } int8_t sd_spi::read_data(void *data, uint16_t size) { uint8_t data_token; uint8_t wait_cnt = 10; while(wait_cnt--) { data_token = 0xFF; if(_spi.read(&data_token, 1)) return RES_SPI_ERR; if(data_token == DATA_TOKEN_CMD17_18_24) break; /* Check for error token */ if(!(data_token & ~ERR_TOKEN_MASK)) { if(data_token & ERR_TOKEN_CARD_LOCKED) return RES_LOCKED; else if(data_token & ERR_TOKEN_OUT_OF_RANGE_ERR) return RES_PARAM_ERR; else if(data_token & ERR_TOKEN_ECC_FAIL) return RES_READ_ERR; else if(data_token & ERR_TOKEN_CC_ERR) return RES_READ_ERR; else if(data_token & ERR_TOKEN_ERR) return RES_READ_ERR; else return RES_READ_ERR; } vTaskDelay(1); } if(!wait_cnt) return RES_NO_RESPONSE; memset(data, 0xFF, size); if(_spi.read(data, size)) return RES_SPI_ERR; uint8_t crc16[2] = {0xFF, 0xFF}; if(_spi.read(crc16, sizeof(crc16))) return RES_SPI_ERR; if(calc_crc16((uint8_t *)data, size) != ((crc16[0] << 8) | crc16[1])) return RES_CRC_ERR; return RES_OK; } int8_t sd_spi::write_data(void *data, uint16_t size) { if(_spi.write(DATA_TOKEN_CMD17_18_24)) return RES_SPI_ERR; if(_spi.write(data, size)) return RES_SPI_ERR; uint16_t crc16_tmp = calc_crc16((uint8_t *)data, size); uint8_t crc16[2] = {(uint8_t)crc16_tmp, (uint8_t)(crc16_tmp << 8)}; if(_spi.write(crc16, sizeof(crc16))) return RES_SPI_ERR; /* Check data response */ uint8_t data_resp; data_resp = 0xFF; if(_spi.read(&data_resp, sizeof(data_resp))) return RES_SPI_ERR; if(!(data_resp & DATA_RESP_START_BIT) || (data_resp & DATA_RESP_END_BIT)) { /* Data response is not valid */ return RES_WRITE_ERR; } switch(data_resp & DATA_RESP_MASK) { case DATA_RESP_ACCEPTED: break; case DATA_RESP_CRC_ERR: return RES_CRC_ERR; case DATA_RESP_WRITE_ERR: default: return RES_WRITE_ERR; } return wait_ready(); } int8_t sd_spi::wait_ready() { uint8_t busy_flag = 0; uint16_t wait_cnt = 500; while(wait_cnt--) { busy_flag = 0xFF; if(_spi.read(&busy_flag, 1)) return RES_SPI_ERR; if(busy_flag == 0xFF) break; vTaskDelay(1); }; return wait_cnt ? RES_OK : RES_NO_RESPONSE; } static uint8_t calc_crc7(uint8_t *buff, uint8_t size) { uint8_t crc = 0; while(size--) crc = crc7_table[crc ^ *buff++]; return crc; } static uint16_t calc_crc16(uint8_t *buff, uint16_t size) { uint16_t crc = 0; while(size--) crc = (crc << 8) ^ crc16_ccitt_table[(crc >> 8) ^ *buff++]; return crc; }
27.925595
81
0.685175
yhsb2k
80e4db6830eb49c5da5e145f6b0ede663193c0df
1,688
cpp
C++
tests/graph/traversal/discovered_flag.cpp
AlCash07/ACTL
15de4e2783d8e39dbd8e10cd635aaab328ca4f5b
[ "BSL-1.0" ]
17
2018-08-22T06:48:20.000Z
2022-02-22T21:20:09.000Z
tests/graph/traversal/discovered_flag.cpp
AlCash07/ACTL
15de4e2783d8e39dbd8e10cd635aaab328ca4f5b
[ "BSL-1.0" ]
null
null
null
tests/graph/traversal/discovered_flag.cpp
AlCash07/ACTL
15de4e2783d8e39dbd8e10cd635aaab328ca4f5b
[ "BSL-1.0" ]
null
null
null
// Copyright 2018 Oleksandr Bacherikov. // // Distributed under the Boost Software License, Version 1.0 // (see accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt). #include <actl/graph/default_map.hpp> #include <actl/graph/traversal/breadth_first_search.hpp> #include <actl/graph/traversal/depth_first_search.hpp> #include <actl/graph/traversal/discovered_flag.hpp> #include "graph/sample_graphs.hpp" #include "map/logging_map.hpp" #include "test.hpp" using Log = std::vector<std::pair<int, bool>>; TEST_CASE("discovered_flag bfs") { auto graph = sample_undirected_graph(); Log log; auto map = logging_map{ make_default_vertex_map<bool>(graph), std::back_inserter(log)}; breadth_first_search{discovered_flag{map}}(graph, 0); CHECK( Log{ {0, false}, {1, false}, {2, false}, {3, false}, {4, false}, {5, false}, {0, true}, {1, true}, {3, true}, {2, true}, {4, true}, {5, true}, } == log); } TEST_CASE("discovered_flag dfs") { auto graph = sample_undirected_graph(); Log log; auto map = logging_map{ make_default_vertex_map<bool>(graph), std::back_inserter(log)}; depth_first_search{discovered_flag{map}}(graph, 0); CHECK( Log{ {0, false}, {1, false}, {2, false}, {3, false}, {4, false}, {5, false}, {0, true}, {1, true}, {2, true}, {3, true}, {4, true}, {5, true}, } == log); }
26.375
71
0.543839
AlCash07
80e670f7c00b65cb090fa7cd8b7eb8eed5df787c
33,813
cpp
C++
indires_macro_actions/src/Indires_macro_actions.cpp
Tutorgaming/indires_navigation
830097ac0a3e3a64da9026518419939b509bbe71
[ "BSD-3-Clause" ]
90
2019-07-19T13:44:35.000Z
2022-02-17T21:39:15.000Z
indires_macro_actions/src/Indires_macro_actions.cpp
Tutorgaming/indires_navigation
830097ac0a3e3a64da9026518419939b509bbe71
[ "BSD-3-Clause" ]
13
2019-12-02T07:32:18.000Z
2021-08-10T09:38:44.000Z
indires_macro_actions/src/Indires_macro_actions.cpp
Tutorgaming/indires_navigation
830097ac0a3e3a64da9026518419939b509bbe71
[ "BSD-3-Clause" ]
26
2019-05-27T14:43:43.000Z
2022-02-17T21:39:19.000Z
#include <indires_macro_actions/Indires_macro_actions.h> /* Status can take this values: uint8 PENDING = 0 # The goal has yet to be processed by the action server uint8 ACTIVE = 1 # The goal is currently being processed by the action server uint8 PREEMPTED = 2 # The goal received a cancel request after it started executing # and has since completed its execution (Terminal State) uint8 SUCCEEDED = 3 # The goal was achieved successfully by the action server (Terminal State) uint8 ABORTED = 4 # The goal was aborted during execution by the action server due # to some failure (Terminal State) uint8 REJECTED = 5 # The goal was rejected by the action server without being processed, # because the goal was unattainable or invalid (Terminal State) uint8 PREEMPTING = 6 # The goal received a cancel request after it started executing # and has not yet completed execution uint8 RECALLING = 7 # The goal received a cancel request before it started executing, # but the action server has not yet confirmed that the goal is canceled uint8 RECALLED = 8 # The goal received a cancel request before it started executing # and was successfully cancelled (Terminal State) uint8 LOST = 9 # An action client can determine that a goal is LOST. This should not be # sent over the wire by an action server */ // namespace macroactions { Indires_macro_actions::Indires_macro_actions(tf2_ros::Buffer* tf) { tf_ = tf; // UpoNav_ = nav; ros::NodeHandle n("~"); // Dynamic reconfigure // dsrv_ = new // dynamic_reconfigure::Server<upo_navigation_macro_actions::NavigationMacroActionsConfig>(n); // dynamic_reconfigure::Server<upo_navigation_macro_actions::NavigationMacroActionsConfig>::CallbackType // cb = boost::bind(&Upo_navigation_macro_actions::reconfigureCB, this, _1, _2); // dsrv_->setCallback(cb); n.param<double>("secs_to_check_block", secs_to_check_block_, 5.0); // seconds n.param<double>("block_dist", block_dist_, 0.4); // meters // n.param<double>("secs_to_wait", secs_to_wait_, 8.0); //seconds n.param<double>("control_frequency", control_frequency_, 15.0); std::string odom_topic = ""; n.param<std::string>("odom_topic", odom_topic, "odom"); manual_control_ = false; // Dynamic reconfigure // dsrv_ = new // dynamic_reconfigure::Server<upo_navigation_macro_actions::NavigationMacroActionsConfig>(n); // dynamic_reconfigure::Server<upo_navigation_macro_actions::NavigationMacroActionsConfig>::CallbackType // cb = boost::bind(&Upo_navigation_macro_actions::reconfigureCB, this, _1, _2); // dsrv_->setCallback(cb); ros::NodeHandle nh; rrtgoal_sub_ = nh.subscribe<geometry_msgs::PoseStamped>( "/rrt_goal", 1, &Indires_macro_actions::rrtGoalCallback, this); pose_sub_ = nh.subscribe<nav_msgs::Odometry>( odom_topic.c_str(), 1, &Indires_macro_actions::robotPoseCallback, this); // Services for walking side by side // start_client_ = nh.serviceClient<teresa_wsbs::start>("/wsbs/start"); // stop_client_ = nh.serviceClient<teresa_wsbs::stop>("/wsbs/stop"); // wsbs_status_sub_ = nh.subscribe<std_msgs::UInt8>("/wsbs/status", 1, // &Upo_navigation_macro_actions::wsbsCallback, this); moveBaseClient_ = new moveBaseClient("move_base", true); // true-> do not need ros::spin() ROS_INFO("Waiting for action server to start..."); moveBaseClient_->waitForServer(); ROS_INFO("Action server connected!"); // Initialize action servers NWActionServer_ = new NWActionServer( nh1_, "NavigateWaypoint", boost::bind(&Indires_macro_actions::navigateWaypointCB, this, _1), false); NHActionServer_ = new NHActionServer( nh2_, "NavigateHome", boost::bind(&Indires_macro_actions::navigateHomeCB, this, _1), false); ExActionServer_ = new ExActionServer( nh3_, "Exploration", boost::bind(&Indires_macro_actions::explorationCB, this, _1), false); TOActionServer_ = new TOActionServer(nh4_, "Teleoperation", boost::bind(&Indires_macro_actions::teleoperationCB, this, _1), false); NWActionServer_->start(); NHActionServer_->start(); ExActionServer_->start(); TOActionServer_->start(); // ros::NodeHandle nodeh("~/RRT_ros_wrapper"); // nodeh.getParam("full_path_stddev", initial_stddev_); } Indires_macro_actions::~Indires_macro_actions() { if (NWActionServer_) delete NWActionServer_; if (NHActionServer_) delete NHActionServer_; if (ExActionServer_) delete ExActionServer_; if (TOActionServer_) delete TOActionServer_; // if(UpoNav_) // delete UpoNav_; // if(dsrv_) // delete dsrv_; } /* void Upo_navigation_macro_actions::reconfigureCB(upo_navigation_macro_actions::NavigationMacroActionsConfig &config, uint32_t level){ boost::recursive_mutex::scoped_lock l(configuration_mutex_); control_frequency_ = config.control_frequency; secs_to_check_block_ = config.secs_to_check_block; block_dist_ = config.block_dist; secs_to_wait_ = config.secs_to_wait; social_approaching_type_ = config.social_approaching_type; secs_to_yield_ = config.secs_to_yield; //use_leds_ = config.use_leds; //leds_number_ = config.leds_number; }*/ /* //Receive feedback messages from upo_navigation void Upo_navigation_macro_actions::feedbackReceived(const move_base_msgs::MoveBaseActionFeedback::ConstPtr& msg) { pose_mutex_.lock(); robot_pose_ = msg->feedback.base_position; pose_mutex_.unlock(); if((unsigned int)(std::string(robot_pose_.header.frame_id).size()) < 3) robot_pose_.header.frame_id = "map"; } //Receive status messages from upo_navigation void Upo_navigation_macro_actions::statusReceived(const actionlib_msgs::GoalStatusArray::ConstPtr& msg) { unsigned int actions = msg->status_list.size(); if(actions != 0) { status_mutex_.lock(); nav_status_ = msg->status_list.at(0).status; nav_text_ = msg->status_list.at(0).text; goal_id_ = msg->status_list.at(0).goal_id.id; status_mutex_.unlock(); } else { status_mutex_.lock(); nav_status_ = -1; nav_text_ = " "; goal_id_ = " "; status_mutex_.unlock(); } } //This topic publishes only when the action finishes (because of reaching the goal or cancelation) void Upo_navigation_macro_actions::resultReceived(const move_base_msgs::MoveBaseActionResult::ConstPtr& msg) { action_end_ = true; }*/ /* MoveBase server: ----------------- Action Subscribed topics: move_base/goal [move_base_msgs::MoveBaseActionGoal] move_base/cancel [actionlib_msgs::GoalID] Action Published topcis: move_base/feedback [move_base_msgs::MoveBaseActionFeedback] move_base/status [actionlib_msgs::GoalStatusArray] move_base/result [move_base_msgs::MoveBaseAcionResult] */ void Indires_macro_actions::navigateWaypointCB( const indires_macro_actions::NavigateWaypointGoal::ConstPtr& goal) { printf("¡¡¡¡¡¡¡MacroAction navigatetoWaypoint --> started!!!!!!\n"); // printf("Goal x: %.2f, y: %.2f frame: %s\n", goal->target_pose.pose.position.x, // goal->target_pose.pose.position.y, goal->target_pose.header.frame_id.c_str()); // UpoNav_->stopRRTPlanning(); move_base_msgs::MoveBaseGoal g; g.target_pose = goal->target_pose; moveBaseClient_->sendGoal(g); // moveBaseClient_->waitForResult(); actionlib::SimpleClientGoalState state = moveBaseClient_->getState(); // moveBaseClient_->cancelAllGoals() // moveBaseClient_->cancelGoal() // moveBaseClient_->getResult() if (moveBaseClient_->getState() == actionlib::SimpleClientGoalState::SUCCEEDED) { ROS_INFO("Success!!!"); } /*else { ROS_INFO("Failed!"); }*/ /*bool ok = UpoNav_->executeNavigation(goal->target_pose); if(!ok) { ROS_INFO("Setting ABORTED state 1"); nwresult_.result = "Aborted. Navigation error"; nwresult_.value = 2; NWActionServer_->setAborted(nwresult_, "Navigation aborted"); //UpoNav_->stopRRTPlanning(); return; }*/ ros::Rate r(control_frequency_); // int pursue_status = 0; bool exit = false; ros::Time time_init = ros::Time::now(); bool first = true; nav_msgs::Odometry pose_init; // ros::WallTime startt; while (nh1_.ok()) { // startt = ros::WallTime::now(); if (NWActionServer_->isPreemptRequested()) { if (NWActionServer_->isNewGoalAvailable()) { indires_macro_actions::NavigateWaypointGoal new_goal = *NWActionServer_->acceptNewGoal(); g.target_pose = new_goal.target_pose; moveBaseClient_->sendGoal(g); /*bool ok = UpoNav_->executeNavigation(new_goal.target_pose); if(!ok) { ROS_INFO("Setting ABORTED state 1"); nwresult_.result = "Aborted. Navigation error"; nwresult_.value = 2; NWActionServer_->setAborted(nwresult_, "Navigation aborted"); UpoNav_->stopRRTPlanning(); if(use_leds_) setLedColor(WHITE); return; }*/ first = true; } else { // if we've been preempted explicitly we need to shut things down // UpoNav_->resetState(); // Cancel????? // notify the ActionServer that we've successfully preempted nwresult_.result = "Preempted"; nwresult_.value = 1; ROS_DEBUG_NAMED("indires_macro_actions", "indires_navigation preempting the current goal"); NWActionServer_->setPreempted(nwresult_, "Navigation preempted"); // we'll actually return from execute after preempting return; } } pose_mutex_.lock(); nav_msgs::Odometry new_pose = odom_pose_; pose_mutex_.unlock(); // pursue_status = UpoNav_->pathFollow(new_pose); // Posible states: // PENDING, ACTIVE, RECALLED, REJECTED, PREEMPTED, ABORTED, SUCCEEDED, LOST actionlib::SimpleClientGoalState state = moveBaseClient_->getState(); if (first) { pose_init = new_pose; time_init = ros::Time::now(); first = false; } if (state == actionlib::SimpleClientGoalState::SUCCEEDED) { // Goal reached ROS_INFO("Setting SUCCEEDED state"); nwresult_.result = "Navigation succeeded"; nwresult_.value = 0; NWActionServer_->setSucceeded(nwresult_, "Goal Reached"); nwfeedback_.text = "Succeeded"; exit = true; } else if (state == actionlib::SimpleClientGoalState::ACTIVE) { // Goal not reached, continue navigating nwfeedback_.text = "Navigating"; } else if (state == actionlib::SimpleClientGoalState::ABORTED) { // Aborted nwfeedback_.text = "Aborted"; ROS_INFO("Setting ABORTED state"); nwresult_.result = "Aborted"; nwresult_.value = 3; NWActionServer_->setAborted(nwresult_, "Navigation aborted"); exit = true; } else if (state == actionlib::SimpleClientGoalState::PENDING) { nwfeedback_.text = "Pending"; // ROS_INFO("Setting ABORTED state"); // nwresult_.result = ""; // nwresult_.value = 3; // NWActionServer_->setAborted(nwresult_, "Navigation aborted"); // exit = true; } else if (state == actionlib::SimpleClientGoalState::RECALLED) { nwfeedback_.text = "Recalled"; } else if (state == actionlib::SimpleClientGoalState::REJECTED) { // Rejected nwfeedback_.text = "Rejected"; ROS_INFO("Setting ABORTED (rejected) state"); nwresult_.result = "Rejected"; nwresult_.value = 3; NWActionServer_->setAborted(nwresult_, "Navigation aborted(rejected)"); exit = true; } else if (state == actionlib::SimpleClientGoalState::LOST) { // Rejected nwfeedback_.text = "Lost"; ROS_INFO("Setting ABORTED (lost) state"); nwresult_.result = "Lost"; nwresult_.value = 3; NWActionServer_->setAborted(nwresult_, "Navigation aborted(lost)"); exit = true; } else if (state == actionlib::SimpleClientGoalState::PREEMPTED) { nwfeedback_.text = "Preempted"; } // push the feedback out geometry_msgs::PoseStamped aux; aux.header = new_pose.header; aux.pose.position = new_pose.pose.pose.position; aux.pose.orientation = new_pose.pose.pose.orientation; nwfeedback_.base_position = aux; NWActionServer_->publishFeedback(nwfeedback_); if (exit) { // UpoNav_->stopRRTPlanning(); return; } // check the blocked situation. double time = (ros::Time::now() - time_init).toSec(); // printf("now: %.2f, init: %.2f, time: %.2f secs\n", ros::Time::now().toSec(), // time_init.toSec(), time); if (time > secs_to_check_block_) { double xinit = pose_init.pose.pose.position.x; double yinit = pose_init.pose.pose.position.y; double hinit = tf::getYaw(pose_init.pose.pose.orientation); double xnow = new_pose.pose.pose.position.x; double ynow = new_pose.pose.pose.position.y; double hnow = tf::getYaw(new_pose.pose.pose.orientation); double dist = sqrt(pow((xinit - xnow), 2) + pow((yinit - ynow), 2)); double yaw_diff = fabs(angles::shortest_angular_distance(hnow, hinit)); // printf("dist: %.2f, yaw_diff: %.2f\n", dist, yaw_diff); if (dist <= block_dist_ && yaw_diff < 0.79) { // 0.79 = 45º ROS_INFO("Setting ABORTED state because of blocked situation"); nwresult_.result = "Aborted. Blocked situation"; nwresult_.value = 5; NWActionServer_->setAborted(nwresult_, "Navigation aborted. blocked"); nwfeedback_.text = "Blocked"; NWActionServer_->publishFeedback(nwfeedback_); // UpoNav_->stopRRTPlanning(); return; } else { pose_init = new_pose; time_init = ros::Time::now(); } } // ros::WallDuration dur = ros::WallTime::now() - startt; // printf("Loop time: %.4f secs\n", dur.toSec()); r.sleep(); } ROS_INFO("Setting ABORTED state"); nwresult_.result = "Aborted. System is shuting down"; nwresult_.value = 6; NWActionServer_->setAborted(nwresult_, "Navigation aborted because the node has been killed"); } void Indires_macro_actions::navigateHomeCB(const indires_macro_actions::NavigateHomeGoal::ConstPtr& goal) { printf("¡¡¡¡¡¡¡MacroAction NavigateHome --> started!!!!!!\n"); // printf("Goal x: %.2f, y: %.2f frame: %s\n", goal->home_pose.pose.position.x, // goal->home_pose.pose.position.y, goal->home_pose.header.frame_id.c_str()); // UpoNav_->stopRRTPlanning(); // boost::recursive_mutex::scoped_lock l(configuration_mutex_); // Put the goal to map origin??? move_base_msgs::MoveBaseGoal g; g.target_pose = goal->home_pose; moveBaseClient_->sendGoal(g); ros::Rate r(control_frequency_); // int pursue_status = 0; bool exit = false; ros::Time time_init = ros::Time::now(); bool first = true; nav_msgs::Odometry pose_init; while (nh2_.ok()) { // startt = ros::WallTime::now(); if (NHActionServer_->isPreemptRequested()) { if (NHActionServer_->isNewGoalAvailable()) { indires_macro_actions::NavigateHomeGoal new_goal = *NHActionServer_->acceptNewGoal(); g.target_pose = new_goal.home_pose; moveBaseClient_->sendGoal(g); first = true; } else { // if we've been preempted explicitly we need to shut things down // UpoNav_->resetState(); // notify the ActionServer that we've successfully preempted ROS_DEBUG_NAMED("indires_macro_actions", "indires_navigation preempting the current goal"); nhresult_.result = "Preempted"; nhresult_.value = 1; NHActionServer_->setPreempted(nhresult_, "Navigation preempted"); // we'll actually return from execute after preempting return; } } pose_mutex_.lock(); nav_msgs::Odometry new_pose = odom_pose_; pose_mutex_.unlock(); // pursue_status = UpoNav_->pathFollow(new_pose); // Posible states: // PENDING, ACTIVE, RECALLED, REJECTED, PREEMPTED, ABORTED, SUCCEEDED, LOST actionlib::SimpleClientGoalState state = moveBaseClient_->getState(); if (first) { pose_init = new_pose; time_init = ros::Time::now(); first = false; } if (state == actionlib::SimpleClientGoalState::SUCCEEDED) { // Goal reached ROS_INFO("Setting SUCCEEDED state"); nhresult_.result = "Navigation succeeded"; nhresult_.value = 0; NHActionServer_->setSucceeded(nhresult_, "Goal Reached"); nhfeedback_.text = "Succeeded"; exit = true; } else if (state == actionlib::SimpleClientGoalState::ACTIVE) { // Goal not reached, continue navigating nhfeedback_.text = "Navigating"; } else if (state == actionlib::SimpleClientGoalState::ABORTED) { // Aborted nhfeedback_.text = "Aborted"; ROS_INFO("Setting ABORTED state"); nhresult_.result = "Aborted"; nhresult_.value = 3; NHActionServer_->setAborted(nhresult_, "Navigation aborted"); exit = true; } else if (state == actionlib::SimpleClientGoalState::PENDING) { nhfeedback_.text = "Pending"; // ROS_INFO("Setting ABORTED state"); // nwresult_.result = ""; // nwresult_.value = 3; // NWActionServer_->setAborted(nwresult_, "Navigation aborted"); // exit = true; } else if (state == actionlib::SimpleClientGoalState::RECALLED) { nhfeedback_.text = "Recalled"; } else if (state == actionlib::SimpleClientGoalState::REJECTED) { // Rejected nhfeedback_.text = "Rejected"; ROS_INFO("Setting ABORTED (rejected) state"); nhresult_.result = "Rejected"; nhresult_.value = 3; NHActionServer_->setAborted(nhresult_, "Navigation aborted(rejected)"); exit = true; } else if (state == actionlib::SimpleClientGoalState::LOST) { // Rejected nhfeedback_.text = "Lost"; ROS_INFO("Setting ABORTED (lost) state"); nhresult_.result = "Lost"; nhresult_.value = 3; NHActionServer_->setAborted(nhresult_, "Navigation aborted(lost)"); exit = true; } else if (state == actionlib::SimpleClientGoalState::PREEMPTED) { nhfeedback_.text = "Preempted"; } // push the feedback out geometry_msgs::PoseStamped aux; aux.header = new_pose.header; aux.pose.position = new_pose.pose.pose.position; aux.pose.orientation = new_pose.pose.pose.orientation; nhfeedback_.base_position = aux; NHActionServer_->publishFeedback(nhfeedback_); if (exit) { // UpoNav_->stopRRTPlanning(); return; } // check the blocked situation. double time = (ros::Time::now() - time_init).toSec(); // printf("now: %.2f, init: %.2f, time: %.2f secs\n", ros::Time::now().toSec(), // time_init.toSec(), time); if (time > secs_to_check_block_) { double xinit = pose_init.pose.pose.position.x; double yinit = pose_init.pose.pose.position.y; double hinit = tf::getYaw(pose_init.pose.pose.orientation); double xnow = new_pose.pose.pose.position.x; double ynow = new_pose.pose.pose.position.y; double hnow = tf::getYaw(new_pose.pose.pose.orientation); double dist = sqrt(pow((xinit - xnow), 2) + pow((yinit - ynow), 2)); double yaw_diff = fabs(angles::shortest_angular_distance(hnow, hinit)); // printf("dist: %.2f, yaw_diff: %.2f\n", dist, yaw_diff); if (dist <= block_dist_ && yaw_diff < 0.79) { // 0.79 = 45º ROS_INFO("Setting ABORTED state because of blocked situation"); nhresult_.result = "Aborted. Blocked situation"; nhresult_.value = 5; NHActionServer_->setAborted(nhresult_, "Navigation aborted. blocked"); nhfeedback_.text = "Blocked"; NHActionServer_->publishFeedback(nhfeedback_); // UpoNav_->stopRRTPlanning(); return; } else { pose_init = new_pose; time_init = ros::Time::now(); } } // ros::WallDuration dur = ros::WallTime::now() - startt; // printf("Loop time: %.4f secs\n", dur.toSec()); r.sleep(); } ROS_INFO("Setting ABORTED state"); nhresult_.result = "Aborted. system is shuting down"; nhresult_.value = 6; NHActionServer_->setAborted(nhresult_, "Navigation aborted because the node has been killed"); } void Indires_macro_actions::explorationCB(const indires_macro_actions::ExplorationGoal::ConstPtr& goal) { printf("¡¡¡¡¡¡¡MacroAction Exploration --> started!!!!!!\n"); // printf("Goal x: %.2f, y: %.2f frame: %s\n", goal->target_pose.pose.position.x, // goal->target_pose.pose.position.y, goal->target_pose.header.frame_id.c_str()); // UpoNav_->stopRRTPlanning(); move_base_msgs::MoveBaseGoal g; g.target_pose = goal->empty; g.target_pose.header.frame_id = ""; g.target_pose.pose.orientation.x = 0.0; g.target_pose.pose.orientation.y = 0.0; g.target_pose.pose.orientation.z = 0.0; g.target_pose.pose.orientation.w = 1.0; moveBaseClient_->sendGoal(g); // moveBaseClient_->waitForResult(); actionlib::SimpleClientGoalState state = moveBaseClient_->getState(); // moveBaseClient_->cancelAllGoals() // moveBaseClient_->cancelGoal() // moveBaseClient_->getResult() if (moveBaseClient_->getState() == actionlib::SimpleClientGoalState::SUCCEEDED) { ROS_INFO("Success!!!"); } /*else { ROS_INFO("Failed!"); }*/ /*bool ok = UpoNav_->executeNavigation(goal->target_pose); if(!ok) { ROS_INFO("Setting ABORTED state 1"); nwresult_.result = "Aborted. Navigation error"; nwresult_.value = 2; NWActionServer_->setAborted(nwresult_, "Navigation aborted"); //UpoNav_->stopRRTPlanning(); return; }*/ ros::Rate r(control_frequency_); // int pursue_status = 0; bool exit = false; ros::Time time_init = ros::Time::now(); bool first = true; nav_msgs::Odometry pose_init; // ros::WallTime startt; while (nh3_.ok()) { // startt = ros::WallTime::now(); if (ExActionServer_->isPreemptRequested()) { if (ExActionServer_->isNewGoalAvailable()) { indires_macro_actions::ExplorationGoal new_goal = *ExActionServer_->acceptNewGoal(); g.target_pose = new_goal.empty; moveBaseClient_->sendGoal(g); /*bool ok = UpoNav_->executeNavigation(new_goal.target_pose); if(!ok) { ROS_INFO("Setting ABORTED state 1"); nwresult_.result = "Aborted. Navigation error"; nwresult_.value = 2; NWActionServer_->setAborted(nwresult_, "Navigation aborted"); UpoNav_->stopRRTPlanning(); if(use_leds_) setLedColor(WHITE); return; }*/ first = true; } else { // if we've been preempted explicitly we need to shut things down // UpoNav_->resetState(); // Cancel????? // notify the ActionServer that we've successfully preempted exresult_.result = "Preempted"; exresult_.value = 1; ROS_DEBUG_NAMED("indires_macro_actions", "indires_exploration preempting the current goal"); ExActionServer_->setPreempted(exresult_, "Exploration preempted"); // we'll actually return from execute after preempting return; } } pose_mutex_.lock(); nav_msgs::Odometry new_pose = odom_pose_; pose_mutex_.unlock(); // pursue_status = UpoNav_->pathFollow(new_pose); // Posible states: // PENDING, ACTIVE, RECALLED, REJECTED, PREEMPTED, ABORTED, SUCCEEDED, LOST state = moveBaseClient_->getState(); if (first) { pose_init = new_pose; time_init = ros::Time::now(); first = false; } if (state == actionlib::SimpleClientGoalState::SUCCEEDED) { // Goal reached // WE MUST TO CONTINUE THE EXPLORATION ROS_INFO("Goal reached. Exploration continues..."); // exresult_.result = "Exploration succeeded"; // exresult_.value = 0; // ExActionServer_->setSucceeded(exresult_, "Goal Reached"); // exfeedback_.text = "Succeeded"; // exit = true; exfeedback_.text = "goal reached. Exploration continues"; moveBaseClient_->sendGoal(g); } else if (state == actionlib::SimpleClientGoalState::ACTIVE) { // Goal not reached, continue navigating exfeedback_.text = "Navigating"; } else if (state == actionlib::SimpleClientGoalState::ABORTED) { // Aborted exfeedback_.text = "Aborted"; ROS_INFO("Setting ABORTED state"); exresult_.result = "Aborted"; exresult_.value = 3; ExActionServer_->setAborted(exresult_, "Exploration aborted"); exit = true; } else if (state == actionlib::SimpleClientGoalState::PENDING) { exfeedback_.text = "Pending"; // ROS_INFO("Setting ABORTED state"); // nwresult_.result = ""; // nwresult_.value = 3; // NWActionServer_->setAborted(nwresult_, "Navigation aborted"); // exit = true; } else if (state == actionlib::SimpleClientGoalState::RECALLED) { exfeedback_.text = "Recalled"; } else if (state == actionlib::SimpleClientGoalState::REJECTED) { // Rejected exfeedback_.text = "Rejected"; ROS_INFO("Setting ABORTED (rejected) state"); exresult_.result = "Rejected"; exresult_.value = 3; ExActionServer_->setAborted(exresult_, "Exploration aborted(rejected)"); exit = true; } else if (state == actionlib::SimpleClientGoalState::LOST) { // Rejected exfeedback_.text = "Lost"; ROS_INFO("Setting ABORTED (lost) state"); exresult_.result = "Lost"; exresult_.value = 3; ExActionServer_->setAborted(exresult_, "Exploration aborted(lost)"); exit = true; } else if (state == actionlib::SimpleClientGoalState::PREEMPTED) { nwfeedback_.text = "Preempted"; } // push the feedback out geometry_msgs::PoseStamped aux; aux.header = new_pose.header; aux.pose.position = new_pose.pose.pose.position; aux.pose.orientation = new_pose.pose.pose.orientation; exfeedback_.base_position = aux; ExActionServer_->publishFeedback(exfeedback_); if (exit) { // UpoNav_->stopRRTPlanning(); return; } // check the blocked situation. double time = (ros::Time::now() - time_init).toSec(); // printf("now: %.2f, init: %.2f, time: %.2f secs\n", ros::Time::now().toSec(), // time_init.toSec(), time); if (time > secs_to_check_block_) { double xinit = pose_init.pose.pose.position.x; double yinit = pose_init.pose.pose.position.y; double hinit = tf::getYaw(pose_init.pose.pose.orientation); double xnow = new_pose.pose.pose.position.x; double ynow = new_pose.pose.pose.position.y; double hnow = tf::getYaw(new_pose.pose.pose.orientation); double dist = sqrt(pow((xinit - xnow), 2) + pow((yinit - ynow), 2)); double yaw_diff = fabs(angles::shortest_angular_distance(hnow, hinit)); // printf("dist: %.2f, yaw_diff: %.2f\n", dist, yaw_diff); if (dist <= block_dist_ && yaw_diff < 0.79) { // 0.79 = 45º ROS_INFO("Setting ABORTED state because of blocked situation"); exresult_.result = "Aborted. Blocked situation"; exresult_.value = 5; ExActionServer_->setAborted(exresult_, "Exploration aborted. blocked"); exfeedback_.text = "Blocked"; ExActionServer_->publishFeedback(exfeedback_); // UpoNav_->stopRRTPlanning(); return; } else { pose_init = new_pose; time_init = ros::Time::now(); } } // ros::WallDuration dur = ros::WallTime::now() - startt; // printf("Loop time: %.4f secs\n", dur.toSec()); r.sleep(); } ROS_INFO("Setting ABORTED state"); exresult_.result = "Aborted. System is shuting down"; exresult_.value = 6; ExActionServer_->setAborted(exresult_, "Exploration aborted because the node has been killed"); } /* bool Indires_macro_actions::reconfigureParameters(std::string node, std::string param_name, std::string value, const datatype type) { //printf("RECONFIGURE PARAMETERS METHOD\n"); dynamic_reconfigure::ReconfigureRequest srv_req; dynamic_reconfigure::ReconfigureResponse srv_resp; dynamic_reconfigure::IntParameter param1; dynamic_reconfigure::BoolParameter param2; dynamic_reconfigure::DoubleParameter param3; dynamic_reconfigure::StrParameter param4; dynamic_reconfigure::Config conf; switch(type) { case INT_TYPE: param1.name = param_name.c_str(); param1.value = stoi(value); conf.ints.push_back(param1); break; case DOUBLE_TYPE: param3.name = param_name.c_str(); //printf("type double. Value: %s\n", param3.name.c_str()); param3.value = stod(value); //printf("conversion to double: %.3f\n", param3.value); conf.doubles.push_back(param3); break; case BOOL_TYPE: param2.name = param_name.c_str(); param2.value = stoi(value); conf.bools.push_back(param2); break; case STRING_TYPE: param4.name = param_name.c_str(); param4.value = value; conf.strs.push_back(param4); break; default: ROS_ERROR("indires_macro_actions. ReconfigureParameters. datatype not valid!"); } srv_req.config = conf; std::string service = node + "/set_parameters"; if (!ros::service::call(service, srv_req, srv_resp)) { ROS_ERROR("Could not call the service %s reconfigure the param %s to %s", service.c_str(), param_name.c_str(), value.c_str()); return false; } return true; } */ void Indires_macro_actions::teleoperationCB(const indires_macro_actions::TeleoperationGoal::ConstPtr& goal) { if (!manual_control_) { printf("¡¡¡¡¡¡¡MacroAction AssistedSteering --> started!!!!!!\n"); manual_control_ = true; moveBaseClient_->cancelAllGoals(); // UpoNav_->stopRRTPlanning(); // stop the current wsbs if it is running // teresa_wsbs::stop stop_srv; // stop_client_.call(stop_srv); } ros::Time time_init; time_init = ros::Time::now(); bool exit = false; // boost::recursive_mutex::scoped_lock l(configuration_mutex_); ros::Rate r(30.0); while (nh4_.ok()) { if (TOActionServer_->isPreemptRequested()) { if (TOActionServer_->isNewGoalAvailable()) { // if we're active and a new goal is available, we'll accept it, but we won't shut // anything down // ROS_INFO("Accepting new goal"); indires_macro_actions::TeleoperationGoal new_goal = *TOActionServer_->acceptNewGoal(); time_init = ros::Time::now(); } else { TOActionServer_->setPreempted(toresult_, "Teleoperation preempted"); return; } } tofeedback_.text = "Robot manually controlled"; // Check the time without receiving commands from the interface double time = (ros::Time::now() - time_init).toSec(); if (time > 5.0) { tofeedback_.text = "Teleoperation finished"; toresult_.result = "Teleoperation Succeeded"; toresult_.value = 0; TOActionServer_->setSucceeded(toresult_, "Teleoperation succeeded"); exit = true; } TOActionServer_->publishFeedback(tofeedback_); if (exit) { manual_control_ = false; return; } r.sleep(); } manual_control_ = false; ROS_INFO("Setting ABORTED state"); TOActionServer_->setAborted(toresult_, "Teleoperation aborted because the node has been killed"); } // void Upo_navigation_macro_actions::poseCallback(const // geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg) void Indires_macro_actions::robotPoseCallback(const nav_msgs::Odometry::ConstPtr& msg) { pose_mutex_.lock(); odom_pose_ = *msg; // robot_global_pose_.y = msg->pose.pose.position.y; // robot_global_pose_.theta = tf::getYaw(msg->pose.pose.orientation); pose_mutex_.unlock(); } void Indires_macro_actions::rrtGoalCallback(const geometry_msgs::PoseStamped::ConstPtr& msg) { /*geometry_msgs::PoseStamped out; out = transformPoseTo(*msg, "map"); geometry_msgs::Pose2D p; p.x = out.pose.position.x; p.y = out.pose.position.y; p.theta = 0.0; */ goal_mutex_.lock(); rrtgoal_ = *msg; goal_mutex_.unlock(); } geometry_msgs::PoseStamped Indires_macro_actions::transformPoseTo(geometry_msgs::PoseStamped pose_in, std::string frame_out) { geometry_msgs::PoseStamped in = pose_in; in.header.stamp = ros::Time(); geometry_msgs::PoseStamped pose_out; try { pose_out = tf_->transform(in, frame_out.c_str()); } catch (tf2::TransformException ex) { ROS_WARN("Macro-Action class. TransformException in method transformPoseTo: %s", ex.what()); pose_out.header = in.header; pose_out.header.stamp = ros::Time::now(); pose_out.pose.position.x = 0.0; pose_out.pose.position.y = 0.0; pose_out.pose.position.z = 0.0; pose_out.pose.orientation = tf::createQuaternionMsgFromYaw(0.0); } return pose_out; } // This method removes the initial slash from the frame names // in order to compare the string names easily void Indires_macro_actions::fixFrame(std::string& cad) { if (cad[0] == '/') { cad.erase(0, 1); } } float Indires_macro_actions::normalizeAngle(float val, float min, float max) { float norm = 0.0; if (val >= min) norm = min + fmod((val - min), (max - min)); else norm = max - fmod((min - val), (max - min)); return norm; }
30.683303
107
0.658001
Tutorgaming
80e6d38c87acd8605315d45b0d400b2a3bd80526
49,223
cpp
C++
agent/agent.cpp
MatthewPowley/cppagent
fccb7794723ba71025dfd1ea633332422f99a3dd
[ "Apache-2.0" ]
null
null
null
agent/agent.cpp
MatthewPowley/cppagent
fccb7794723ba71025dfd1ea633332422f99a3dd
[ "Apache-2.0" ]
null
null
null
agent/agent.cpp
MatthewPowley/cppagent
fccb7794723ba71025dfd1ea633332422f99a3dd
[ "Apache-2.0" ]
null
null
null
/* * Copyright Copyright 2012, System Insights, Inc. * * 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 * * 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. */ #include "agent.hpp" #include "dlib/logger.h" #include <sys/stat.h> #include <fcntl.h> #include <sstream> #include <stdexcept> #include <dlib/tokenizer.h> #include <dlib/misc_api.h> #include <dlib/array.h> #include <dlib/dir_nav.h> #include <dlib/config_reader.h> #include <dlib/queue.h> #include <functional> using namespace std; static const string sUnavailable("UNAVAILABLE"); static const string sConditionUnavailable("UNAVAILABLE|||"); static const string sAvailable("AVAILABLE"); static dlib::logger sLogger("agent"); /* Agent public methods */ Agent::Agent(const string& configXmlPath, int aBufferSize, int aMaxAssets, int aCheckpointFreq) : mPutEnabled(false), mLogStreamData(false) { mMimeTypes["xsl"] = "text/xsl"; mMimeTypes["xml"] = "text/xml"; mMimeTypes["css"] = "text/css"; mMimeTypes["xsd"] = "text/xml"; mMimeTypes["jpg"] = "image/jpeg"; mMimeTypes["jpeg"] = "image/jpeg"; mMimeTypes["png"] = "image/png"; mMimeTypes["ico"] = "image/x-icon"; try { // Load the configuration for the Agent mXmlParser = new XmlParser(); mDevices = mXmlParser->parseFile(configXmlPath); std::vector<Device *>::iterator device; std::set<std::string> uuids; for (device = mDevices.begin(); device != mDevices.end(); ++device) { if (uuids.count((*device)->getUuid()) > 0) throw runtime_error("Duplicate UUID: " + (*device)->getUuid()); uuids.insert((*device)->getUuid()); (*device)->resolveReferences(); } } catch (runtime_error & e) { sLogger << LFATAL << "Error loading xml configuration: " + configXmlPath; sLogger << LFATAL << "Error detail: " << e.what(); cerr << e.what() << endl; throw e; } catch (exception &f) { sLogger << LFATAL << "Error loading xml configuration: " + configXmlPath; sLogger << LFATAL << "Error detail: " << f.what(); cerr << f.what() << endl; throw f; } // Grab data from configuration string time = getCurrentTime(GMT_UV_SEC); // Unique id number for agent instance mInstanceId = getCurrentTimeInSec(); // Sequence number and sliding buffer for data mSequence = 1; mSlidingBufferSize = 1 << aBufferSize; mSlidingBuffer = new sliding_buffer_kernel_1<ComponentEventPtr>(); mSlidingBuffer->set_size(aBufferSize); mCheckpointFreq = aCheckpointFreq; mCheckpointCount = (mSlidingBufferSize / aCheckpointFreq) + 1; // Asset sliding buffer mMaxAssets = aMaxAssets; // Create the checkpoints at a regular frequency mCheckpoints = new Checkpoint[mCheckpointCount]; // Mutex used for synchronized access to sliding buffer and sequence number mSequenceLock = new dlib::mutex; mAssetLock = new dlib::mutex; // Add the devices to the device map and create availability and // asset changed events if they don't exist std::vector<Device *>::iterator device; for (device = mDevices.begin(); device != mDevices.end(); ++device) { mDeviceMap[(*device)->getName()] = *device; // Make sure we have two device level data items: // 1. Availability // 2. AssetChanged if ((*device)->getAvailability() == NULL) { // Create availability data item and add it to the device. std::map<string,string> attrs; attrs["type"] = "AVAILABILITY"; attrs["id"] = (*device)->getId() + "_avail"; attrs["category"] = "EVENT"; DataItem *di = new DataItem(attrs); di->setComponent(*(*device)); (*device)->addDataItem(*di); (*device)->addDeviceDataItem(*di); (*device)->mAvailabilityAdded = true; } int major, minor; char c; stringstream ss(XmlPrinter::getSchemaVersion()); ss >> major >> c >> minor; if ((*device)->getAssetChanged() == NULL && (major > 1 || (major == 1 && minor >= 2))) { // Create asset change data item and add it to the device. std::map<string,string> attrs; attrs["type"] = "ASSET_CHANGED"; attrs["id"] = (*device)->getId() + "_asset_chg"; attrs["category"] = "EVENT"; DataItem *di = new DataItem(attrs); di->setComponent(*(*device)); (*device)->addDataItem(*di); (*device)->addDeviceDataItem(*di); } if ((*device)->getAssetRemoved() == NULL && (major > 1 || (major == 1 && minor >= 3))) { // Create asset removed data item and add it to the device. std::map<string,string> attrs; attrs["type"] = "ASSET_REMOVED"; attrs["id"] = (*device)->getId() + "_asset_rem"; attrs["category"] = "EVENT"; DataItem *di = new DataItem(attrs); di->setComponent(*(*device)); (*device)->addDataItem(*di); (*device)->addDeviceDataItem(*di); } } // Reload the document for path resolution mXmlParser->loadDocument(XmlPrinter::printProbe(mInstanceId, mSlidingBufferSize, mMaxAssets, mAssets.size(), mSequence, mDevices)); /* Initialize the id mapping for the devices and set all data items to UNAVAILABLE */ for (device = mDevices.begin(); device != mDevices.end(); ++device) { const std::map<string, DataItem*> &items = (*device)->getDeviceDataItems(); std::map<string, DataItem *>::const_iterator item; for (item = items.begin(); item != items.end(); ++item) { // Check for single valued constrained data items. DataItem *d = item->second; const string *value = &sUnavailable; if (d->isCondition()) { value = &sConditionUnavailable; } else if (d->hasConstantValue()) { value = &(d->getConstrainedValues()[0]); } addToBuffer(d, *value, time); if (mDataItemMap.count(d->getId()) == 0) mDataItemMap[d->getId()] = d; else { sLogger << LFATAL << "Duplicate DataItem id " << d->getId() << " for device: " << (*device)->getName() << " and data item name: " << d->getName(); exit(1); } } } } Device *Agent::findDeviceByUUIDorName(const std::string& aId) { Device *device = NULL; std::vector<Device *>::iterator it; for (it = mDevices.begin(); device == NULL && it != mDevices.end(); it++) { if ((*it)->getUuid() == aId || (*it)->getName() == aId) device = *it; } return device; } Agent::~Agent() { delete mSlidingBuffer; delete mSequenceLock; delete mAssetLock; delete mXmlParser; delete[] mCheckpoints; } void Agent::start() { try { // Start all the adapters std::vector<Adapter*>::iterator iter; for (iter = mAdapters.begin(); iter != mAdapters.end(); iter++) { (*iter)->start(); } // Start the server. This blocks until the server stops. server_http::start(); } catch (dlib::socket_error &e) { sLogger << LFATAL << "Cannot start server: " << e.what(); exit(1); } } void Agent::clear() { // Stop all adapter threads... std::vector<Adapter *>::iterator iter; sLogger << LINFO << "Shutting down adapters"; // Deletes adapter and waits for it to exit. for (iter = mAdapters.begin(); iter != mAdapters.end(); iter++) { (*iter)->stop(); } sLogger << LINFO << "Shutting down server"; server::http_1a::clear(); sLogger << LINFO << "Shutting completed"; for (iter = mAdapters.begin(); iter != mAdapters.end(); iter++) { delete (*iter); } mAdapters.clear(); } // Register a file void Agent::registerFile(const string &aUri, const string &aPath) { try { directory dir(aPath); queue<file>::kernel_1a files; dir.get_files(files); files.reset(); string baseUri = aUri; if (*baseUri.rbegin() != '/') baseUri.append(1, '/'); while (files.move_next()) { file &file = files.element(); string name = file.name(); string uri = baseUri + name; mFileMap.insert(pair<string,string>(uri, file.full_name())); // Check if the file name maps to a standard MTConnect schema file. if (name.find("MTConnect") == 0 && name.substr(name.length() - 4, 4) == ".xsd" && XmlPrinter::getSchemaVersion() == name.substr(name.length() - 7, 3)) { string version = name.substr(name.length() - 7, 3); if (name.substr(9, 5) == "Error") { string urn = "urn:mtconnect.org:MTConnectError:" + XmlPrinter::getSchemaVersion(); XmlPrinter::addErrorNamespace(urn, uri, "m"); } else if (name.substr(9, 7) == "Devices") { string urn = "urn:mtconnect.org:MTConnectDevices:" + XmlPrinter::getSchemaVersion(); XmlPrinter::addDevicesNamespace(urn, uri, "m"); } else if (name.substr(9, 6) == "Assets") { string urn = "urn:mtconnect.org:MTConnectAssets:" + XmlPrinter::getSchemaVersion(); XmlPrinter::addAssetsNamespace(urn, uri, "m"); } else if (name.substr(9, 7) == "Streams") { string urn = "urn:mtconnect.org:MTConnectStreams:" + XmlPrinter::getSchemaVersion(); XmlPrinter::addStreamsNamespace(urn, uri, "m"); } } } } catch (directory::dir_not_found e) { sLogger << LDEBUG << "registerFile: Path " << aPath << " is not a directory: " << e.what() << ", trying as a file"; try { file file(aPath); mFileMap.insert(pair<string,string>(aUri, aPath)); } catch (file::file_not_found e) { sLogger << LERROR << "Cannot register file: " << aPath << ": " << e.what(); } } } // Methods for service const string Agent::on_request (const incoming_things& incoming, outgoing_things& outgoing) { string result; outgoing.headers["Content-Type"] = "text/xml"; try { sLogger << LDEBUG << "Request: " << incoming.request_type << " " << incoming.path << " from " << incoming.foreign_ip << ":" << incoming.foreign_port; if (mPutEnabled) { if ((incoming.request_type == "PUT" || incoming.request_type == "POST") && !mPutAllowedHosts.empty() && mPutAllowedHosts.count(incoming.foreign_ip) == 0) { return printError("UNSUPPORTED", "HTTP PUT is not allowed from " + incoming.foreign_ip); } if (incoming.request_type != "GET" && incoming.request_type != "PUT" && incoming.request_type != "POST") { return printError("UNSUPPORTED", "Only the HTTP GET and PUT requests are supported"); } } else { if (incoming.request_type != "GET") { return printError("UNSUPPORTED", "Only the HTTP GET request is supported"); } } // Parse the URL path looking for '/' string path = incoming.path; size_t qm = path.find_last_of('?'); if (qm != string::npos) path = path.substr(0, qm); if (isFile(path)) { return handleFile(path, outgoing); } string::size_type loc1 = path.find("/", 1); string::size_type end = (path[path.length()-1] == '/') ? path.length() - 1 : string::npos; string first = path.substr(1, loc1-1); string call, device; if (first == "assets" || first == "asset") { string list; if (loc1 != string::npos) list = path.substr(loc1 + 1); if (incoming.request_type == "GET") result = handleAssets(*outgoing.out, incoming.queries, list); else result = storeAsset(*outgoing.out, incoming.queries, list, incoming.body); } else { // If a '/' was found if (loc1 < end) { // Look for another '/' string::size_type loc2 = path.find("/", loc1+1); if (loc2 == end) { device = first; call = path.substr(loc1+1, loc2-loc1-1); } else { // Path is too long return printError("UNSUPPORTED", "The following path is invalid: " + path); } } else { // Try to handle the call call = first; } if (incoming.request_type == "GET") result = handleCall(*outgoing.out, path, incoming.queries, call, device); else result = handlePut(*outgoing.out, path, incoming.queries, call, device); } } catch (exception & e) { printError("SERVER_EXCEPTION",(string) e.what()); } return result; } Adapter * Agent::addAdapter(const string& aDeviceName, const string& aHost, const unsigned int aPort, bool aStart, int aLegacyTimeout ) { Adapter *adapter = new Adapter(aDeviceName, aHost, aPort, aLegacyTimeout); adapter->setAgent(*this); mAdapters.push_back(adapter); Device *dev = mDeviceMap[aDeviceName]; if (dev != NULL && dev->mAvailabilityAdded) adapter->setAutoAvailable(true); if (aStart) adapter->start(); return adapter; } unsigned int Agent::addToBuffer(DataItem *dataItem, const string& value, string time ) { if (dataItem == NULL) return 0; dlib::auto_mutex lock(*mSequenceLock); uint64_t seqNum = mSequence++; ComponentEvent *event = new ComponentEvent(*dataItem, seqNum, time, value); (*mSlidingBuffer)[seqNum] = event; mLatest.addComponentEvent(event); event->unrefer(); // Special case for the first event in the series to prime the first checkpoint. if (seqNum == 1) { mFirst.addComponentEvent(event); } // Checkpoint management int index = mSlidingBuffer->get_element_id(seqNum); if (mCheckpointCount > 0 && index % mCheckpointFreq == 0) { // Copy the checkpoint from the current into the slot mCheckpoints[index / mCheckpointFreq].copy(mLatest); } // See if the next sequence has an event. If the event exists it // should be added to the first checkpoint. if ((*mSlidingBuffer)[mSequence] != NULL) { // Keep the last checkpoint up to date with the last. mFirst.addComponentEvent((*mSlidingBuffer)[mSequence]); } dataItem->signalObservers(seqNum); return seqNum; } bool Agent::addAsset(Device *aDevice, const string &aId, const string &aAsset, const string &aType, const string &aTime) { // Check to make sure the values are present if (aType.empty() || aAsset.empty() || aId.empty()) { sLogger << LWARN << "Asset '" << aId << "' missing required type, id, or body. Asset is rejected."; return false; } string time; if (aTime.empty()) time = getCurrentTime(GMT_UV_SEC); else time = aTime; AssetPtr ptr; // Lock the asset addition to protect from multithreaded collisions. Releaes // before we add the event so we don't cause a race condition. { dlib::auto_mutex lock(*mAssetLock); try { ptr = mXmlParser->parseAsset(aId, aType, aAsset); } catch (runtime_error &e) { sLogger << LERROR << "addAsset: Error parsing asset: " << aAsset << "\n" << e.what(); return false; } if (ptr.getObject() == NULL) { sLogger << LERROR << "addAssete: Error parsing asset"; return false; } AssetPtr *old = &mAssetMap[aId]; if (!ptr->isRemoved()) { if (old->getObject() != NULL) mAssets.remove(old); else mAssetCounts[aType] += 1; } else if (old->getObject() == NULL) { sLogger << LWARN << "Cannot remove non-existent asset"; return false; } if (ptr.getObject() == NULL) { sLogger << LWARN << "Asset could not be created"; return false; } else { ptr->setAssetId(aId); ptr->setTimestamp(time); ptr->setDeviceUuid(aDevice->getUuid()); } // Check for overflow if (mAssets.size() >= mMaxAssets) { AssetPtr oldref(*mAssets.front()); mAssetCounts[oldref->getType()] -= 1; mAssets.pop_front(); mAssetMap.erase(oldref->getAssetId()); // Remove secondary keys AssetKeys &keys = oldref->getKeys(); AssetKeys::iterator iter; for (iter = keys.begin(); iter != keys.end(); iter++) { AssetIndex &index = mAssetIndices[iter->first]; index.erase(iter->second); } } mAssetMap[aId] = ptr; if (!ptr->isRemoved()) { AssetPtr &newPtr = mAssetMap[aId]; mAssets.push_back(&newPtr); } // Add secondary keys AssetKeys &keys = ptr->getKeys(); AssetKeys::iterator iter; for (iter = keys.begin(); iter != keys.end(); iter++) { AssetIndex &index = mAssetIndices[iter->first]; index[iter->second] = ptr; } } // Generate an asset chnaged event. if (ptr->isRemoved()) addToBuffer(aDevice->getAssetRemoved(), aType + "|" + aId, time); else addToBuffer(aDevice->getAssetChanged(), aType + "|" + aId, time); return true; } bool Agent::updateAsset(Device *aDevice, const std::string &aId, AssetChangeList &aList, const string &aTime) { AssetPtr asset; string time; if (aTime.empty()) time = getCurrentTime(GMT_UV_SEC); else time = aTime; { dlib::auto_mutex lock(*mAssetLock); asset = mAssetMap[aId]; if (asset.getObject() == NULL) return false; if (asset->getType() != "CuttingTool" && asset->getType() != "CuttingToolArchitype") return false; CuttingToolPtr tool((CuttingTool*) asset.getObject()); try { AssetChangeList::iterator iter; for (iter = aList.begin(); iter != aList.end(); ++iter) { if (iter->first == "xml") { mXmlParser->updateAsset(asset, asset->getType(), iter->second); } else { tool->updateValue(iter->first, iter->second); } } } catch (runtime_error &e) { sLogger << LERROR << "updateAsset: Error parsing asset: " << asset << "\n" << e.what(); return false; } // Move it to the front of the queue mAssets.remove(&asset); mAssets.push_back(&asset); tool->setTimestamp(time); tool->setDeviceUuid(aDevice->getUuid()); tool->changed(); } addToBuffer(aDevice->getAssetChanged(), asset->getType() + "|" + aId, time); return true; } bool Agent::removeAsset(Device *aDevice, const std::string &aId, const string &aTime) { AssetPtr asset; string time; if (aTime.empty()) time = getCurrentTime(GMT_UV_SEC); else time = aTime; { dlib::auto_mutex lock(*mAssetLock); asset = mAssetMap[aId]; if (asset.getObject() == NULL) return false; asset->setRemoved(true); asset->setTimestamp(time); // Check if the asset changed id is the same as this asset. ComponentEventPtr *ptr = mLatest.getEventPtr(aDevice->getAssetChanged()->getId()); if (ptr != NULL && (*ptr)->getValue() == aId) { addToBuffer(aDevice->getAssetChanged(), asset->getType() + "|UNAVAILABLE", time); } } addToBuffer(aDevice->getAssetRemoved(), asset->getType() + "|" + aId, time); return true; } bool Agent::removeAllAssets(Device *aDevice, const std::string &aType, const std::string &aTime) { string time; if (aTime.empty()) time = getCurrentTime(GMT_UV_SEC); else time = aTime; { dlib::auto_mutex lock(*mAssetLock); ComponentEventPtr *ptr = mLatest.getEventPtr(aDevice->getAssetChanged()->getId()); string changedId; if (ptr != NULL) changedId = (*ptr)->getValue(); list<AssetPtr*>::reverse_iterator iter; for (iter = mAssets.rbegin(); iter != mAssets.rend(); ++iter) { AssetPtr asset = (**iter); if (aType == asset->getType() && !asset->isRemoved()) { asset->setRemoved(true); asset->setTimestamp(time); addToBuffer(aDevice->getAssetRemoved(), asset->getType() + "|" + asset->getAssetId(), time); if (changedId == asset->getAssetId()) addToBuffer(aDevice->getAssetChanged(), asset->getType() + "|UNAVAILABLE", time); } } } return true; } /* Add values for related data items UNAVAILABLE */ void Agent::disconnected(Adapter *anAdapter, std::vector<Device*> aDevices) { string time = getCurrentTime(GMT_UV_SEC); sLogger << LDEBUG << "Disconnected from adapter, setting all values to UNAVAILABLE"; std::vector<Device*>::iterator iter; for (iter = aDevices.begin(); iter != aDevices.end(); ++iter) { const std::map<std::string, DataItem *> &dataItems = (*iter)->getDeviceDataItems(); std::map<std::string, DataItem*>::const_iterator dataItemAssoc; for (dataItemAssoc = dataItems.begin(); dataItemAssoc != dataItems.end(); ++dataItemAssoc) { DataItem *dataItem = (*dataItemAssoc).second; if (dataItem != NULL && (dataItem->getDataSource() == anAdapter || (anAdapter->isAutoAvailable() && dataItem->getDataSource() == NULL && dataItem->getType() == "AVAILABILITY"))) { ComponentEventPtr *ptr = mLatest.getEventPtr(dataItem->getId()); if (ptr != NULL) { const string *value = NULL; if (dataItem->isCondition()) { if ((*ptr)->getLevel() != ComponentEvent::UNAVAILABLE) value = &sConditionUnavailable; } else if (dataItem->hasConstraints()) { std::vector<std::string> &values = dataItem->getConstrainedValues(); if (values.size() > 1 && (*ptr)->getValue() != sUnavailable) value = &sUnavailable; } else if ((*ptr)->getValue() != sUnavailable) { value = &sUnavailable; } if (value != NULL && !anAdapter->isDuplicate(dataItem, *value, NAN)) addToBuffer(dataItem, *value, time); } } else if (dataItem == NULL) { sLogger << LWARN << "No data Item for " << (*dataItemAssoc).first; } } } } void Agent::connected(Adapter *anAdapter, std::vector<Device*> aDevices) { if (anAdapter->isAutoAvailable()) { string time = getCurrentTime(GMT_UV_SEC); std::vector<Device*>::iterator iter; for (iter = aDevices.begin(); iter != aDevices.end(); ++iter) { sLogger << LDEBUG << "Connected to adapter, setting all Availability data items to AVAILABLE"; if ((*iter)->getAvailability() != NULL) { sLogger << LDEBUG << "Adding availabilty event for " << (*iter)->getAvailability()->getId(); addToBuffer((*iter)->getAvailability(), sAvailable, time); } else { sLogger << LDEBUG << "Cannot find availability for " << (*iter)->getName(); } } } } /* Agent protected methods */ string Agent::handleCall(ostream& out, const string& path, const key_value_map& queries, const string& call, const string& device) { try { string deviceName; if (!device.empty()) { deviceName = device; } if (call == "current") { const string path = queries[(string) "path"]; string result; int freq = checkAndGetParam(queries, "frequency", NO_FREQ, FASTEST_FREQ, false,SLOWEST_FREQ); // Check for 1.2 conversion to interval if (freq == NO_FREQ) freq = checkAndGetParam(queries, "interval", NO_FREQ, FASTEST_FREQ, false, SLOWEST_FREQ); uint64_t at = checkAndGetParam64(queries, "at", NO_START, getFirstSequence(), true, mSequence - 1); int heartbeat = checkAndGetParam(queries, "heartbeat", 10000, 10, true, 600000); if (freq != NO_FREQ && at != NO_START) { return printError("INVALID_REQUEST", "You cannot specify both the at and frequency arguments to a current request"); } return handleStream(out, devicesAndPath(path, deviceName), true, freq, at, 0, heartbeat); } else if (call == "probe" || call.empty()) { return handleProbe(deviceName); } else if (call == "sample") { string path = queries[(string) "path"]; string result; int count = checkAndGetParam(queries, "count", DEFAULT_COUNT, 1, true, mSlidingBufferSize); int freq = checkAndGetParam(queries, "frequency", NO_FREQ, FASTEST_FREQ, false, SLOWEST_FREQ); // Check for 1.2 conversion to interval if (freq == NO_FREQ) freq = checkAndGetParam(queries, "interval", NO_FREQ, FASTEST_FREQ, false, SLOWEST_FREQ); uint64 start = checkAndGetParam64(queries, "start", NO_START, getFirstSequence(), true, mSequence); if (start == NO_START) // If there was no data in queries { start = checkAndGetParam64(queries, "from", 1, getFirstSequence(), true, mSequence); } int heartbeat = checkAndGetParam(queries, "heartbeat", 10000, 10, true, 600000); return handleStream(out, devicesAndPath(path, deviceName), false, freq, start, count, heartbeat); } else if ((mDeviceMap[call] != NULL) && device.empty()) { return handleProbe(call); } else { return printError("UNSUPPORTED", "The following path is invalid: " + path); } } catch (ParameterError &aError) { return printError(aError.mCode, aError.mMessage); } } /* Agent protected methods */ string Agent::handlePut( ostream& out, const string& path, const key_value_map& queries, const string& adapter, const string& deviceName ) { string device = deviceName; if (device.empty() && adapter.empty()) { return printError("UNSUPPORTED", "Device must be specified for PUT"); } else if (device.empty()) { device = adapter; } Device *dev = mDeviceMap[device]; if (dev == NULL) { string message = ((string) "Cannot find device: ") + device; return printError("UNSUPPORTED", message); } // First check if this is an adapter put or a data put... if (queries["_type"] == "command") { std::vector<Adapter*>::iterator adpt; for (adpt = dev->mAdapters.begin(); adpt != dev->mAdapters.end(); adpt++) { key_value_map::const_iterator kv; for (kv = queries.begin(); kv != queries.end(); kv++) { string command = kv->first + "=" + kv->second; sLogger << LDEBUG << "Sending command '" << command << "' to " << device; (*adpt)->sendCommand(command); } } } else { string time = queries["time"]; if (time.empty()) time = getCurrentTime(GMT_UV_SEC); key_value_map::const_iterator kv; for (kv = queries.begin(); kv != queries.end(); kv++) { if (kv->first != "time") { DataItem *di = dev->getDeviceDataItem(kv->first); if (di != NULL) addToBuffer(di, kv->second, time); else sLogger << LWARN << "(" << device << ") Could not find data item: " << kv->first; } } } return "<success/>"; } string Agent::handleProbe(const string& name) { std::vector<Device *> mDeviceList; if (!name.empty()) { Device * device = getDeviceByName(name); if (device == NULL) { return printError("NO_DEVICE", "Could not find the device '" + name + "'"); } else { mDeviceList.push_back(device); } } else { mDeviceList = mDevices; } return XmlPrinter::printProbe(mInstanceId, mSlidingBufferSize, mSequence, mMaxAssets, mAssets.size(), mDeviceList, &mAssetCounts); } string Agent::handleStream( ostream& out, const string& path, bool current, unsigned int frequency, uint64_t start, unsigned int count, unsigned int aHb ) { std::set<string> filter; try { mXmlParser->getDataItems(filter, path); } catch (exception& e) { return printError("INVALID_XPATH", e.what()); } if (filter.empty()) { return printError("INVALID_XPATH", "The path could not be parsed. Invalid syntax: " + path); } // Check if there is a frequency to stream data or not if (frequency != (unsigned) NO_FREQ) { streamData(out, filter, current, frequency, start, count, aHb); return ""; } else { uint64_t end; bool endOfBuffer; if (current) return fetchCurrentData(filter, start); else return fetchSampleData(filter, start, count, end, endOfBuffer); } } std::string Agent::handleAssets(std::ostream& aOut, const key_value_map& aQueries, const std::string& aList) { using namespace dlib; std::vector<AssetPtr> assets; if (!aList.empty()) { auto_mutex lock(*mAssetLock); istringstream str(aList); tokenizer_kernel_1 tok; tok.set_stream(str); tok.set_identifier_token(tok.lowercase_letters() + tok.uppercase_letters() + tok.numbers() + "_.@$%&^:+-_=", tok.lowercase_letters() + tok.uppercase_letters() + tok.numbers() + "_.@$%&^:+-_="); int type; string token; for (tok.get_token(type, token); type != tok.END_OF_FILE; tok.get_token(type, token)) { if (type == tok.IDENTIFIER) { AssetPtr ptr = mAssetMap[token]; if (ptr.getObject() == NULL) return XmlPrinter::printError(mInstanceId, 0, 0, "ASSET_NOT_FOUND", (string) "Could not find asset: " + token); assets.push_back(ptr); } } } else { auto_mutex lock(*mAssetLock); // Return all asssets, first check if there is a type attribute string type = aQueries["type"]; bool removed = (aQueries.count("removed") > 0 && aQueries["removed"] == "true"); int count = checkAndGetParam(aQueries, "count", mAssets.size(), 1, false, NO_VALUE32); list<AssetPtr*>::reverse_iterator iter; for (iter = mAssets.rbegin(); iter != mAssets.rend() && count > 0; ++iter, --count) { if ((type.empty() || type == (**iter)->getType()) && (removed || !(**iter)->isRemoved())) { assets.push_back(**iter); } } } return XmlPrinter::printAssets(mInstanceId, mMaxAssets, mAssets.size(), assets); } // Store an asset in the map by asset # and use the circular buffer as // an LRU. Check if we're removing an existing asset and clean up the // map, and then store this asset. std::string Agent::storeAsset(std::ostream& aOut, const key_value_map& aQueries, const std::string& aId, const std::string& aBody) { string name = aQueries["device"]; string type = aQueries["type"]; Device *device = NULL; if (!name.empty()) device = mDeviceMap[name]; // If the device was not found or was not provided, use the default device. if (device == NULL) device = mDevices[0]; if (addAsset(device, aId, aBody, type)) return "<success/>"; else return "<failure/>"; } string Agent::handleFile(const string &aUri, outgoing_things& aOutgoing) { // Get the mime type for the file. bool unknown = true; size_t last = aUri.find_last_of("./"); string contentType; if (last != string::npos && aUri[last] == '.') { string ext = aUri.substr(last + 1); if (mMimeTypes.count(ext) > 0) { contentType = mMimeTypes[ext]; unknown = false; } } if (unknown) contentType = "application/octet-stream"; // Check if the file is cached RefCountedPtr<CachedFile> cachedFile; std::map<string, RefCountedPtr<CachedFile> >::iterator cached = mFileCache.find(aUri); if (cached != mFileCache.end()) cachedFile = cached->second; else { std::map<string,string>::iterator file = mFileMap.find(aUri); // Should never happen if (file == mFileMap.end()) { aOutgoing.http_return = 404; aOutgoing.http_return_status = "File not found"; return ""; } const char *path = file->second.c_str(); struct stat fs; int res = stat(path, &fs); if (res != 0) { aOutgoing.http_return = 404; aOutgoing.http_return_status = "File not found"; return ""; } int fd = open(path, O_RDONLY | O_BINARY); if (res < 0) { aOutgoing.http_return = 404; aOutgoing.http_return_status = "File not found"; return ""; } cachedFile.setObject(new CachedFile(fs.st_size), true); int bytes = read(fd, cachedFile->mBuffer, fs.st_size); close(fd); if (bytes < fs.st_size) { aOutgoing.http_return = 404; aOutgoing.http_return_status = "File not found"; return ""; } // If this is a small file, cache it. if (bytes <= SMALL_FILE) { mFileCache.insert(pair<string, RefCountedPtr<CachedFile> >(aUri, cachedFile)); } } (*aOutgoing.out) << "HTTP/1.1 200 OK\r\n" "Date: " << getCurrentTime(HUM_READ) << "\r\n" "Server: MTConnectAgent\r\n" "Connection: close\r\n" "Content-Length: " << cachedFile->mSize << "\r\n" "Expires: " << getCurrentTime(time(NULL) + 60 * 60 * 24, 0, HUM_READ) << "\r\n" "Content-Type: " << contentType << "\r\n\r\n"; aOutgoing.out->write(cachedFile->mBuffer, cachedFile->mSize); aOutgoing.out->setstate(ios::badbit); return ""; } void Agent::streamData(ostream& out, std::set<string> &aFilter, bool current, unsigned int aInterval, uint64_t start, unsigned int count, unsigned int aHeartbeat ) { // Create header string boundary = md5(intToString(time(NULL))); ofstream log; if (mLogStreamData) { string filename = "Stream_" + getCurrentTime(LOCAL) + "_" + int64ToString((uint64_t) dlib::get_thread_id()) + ".log"; log.open(filename.c_str()); } out << "HTTP/1.1 200 OK\r\n" "Date: " << getCurrentTime(HUM_READ) << "\r\n" "Server: MTConnectAgent\r\n" "Expires: -1\r\n" "Connection: close\r\n" "Cache-Control: private, max-age=0\r\n" "Content-Type: multipart/x-mixed-replace;boundary=" << boundary << "\r\n" "Transfer-Encoding: chunked\r\n\r\n"; // This object will automatically clean up all the observer from the // signalers in an exception proof manor. ChangeObserver observer; // Add observers std::set<string>::iterator iter; for (iter = aFilter.begin(); iter != aFilter.end(); ++iter) mDataItemMap[*iter]->addObserver(&observer); uint64_t interMicros = aInterval * 1000; uint64_t firstSeq = getFirstSequence(); if (start < firstSeq) start = firstSeq; try { // Loop until the user closes the connection timestamper ts; while (out.good()) { // Remember when we started this grab... uint64_t last = ts.get_timestamp(); // Fetch sample data now resets the observer while holding the sequence // mutex to make sure that a new event will be recorded in the observer // when it returns. string content; uint64_t end; bool endOfBuffer = true; if (current) { content = fetchCurrentData(aFilter, NO_START); } else { // Check if we're falling too far behind. If we are, generate an // MTConnectError and return. if (start < getFirstSequence()) { sLogger << LWARN << "Client fell too far behind, disconnecting"; throw ParameterError("OUT_OF_RANGE", "Client can't keep up with event stream, disconnecting"); } else { // end and endOfBuffer are set during the fetch sample data while the // mutex is held. This removed the race to check if we are at the end of // the bufffer and setting the next start to the last sequence number // sent. content = fetchSampleData(aFilter, start, count, end, endOfBuffer, &observer); } if (mLogStreamData) log << content << endl; } ostringstream str; // Make sure we're terminated with a <cr><nl> content.append("\r\n"); out.setf(ios::dec, ios::basefield); str << "--" << boundary << "\r\n" "Content-type: text/xml\r\n" "Content-length: " << content.length() << "\r\n\r\n" << content; string chunk = str.str(); out.setf(ios::hex, ios::basefield); out << chunk.length() << "\r\n"; out << chunk << "\r\n"; out.flush(); // Wait for up to frequency ms for something to arrive... Don't wait if // we are not at the end of the buffer. Just put the next set after aInterval // has elapsed. Check also if in the intervening time between the last fetch // and now. If so, we just spin through and wait the next interval. // Even if we are at the end of the buffer, or within range. If we are filtering, // we will need to make sure we are not spinning when there are no valid events // to be reported. we will waste cycles spinning on the end of the buffer when // we should be in a heartbeat wait as well. if (!endOfBuffer) { // If we're not at the end of the buffer, move to the end of the previous set and // begin filtering from where we left off. start = end; // For replaying of events, we will stream as fast as we can with a 1ms sleep // to allow other threads to run. dlib::sleep(1); } else { uint64 delta; if (!current) { // Busy wait to make sure the signal was actually signaled. We have observed that // a signal can occur in rare conditions where there are multiple threads listening // on separate condition variables and this pops out too soon. This will make sure // observer was actually signaled and instead of throwing an error will wait again // for the remaining hartbeat interval. delta = (ts.get_timestamp() - last) / 1000; while (delta < aHeartbeat && observer.wait(aHeartbeat - delta) && !observer.wasSignaled()) { delta = (ts.get_timestamp() - last) / 1000; } { dlib::auto_mutex lock(*mSequenceLock); // Make sure the observer was signaled! if (!observer.wasSignaled()) { // If nothing came out during the last wait, we may have still have advanced // the sequence number. We should reset the start to something closer to the // current sequence. If we lock the sequence lock, we can check if the observer // was signaled between the time the wait timed out and the mutex was locked. // Otherwise, nothing has arrived and we set to the next sequence number to // the next sequence number to be allocated and continue. start = mSequence; } else { // Get the sequence # signaled in the observer when the earliest event arrived. // This will allow the next set of data to be pulled. Any later events will have // greater sequence numbers, so this should not cause a problem. Also, signaled // sequence numbers can only decrease, never increase. start = observer.getSequence(); } } } // Now wait the remainder if we triggered before the timer was up. delta = ts.get_timestamp() - last; if (delta < interMicros) { // Sleep the remainder dlib::sleep((interMicros - delta) / 1000); } } } } catch (ParameterError &aError) { sLogger << LINFO << "Caught a parameter error."; if (out.good()) { ostringstream str; string content = printError(aError.mCode, aError.mMessage); str << "--" << boundary << "\r\n" "Content-type: text/xml\r\n" "Content-length: " << content.length() << "\r\n\r\n" << content; string chunk = str.str(); out.setf(ios::hex, ios::basefield); out << chunk.length() << "\r\n"; out << chunk << "\r\n"; out.flush(); } } catch (...) { sLogger << LWARN << "Error occurred during streaming data"; if (out.good()) { ostringstream str; string content = printError("INTERNAL_ERROR", "Unknown error occurred during streaming"); str << "--" << boundary << "\r\n" "Content-type: text/xml\r\n" "Content-length: " << content.length() << "\r\n\r\n" << content; string chunk = str.str(); out.setf(ios::hex, ios::basefield); out << chunk.length() << "\r\n"; out << chunk; out.flush(); } } out.setstate(ios::badbit); // Observer is auto removed from signalers } string Agent::fetchCurrentData(std::set<string> &aFilter, uint64_t at) { ComponentEventPtrArray events; uint64_t firstSeq, seq; { dlib::auto_mutex lock(*mSequenceLock); firstSeq = getFirstSequence(); seq = mSequence; if (at == NO_START) { mLatest.getComponentEvents(events, &aFilter); } else { long pos = (long) mSlidingBuffer->get_element_id(at); long first = (long) mSlidingBuffer->get_element_id(firstSeq); long checkIndex = pos / mCheckpointFreq; long closestCp = checkIndex * mCheckpointFreq; unsigned long index; Checkpoint *ref; // Compute the closest checkpoint. If the checkpoint is after the // first checkpoint and before the next incremental checkpoint, // use first. if (first > closestCp && pos >= first) { ref = &mFirst; // The checkpoint is inclusive of the "first" event. So we add one // so we don't duplicate effort. index = first + 1; } else { index = closestCp + 1; ref = &mCheckpoints[checkIndex]; } Checkpoint check(*ref, &aFilter); // Roll forward from the checkpoint. for (; index <= (unsigned long) pos; index++) { check.addComponentEvent(((*mSlidingBuffer)[(unsigned long)index]).getObject()); } check.getComponentEvents(events); } } string toReturn = XmlPrinter::printSample(mInstanceId, mSlidingBufferSize, seq, firstSeq, mSequence - 1, events); return toReturn; } string Agent::fetchSampleData(std::set<string> &aFilter, uint64_t start, unsigned int count, uint64_t &end, bool &endOfBuffer, ChangeObserver *aObserver) { ComponentEventPtrArray results; uint64_t firstSeq; { dlib::auto_mutex lock(*mSequenceLock); firstSeq = (mSequence > mSlidingBufferSize) ? mSequence - mSlidingBufferSize : 1; // START SHOULD BE BETWEEN 0 AND SEQUENCE NUMBER start = (start <= firstSeq) ? firstSeq : start; uint64_t i; for (i = start; results.size() < count && i < mSequence; i++) { // Filter out according to if it exists in the list const string &dataId = (*mSlidingBuffer)[i]->getDataItem()->getId(); if (aFilter.count(dataId) > 0) { ComponentEventPtr event = (*mSlidingBuffer)[i]; results.push_back(event); } } end = i; if (i >= mSequence) endOfBuffer = true; else endOfBuffer = false; if (aObserver != NULL) aObserver->reset(); } return XmlPrinter::printSample(mInstanceId, mSlidingBufferSize, end, firstSeq, mSequence - 1, results); } string Agent::printError(const string& errorCode, const string& text) { sLogger << LDEBUG << "Returning error " << errorCode << ": " << text; return XmlPrinter::printError(mInstanceId, mSlidingBufferSize, mSequence, errorCode, text); } string Agent::devicesAndPath(const string& path, const string& device) { string dataPath = ""; if (!device.empty()) { string prefix = "//Devices/Device[@name=\"" + device + "\"]"; if (!path.empty()) { istringstream toParse(path); string token; // Prefix path (i.e. "path1|path2" => "{prefix}path1|{prefix}path2") while (getline(toParse, token, '|')) { dataPath += prefix + token + "|"; } dataPath.erase(dataPath.length()-1); } else { dataPath = prefix; } } else { dataPath = (!path.empty()) ? path : "//Devices/Device"; } return dataPath; } int Agent::checkAndGetParam(const key_value_map& queries, const string& param, const int defaultValue, const int minValue, bool minError, const int maxValue) { if (queries.count(param) == 0) { return defaultValue; } if (queries[param].empty()) { throw ParameterError("QUERY_ERROR", "'" + param + "' cannot be empty."); } if (!isNonNegativeInteger(queries[param])) { throw ParameterError("OUT_OF_RANGE", "'" + param + "' must be a positive integer."); } long int value = strtol(queries[param].c_str(), NULL, 10); if (minValue != NO_VALUE32 && value < minValue) { if (minError) { throw ParameterError("OUT_OF_RANGE", "'" + param + "' must be greater than or equal to " + intToString(minValue) + "."); } return minValue; } if (maxValue != NO_VALUE32 && value > maxValue) { throw ParameterError("OUT_OF_RANGE", "'" + param + "' must be less than or equal to " + intToString(maxValue) + "."); } return value; } uint64_t Agent::checkAndGetParam64(const key_value_map& queries, const string& param, const uint64_t defaultValue, const uint64_t minValue, bool minError, const uint64_t maxValue) { if (queries.count(param) == 0) { return defaultValue; } if (queries[param].empty()) { throw ParameterError("QUERY_ERROR", "'" + param + "' cannot be empty."); } if (!isNonNegativeInteger(queries[param])) { throw ParameterError("OUT_OF_RANGE", "'" + param + "' must be a positive integer."); } uint64_t value = strtoull(queries[param].c_str(), NULL, 10); if (minValue != NO_VALUE64 && value < minValue) { if (minError) { throw ParameterError("OUT_OF_RANGE", "'" + param + "' must be greater than or equal to " + int64ToString(minValue) + "."); } return minValue; } if (maxValue != NO_VALUE64 && value > maxValue) { throw ParameterError("OUT_OF_RANGE", "'" + param + "' must be less than or equal to " + int64ToString(maxValue) + "."); } return value; } DataItem * Agent::getDataItemByName(const string& device, const string& name) { Device *dev = mDeviceMap[device]; return (dev) ? dev->getDeviceDataItem(name) : NULL; } void Agent::updateDom(Device *aDevice) { mXmlParser->updateDevice(aDevice); }
31.232868
124
0.572639
MatthewPowley
80eb98790843ae825cc31caf05545e7d7fc50507
1,382
hpp
C++
src/frontmatter/frontmatter.hpp
foo-dogsquared/automate-md
c278c7ab93d34da198ce409556a8e2df287f4b17
[ "MIT" ]
4
2018-09-29T17:00:16.000Z
2022-01-23T14:53:04.000Z
src/frontmatter/frontmatter.hpp
foo-dogsquared/automate-md
c278c7ab93d34da198ce409556a8e2df287f4b17
[ "MIT" ]
5
2018-11-06T15:45:17.000Z
2018-12-11T13:39:31.000Z
src/frontmatter/frontmatter.hpp
foo-dogsquared/automate-md
c278c7ab93d34da198ce409556a8e2df287f4b17
[ "MIT" ]
null
null
null
#include <map> #include <regex> #define MAX_ARR_LENGTH 16 #define MAX_DATE_LENGTH 26 #define MAX_TITLE_LENGTH 64 #define MAX_AUTHOR_LENGTH 32 typedef struct _frontmatter { std::map<std::string, std::string> list; int categories_length; int tags_length; std::string type; std::string __open_divider; std::string __close_divider; std::string __tab; std::string __assigner; std::string __space; } frontmatter; static void init_fm_format_data(frontmatter &__fm) { if (__fm.type == "YAML" || __fm.type == "yaml") { __fm.__open_divider = "---"; __fm.__close_divider = "---"; __fm.__tab = ""; __fm.__assigner = ":"; __fm.__space = ""; } else if (__fm.type == "TOML" || __fm.type == "toml") { __fm.__open_divider = "+++"; __fm.__close_divider = "+++"; __fm.__tab = ""; __fm.__assigner = "="; __fm.__space = " "; } else if (__fm.type == "JSON" || __fm.type == "json") { __fm.__open_divider = "{"; __fm.__close_divider = "}"; __fm.__tab = "\t"; __fm.__assigner = ":"; __fm.__space = ""; } } static std::string detect_type(std::string __str) { std::regex __YAML("---\\s*"), __TOML("\\+\\+\\+\\s*"), __JSON("\\{\\s*|\\}\\s*"); if (std::regex_match(__str, __YAML)) return "YAML"; else if (std::regex_match(__str, __TOML)) return "TOML"; else if (std::regex_match(__str, __JSON)) return "JSON"; else return nullptr; }
23.827586
82
0.631693
foo-dogsquared
80ed2ad5b3adb1be832fa47ad9ed66fd518e0574
4,219
hpp
C++
src/base/interpolator/Interpolator.hpp
rockstorm101/GMAT
00b6b61a40560c095da3d83dab4ab1e9157f01c7
[ "Apache-2.0" ]
1
2018-09-18T07:09:36.000Z
2018-09-18T07:09:36.000Z
src/base/interpolator/Interpolator.hpp
rockstorm101/GMAT
00b6b61a40560c095da3d83dab4ab1e9157f01c7
[ "Apache-2.0" ]
null
null
null
src/base/interpolator/Interpolator.hpp
rockstorm101/GMAT
00b6b61a40560c095da3d83dab4ab1e9157f01c7
[ "Apache-2.0" ]
2
2020-06-18T04:45:30.000Z
2021-07-20T02:11:54.000Z
//$Id$ //------------------------------------------------------------------------------ // Interpolator //------------------------------------------------------------------------------ // GMAT: General Mission Analysis Tool. // // Copyright (c) 2002 - 2015 United States Government as represented by the // Administrator of the National Aeronautics and Space Administration. // All Other Rights Reserved. // // 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: // 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. // // Developed jointly by NASA/GSFC and Thinking Systems, Inc. under contract // number S-67573-G // // Author: Darrel J. Conway // Created: 2003/09/23 // /** * Definition for the Interpolator base class */ //------------------------------------------------------------------------------ #ifndef Interpolator_hpp #define Interpolator_hpp #include "GmatBase.hpp" /** * Base class for the GMAT Interpolators */ class GMAT_API Interpolator : public GmatBase { public: Interpolator(const std::string &name, const std::string &typestr, Integer dim = 1); virtual ~Interpolator(); Interpolator(const Interpolator &i); Interpolator& operator=(const Interpolator &i); virtual Integer IsInterpolationFeasible(Real ind); virtual void SetForceInterpolation(bool flag); virtual bool GetForceInterpolation(); virtual bool AddPoint(const Real ind, const Real *data); virtual void Clear(); virtual Integer GetBufferSize(); virtual Integer GetPointCount(); //--------------------------------------------------------------------------- // bool Interpolate(const Real ind, Real *results) //--------------------------------------------------------------------------- /** * Interpolate the data. * * Derived classes implement this method to provide the mathematics that * perform the data interpolation, resulint in an array of interpolated data * valid at the desired value of the independent variable. * * @param <ind> Value of the independent variable at which the data is * interpolated. * @param <results> Array of interpolated data. * * @return true on success, false (or throw) on failure. */ //--------------------------------------------------------------------------- virtual bool Interpolate(const Real ind, Real *results) = 0; DEFAULT_TO_NO_CLONES DEFAULT_TO_NO_REFOBJECTS protected: /// Data array used for the independent variable Real *independent; /// The data that gets interpolated Real **dependent; /// Previous independent value, used to determine direction data is going Real previousX; // Parameters /// Number of dependent points to be interpolated Integer dimension; /// Number of points required to interpolate Integer requiredPoints; /// Number of points managed by the interpolator Integer bufferSize; /// Number of points fed to the interpolator Integer pointCount; /// Pointer to most recent point, for the ring buffer implementation Integer latestPoint; /// Valid range for the data points Real range[2]; /// Flag used to detect if range has already been calculated bool rangeCalculated; /// Flag used to determine if independent variable increases or decreases bool dataIncreases; /// Flag used for additional feasiblity checking bool forceInterpolation; virtual void AllocateArrays(); virtual void CleanupArrays(); virtual void CopyArrays(const Interpolator &i); void SetRange(); }; #endif // Interpolator_hpp
35.158333
81
0.604172
rockstorm101
80ee8e5fcad8c9774fabe3dc0d0081079af6ae80
4,849
cc
C++
lite/backends/nnadapter/nnadapter/driver/huawei_ascend_npu/converter/pool2d.cc
ChinaCYong/Paddle-Lite
8d161bd76c86445c42f00421983e389c11323797
[ "Apache-2.0" ]
1
2021-07-12T10:46:19.000Z
2021-07-12T10:46:19.000Z
lite/backends/nnadapter/nnadapter/driver/huawei_ascend_npu/converter/pool2d.cc
fuaq/Paddle-Lite
56e1239410d976842fc6f7792de13c9d007d253f
[ "Apache-2.0" ]
null
null
null
lite/backends/nnadapter/nnadapter/driver/huawei_ascend_npu/converter/pool2d.cc
fuaq/Paddle-Lite
56e1239410d976842fc6f7792de13c9d007d253f
[ "Apache-2.0" ]
null
null
null
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. // // 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 // // 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. #include "driver/huawei_ascend_npu/converter.h" #include "utility/debug.h" #include "utility/logging.h" namespace nnadapter { namespace huawei_ascend_npu { int Program::ConvertPool2D(hal::Operation* operation) { auto& input_operands = operation->input_operands; auto& output_operands = operation->output_operands; auto input_count = input_operands.size(); auto output_count = output_operands.size(); NNADAPTER_CHECK_EQ(input_count, 12); NNADAPTER_CHECK_EQ(output_count, 1); // Input auto input_operand = input_operands[0]; NNADAPTER_VLOG(5) << "input: " << OperandToString(input_operand); // Paddings auto padding_width_left = *reinterpret_cast<int32_t*>(input_operands[1]->buffer); auto padding_width_right = *reinterpret_cast<int32_t*>(input_operands[2]->buffer); auto padding_height_top = *reinterpret_cast<int32_t*>(input_operands[3]->buffer); auto padding_height_bottom = *reinterpret_cast<int32_t*>(input_operands[4]->buffer); NNADAPTER_VLOG(5) << "paddings=[" << padding_width_left << "," << padding_width_right << "," << padding_height_top << "," << padding_height_bottom << "]"; // Strides auto stride_width = *reinterpret_cast<int32_t*>(input_operands[5]->buffer); auto stride_height = *reinterpret_cast<int32_t*>(input_operands[6]->buffer); NNADAPTER_VLOG(5) << "strides=[" << stride_width << "," << stride_height << "]"; // Filter auto filter_width = *reinterpret_cast<int32_t*>(input_operands[7]->buffer); auto filter_height = *reinterpret_cast<int32_t*>(input_operands[8]->buffer); NNADAPTER_VLOG(5) << "filter=[" << filter_width << "," << filter_height << "]"; bool global_pooling = filter_width == input_operand->type.dimensions[3] && filter_height == input_operand->type.dimensions[2]; NNADAPTER_VLOG(5) << "global_pooling=" << global_pooling; // Fuse code auto fuse_code = *reinterpret_cast<int32_t*>(input_operands[9]->buffer); NNADAPTER_VLOG(5) << "fuse_code=" << fuse_code; // Ceil mode bool ceil_mode = *reinterpret_cast<int8_t*>(input_operands[10]->buffer); NNADAPTER_VLOG(5) << "ceil_mode=" << ceil_mode; // Count include pad bool count_include_pad = *reinterpret_cast<int8_t*>(input_operands[11]->buffer); NNADAPTER_VLOG(5) << "count_include_pad=" << count_include_pad; // Output auto output_operand = output_operands[0]; NNADAPTER_VLOG(5) << "output: " << OperandToString(output_operand); // Convert to GE operators auto input_operator = GetMappedOperator(input_operand); if (!input_operator) { input_operator = ConvertOperand(input_operand); } auto pool2d_name = GetOperatorName(output_operand); auto pool2d_op = std::make_shared<ge::op::Pooling>(pool2d_name); if (operation->type == NNADAPTER_AVERAGE_POOL_2D) { pool2d_op->set_attr_mode(1); NNADAPTER_CHECK(!count_include_pad) << "Only count_include_pad=false is " "supported for the pooling type " "'avg' in GE"; } else if (operation->type == NNADAPTER_MAX_POOL_2D) { pool2d_op->set_attr_mode(0); } else { NNADAPTER_LOG(FATAL) << "Unsupported pooling operation type " << OperationTypeToString(operation->type) << " is found."; } pool2d_op->set_attr_global_pooling(global_pooling); pool2d_op->set_attr_window( ge::Operator::OpListInt({filter_height, filter_width})); pool2d_op->set_attr_pad(ge::Operator::OpListInt({padding_height_bottom, padding_height_top, padding_width_right, padding_width_left})); pool2d_op->set_attr_stride( ge::Operator::OpListInt({stride_height, stride_width})); // "0" (ceil mode) or "1" (floor mode). Defaults to "0" if (!ceil_mode) { pool2d_op->set_attr_ceil_mode(1); } SET_INPUT(pool2d_op, x, input_operator); MAP_OUTPUT(pool2d_op, y, output_operand); return NNADAPTER_NO_ERROR; } } // namespace huawei_ascend_npu } // namespace nnadapter
44.081818
78
0.670241
ChinaCYong
80ef0d8a50449bb2b90ce59f752fc9c46bbcd66d
4,254
cpp
C++
Userland/Libraries/LibWeb/Layout/Label.cpp
r00ster91/serenity
f8387dea2689d564aff612bfd4ec5086393fac35
[ "BSD-2-Clause" ]
19,438
2019-05-20T15:11:11.000Z
2022-03-31T23:31:32.000Z
Userland/Libraries/LibWeb/Layout/Label.cpp
r00ster91/serenity
f8387dea2689d564aff612bfd4ec5086393fac35
[ "BSD-2-Clause" ]
7,882
2019-05-20T01:03:52.000Z
2022-03-31T23:26:31.000Z
Userland/Libraries/LibWeb/Layout/Label.cpp
r00ster91/serenity
f8387dea2689d564aff612bfd4ec5086393fac35
[ "BSD-2-Clause" ]
2,721
2019-05-23T00:44:57.000Z
2022-03-31T22:49:34.000Z
/* * Copyright (c) 2021, Tim Flynn <trflynn89@pm.me> * * SPDX-License-Identifier: BSD-2-Clause */ #include <LibGUI/Event.h> #include <LibGfx/Painter.h> #include <LibGfx/StylePainter.h> #include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Element.h> #include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Label.h> #include <LibWeb/Layout/LabelableNode.h> #include <LibWeb/Layout/TextNode.h> namespace Web::Layout { Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, NonnullRefPtr<CSS::StyleProperties> style) : BlockContainer(document, element, move(style)) { } Label::~Label() { } void Label::handle_mousedown_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button) { if (button != GUI::MouseButton::Primary) return; if (auto* control = control_node(); control) control->handle_associated_label_mousedown({}); m_tracking_mouse = true; } void Label::handle_mouseup_on_label(Badge<TextNode>, const Gfx::IntPoint& position, unsigned button) { if (!m_tracking_mouse || button != GUI::MouseButton::Primary) return; // NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node. NonnullRefPtr protect = *this; if (auto* control = control_node(); control) { bool is_inside_control = enclosing_int_rect(control->absolute_rect()).contains(position); bool is_inside_label = enclosing_int_rect(absolute_rect()).contains(position); if (is_inside_control || is_inside_label) control->handle_associated_label_mouseup({}); } m_tracking_mouse = false; } void Label::handle_mousemove_on_label(Badge<TextNode>, const Gfx::IntPoint& position, unsigned) { if (!m_tracking_mouse) return; if (auto* control = control_node(); control) { bool is_inside_control = enclosing_int_rect(control->absolute_rect()).contains(position); bool is_inside_label = enclosing_int_rect(absolute_rect()).contains(position); control->handle_associated_label_mousemove({}, is_inside_control || is_inside_label); } } bool Label::is_inside_associated_label(LabelableNode& control, const Gfx::IntPoint& position) { if (auto* label = label_for_control_node(control); label) return enclosing_int_rect(label->absolute_rect()).contains(position); return false; } bool Label::is_associated_label_hovered(LabelableNode& control) { if (auto* label = label_for_control_node(control); label) { if (label->document().hovered_node() == &label->dom_node()) return true; if (auto* child = label->first_child_of_type<TextNode>(); child) return label->document().hovered_node() == &child->dom_node(); } return false; } Label* Label::label_for_control_node(LabelableNode& control) { Label* label = nullptr; if (!control.document().layout_node()) return label; String id = control.dom_node().attribute(HTML::AttributeNames::id); if (id.is_empty()) return label; control.document().layout_node()->for_each_in_inclusive_subtree_of_type<Label>([&](auto& node) { if (node.dom_node().for_() == id) { label = &node; return IterationDecision::Break; } return IterationDecision::Continue; }); // FIXME: The spec also allows for associating a label with a labelable node by putting the // labelable node inside the label. return label; } LabelableNode* Label::control_node() { LabelableNode* control = nullptr; if (!document().layout_node()) return control; String for_ = dom_node().for_(); if (for_.is_empty()) return control; document().layout_node()->for_each_in_inclusive_subtree_of_type<LabelableNode>([&](auto& node) { if (node.dom_node().attribute(HTML::AttributeNames::id) == for_) { control = &node; return IterationDecision::Break; } return IterationDecision::Continue; }); // FIXME: The spec also allows for associating a label with a labelable node by putting the // labelable node inside the label. return control; } }
30.170213
113
0.683827
r00ster91
80f1149c50a621b596022f27e1eb8c5ddc1b3b2f
4,540
hpp
C++
src/mat/opr/num.hpp
Thhethssmuz/mmm
ee91a990fba3849db1fc2b6df0e89004e2df466f
[ "MIT" ]
1
2017-03-14T20:45:54.000Z
2017-03-14T20:45:54.000Z
src/mat/opr/num.hpp
Thhethssmuz/mmm
ee91a990fba3849db1fc2b6df0e89004e2df466f
[ "MIT" ]
1
2017-03-08T17:14:03.000Z
2017-03-08T23:40:35.000Z
src/mat/opr/num.hpp
Thhethssmuz/mmm
ee91a990fba3849db1fc2b6df0e89004e2df466f
[ "MIT" ]
null
null
null
#pragma once template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator+(T s, const tmat<T, N, M>& m); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator+(U s, const tmat<T, N, M>& m); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator+(const tmat<T, N, M>& m, T s); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator+(const tmat<T, N, M>& m, U s); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator+(const tmat<T, N, M>& m, const tmat<T, N, M>& n); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator-(T s, const tmat<T, N, M>& m); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator-(U s, const tmat<T, N, M>& m); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator-(const tmat<T, N, M>& m, T s); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator-(const tmat<T, N, M>& m, U s); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator-(const tmat<T, N, M>& m); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator-(const tmat<T, N, M>& m, const tmat<T, N, M>& n); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator*(T s, const tmat<T, N, M>& m); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator*(U s, const tmat<T, N, M>& m); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator*(const tmat<T, N, M>& m, T s); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator*(const tmat<T, N, M>& m, U s); template <typename T, size_t M, typename = typefu::for_arithmetic<T>> constexpr tvec<T, 2> operator*(const tvec<T, M>& v, const tmat<T, 2, M>& m); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tvec<T, N> operator*(const tvec<T, M>& v, const tmat<T, N, M>& m); template <typename T, size_t N, size_t M, typename A, typename = typefu::for_arithmetic<T>> constexpr tvec<T, N> operator*(const vecType<T, M, A>& v, const tmat<T, N, M>& m); template <typename T, size_t N, typename = typefu::for_arithmetic<T>> constexpr tvec<T, 2> operator*(const tmat<T, N, 2>& m, const tvec<T, N>& v); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tvec<T, M> operator*(const tmat<T, N, M>& m, const tvec<T, N>& v); template <typename T, size_t N, size_t M, typename A, typename = typefu::for_arithmetic<T>> constexpr tvec<T, M> operator*(const tmat<T, N, M>& m, const vecType<T, N, A>& v); template <typename T, size_t N, size_t M, size_t O, typename = typefu::for_arithmetic<T>> constexpr tmat<T, O, M> operator*(const tmat<T, N, M>& m, const tmat<T, O, N>& n); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator/(T s, const tmat<T, N, M>& m); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator/(U s, const tmat<T, N, M>& m); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator/(const tmat<T, N, M>& m, T s); template <typename T, typename U, size_t N, size_t M, typename = typefu::for_arithmetic<T, U>> constexpr tmat<T, N, M> operator/(const tmat<T, N, M>& m, U s); template <typename T, size_t N, size_t M, typename = typefu::for_arithmetic<T>> constexpr tmat<T, N, M> operator/(const tmat<T, N, M>& m, const tmat<T, N, M>& n);
41.651376
79
0.633921
Thhethssmuz
80f150649a995bbec45e690f159257810537b405
25,084
hpp
C++
include/RAJA/policy/hip/sort.hpp
keichi/RAJA
8e8cc96cbccda2bfc33b14b57a8591b2cf9ca342
[ "BSD-3-Clause" ]
null
null
null
include/RAJA/policy/hip/sort.hpp
keichi/RAJA
8e8cc96cbccda2bfc33b14b57a8591b2cf9ca342
[ "BSD-3-Clause" ]
null
null
null
include/RAJA/policy/hip/sort.hpp
keichi/RAJA
8e8cc96cbccda2bfc33b14b57a8591b2cf9ca342
[ "BSD-3-Clause" ]
null
null
null
/*! ****************************************************************************** * * \file * * \brief Header file providing RAJA sort declarations. * ****************************************************************************** */ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// // Copyright (c) 2016-22, Lawrence Livermore National Security, LLC // and RAJA project contributors. See the RAJA/LICENSE file for details. // // SPDX-License-Identifier: (BSD-3-Clause) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// #ifndef RAJA_sort_hip_HPP #define RAJA_sort_hip_HPP #include "RAJA/config.hpp" #if defined(RAJA_ENABLE_HIP) #include <climits> #include <iterator> #include <type_traits> #if defined(__HIPCC__) #define ROCPRIM_HIP_API 1 #include "rocprim/device/device_transform.hpp" #include "rocprim/device/device_radix_sort.hpp" #elif defined(__CUDACC__) #include "cub/device/device_radix_sort.cuh" #endif #include "RAJA/util/concepts.hpp" #include "RAJA/util/Operators.hpp" #include "RAJA/pattern/detail/algorithm.hpp" #include "RAJA/policy/hip/MemUtils_HIP.hpp" #include "RAJA/policy/hip/policy.hpp" namespace RAJA { namespace impl { namespace sort { namespace detail { #if defined(__HIPCC__) template < typename R > using double_buffer = ::rocprim::double_buffer<R>; #elif defined(__CUDACC__) template < typename R > using double_buffer = ::cub::DoubleBuffer<R>; #endif template < typename R > R* get_current(double_buffer<R>& d_bufs) { #if defined(__HIPCC__) return d_bufs.current(); #elif defined(__CUDACC__) return d_bufs.Current(); #endif } } /*! \brief static assert unimplemented stable sort */ template <size_t BLOCK_SIZE, bool Async, typename Iter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Hip>, concepts::negate<concepts::all_of< type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>, concepts::any_of< camp::is_same<Compare, operators::less<RAJA::detail::IterVal<Iter>>>, camp::is_same<Compare, operators::greater<RAJA::detail::IterVal<Iter>>>>>>> stable( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, Iter, Iter, Compare) { static_assert(concepts::all_of< type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>, concepts::any_of< camp::is_same<Compare, operators::less<RAJA::detail::IterVal<Iter>>>, camp::is_same<Compare, operators::greater<RAJA::detail::IterVal<Iter>>>>>::value, "RAJA stable_sort<hip_exec> is only implemented for pointers to arithmetic types and RAJA::operators::less and RAJA::operators::greater."); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief stable sort given range in ascending order */ template <size_t BLOCK_SIZE, bool Async, typename Iter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>> stable( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, Iter begin, Iter end, operators::less<RAJA::detail::IterVal<Iter>>) { hipStream_t stream = hip_res.get_stream(); using R = RAJA::detail::IterVal<Iter>; int len = std::distance(begin, end); int begin_bit=0; int end_bit=sizeof(R)*CHAR_BIT; // Allocate temporary storage for the output array R* d_out = hip::device_mempool_type::getInstance().malloc<R>(len); // use cub double buffer to reduce temporary memory requirements // by allowing cub to write to the begin buffer detail::double_buffer<R> d_keys(begin, d_out); // Determine temporary device storage requirements void* d_temp_storage = nullptr; size_t temp_storage_bytes = 0; #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_keys(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortKeys(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #endif // Allocate temporary storage d_temp_storage = hip::device_mempool_type::getInstance().malloc<unsigned char>( temp_storage_bytes); // Run #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_keys(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortKeys(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #endif // Free temporary storage hip::device_mempool_type::getInstance().free(d_temp_storage); if (detail::get_current(d_keys) == d_out) { // copy hipErrchk(hipMemcpyAsync(begin, d_out, len*sizeof(R), hipMemcpyDefault, stream)); } hip::device_mempool_type::getInstance().free(d_out); hip::launch(hip_res, Async); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief stable sort given range in descending order */ template <size_t BLOCK_SIZE, bool Async, typename Iter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>> stable( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, Iter begin, Iter end, operators::greater<RAJA::detail::IterVal<Iter>>) { hipStream_t stream = hip_res.get_stream(); using R = RAJA::detail::IterVal<Iter>; int len = std::distance(begin, end); int begin_bit=0; int end_bit=sizeof(R)*CHAR_BIT; // Allocate temporary storage for the output array R* d_out = hip::device_mempool_type::getInstance().malloc<R>(len); // use cub double buffer to reduce temporary memory requirements // by allowing cub to write to the begin buffer detail::double_buffer<R> d_keys(begin, d_out); // Determine temporary device storage requirements void* d_temp_storage = nullptr; size_t temp_storage_bytes = 0; #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_keys_desc(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortKeysDescending(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #endif // Allocate temporary storage d_temp_storage = hip::device_mempool_type::getInstance().malloc<unsigned char>( temp_storage_bytes); // Run #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_keys_desc(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortKeysDescending(d_temp_storage, temp_storage_bytes, d_keys, len, begin_bit, end_bit, stream)); #endif // Free temporary storage hip::device_mempool_type::getInstance().free(d_temp_storage); if (detail::get_current(d_keys) == d_out) { // copy hipErrchk(hipMemcpyAsync(begin, d_out, len*sizeof(R), hipMemcpyDefault, stream)); } hip::device_mempool_type::getInstance().free(d_out); hip::launch(hip_res, Async); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief static assert unimplemented sort */ template <size_t BLOCK_SIZE, bool Async, typename Iter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Hip>, concepts::negate<concepts::all_of< type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>, concepts::any_of< camp::is_same<Compare, operators::less<RAJA::detail::IterVal<Iter>>>, camp::is_same<Compare, operators::greater<RAJA::detail::IterVal<Iter>>>>>>> unstable( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, Iter, Iter, Compare) { static_assert(concepts::all_of< type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>, concepts::any_of< camp::is_same<Compare, operators::less<RAJA::detail::IterVal<Iter>>>, camp::is_same<Compare, operators::greater<RAJA::detail::IterVal<Iter>>>>>::value, "RAJA sort<hip_exec> is only implemented for pointers to arithmetic types and RAJA::operators::less and RAJA::operators::greater."); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief sort given range in ascending order */ template <size_t BLOCK_SIZE, bool Async, typename Iter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>> unstable( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async> p, Iter begin, Iter end, operators::less<RAJA::detail::IterVal<Iter>> comp) { return stable(hip_res, p, begin, end, comp); } /*! \brief sort given range in descending order */ template <size_t BLOCK_SIZE, bool Async, typename Iter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<Iter>>, std::is_pointer<Iter>> unstable( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async> p, Iter begin, Iter end, operators::greater<RAJA::detail::IterVal<Iter>> comp) { return stable(hip_res, p, begin, end, comp); } /*! \brief static assert unimplemented stable sort pairs */ template <size_t BLOCK_SIZE, bool Async, typename KeyIter, typename ValIter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Hip>, concepts::negate<concepts::all_of< type_traits::is_arithmetic<RAJA::detail::IterVal<KeyIter>>, std::is_pointer<KeyIter>, std::is_pointer<ValIter>, concepts::any_of< camp::is_same<Compare, operators::less<RAJA::detail::IterVal<KeyIter>>>, camp::is_same<Compare, operators::greater<RAJA::detail::IterVal<KeyIter>>>>>>> stable_pairs( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, KeyIter, KeyIter, ValIter, Compare) { static_assert (std::is_pointer<KeyIter>::value, "stable_sort_pairs<hip_exec> is only implemented for pointers"); static_assert (std::is_pointer<ValIter>::value, "stable_sort_pairs<hip_exec> is only implemented for pointers"); using K = RAJA::detail::IterVal<KeyIter>; static_assert (type_traits::is_arithmetic<K>::value, "stable_sort_pairs<hip_exec> is only implemented for arithmetic types"); static_assert (concepts::any_of< camp::is_same<Compare, operators::less<K>>, camp::is_same<Compare, operators::greater<K>>>::value, "stable_sort_pairs<hip_exec> is only implemented for RAJA::operators::less or RAJA::operators::greater"); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief stable sort given range of pairs in ascending order of keys */ template <size_t BLOCK_SIZE, bool Async, typename KeyIter, typename ValIter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<KeyIter>>, std::is_pointer<KeyIter>, std::is_pointer<ValIter>> stable_pairs( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, KeyIter keys_begin, KeyIter keys_end, ValIter vals_begin, operators::less<RAJA::detail::IterVal<KeyIter>>) { hipStream_t stream = hip_res.get_stream(); using K = RAJA::detail::IterVal<KeyIter>; using V = RAJA::detail::IterVal<ValIter>; int len = std::distance(keys_begin, keys_end); int begin_bit=0; int end_bit=sizeof(K)*CHAR_BIT; // Allocate temporary storage for the output arrays K* d_keys_out = hip::device_mempool_type::getInstance().malloc<K>(len); V* d_vals_out = hip::device_mempool_type::getInstance().malloc<V>(len); // use cub double buffer to reduce temporary memory requirements // by allowing cub to write to the keys_begin and vals_begin buffers detail::double_buffer<K> d_keys(keys_begin, d_keys_out); detail::double_buffer<V> d_vals(vals_begin, d_vals_out); // Determine temporary device storage requirements void* d_temp_storage = nullptr; size_t temp_storage_bytes = 0; #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_pairs(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortPairs(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #endif // Allocate temporary storage d_temp_storage = hip::device_mempool_type::getInstance().malloc<unsigned char>( temp_storage_bytes); // Run #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_pairs(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortPairs(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #endif // Free temporary storage hip::device_mempool_type::getInstance().free(d_temp_storage); if (detail::get_current(d_keys) == d_keys_out) { // copy keys hipErrchk(hipMemcpyAsync(keys_begin, d_keys_out, len*sizeof(K), hipMemcpyDefault, stream)); } if (detail::get_current(d_vals) == d_vals_out) { // copy vals hipErrchk(hipMemcpyAsync(vals_begin, d_vals_out, len*sizeof(V), hipMemcpyDefault, stream)); } hip::device_mempool_type::getInstance().free(d_keys_out); hip::device_mempool_type::getInstance().free(d_vals_out); hip::launch(hip_res, Async); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief stable sort given range of pairs in descending order of keys */ template <size_t BLOCK_SIZE, bool Async, typename KeyIter, typename ValIter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<KeyIter>>, std::is_pointer<KeyIter>, std::is_pointer<ValIter>> stable_pairs( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, KeyIter keys_begin, KeyIter keys_end, ValIter vals_begin, operators::greater<RAJA::detail::IterVal<KeyIter>>) { hipStream_t stream = hip_res.get_stream(); using K = RAJA::detail::IterVal<KeyIter>; using V = RAJA::detail::IterVal<ValIter>; int len = std::distance(keys_begin, keys_end); int begin_bit=0; int end_bit=sizeof(K)*CHAR_BIT; // Allocate temporary storage for the output arrays K* d_keys_out = hip::device_mempool_type::getInstance().malloc<K>(len); V* d_vals_out = hip::device_mempool_type::getInstance().malloc<V>(len); // use cub double buffer to reduce temporary memory requirements // by allowing cub to write to the keys_begin and vals_begin buffers detail::double_buffer<K> d_keys(keys_begin, d_keys_out); detail::double_buffer<V> d_vals(vals_begin, d_vals_out); // Determine temporary device storage requirements void* d_temp_storage = nullptr; size_t temp_storage_bytes = 0; #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_pairs_desc(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortPairsDescending(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #endif // Allocate temporary storage d_temp_storage = hip::device_mempool_type::getInstance().malloc<unsigned char>( temp_storage_bytes); // Run #if defined(__HIPCC__) hipErrchk(::rocprim::radix_sort_pairs_desc(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #elif defined(__CUDACC__) cudaErrchk(::cub::DeviceRadixSort::SortPairsDescending(d_temp_storage, temp_storage_bytes, d_keys, d_vals, len, begin_bit, end_bit, stream)); #endif // Free temporary storage hip::device_mempool_type::getInstance().free(d_temp_storage); if (detail::get_current(d_keys) == d_keys_out) { // copy keys hipErrchk(hipMemcpyAsync(keys_begin, d_keys_out, len*sizeof(K), hipMemcpyDefault, stream)); } if (detail::get_current(d_vals) == d_vals_out) { // copy vals hipErrchk(hipMemcpyAsync(vals_begin, d_vals_out, len*sizeof(V), hipMemcpyDefault, stream)); } hip::device_mempool_type::getInstance().free(d_keys_out); hip::device_mempool_type::getInstance().free(d_vals_out); hip::launch(hip_res, Async); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief static assert unimplemented sort pairs */ template <size_t BLOCK_SIZE, bool Async, typename KeyIter, typename ValIter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Hip>, concepts::negate<concepts::all_of< type_traits::is_arithmetic<RAJA::detail::IterVal<KeyIter>>, std::is_pointer<KeyIter>, std::is_pointer<ValIter>, concepts::any_of< camp::is_same<Compare, operators::less<RAJA::detail::IterVal<KeyIter>>>, camp::is_same<Compare, operators::greater<RAJA::detail::IterVal<KeyIter>>>>>>> unstable_pairs( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async>, KeyIter, KeyIter, ValIter, Compare) { static_assert (std::is_pointer<KeyIter>::value, "sort_pairs<hip_exec> is only implemented for pointers"); static_assert (std::is_pointer<ValIter>::value, "sort_pairs<hip_exec> is only implemented for pointers"); using K = RAJA::detail::IterVal<KeyIter>; static_assert (type_traits::is_arithmetic<K>::value, "sort_pairs<hip_exec> is only implemented for arithmetic types"); static_assert (concepts::any_of< camp::is_same<Compare, operators::less<K>>, camp::is_same<Compare, operators::greater<K>>>::value, "sort_pairs<hip_exec> is only implemented for RAJA::operators::less or RAJA::operators::greater"); return resources::EventProxy<resources::Hip>(hip_res); } /*! \brief stable sort given range of pairs in ascending order of keys */ template <size_t BLOCK_SIZE, bool Async, typename KeyIter, typename ValIter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<KeyIter>>, std::is_pointer<KeyIter>, std::is_pointer<ValIter>> unstable_pairs( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async> p, KeyIter keys_begin, KeyIter keys_end, ValIter vals_begin, operators::less<RAJA::detail::IterVal<KeyIter>> comp) { return stable_pairs(hip_res, p, keys_begin, keys_end, vals_begin, comp); } /*! \brief stable sort given range of pairs in descending order of keys */ template <size_t BLOCK_SIZE, bool Async, typename KeyIter, typename ValIter> concepts::enable_if_t<resources::EventProxy<resources::Hip>, type_traits::is_arithmetic<RAJA::detail::IterVal<KeyIter>>, std::is_pointer<KeyIter>, std::is_pointer<ValIter>> unstable_pairs( resources::Hip hip_res, hip_exec<BLOCK_SIZE, Async> p, KeyIter keys_begin, KeyIter keys_end, ValIter vals_begin, operators::greater<RAJA::detail::IterVal<KeyIter>> comp) { return stable_pairs(hip_res, p, keys_begin, keys_end, vals_begin, comp); } } // namespace sort } // namespace impl } // namespace RAJA #endif // closing endif for RAJA_ENABLE_HIP guard #endif // closing endif for header file include guard
37.271917
155
0.54772
keichi
80f3d98b065279779da3a4fa531dcb89099b8e50
14,935
cc
C++
modules/perception/obstacle/camera/converter/geometry_camera_converter.cc
DinnerHowe/apollo
f45b63ea2f2409dbd1b007476d816d6ec44ba06c
[ "Apache-2.0" ]
19
2018-07-26T03:17:32.000Z
2021-01-04T02:17:09.000Z
modules/perception/obstacle/camera/converter/geometry_camera_converter.cc
DinnerHowe/apollo
f45b63ea2f2409dbd1b007476d816d6ec44ba06c
[ "Apache-2.0" ]
null
null
null
modules/perception/obstacle/camera/converter/geometry_camera_converter.cc
DinnerHowe/apollo
f45b63ea2f2409dbd1b007476d816d6ec44ba06c
[ "Apache-2.0" ]
10
2018-10-17T03:18:16.000Z
2020-07-02T06:18:14.000Z
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * 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 * * 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. *****************************************************************************/ // Convert 2D detections into 3D objects #include "modules/perception/obstacle/camera/converter/geometry_camera_converter.h" namespace apollo { namespace perception { bool GeometryCameraConverter::Init() { ConfigManager *config_manager = ConfigManager::instance(); const ModelConfig *model_config = config_manager->GetModelConfig(Name()); if (model_config == nullptr) { AERROR << "Model config: " << Name() << " not found"; return false; } std::string intrinsic_file_path = ""; if (!model_config->GetValue("camera_intrinsic_file", &intrinsic_file_path)) { AERROR << "Failed to get camera intrinsics file path: " << Name(); return false; } if (!LoadCameraIntrinsics(intrinsic_file_path)) { AERROR << "Failed to get camera intrinsics: " << intrinsic_file_path; return false; } return true; } bool GeometryCameraConverter::Convert(std::vector<VisualObjectPtr> *objects) { if (!objects) return false; for (auto &obj : *objects) { Eigen::Vector2f trunc_center_pixel = Eigen::Vector2f::Zero(); CheckTruncation(obj, &trunc_center_pixel); CheckSizeSanity(obj); float deg_alpha = obj->alpha * 180.0f / M_PI; Eigen::Vector2f upper_left(obj->upper_left.x(), obj->upper_left.y()); Eigen::Vector2f lower_right(obj->lower_right.x(), obj->lower_right.y()); float distance_w = 0.0; float distance_h = 0.0; Eigen::Vector2f mass_center_pixel = Eigen::Vector2f::Zero(); ConvertSingle(obj->height, obj->width, obj->length, deg_alpha, upper_left, lower_right, &distance_w, &distance_h, &mass_center_pixel); if (obj->trunc_width > 0.25f && obj->trunc_height > 0.25f) { // Give fix values for detected box with both side and bottom truncation distance_w = distance_h = 10.0f; obj->distance = DecideDistance(distance_h, distance_w, obj); // Estimation of center pixel due to unknown truncation ratio if (obj->trunc_width > 0.25f) mass_center_pixel = trunc_center_pixel; } else if (distance_w > 40.0f || distance_h > 40.0f || obj->trunc_width > 0.25f) { // Reset alpha angle and redo again (Model dependent issue) obj->distance = DecideDistance(distance_h, distance_w, obj); DecideAngle(camera_model_.unproject(mass_center_pixel), obj); deg_alpha = obj->alpha * 180.0f / M_PI; ConvertSingle(obj->height, obj->width, obj->length, deg_alpha, upper_left, lower_right, &distance_w, &distance_h, &mass_center_pixel); } obj->distance = DecideDistance(distance_h, distance_w, obj); Eigen::Vector3f camera_ray = camera_model_.unproject(mass_center_pixel); DecideAngle(camera_ray, obj); // Center (3D Mass Center of 3D BBox) float scale = obj->distance / sqrt(camera_ray.x() * camera_ray.x() + camera_ray.y() * camera_ray.y() + camera_ray.z() * camera_ray.z()); obj->center = camera_ray * scale; // Set 8 corner pixels obj->pts8.resize(16); if (obj->trunc_width < 0.25f && obj->trunc_height < 0.25f) { for (int i = 0; i < 8; i++) { obj->pts8[i * 2] = pixel_corners_[i].x(); obj->pts8[i * 2 + 1] = pixel_corners_[i].y(); } } } return true; } void GeometryCameraConverter::SetDebug(bool flag) { debug_ = flag; } std::string GeometryCameraConverter::Name() const { return "GeometryCameraConverter"; } bool GeometryCameraConverter::LoadCameraIntrinsics( const std::string &file_path) { YAML::Node node = YAML::LoadFile(file_path); Eigen::Matrix3f intrinsic_k; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { int index = i * 3 + j; intrinsic_k(i, j) = node["K"][index].as<float>(); } } Eigen::Matrix<float, 5, 1> intrinsic_d; for (int i = 0; i < 5; i++) { intrinsic_d(i, 0) = node["D"][i].as<float>(); } float height = node["height"].as<float>(); float width = node["width"].as<float>(); camera_model_.set(intrinsic_k, width, height); camera_model_.set_distort_params(intrinsic_d); return true; } bool GeometryCameraConverter::ConvertSingle( const float &h, const float &w, const float &l, const float &alpha_deg, const Eigen::Vector2f &upper_left, const Eigen::Vector2f &lower_right, float *distance_w, float *distance_h, Eigen::Vector2f *mass_center_pixel) { // Target Goals: Projection target int pixel_width = static_cast<int>(lower_right.x() - upper_left.x()); int pixel_height = static_cast<int>(lower_right.y() - upper_left.y()); // Target Goals: Box center pixel Eigen::Matrix<float, 2, 1> box_center_pixel; box_center_pixel.x() = (lower_right.x() + upper_left.x()) / 2.0f; box_center_pixel.y() = (lower_right.y() + upper_left.y()) / 2.0f; // Generate alpha rotated 3D template here. Corners in Camera space: // Bottom: FL, FR, RR, RL => Top: FL, FR, RR, RL float deg_alpha = alpha_deg; float h_half = h / 2.0f; float w_half = w / 2.0f; float l_half = l / 2.0f; std::vector<Eigen::Vector3f> corners; corners.resize(8); corners[0] = Eigen::Vector3f(l_half, h_half, w_half); corners[1] = Eigen::Vector3f(l_half, h_half, -w_half); corners[2] = Eigen::Vector3f(-l_half, h_half, -w_half); corners[3] = Eigen::Vector3f(-l_half, h_half, w_half); corners[4] = Eigen::Vector3f(l_half, -h_half, w_half); corners[5] = Eigen::Vector3f(l_half, -h_half, -w_half); corners[6] = Eigen::Vector3f(-l_half, -h_half, -w_half); corners[7] = Eigen::Vector3f(-l_half, -h_half, w_half); Rotate(deg_alpha, &corners); corners_ = corners; pixel_corners_.clear(); pixel_corners_.resize(8); // Try to get an initial Mass center pixel and vector Eigen::Matrix<float, 3, 1> middle_v(0.0f, 0.0f, 20.0f); Eigen::Matrix<float, 2, 1> center_pixel = camera_model_.project(middle_v); float max_pixel_x = std::numeric_limits<float>::min(); float min_pixel_x = std::numeric_limits<float>::max(); float max_pixel_y = std::numeric_limits<float>::min(); float min_pixel_y = std::numeric_limits<float>::max(); for (size_t i = 0; i < corners.size(); ++i) { Eigen::Vector2f point_2d = camera_model_.project(corners[i] + middle_v); min_pixel_x = std::min(min_pixel_x, point_2d.x()); max_pixel_x = std::max(max_pixel_x, point_2d.x()); min_pixel_y = std::min(min_pixel_y, point_2d.y()); max_pixel_y = std::max(max_pixel_y, point_2d.y()); } float relative_x = (center_pixel.x() - min_pixel_x) / (max_pixel_x - min_pixel_x); float relative_y = (center_pixel.y() - min_pixel_y) / (max_pixel_y - min_pixel_y); mass_center_pixel->x() = (lower_right.x() - upper_left.x()) * relative_x + upper_left.x(); mass_center_pixel->y() = (lower_right.y() - upper_left.y()) * relative_y + upper_left.y(); Eigen::Matrix<float, 3, 1> mass_center_v = camera_model_.unproject(*mass_center_pixel); mass_center_v = MakeUnit(mass_center_v); // Binary search *distance_w = SearchDistance(pixel_width, true, mass_center_v); *distance_h = SearchDistance(pixel_height, false, mass_center_v); for (size_t i = 0; i < 2; ++i) { // Mass center search SearchCenterDirection(box_center_pixel, *distance_h, &mass_center_v, mass_center_pixel); // Binary search *distance_w = SearchDistance(pixel_width, true, mass_center_v); *distance_h = SearchDistance(pixel_height, false, mass_center_v); } return true; } void GeometryCameraConverter::Rotate( const float &alpha_deg, std::vector<Eigen::Vector3f> *corners) const { Eigen::AngleAxisf yaw(alpha_deg / 180.0f * M_PI, Eigen::Vector3f::UnitY()); Eigen::AngleAxisf pitch(0.0, Eigen::Vector3f::UnitX()); Eigen::AngleAxisf roll(0.0, Eigen::Vector3f::UnitZ()); Eigen::Matrix3f rotation = yaw.toRotationMatrix() * pitch.toRotationMatrix() * roll.toRotationMatrix(); Eigen::Matrix4f transform; transform.setIdentity(); transform.block(0, 0, 3, 3) = rotation; for (auto &corner : *corners) { Eigen::Vector4f temp(corner.x(), corner.y(), corner.z(), 1.0f); temp = transform * temp; corner = Eigen::Vector3f(temp.x(), temp.y(), temp.z()); } } float GeometryCameraConverter::SearchDistance( const int &pixel_length, const bool &use_width, const Eigen::Matrix<float, 3, 1> &mass_center_v) { float close_d = 0.1f; float far_d = 200.0f; float curr_d = 0.0f; int depth = 0; while (close_d <= far_d && depth < kMaxDistanceSearchDepth_) { curr_d = (far_d + close_d) / 2.0f; Eigen::Vector3f curr_p = mass_center_v * curr_d; float min_p = std::numeric_limits<float>::max(); float max_p = 0.0f; for (size_t i = 0; i < corners_.size(); ++i) { Eigen::Vector2f point_2d = camera_model_.project(corners_[i] + curr_p); pixel_corners_[i] = point_2d; float curr_pixel = 0.0f; if (use_width) { curr_pixel = point_2d.x(); } else { curr_pixel = point_2d.y(); } min_p = std::min(min_p, curr_pixel); max_p = std::max(max_p, curr_pixel); } int curr_pixel_length = static_cast<int>(max_p - min_p); if (curr_pixel_length == pixel_length) { break; } else if (pixel_length < curr_pixel_length) { close_d = curr_d + 0.01f; } else { // pixel_length > curr_pixel_length far_d = curr_d - 0.01f; } // Early break for 0.01m accuracy float next_d = (far_d + close_d) / 2.0f; if (std::abs(next_d - curr_d) < 0.01f) { break; } ++depth; } return curr_d; } void GeometryCameraConverter::SearchCenterDirection( const Eigen::Matrix<float, 2, 1> &box_center_pixel, const float &curr_d, Eigen::Matrix<float, 3, 1> *mass_center_v, Eigen::Matrix<float, 2, 1> *mass_center_pixel) const { int depth = 0; while (depth < kMaxCenterDirectionSearchDepth_) { Eigen::Matrix<float, 3, 1> new_center_v = *mass_center_v * curr_d; float max_pixel_x = std::numeric_limits<float>::min(); float min_pixel_x = std::numeric_limits<float>::max(); float max_pixel_y = std::numeric_limits<float>::min(); float min_pixel_y = std::numeric_limits<float>::max(); for (size_t i = 0; i < corners_.size(); ++i) { Eigen::Vector2f point_2d = camera_model_.project(corners_[i] + new_center_v); min_pixel_x = std::min(min_pixel_x, point_2d.x()); max_pixel_x = std::max(max_pixel_x, point_2d.x()); min_pixel_y = std::min(min_pixel_y, point_2d.y()); max_pixel_y = std::max(max_pixel_y, point_2d.y()); } Eigen::Matrix<float, 2, 1> current_box_center_pixel; current_box_center_pixel.x() = (max_pixel_x + min_pixel_x) / 2.0; current_box_center_pixel.y() = (max_pixel_y + min_pixel_y) / 2.0; // Update mass center *mass_center_pixel += box_center_pixel - current_box_center_pixel; *mass_center_v = camera_model_.unproject(*mass_center_pixel); *mass_center_v = MakeUnit(*mass_center_v); if (std::abs(mass_center_pixel->x() - box_center_pixel.x()) < 1.0 && std::abs(mass_center_pixel->y() - box_center_pixel.y()) < 1.0) { break; } ++depth; } return; } Eigen::Matrix<float, 3, 1> GeometryCameraConverter::MakeUnit( const Eigen::Matrix<float, 3, 1> &v) const { Eigen::Matrix<float, 3, 1> unit_v = v; float to_unit_scale = std::sqrt(unit_v.x() * unit_v.x() + unit_v.y() * unit_v.y() + unit_v.z() * unit_v.z()); unit_v /= to_unit_scale; return unit_v; } void GeometryCameraConverter::CheckSizeSanity(VisualObjectPtr obj) const { if (obj->type == ObjectType::VEHICLE) { obj->length = std::max(obj->length, 3.6f); obj->width = std::max(obj->width, 1.6f); obj->height = std::max(obj->height, 1.5f); } else if (obj->type == ObjectType::PEDESTRIAN) { obj->length = std::max(obj->length, 0.5f); obj->width = std::max(obj->width, 0.5f); obj->height = std::max(obj->height, 1.7f); } else if (obj->type == ObjectType::BICYCLE) { obj->length = std::max(obj->length, 1.8f); obj->width = std::max(obj->width, 1.2f); obj->height = std::max(obj->height, 1.5f); } else { obj->length = std::max(obj->length, 0.5f); obj->width = std::max(obj->width, 0.5f); obj->height = std::max(obj->height, 1.5f); } } void GeometryCameraConverter::CheckTruncation(VisualObjectPtr obj, Eigen::Matrix<float, 2, 1> *trunc_center_pixel) const { auto width = camera_model_.get_width(); auto height = camera_model_.get_height(); // Ad-hoc 2D box truncation binary determination if (obj->upper_left.x() < 30.0f || width - 30.0f < obj->lower_right.x()) { obj->trunc_width = 0.5f; trunc_center_pixel->y() = (obj->upper_left.y() + obj->lower_right.y()) / 2.0f; if (obj->upper_left.x() < 30.0f) { trunc_center_pixel->x() = obj->upper_left.x(); } else { trunc_center_pixel->x() = obj->lower_right.x(); } } if (obj->upper_left.y() < 30.0f || height - 30.0f < obj->lower_right.y()) { obj->trunc_height = 0.5f; } } float GeometryCameraConverter::DecideDistance(const float &distance_h, const float &distance_w, VisualObjectPtr obj) const { float distance = distance_h; // TODO(later): Deal with truncation return distance; } void GeometryCameraConverter::DecideAngle(const Eigen::Vector3f &camera_ray, VisualObjectPtr obj) const { float beta = std::atan2(camera_ray.x(), camera_ray.z()); // Orientation is not reliable in these cases (DL model specific issue) if (obj->distance > 50.0f || obj->trunc_width > 0.25f) { obj->theta = -1.0f * M_PI_2; obj->alpha = obj->theta - beta; if (obj->alpha > M_PI) { obj->alpha -= 2 * M_PI; } else if (obj->alpha < -M_PI) { obj->alpha += 2 * M_PI; } } else { // Normal cases float theta = obj->alpha + beta; if (theta > M_PI) { theta -= 2 * M_PI; } else if (theta < -M_PI) { theta += 2 * M_PI; } obj->theta = theta; } } } // namespace perception } // namespace apollo
36.3382
83
0.640509
DinnerHowe
80f457acb73146c1efd6b335b61609bd3182ebbc
2,890
cpp
C++
StepEditor/RawResponseDlg.cpp
edwig/Kwatta
ce1ca2907608e65ed62d7dbafa9ab1d030caccfe
[ "MIT" ]
1
2021-12-31T17:20:01.000Z
2021-12-31T17:20:01.000Z
StepEditor/RawResponseDlg.cpp
edwig/Kwatta
ce1ca2907608e65ed62d7dbafa9ab1d030caccfe
[ "MIT" ]
10
2022-01-14T13:28:32.000Z
2022-02-13T12:46:34.000Z
StepEditor/RawResponseDlg.cpp
edwig/Kwatta
ce1ca2907608e65ed62d7dbafa9ab1d030caccfe
[ "MIT" ]
null
null
null
/////////////////////////////////////////////////////////////////////////////////////////////////////// // // // ██╗░░██╗░██╗░░░░░░░██╗░█████╗░████████╗████████╗░█████╗░ // ██║░██╔╝░██║░░██╗░░██║██╔══██╗╚══██╔══╝╚══██╔══╝██╔══██╗ // █████═╝░░╚██╗████╗██╔╝███████║░░░██║░░░░░░██║░░░███████║ // ██╔═██╗░░░████╔═████║░██╔══██║░░░██║░░░░░░██║░░░██╔══██║ // ██║░╚██╗░░╚██╔╝░╚██╔╝░██║░░██║░░░██║░░░░░░██║░░░██║░░██║ // ╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝░░╚═╝░░░╚═╝░░░░░░╚═╝░░░╚═╝░░╚═╝ // // // This product: KWATTA (KWAliTy Test API) Test suite for Command-line SOAP/JSON/HTTP internet API's // This program: StepEditor // This File : RawResponseDlg.cpp // What it does: Resulting raw response of a HTTP internet test call // Author : ir. W.E. Huisman // License : See license.md file in the root directory // /////////////////////////////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "StepEditor.h" #include "TestStepNET.h" #include "StepResultNET.h" #include "RawResponseDlg.h" #include "StepInternetDlg.h" #include "afxdialogex.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[] = __FILE__; #define new DEBUG_NEW #endif // RawResponseDlg dialog IMPLEMENT_DYNAMIC(RawResponseDlg,StyleDialog) RawResponseDlg::RawResponseDlg(CWnd* pParent /*=nullptr*/) :StyleDialog(IDD_RAW_RESPONSE,pParent) { } RawResponseDlg::~RawResponseDlg() { } void RawResponseDlg::DoDataExchange(CDataExchange* pDX) { StyleDialog::DoDataExchange(pDX); DDX_Control(pDX,IDC_RAW,m_editPayload,m_payload); } BEGIN_MESSAGE_MAP(RawResponseDlg,StyleDialog) ON_EN_KILLFOCUS(IDC_RAW,&RawResponseDlg::OnEnKillfocusPayload) END_MESSAGE_MAP() BOOL RawResponseDlg::OnInitDialog() { StyleDialog::OnInitDialog(); InitPayload(); SetCanResize(); return TRUE; } void RawResponseDlg::SetupDynamicLayout() { StyleDialog::SetupDynamicLayout(); CMFCDynamicLayout& manager = *GetDynamicLayout(); #ifdef _DEBUG manager.AssertValid(); #endif manager.AddItem(IDC_RAW,CMFCDynamicLayout::MoveNone(),CMFCDynamicLayout::SizeHorizontalAndVertical(100,100)); } void RawResponseDlg::InitPayload() { m_editPayload.SetFontName("Courier new",100); m_editPayload.SetMutable(false); } void RawResponseDlg::InitTab() { m_payload.Empty(); UpdateData(FALSE); } void RawResponseDlg::SetResult(StepResultNET* p_result) { m_payload = p_result->GetRawResponse(); m_payload.Replace("\n","\r\n"); UpdateData(FALSE); } void RawResponseDlg::StoreVariables() { // Nothing to do } // RawResponseDlg message handlers void RawResponseDlg::OnEnKillfocusPayload() { // Getting the payload as body for the message UpdateData(); if(m_testStep) { m_testStep->SetBody(m_payload); // Check parameters StepInternetDlg* step = reinterpret_cast<StepInternetDlg*>(GetParent()->GetParent()); step->EffectiveParameters(); } }
22.403101
111
0.597924
edwig
80f9094b2e531ee4919911441a2d788de2d55135
2,871
hpp
C++
hpx/performance_counters/parcels/count_time_stats.hpp
andreasbuhr/hpx
4366a90aacbd3e95428a94ab24a1646a67459cc2
[ "BSL-1.0" ]
null
null
null
hpx/performance_counters/parcels/count_time_stats.hpp
andreasbuhr/hpx
4366a90aacbd3e95428a94ab24a1646a67459cc2
[ "BSL-1.0" ]
null
null
null
hpx/performance_counters/parcels/count_time_stats.hpp
andreasbuhr/hpx
4366a90aacbd3e95428a94ab24a1646a67459cc2
[ "BSL-1.0" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011 Katelyn Kufahl // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //////////////////////////////////////////////////////////////////////////////// #if !defined(HPX_05A1C29B_DB73_463A_8C9D_B8EDC3B69F5E) #define HPX_05A1C29B_DB73_463A_8C9D_B8EDC3B69F5E #include <boost/config.hpp> #include <boost/assert.hpp> #include <boost/accumulators/accumulators.hpp> #include <boost/accumulators/statistics/variance.hpp> #include <boost/accumulators/statistics/mean.hpp> #include <boost/accumulators/statistics/moment.hpp> #include <boost/cstdint.hpp> #include <boost/atomic.hpp> #include <hpx/performance_counters/parcels/count_and_time_data_point.hpp> #include <hpx/util/high_resolution_timer.hpp> #include <hpx/util/spinlock.hpp> namespace hpx { namespace performance_counters { namespace parcels { class count_time_stats { typedef hpx::util::spinlock mutex_type; typedef mutex_type::scoped_lock lock; typedef boost::accumulators::accumulator_set acc_set; public: count_time_stats(): count_time_stats_size(0) {} boost::int64_t size() const; void push_back(data_point const& x); double mean_time() const; double moment_time() const; double variance_time() const; double total_time() const; private: util::high_resolution_timer timer; boost::atomic<boost::int64_t> count_time_stats_size; // Create mutexes for accumulator functions. mutable mutex_type acc_mtx; // Create accumulator sets. acc_set < double, boost::accumulators::features< boost::accumulators::tag::mean > > mean_time_acc; acc_set < double, boost::accumulators::features< boost::accumulators::tag::moment<2> > > moment_time_acc; acc_set < double, boost::accumulators::features< boost::accumulators::tag::variance> > variance_time_acc; }; inline void count_time_stats::push_back(count_and_time_data_point const& x) { lock mtx(acc_mtx) ++count_time_stats_size; mean_time_acc(x.time); moment_time_acc(x.time); variance_time_acc(x.time); } inline boost::int64_t count_time_stats::size() const { return count_time_stats_size.load(); } inline double count_time_stats::mean_time() const { lock mtx(acc_mtx); return boost::accumulators::extract::mean(mean_time_acc); } inline double count_time_stats::moment_time() const { lock mtx(acc_mtx); return boost::accumulators::extract::moment<2>(moment_time_acc); } inline double count_time_stats::variance_time() const { lock mtx(acc_mtx); return boost::accumulators::extract::variance(variance_time_acc); } }}} #endif // HPX_05A1C29B_DB73_463A_8C9D_B8EDC3B69F5E
26.831776
80
0.695925
andreasbuhr
80fd9445db389266bd3811e34ba54dcf7ca678d3
532
cpp
C++
lab0/Q5.cpp
jasonsie88/Algorithm
4d373df037aa68f4810e271d7f8488f3ded81864
[ "MIT" ]
1
2021-09-14T12:10:50.000Z
2021-09-14T12:10:50.000Z
lab0/Q5.cpp
jasonsie88/Algorithm
4d373df037aa68f4810e271d7f8488f3ded81864
[ "MIT" ]
null
null
null
lab0/Q5.cpp
jasonsie88/Algorithm
4d373df037aa68f4810e271d7f8488f3ded81864
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; int main(){ int ncase; while(cin>>ncase){ if(ncase==0){ break; } int a1[ncase+5],a2[ncase+5]; for(int i=0;i<ncase;i++){ cin>>a1[i]>>a2[i]; } bool flag=true; if(ncase%2){ cout<<"NO\n"; }else{ sort(a1,a1+ncase); sort(a2,a2+ncase); for(int i=0;i<ncase;i++){ if(a1[i]!=a2[i]){ flag=false; break; } } if(flag){ cout<<"YES\n"; }else{ cout<<"NO\n"; } } } return 0; }
14
33
0.456767
jasonsie88
44005351e0d4c83cc5ca5c08aee2c529b22f4080
40,782
cc
C++
src/bin/dhcp6/json_config_parser.cc
oss-mirror/isc-kea
e7bfb8886b0312a293e73846499095e7ec9686b9
[ "Apache-2.0" ]
273
2015-01-22T14:14:42.000Z
2022-03-13T10:27:44.000Z
src/bin/dhcp6/json_config_parser.cc
oss-mirror/isc-kea
e7bfb8886b0312a293e73846499095e7ec9686b9
[ "Apache-2.0" ]
104
2015-01-16T16:37:06.000Z
2021-08-08T19:38:45.000Z
src/bin/dhcp6/json_config_parser.cc
oss-mirror/isc-kea
e7bfb8886b0312a293e73846499095e7ec9686b9
[ "Apache-2.0" ]
133
2015-02-21T14:06:39.000Z
2022-02-27T08:56:40.000Z
// Copyright (C) 2012-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> #include <asiolink/io_address.h> #include <cc/data.h> #include <cc/command_interpreter.h> #include <config/command_mgr.h> #include <database/dbaccess_parser.h> #include <dhcp/libdhcp++.h> #include <dhcp6/json_config_parser.h> #include <dhcp6/dhcp6_log.h> #include <dhcp6/dhcp6_srv.h> #include <dhcp/iface_mgr.h> #include <dhcpsrv/cb_ctl_dhcp4.h> #include <dhcpsrv/cfg_option.h> #include <dhcpsrv/cfgmgr.h> #include <dhcpsrv/db_type.h> #include <dhcpsrv/pool.h> #include <dhcpsrv/subnet.h> #include <dhcpsrv/timer_mgr.h> #include <dhcpsrv/triplet.h> #include <dhcpsrv/parsers/client_class_def_parser.h> #include <dhcpsrv/parsers/dhcp_parsers.h> #include <dhcpsrv/parsers/duid_config_parser.h> #include <dhcpsrv/parsers/expiration_config_parser.h> #include <dhcpsrv/parsers/host_reservation_parser.h> #include <dhcpsrv/parsers/host_reservations_list_parser.h> #include <dhcpsrv/parsers/ifaces_config_parser.h> #include <dhcpsrv/parsers/multi_threading_config_parser.h> #include <dhcpsrv/parsers/option_data_parser.h> #include <dhcpsrv/parsers/dhcp_queue_control_parser.h> #include <dhcpsrv/parsers/simple_parser6.h> #include <dhcpsrv/parsers/shared_networks_list_parser.h> #include <dhcpsrv/parsers/sanity_checks_parser.h> #include <dhcpsrv/host_data_source_factory.h> #include <hooks/hooks_parser.h> #include <hooks/hooks_manager.h> #include <log/logger_support.h> #include <process/config_ctl_parser.h> #include <util/encode/hex.h> #include <util/strutil.h> #include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> #include <boost/scoped_ptr.hpp> #include <boost/shared_ptr.hpp> #include <iostream> #include <limits> #include <map> #include <netinet/in.h> #include <vector> #include <stdint.h> using namespace std; using namespace isc; using namespace isc::data; using namespace isc::dhcp; using namespace isc::asiolink; using namespace isc::hooks; using namespace isc::process; namespace { /// @brief Checks if specified directory exists. /// /// @param dir_path Path to a directory. /// @throw BadValue If the directory does not exist or is not a directory. void dirExists(const string& dir_path) { struct stat statbuf; if (stat(dir_path.c_str(), &statbuf) < 0) { isc_throw(BadValue, "Bad directory '" << dir_path << "': " << strerror(errno)); } if ((statbuf.st_mode & S_IFMT) != S_IFDIR) { isc_throw(BadValue, "'" << dir_path << "' is not a directory"); } } /// @brief Parser for list of RSOO options /// /// This parser handles a Dhcp6/relay-supplied-options entry. It contains a /// list of RSOO-enabled options which should be sent back to the client. /// /// The options on this list can be specified using an option code or option /// name. Therefore, the values on the list should always be enclosed in /// "quotes". class RSOOListConfigParser : public isc::data::SimpleParser { public: /// @brief parses parameters value /// /// Parses configuration entry (list of sources) and adds each element /// to the RSOO list. /// /// @param value pointer to the content of parsed values /// @param cfg server configuration (RSOO will be stored here) void parse(const SrvConfigPtr& cfg, const isc::data::ConstElementPtr& value) { try { BOOST_FOREACH(ConstElementPtr source_elem, value->listValue()) { std::string option_str = source_elem->stringValue(); // This option can be either code (integer) or name. Let's try code first int64_t code = 0; try { code = boost::lexical_cast<int64_t>(option_str); // Protect against the negative value and too high value. if (code < 0) { isc_throw(BadValue, "invalid option code value specified '" << option_str << "', the option code must be a" " non-negative value"); } else if (code > std::numeric_limits<uint16_t>::max()) { isc_throw(BadValue, "invalid option code value specified '" << option_str << "', the option code must not be" " greater than '" << std::numeric_limits<uint16_t>::max() << "'"); } } catch (const boost::bad_lexical_cast &) { // Oh well, it's not a number } if (!code) { const OptionDefinitionPtr def = LibDHCP::getOptionDef(DHCP6_OPTION_SPACE, option_str); if (def) { code = def->getCode(); } else { isc_throw(BadValue, "unable to find option code for the " " specified option name '" << option_str << "'" " while parsing the list of enabled" " relay-supplied-options"); } } cfg->getCfgRSOO()->enable(code); } } catch (const std::exception& ex) { // Rethrow exception with the appended position of the parsed // element. isc_throw(DhcpConfigError, ex.what() << " (" << value->getPosition() << ")"); } } }; /// @brief Parser that takes care of global DHCPv6 parameters and utility /// functions that work on global level. /// /// This class is a collection of utility method that either handle /// global parameters (see @ref parse), or conducts operations on /// global level (see @ref sanityChecks and @ref copySubnets6). /// /// See @ref parse method for a list of supported parameters. class Dhcp6ConfigParser : public isc::data::SimpleParser { public: /// @brief Sets global parameters in staging configuration /// /// @param global global configuration scope /// @param cfg Server configuration (parsed parameters will be stored here) /// /// Currently this method sets the following global parameters: /// /// - data-directory /// - decline-probation-period /// - dhcp4o6-port /// - user-context /// /// @throw DhcpConfigError if parameters are missing or /// or having incorrect values. void parse(const SrvConfigPtr& srv_config, const ConstElementPtr& global) { // Set the data directory for server id file. if (global->contains("data-directory")) { CfgMgr::instance().setDataDir(getString(global, "data-directory"), false); } // Set the probation period for decline handling. uint32_t probation_period = getUint32(global, "decline-probation-period"); srv_config->setDeclinePeriod(probation_period); // Set the DHCPv4-over-DHCPv6 interserver port. uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port"); srv_config->setDhcp4o6Port(dhcp4o6_port); // Set the global user context. ConstElementPtr user_context = global->get("user-context"); if (user_context) { srv_config->setContext(user_context); } // Set the server's logical name std::string server_tag = getString(global, "server-tag"); srv_config->setServerTag(server_tag); } /// @brief Sets global parameters before other parameters are parsed. /// /// This method sets selected global parameters before other parameters /// are parsed. This is important when the behavior of the parsers /// run later depends on these global parameters. /// /// Currently this method sets the following global parameters: /// - ip-reservations-unique /// /// @param global global configuration scope /// @param cfg Server configuration (parsed parameters will be stored here) void parseEarly(const SrvConfigPtr& cfg, const ConstElementPtr& global) { // Set ip-reservations-unique flag. bool ip_reservations_unique = getBoolean(global, "ip-reservations-unique"); cfg->setIPReservationsUnique(ip_reservations_unique); } /// @brief Copies subnets from shared networks to regular subnets container /// /// @param from pointer to shared networks container (copy from here) /// @param dest pointer to cfg subnets6 (copy to here) /// @throw BadValue if any pointer is missing /// @throw DhcpConfigError if there are duplicates (or other subnet defects) void copySubnets6(const CfgSubnets6Ptr& dest, const CfgSharedNetworks6Ptr& from) { if (!dest || !from) { isc_throw(BadValue, "Unable to copy subnets: at least one pointer is null"); } const SharedNetwork6Collection* networks = from->getAll(); if (!networks) { // Nothing to copy. Technically, it should return a pointer to empty // container, but let's handle null pointer as well. return; } // Let's go through all the networks one by one for (auto net = networks->begin(); net != networks->end(); ++net) { // For each network go through all the subnets in it. const Subnet6Collection* subnets = (*net)->getAllSubnets(); if (!subnets) { // Shared network without subnets it weird, but we decided to // accept such configurations. continue; } // For each subnet, add it to a list of regular subnets. for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) { dest->add(*subnet); } } } /// @brief Conducts global sanity checks /// /// This method is very simple now, but more sanity checks are expected /// in the future. /// /// @param cfg - the parsed structure /// @param global global Dhcp4 scope /// @throw DhcpConfigError in case of issues found void sanityChecks(const SrvConfigPtr& cfg, const ConstElementPtr& global) { /// Global lifetime sanity checks cfg->sanityChecksLifetime("preferred-lifetime"); cfg->sanityChecksLifetime("valid-lifetime"); /// Shared network sanity checks const SharedNetwork6Collection* networks = cfg->getCfgSharedNetworks6()->getAll(); if (networks) { sharedNetworksSanityChecks(*networks, global->get("shared-networks")); } } /// @brief Sanity checks for shared networks /// /// This method verifies if there are no issues with shared networks. /// @param networks pointer to shared networks being checked /// @param json shared-networks element /// @throw DhcpConfigError if issues are encountered void sharedNetworksSanityChecks(const SharedNetwork6Collection& networks, ConstElementPtr json) { /// @todo: in case of errors, use json to extract line numbers. if (!json) { // No json? That means that the shared-networks was never specified // in the config. return; } // Used for names uniqueness checks. std::set<string> names; // Let's go through all the networks one by one for (auto net = networks.begin(); net != networks.end(); ++net) { string txt; // Let's check if all subnets have either the same interface // or don't have the interface specified at all. string iface = (*net)->getIface(); const Subnet6Collection* subnets = (*net)->getAllSubnets(); if (subnets) { bool rapid_commit = false; // For each subnet, add it to a list of regular subnets. for (auto subnet = subnets->begin(); subnet != subnets->end(); ++subnet) { // Rapid commit must either be enabled or disabled in all subnets // in the shared network. if (subnet == subnets->begin()) { // If this is the first subnet, remember the value. rapid_commit = (*subnet)->getRapidCommit(); } else { // Ok, this is the second or following subnets. The value // must match what was set in the first subnet. if (rapid_commit != (*subnet)->getRapidCommit()) { isc_throw(DhcpConfigError, "All subnets in a shared network " "must have the same rapid-commit value. Subnet " << (*subnet)->toText() << " has specified rapid-commit " << ( (*subnet)->getRapidCommit() ? "true" : "false") << ", but earlier subnet in the same shared-network" << " or the shared-network itself used rapid-commit " << (rapid_commit ? "true" : "false")); } } if (iface.empty()) { iface = (*subnet)->getIface(); continue; } if ((*subnet)->getIface().empty()) { continue; } if ((*subnet)->getIface() != iface) { isc_throw(DhcpConfigError, "Subnet " << (*subnet)->toText() << " has specified interface " << (*subnet)->getIface() << ", but earlier subnet in the same shared-network" << " or the shared-network itself used " << iface); } // Let's collect the subnets in case we later find out the // subnet doesn't have a mandatory name. txt += (*subnet)->toText() + " "; } } // Next, let's check name of the shared network. if ((*net)->getName().empty()) { isc_throw(DhcpConfigError, "Shared-network with subnets " << txt << " is missing mandatory 'name' parameter"); } // Is it unique? if (names.find((*net)->getName()) != names.end()) { isc_throw(DhcpConfigError, "A shared-network with " "name " << (*net)->getName() << " defined twice."); } names.insert((*net)->getName()); } } }; } // anonymous namespace namespace isc { namespace dhcp { /// @brief Initialize the command channel based on the staging configuration /// /// Only close the current channel, if the new channel configuration is /// different. This avoids disconnecting a client and hence not sending them /// a command result, unless they specifically alter the channel configuration. /// In that case the user simply has to accept they'll be disconnected. /// void configureCommandChannel() { // Get new socket configuration. ConstElementPtr sock_cfg = CfgMgr::instance().getStagingCfg()->getControlSocketInfo(); // Get current socket configuration. ConstElementPtr current_sock_cfg = CfgMgr::instance().getCurrentCfg()->getControlSocketInfo(); // Determine if the socket configuration has changed. It has if // both old and new configuration is specified but respective // data elements aren't equal. bool sock_changed = (sock_cfg && current_sock_cfg && !sock_cfg->equals(*current_sock_cfg)); // If the previous or new socket configuration doesn't exist or // the new configuration differs from the old configuration we // close the existing socket and open a new socket as appropriate. // Note that closing an existing socket means the client will not // receive the configuration result. if (!sock_cfg || !current_sock_cfg || sock_changed) { // Close the existing socket (if any). isc::config::CommandMgr::instance().closeCommandSocket(); if (sock_cfg) { // This will create a control socket and install the external // socket in IfaceMgr. That socket will be monitored when // Dhcp4Srv::receivePacket() calls IfaceMgr::receive4() and // callback in CommandMgr will be called, if necessary. isc::config::CommandMgr::instance().openCommandSocket(sock_cfg); } } } isc::data::ConstElementPtr configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set, bool check_only) { if (!config_set) { ConstElementPtr answer = isc::config::createAnswer(1, string("Can't parse NULL config")); return (answer); } LOG_DEBUG(dhcp6_logger, DBG_DHCP6_COMMAND, DHCP6_CONFIG_START) .arg(server.redactConfig(config_set)->str()); // Before starting any subnet operations, let's reset the subnet-id counter, // so newly recreated configuration starts with first subnet-id equal 1. Subnet::resetSubnetID(); // Close DHCP sockets and remove any existing timers. if (!check_only) { IfaceMgr::instance().closeSockets(); TimerMgr::instance()->unregisterTimers(); server.discardPackets(); server.getCBControl()->reset(); } // Revert any runtime option definitions configured so far and not committed. LibDHCP::revertRuntimeOptionDefs(); // Let's set empty container in case a user hasn't specified any configuration // for option definitions. This is equivalent to committing empty container. LibDHCP::setRuntimeOptionDefs(OptionDefSpaceContainer()); // Print the list of known backends. HostDataSourceFactory::printRegistered(); // Answer will hold the result. ConstElementPtr answer; // Rollback informs whether error occurred and original data // have to be restored to global storages. bool rollback = false; // Global parameter name in case of an error. string parameter_name; ElementPtr mutable_cfg; SrvConfigPtr srv_config; try { // Get the staging configuration. srv_config = CfgMgr::instance().getStagingCfg(); // This is a way to convert ConstElementPtr to ElementPtr. // We need a config that can be edited, because we will insert // default values and will insert derived values as well. mutable_cfg = boost::const_pointer_cast<Element>(config_set); // Relocate dhcp-ddns parameters that have moved to global scope. // Rule is that a global value overrides the dhcp-ddns value, so // we need to do this before we apply global defaults. // Note this is done for backward compatibility. srv_config->moveDdnsParams(mutable_cfg); // Move from reservation mode to new reservations flags. // @todo add warning BaseNetworkParser::moveReservationMode(mutable_cfg); // Set all default values if not specified by the user. SimpleParser6::setAllDefaults(mutable_cfg); // And now derive (inherit) global parameters to subnets, if not specified. SimpleParser6::deriveParameters(mutable_cfg); // In principle we could have the following code structured as a series // of long if else if clauses. That would give a marginal performance // boost, but would make the code less readable. We had serious issues // with the parser code debugability, so I decided to keep it as a // series of independent ifs. // This parser is used in several places. Dhcp6ConfigParser global_parser; // Apply global options in the staging config, e.g. ip-reservations-unique global_parser.parseEarly(srv_config, mutable_cfg); // Specific check for this global parameter. ConstElementPtr data_directory = mutable_cfg->get("data-directory"); if (data_directory) { parameter_name = "data-directory"; dirExists(data_directory->stringValue()); } // We need definitions first ConstElementPtr option_defs = mutable_cfg->get("option-def"); if (option_defs) { parameter_name = "option-def"; OptionDefListParser parser(AF_INET6); CfgOptionDefPtr cfg_option_def = srv_config->getCfgOptionDef(); parser.parse(cfg_option_def, option_defs); } ConstElementPtr option_datas = mutable_cfg->get("option-data"); if (option_datas) { parameter_name = "option-data"; OptionDataListParser parser(AF_INET6); CfgOptionPtr cfg_option = srv_config->getCfgOption(); parser.parse(cfg_option, option_datas); } ConstElementPtr mac_sources = mutable_cfg->get("mac-sources"); if (mac_sources) { parameter_name = "mac-sources"; MACSourcesListConfigParser parser; CfgMACSource& mac_source = srv_config->getMACSources(); parser.parse(mac_source, mac_sources); } ConstElementPtr control_socket = mutable_cfg->get("control-socket"); if (control_socket) { parameter_name = "control-socket"; ControlSocketParser parser; parser.parse(*srv_config, control_socket); } ConstElementPtr multi_threading = mutable_cfg->get("multi-threading"); if (multi_threading) { parameter_name = "multi-threading"; MultiThreadingConfigParser parser; parser.parse(*srv_config, multi_threading); } ConstElementPtr queue_control = mutable_cfg->get("dhcp-queue-control"); if (queue_control) { parameter_name = "dhcp-queue-control"; DHCPQueueControlParser parser; srv_config->setDHCPQueueControl(parser.parse(queue_control)); } ConstElementPtr hr_identifiers = mutable_cfg->get("host-reservation-identifiers"); if (hr_identifiers) { parameter_name = "host-reservation-identifiers"; HostReservationIdsParser6 parser; parser.parse(hr_identifiers); } ConstElementPtr server_id = mutable_cfg->get("server-id"); if (server_id) { parameter_name = "server-id"; DUIDConfigParser parser; const CfgDUIDPtr& cfg = srv_config->getCfgDUID(); parser.parse(cfg, server_id); } ConstElementPtr ifaces_config = mutable_cfg->get("interfaces-config"); if (ifaces_config) { parameter_name = "interfaces-config"; IfacesConfigParser parser(AF_INET6, check_only); CfgIfacePtr cfg_iface = srv_config->getCfgIface(); parser.parse(cfg_iface, ifaces_config); } ConstElementPtr sanity_checks = mutable_cfg->get("sanity-checks"); if (sanity_checks) { parameter_name = "sanity-checks"; SanityChecksParser parser; parser.parse(*srv_config, sanity_checks); } ConstElementPtr expiration_cfg = mutable_cfg->get("expired-leases-processing"); if (expiration_cfg) { parameter_name = "expired-leases-processing"; ExpirationConfigParser parser; parser.parse(expiration_cfg); } // The hooks-libraries configuration must be parsed after parsing // multi-threading configuration so that libraries are checked // for multi-threading compatibility. ConstElementPtr hooks_libraries = mutable_cfg->get("hooks-libraries"); if (hooks_libraries) { parameter_name = "hooks-libraries"; HooksLibrariesParser hooks_parser; HooksConfig& libraries = srv_config->getHooksConfig(); hooks_parser.parse(libraries, hooks_libraries); libraries.verifyLibraries(hooks_libraries->getPosition()); } // D2 client configuration. D2ClientConfigPtr d2_client_cfg; // Legacy DhcpConfigParser stuff below. ConstElementPtr dhcp_ddns = mutable_cfg->get("dhcp-ddns"); if (dhcp_ddns) { parameter_name = "dhcp-ddns"; // Apply defaults D2ClientConfigParser::setAllDefaults(dhcp_ddns); D2ClientConfigParser parser; d2_client_cfg = parser.parse(dhcp_ddns); } ConstElementPtr client_classes = mutable_cfg->get("client-classes"); if (client_classes) { parameter_name = "client-classes"; ClientClassDefListParser parser; ClientClassDictionaryPtr dictionary = parser.parse(client_classes, AF_INET6); srv_config->setClientClassDictionary(dictionary); } // Please move at the end when migration will be finished. ConstElementPtr lease_database = mutable_cfg->get("lease-database"); if (lease_database) { parameter_name = "lease-database"; db::DbAccessParser parser; std::string access_string; parser.parse(access_string, lease_database); CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); cfg_db_access->setLeaseDbAccessString(access_string); } ConstElementPtr hosts_database = mutable_cfg->get("hosts-database"); if (hosts_database) { parameter_name = "hosts-database"; db::DbAccessParser parser; std::string access_string; parser.parse(access_string, hosts_database); CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); cfg_db_access->setHostDbAccessString(access_string); } ConstElementPtr hosts_databases = mutable_cfg->get("hosts-databases"); if (hosts_databases) { parameter_name = "hosts-databases"; CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess(); db::DbAccessParser parser; for (auto it : hosts_databases->listValue()) { std::string access_string; parser.parse(access_string, it); cfg_db_access->setHostDbAccessString(access_string); } } // Keep relative orders of shared networks and subnets. ConstElementPtr shared_networks = mutable_cfg->get("shared-networks"); if (shared_networks) { parameter_name = "shared-networks"; /// We need to create instance of SharedNetworks6ListParser /// and parse the list of the shared networks into the /// CfgSharedNetworks6 object. One additional step is then to /// add subnets from the CfgSharedNetworks6 into CfgSubnets6 /// as well. SharedNetworks6ListParser parser; CfgSharedNetworks6Ptr cfg = srv_config->getCfgSharedNetworks6(); parser.parse(cfg, shared_networks); // We also need to put the subnets it contains into normal // subnets list. global_parser.copySubnets6(srv_config->getCfgSubnets6(), cfg); } ConstElementPtr subnet6 = mutable_cfg->get("subnet6"); if (subnet6) { parameter_name = "subnet6"; Subnets6ListConfigParser subnets_parser; // parse() returns number of subnets parsed. We may log it one day. subnets_parser.parse(srv_config, subnet6); } ConstElementPtr reservations = mutable_cfg->get("reservations"); if (reservations) { parameter_name = "reservations"; HostCollection hosts; HostReservationsListParser<HostReservationParser6> parser; parser.parse(SUBNET_ID_GLOBAL, reservations, hosts); for (auto h = hosts.begin(); h != hosts.end(); ++h) { srv_config->getCfgHosts()->add(*h); } } ConstElementPtr config_control = mutable_cfg->get("config-control"); if (config_control) { parameter_name = "config-control"; ConfigControlParser parser; ConfigControlInfoPtr config_ctl_info = parser.parse(config_control); CfgMgr::instance().getStagingCfg()->setConfigControlInfo(config_ctl_info); } ConstElementPtr rsoo_list = mutable_cfg->get("relay-supplied-options"); if (rsoo_list) { parameter_name = "relay-supplied-options"; RSOOListConfigParser parser; parser.parse(srv_config, rsoo_list); } ConstElementPtr compatibility = mutable_cfg->get("compatibility"); if (compatibility) { for (auto kv : compatibility->mapValue()) { if (kv.first == "lenient-option-parsing") { CfgMgr::instance().getStagingCfg()->setLenientOptionParsing( kv.second->boolValue()); } } } // Make parsers grouping. ConfigPair config_pair; const std::map<std::string, ConstElementPtr>& values_map = mutable_cfg->mapValue(); BOOST_FOREACH(config_pair, values_map) { parameter_name = config_pair.first; // These are converted to SimpleParser and are handled already above. if ((config_pair.first == "data-directory") || (config_pair.first == "option-def") || (config_pair.first == "option-data") || (config_pair.first == "mac-sources") || (config_pair.first == "control-socket") || (config_pair.first == "multi-threading") || (config_pair.first == "dhcp-queue-control") || (config_pair.first == "host-reservation-identifiers") || (config_pair.first == "server-id") || (config_pair.first == "interfaces-config") || (config_pair.first == "sanity-checks") || (config_pair.first == "expired-leases-processing") || (config_pair.first == "hooks-libraries") || (config_pair.first == "dhcp-ddns") || (config_pair.first == "client-classes") || (config_pair.first == "lease-database") || (config_pair.first == "hosts-database") || (config_pair.first == "hosts-databases") || (config_pair.first == "subnet6") || (config_pair.first == "shared-networks") || (config_pair.first == "reservations") || (config_pair.first == "config-control") || (config_pair.first == "relay-supplied-options") || (config_pair.first == "compatibility")) { continue; } // As of Kea 1.6.0 we have two ways of inheriting the global parameters. // The old method is used in JSON configuration parsers when the global // parameters are derived into the subnets and shared networks and are // being treated as explicitly specified. The new way used by the config // backend is the dynamic inheritance whereby each subnet and shared // network uses a callback function to return global parameter if it // is not specified at lower level. This callback uses configured globals. // We deliberately include both default and explicitly specified globals // so as the callback can access the appropriate global values regardless // whether they are set to a default or other value. if ( (config_pair.first == "renew-timer") || (config_pair.first == "rebind-timer") || (config_pair.first == "preferred-lifetime") || (config_pair.first == "min-preferred-lifetime") || (config_pair.first == "max-preferred-lifetime") || (config_pair.first == "valid-lifetime") || (config_pair.first == "min-valid-lifetime") || (config_pair.first == "max-valid-lifetime") || (config_pair.first == "decline-probation-period") || (config_pair.first == "dhcp4o6-port") || (config_pair.first == "server-tag") || (config_pair.first == "reservation-mode") || (config_pair.first == "reservations-global") || (config_pair.first == "reservations-in-subnet") || (config_pair.first == "reservations-out-of-pool") || (config_pair.first == "calculate-tee-times") || (config_pair.first == "t1-percent") || (config_pair.first == "t2-percent") || (config_pair.first == "cache-threshold") || (config_pair.first == "cache-max-age") || (config_pair.first == "loggers") || (config_pair.first == "hostname-char-set") || (config_pair.first == "hostname-char-replacement") || (config_pair.first == "ddns-send-updates") || (config_pair.first == "ddns-override-no-update") || (config_pair.first == "ddns-override-client-update") || (config_pair.first == "ddns-replace-client-name") || (config_pair.first == "ddns-generated-prefix") || (config_pair.first == "ddns-qualifying-suffix") || (config_pair.first == "ddns-update-on-renew") || (config_pair.first == "ddns-use-conflict-resolution") || (config_pair.first == "store-extended-info") || (config_pair.first == "statistic-default-sample-count") || (config_pair.first == "statistic-default-sample-age") || (config_pair.first == "ip-reservations-unique") || (config_pair.first == "parked-packet-limit")) { CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first, config_pair.second); continue; } // Nothing to configure for the user-context. if (config_pair.first == "user-context") { continue; } // If we got here, no code handled this parameter, so we bail out. isc_throw(DhcpConfigError, "unsupported global configuration parameter: " << config_pair.first << " (" << config_pair.second->getPosition() << ")"); } // Reset parameter name. parameter_name = "<post parsing>"; // Apply global options in the staging config. global_parser.parse(srv_config, mutable_cfg); // This method conducts final sanity checks and tweaks. In particular, // it checks that there is no conflict between plain subnets and those // defined as part of shared networks. global_parser.sanityChecks(srv_config, mutable_cfg); // Validate D2 client configuration. if (!d2_client_cfg) { d2_client_cfg.reset(new D2ClientConfig()); } d2_client_cfg->validateContents(); srv_config->setD2ClientConfig(d2_client_cfg); } catch (const isc::Exception& ex) { LOG_ERROR(dhcp6_logger, DHCP6_PARSER_FAIL) .arg(parameter_name).arg(ex.what()); answer = isc::config::createAnswer(1, ex.what()); // An error occurred, so make sure that we restore original data. rollback = true; } catch (...) { // For things like bad_cast in boost::lexical_cast LOG_ERROR(dhcp6_logger, DHCP6_PARSER_EXCEPTION).arg(parameter_name); answer = isc::config::createAnswer(1, "undefined configuration" " processing error"); // An error occurred, so make sure that we restore original data. rollback = true; } if (check_only) { rollback = true; if (!answer) { answer = isc::config::createAnswer(0, "Configuration seems sane. Control-socket, hook-libraries, and D2 " "configuration were sanity checked, but not applied."); } } // So far so good, there was no parsing error so let's commit the // configuration. This will add created subnets and option values into // the server's configuration. // This operation should be exception safe but let's make sure. if (!rollback) { try { // Setup the command channel. configureCommandChannel(); // No need to commit interface names as this is handled by the // CfgMgr::commit() function. // Apply the staged D2ClientConfig, used to be done by parser commit D2ClientConfigPtr cfg; cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig(); CfgMgr::instance().setD2ClientConfig(cfg); // This occurs last as if it succeeds, there is no easy way to // revert it. As a result, the failure to commit a subsequent // change causes problems when trying to roll back. HooksManager::prepareUnloadLibraries(); static_cast<void>(HooksManager::unloadLibraries()); const HooksConfig& libraries = CfgMgr::instance().getStagingCfg()->getHooksConfig(); libraries.loadLibraries(); } catch (const isc::Exception& ex) { LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what()); answer = isc::config::createAnswer(2, ex.what()); // An error occurred, so make sure to restore the original data. rollback = true; } catch (...) { // For things like bad_cast in boost::lexical_cast LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_EXCEPTION); answer = isc::config::createAnswer(2, "undefined configuration" " parsing error"); // An error occurred, so make sure to restore the original data. rollback = true; } } // Moved from the commit block to add the config backend indication. if (!rollback) { try { // If there are config backends, fetch and merge into staging config server.getCBControl()->databaseConfigFetch(srv_config, CBControlDHCPv6::FetchMode::FETCH_ALL); } catch (const isc::Exception& ex) { std::ostringstream err; err << "during update from config backend database: " << ex.what(); LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(err.str()); answer = isc::config::createAnswer(2, err.str()); // An error occurred, so make sure to restore the original data. rollback = true; } catch (...) { // For things like bad_cast in boost::lexical_cast std::ostringstream err; err << "during update from config backend database: " << "undefined configuration parsing error"; LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(err.str()); answer = isc::config::createAnswer(2, err.str()); // An error occurred, so make sure to restore the original data. rollback = true; } } // Rollback changes as the configuration parsing failed. if (rollback) { // Revert to original configuration of runtime option definitions // in the libdhcp++. LibDHCP::revertRuntimeOptionDefs(); return (answer); } LOG_INFO(dhcp6_logger, DHCP6_CONFIG_COMPLETE) .arg(CfgMgr::instance().getStagingCfg()-> getConfigSummary(SrvConfig::CFGSEL_ALL6)); // Everything was fine. Configuration is successful. answer = isc::config::createAnswer(0, "Configuration successful."); return (answer); } } // namespace dhcp } // namespace isc
42.569937
94
0.597568
oss-mirror
4400ac6a4b285923557ac5fb8ca4f0d259f3ca9e
774
cpp
C++
2stack_queue.cpp
xiaobinf/algorithm
85a0cfc72daf6da91c4d0f568e31be69d4f19bd9
[ "MIT" ]
null
null
null
2stack_queue.cpp
xiaobinf/algorithm
85a0cfc72daf6da91c4d0f568e31be69d4f19bd9
[ "MIT" ]
null
null
null
2stack_queue.cpp
xiaobinf/algorithm
85a0cfc72daf6da91c4d0f568e31be69d4f19bd9
[ "MIT" ]
null
null
null
#include <iostream> #include <stack> #include <exception> using std::clog; using std::endl; /** * 用两个栈模拟队列操作 画好过程图 * @tparam T */ template <class T> class QStack{ public: QStack(){} ~QStack(){} T q_pop(); void q_push(T x); private: std::stack<T> s1; std::stack<T> s2; }; template <class T> T QStack::q_pop(){ if(s1.size()<=0){ while(s2.size()>0){ T& data=s2.top(); s2.pop(); s1.push(data); } } if(s1.size()==0){ clog<<"stack is empty"<<endl; throw std::exception(); } T head=s1.top(); s1.pop(); return head; } template <class T> void QStack::q_push(T x) { s2.push(x); } int main() { return 0; }
16.468085
38
0.484496
xiaobinf
44010427dfc62f2f560cc39530688bc9d5ee9cf0
478
cc
C++
abel/strings/internal/ostringstream.cc
Conun/abel
485ef38c917c0df3750242cc38966a2bcb163588
[ "BSD-3-Clause" ]
null
null
null
abel/strings/internal/ostringstream.cc
Conun/abel
485ef38c917c0df3750242cc38966a2bcb163588
[ "BSD-3-Clause" ]
null
null
null
abel/strings/internal/ostringstream.cc
Conun/abel
485ef38c917c0df3750242cc38966a2bcb163588
[ "BSD-3-Clause" ]
null
null
null
// #include <abel/strings/internal/ostringstream.h> namespace abel { namespace strings_internal { OStringStream::Buf::int_type OStringStream::overflow(int c) { assert(s_); if (!Buf::traits_type::eq_int_type(c, Buf::traits_type::eof())) s_->push_back(static_cast<char>(c)); return 1; } std::streamsize OStringStream::xsputn(const char* s, std::streamsize n) { assert(s_); s_->append(s, n); return n; } } // namespace strings_internal } // namespace abel
19.12
73
0.696653
Conun
4401838fbbaf23517ca138f45a07b2e3294e7e9f
887
cc
C++
netz/ether_support.cc
PariKhaleghi/BlackFish
dde6e4de00744be04848853e6f8d12cd4c54fd73
[ "BSD-3-Clause" ]
1
2022-03-03T08:47:33.000Z
2022-03-03T08:47:33.000Z
netz/ether_support.cc
PariKhaleghi/BlackFish
dde6e4de00744be04848853e6f8d12cd4c54fd73
[ "BSD-3-Clause" ]
null
null
null
netz/ether_support.cc
PariKhaleghi/BlackFish
dde6e4de00744be04848853e6f8d12cd4c54fd73
[ "BSD-3-Clause" ]
null
null
null
#ifdef OS_AIX #include <memory.h> #endif #ifdef OS_OPENBSD #include <memory.h> #endif #ifdef OS_LINUX #include <string.h> #endif #include "ether_support.h" #include "support.h" c_ether_header::c_ether_header(byte *ether_header) { header = (s_ether_header *)ether_header; } c_ether_header::c_ether_header(s_ether_header *ether_header) { header = ether_header; } byte *c_ether_header::get_raw() { return (byte *)header; } byte *c_ether_header::get_dst() { return header->dst; } void c_ether_header::set_dst(byte *dst) { memcpy(header->dst, dst, ETHER_ADDR_LEN); } byte *c_ether_header::get_src() { return header->src; } void c_ether_header::set_src(byte *src) { memcpy(header->src, src, ETHER_ADDR_LEN); } word c_ether_header::get_type() { return ntoh(header->type); } void c_ether_header::set_type(word type) { header->type = hton(type); }
14.783333
60
0.706877
PariKhaleghi
4402919f1922b8d1c7aa1b0aba90b53f65624833
1,803
cpp
C++
2course/Programming/examples/from_study_guide/5_1.cpp
posgen/OmsuMaterials
6132fe300154db97327667728c4cf3b0e19420e6
[ "Unlicense" ]
9
2017-04-03T08:52:58.000Z
2020-06-05T18:25:02.000Z
2course/Programming/examples/from_study_guide/5_1.cpp
posgen/OmsuMaterials
6132fe300154db97327667728c4cf3b0e19420e6
[ "Unlicense" ]
6
2018-02-07T18:26:27.000Z
2021-09-02T04:46:06.000Z
2course/Programming/examples/from_study_guide/5_1.cpp
posgen/OmsuMaterials
6132fe300154db97327667728c4cf3b0e19420e6
[ "Unlicense" ]
10
2018-11-12T18:18:47.000Z
2020-06-06T06:17:01.000Z
/* Определить функцию для вычисления по формуле Ньютона приблежённого значения арифметического квадратного корня. В формуле Ньютона итерации определяются по формуле r_[n+1] = (r_[n] + x / r_[n]) / 2 Версия для C++ */ #include <iostream> #include <cmath> #include <clocale> const double PRECISION = 0.000000001; /* Объявление функции с именем newton_root. Она принимает один аргумент типа double и возращает значение типа double. Объявление без описания тела функции (блок кода в фигурных скобках) - позволяет делать вызов этой функции в любом месте, до определения самой функции. */ double newton_root(double ); int main() { std::setlocale(LC_ALL, "RUS"); double x, result; std::cout << "Введите x: "; std::cin >> x; // вызываем функцию, передавая ей в качестве аргумента переменную x и сохраняя возращённый ею результат в переменной result result = newton_root(x); std::cout << "Корень из x: " << result; return 0; } /* Ниже производится определение функции. В отличие от объявления, здесь обязательно указание имени передаваемых аргументов. Имя аргумента используется только в теле функции. Стоит заметить, что отделение объявления и определения функции не является обязательным при записи всего в одном файле. */ double newton_root(double num) { double r_cur, r_next = num; /* Действительные числа (float, double) лучше сравнивать с некоторой заранее определённой точностью по числу знаков после запятой. num == 0.0 - не гарантирует, что сравнение будет истино даже если num = 0; */ if (num < PRECISION) return 0.0; do { r_cur = r_next; r_next = (r_cur + num / r_cur) / 2; } while ( abs(r_cur - r_next) > PRECISION ); return r_next; }
28.619048
127
0.688297
posgen
4405819af9694991e962881bc68366cfcf3778a2
116
cpp
C++
src/virtual_call_in_destructor_link.cpp
geoffviola/undefined_behavior_study
c405fa766284473c5b3c9ce415c18bcc2bba227c
[ "Apache-2.0" ]
9
2017-03-18T09:15:36.000Z
2020-05-24T18:00:37.000Z
src/virtual_call_in_destructor_link.cpp
geoffviola/undefined_behavior_study
c405fa766284473c5b3c9ce415c18bcc2bba227c
[ "Apache-2.0" ]
1
2018-06-19T19:36:19.000Z
2018-10-15T16:49:29.000Z
src/virtual_call_in_destructor_link.cpp
geoffviola/undefined_behavior_study
c405fa766284473c5b3c9ce415c18bcc2bba227c
[ "Apache-2.0" ]
3
2017-03-18T01:44:49.000Z
2022-01-04T03:22:02.000Z
#include <cstdlib> #include "virtual_call_in_destructor_lib.hpp" int main() { Child c; return EXIT_SUCCESS; }
12.888889
45
0.732759
geoffviola
440766b9513511298f9600103484d10624b58b09
2,063
cpp
C++
library/src/main/jni/_onload.cpp
badpx/IndexBitmap
d940d56a31ce7f0ee717d12132c4c51c2fd6520b
[ "Apache-2.0" ]
11
2015-08-24T13:29:10.000Z
2020-07-18T08:10:55.000Z
library/src/main/jni/_onload.cpp
badpx/IndexBitmap
d940d56a31ce7f0ee717d12132c4c51c2fd6520b
[ "Apache-2.0" ]
3
2016-03-28T10:23:15.000Z
2018-11-02T02:13:00.000Z
library/src/main/jni/_onload.cpp
badpx/IndexBitmap
d940d56a31ce7f0ee717d12132c4c51c2fd6520b
[ "Apache-2.0" ]
4
2016-01-09T10:42:03.000Z
2019-05-02T03:04:37.000Z
#include <android/log.h> #include "baseutils.h" #include "_onload.h" #include "skbitmap_helper.h" #define LOCAL_DEBUG 0 static JNINativeMethod methods[] = { { "nativeInit", "(Landroid/graphics/Bitmap;[I)Z", (void*)Init }, { "nativeGetBytesPerPixel", "(Landroid/graphics/Bitmap;)I", (void*)GetBytesPerPixel }, { "nativeGetPalette", "(Landroid/graphics/Bitmap;[I)I", (void*)GetPalette }, { "nativeChangePalette", "(Landroid/graphics/Bitmap;[I)I", (void*)ChangePalette }, { "nativeIndex8FakeToAlpha8", "(Landroid/graphics/Bitmap;Z)I", (void*)Index8FakeToAlpha8 }, { "nativeGetConfig", "(Landroid/graphics/Bitmap;)I", (void*)GetConfig }, { "nativeSetConfig", "(Landroid/graphics/Bitmap;I)I", (void*)SetConfig }, { "nativeGetIndex8Config", "()I", (void*)GetIndex8Config }, }; jint registerNativeMethods(JNIEnv* env, const char *class_name, JNINativeMethod *methods, int num_methods) { int result = 0; jclass clazz = env->FindClass(class_name); if (LIKELY(clazz)) { result = env->RegisterNatives(clazz, methods, num_methods); if (UNLIKELY(result < 0)) { LOGE("registerNativeMethods failed(class=%s)", class_name); } } else { LOGE("registerNativeMethods: class'%s' not found", class_name); } return result; } static int register_native_methods(JNIEnv *env) { LOGV("register native method:"); if (registerNativeMethods(env, PACKAGE_NAME, methods, NUM_ARRAY_ELEMENTS(methods)) < 0) { return JNI_ERR; } return JNI_OK; } jint JNI_OnLoad(JavaVM *vm, void *) { #if LOCAL_DEBUG LOGI("JNI_OnLoad"); #endif JNIEnv *env; if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK) { return JNI_ERR; } if (!setupLibrary(env)) { #if LOCAL_DEBUG LOGF("setup library failed!"); #endif return JNI_ERR; } // register native methods if (register_native_methods(env) != JNI_OK) { return JNI_ERR; } setVM(vm); #if LOCAL_DEBUG LOGI("JNI_OnLoad:finshed:result=%d", result); #endif return JNI_VERSION_1_6; }
28.652778
108
0.672807
badpx
44076f00c9acc115ab70c1121a76857ad79248c9
438
hpp
C++
i23dSFM/matching/matcher_type.hpp
zyxrrr/GraphSfM
1af22ec17950ffc8a5c737a6a46f4465c40aa470
[ "BSD-3-Clause" ]
null
null
null
i23dSFM/matching/matcher_type.hpp
zyxrrr/GraphSfM
1af22ec17950ffc8a5c737a6a46f4465c40aa470
[ "BSD-3-Clause" ]
null
null
null
i23dSFM/matching/matcher_type.hpp
zyxrrr/GraphSfM
1af22ec17950ffc8a5c737a6a46f4465c40aa470
[ "BSD-3-Clause" ]
1
2019-02-18T09:49:32.000Z
2019-02-18T09:49:32.000Z
// Copyright (c) 2015 Pierre MOULON. // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #pragma once namespace i23dSFM{ namespace matching{ enum EMatcherType { BRUTE_FORCE_L2, ANN_L2, CASCADE_HASHING_L2, BRUTE_FORCE_HAMMING }; } // namespace matching } // namespace i23dSFM
19.909091
70
0.730594
zyxrrr
44091448f0282afc5ca5f79268da2865dfb7cf86
2,683
cpp
C++
tests/IDL_Test/Double_Inherited_Component/ComponentC_exec.cpp
qinwang13/CIAO
e69add1b5da8e9602bcc85d581ecbf1bd41c49a3
[ "DOC" ]
10
2016-07-20T00:55:50.000Z
2020-10-04T19:07:10.000Z
tests/IDL_Test/Double_Inherited_Component/ComponentC_exec.cpp
qinwang13/CIAO
e69add1b5da8e9602bcc85d581ecbf1bd41c49a3
[ "DOC" ]
13
2016-09-27T14:08:27.000Z
2020-11-11T10:45:56.000Z
tests/IDL_Test/Double_Inherited_Component/ComponentC_exec.cpp
qinwang13/CIAO
e69add1b5da8e9602bcc85d581ecbf1bd41c49a3
[ "DOC" ]
12
2016-04-20T09:57:02.000Z
2021-12-24T17:23:45.000Z
// -*- C++ -*- #include "ComponentC_exec.h" #include "ace/Log_Msg.h" namespace CIAO_connector_test_C_Impl { //============================================================ // Pulse generator //============================================================ ComponentC_exec_i::ComponentC_exec_i (void) : topic_name_c_ (""), topic_name_b_ (""), topic_name_a_ (""), topic_name_c_has_been_set_ (false), topic_name_b_has_been_set_ (false), topic_name_a_has_been_set_ (false) { } ComponentC_exec_i::~ComponentC_exec_i (void) { } // Port operations. void ComponentC_exec_i::topic_name_c (const char * topic_name) { this->topic_name_c_ = topic_name; this->topic_name_c_has_been_set_ = true; } char * ComponentC_exec_i::topic_name_c (void) { return CORBA::string_dup (this->topic_name_c_.in ()); } void ComponentC_exec_i::topic_name_b (const char * topic_name) { this->topic_name_b_ = topic_name; this->topic_name_b_has_been_set_ = true; } char * ComponentC_exec_i::topic_name_b (void) { return CORBA::string_dup (this->topic_name_b_.in ()); } void ComponentC_exec_i::topic_name_a (const char * topic_name) { this->topic_name_a_ = topic_name; this->topic_name_a_has_been_set_ = true; } char * ComponentC_exec_i::topic_name_a (void) { return CORBA::string_dup (this->topic_name_a_.in ()); } // Operations from Components::SessionComponent. void ComponentC_exec_i::set_session_context ( ::Components::SessionContext_ptr ctx) { this->context_ = ::connector_test::CCM_C_Context::_narrow (ctx); if ( ::CORBA::is_nil (this->context_.in ())) { throw ::CORBA::INTERNAL (); } } void ComponentC_exec_i::configuration_complete (void) { } void ComponentC_exec_i::ccm_activate (void) { } void ComponentC_exec_i::ccm_passivate (void) { } void ComponentC_exec_i::ccm_remove (void) { if (!this->topic_name_c_has_been_set_) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR : Topic name C has not been set\n"))); if (!this->topic_name_b_has_been_set_) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR : Topic name B has not been set\n"))); if (!this->topic_name_a_has_been_set_) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR : Topic name A has not been set\n"))); } extern "C" INHERITED_COMPONENTS_EXEC_Export ::Components::EnterpriseComponent_ptr create_ComponentC_Impl (void) { ::Components::EnterpriseComponent_ptr retval = ::Components::EnterpriseComponent::_nil (); ACE_NEW_NORETURN ( retval, ComponentC_exec_i ); return retval; } }
23.330435
83
0.642564
qinwang13
440d7c861defadb803bd8ec0c6833afed1f8e277
1,165
cpp
C++
libraries/fc/src/crypto/openssl.cpp
SophiaTX/SophiaTx-Blockchain
c964691c020962ad1aba8263c0d8a78a9fa27e45
[ "MIT" ]
8
2018-07-25T20:42:43.000Z
2019-03-11T03:14:09.000Z
libraries/fc/src/crypto/openssl.cpp
SophiaTX/SophiaTx-Blockchain
c964691c020962ad1aba8263c0d8a78a9fa27e45
[ "MIT" ]
13
2018-07-25T17:41:28.000Z
2019-01-25T13:38:11.000Z
libraries/fc/src/crypto/openssl.cpp
SophiaTX/SophiaTx-Blockchain
c964691c020962ad1aba8263c0d8a78a9fa27e45
[ "MIT" ]
11
2018-07-25T14:34:13.000Z
2019-05-03T13:29:37.000Z
#include <fc/crypto/openssl.hpp> #include <fc/filesystem.hpp> #include <boost/filesystem/path.hpp> #include <cstdlib> #include <string> #include <stdlib.h> namespace fc { struct openssl_scope { static ENGINE* eng; openssl_scope() { ENGINE_load_rdrand(); ENGINE* eng = ENGINE_by_id("rdrand"); if(NULL == eng) { clean_up_engine(); return; } if(!ENGINE_init(eng)) { clean_up_engine(); return; } if(!ENGINE_set_default(eng, ENGINE_METHOD_RAND)) { clean_up_engine(); } } ~openssl_scope() { FIPS_mode_set(0); CONF_modules_unload(1); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); clean_up_engine(); } void clean_up_engine() { if(eng != NULL) { ENGINE_finish(eng); ENGINE_free(eng); } ENGINE_cleanup(); } }; ENGINE* openssl_scope::eng; int init_openssl() { static openssl_scope ossl; return 0; } }
17.923077
60
0.498712
SophiaTX
440e8c81f92ce8229a8463756046dc9995685f1b
5,679
cpp
C++
build_linux/moc_addressbookpage.cpp
bitcrystal2/bitcrystal_v20_last_linux_branch
a5d759e9b5134502a28483fea3567894eec08e7f
[ "MIT" ]
null
null
null
build_linux/moc_addressbookpage.cpp
bitcrystal2/bitcrystal_v20_last_linux_branch
a5d759e9b5134502a28483fea3567894eec08e7f
[ "MIT" ]
null
null
null
build_linux/moc_addressbookpage.cpp
bitcrystal2/bitcrystal_v20_last_linux_branch
a5d759e9b5134502a28483fea3567894eec08e7f
[ "MIT" ]
null
null
null
/**************************************************************************** ** Meta object code from reading C++ file 'addressbookpage.h' ** ** Created: Thu Dec 25 23:31:32 2014 ** by: The Qt Meta Object Compiler version 63 (Qt 4.8.2) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../src/qt/addressbookpage.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'addressbookpage.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 63 #error "This file was generated using the moc from 4.8.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_AddressBookPage[] = { // content: 6, // revision 0, // classname 0, 0, // classinfo 17, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 3, // signalCount // signals: signature, parameters, type, tag, flags 22, 17, 16, 16, 0x05, 43, 17, 16, 16, 0x05, 66, 17, 16, 16, 0x05, // slots: signature, parameters, type, tag, flags 92, 85, 16, 16, 0x0a, 102, 16, 16, 16, 0x08, 129, 16, 16, 16, 0x08, 153, 16, 16, 16, 0x08, 178, 16, 16, 16, 0x08, 203, 16, 16, 16, 0x08, 230, 16, 16, 16, 0x08, 250, 16, 16, 16, 0x08, 274, 16, 16, 16, 0x08, 294, 16, 16, 16, 0x08, 309, 16, 16, 16, 0x08, 335, 16, 16, 16, 0x08, 360, 354, 16, 16, 0x08, 397, 383, 16, 16, 0x08, 0 // eod }; static const char qt_meta_stringdata_AddressBookPage[] = { "AddressBookPage\0\0addr\0signMessage(QString)\0" "verifyMessage(QString)\0sendCoins(QString)\0" "retval\0done(int)\0on_deleteAddress_clicked()\0" "on_newAddress_clicked()\0" "on_copyAddress_clicked()\0" "on_signMessage_clicked()\0" "on_verifyMessage_clicked()\0" "onSendCoinsAction()\0on_showQRCode_clicked()\0" "onCopyLabelAction()\0onEditAction()\0" "on_exportButton_clicked()\0selectionChanged()\0" "point\0contextualMenu(QPoint)\0parent,begin,\0" "selectNewAddress(QModelIndex,int,int)\0" }; void AddressBookPage::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); AddressBookPage *_t = static_cast<AddressBookPage *>(_o); switch (_id) { case 0: _t->signMessage((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: _t->verifyMessage((*reinterpret_cast< QString(*)>(_a[1]))); break; case 2: _t->sendCoins((*reinterpret_cast< QString(*)>(_a[1]))); break; case 3: _t->done((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: _t->on_deleteAddress_clicked(); break; case 5: _t->on_newAddress_clicked(); break; case 6: _t->on_copyAddress_clicked(); break; case 7: _t->on_signMessage_clicked(); break; case 8: _t->on_verifyMessage_clicked(); break; case 9: _t->onSendCoinsAction(); break; case 10: _t->on_showQRCode_clicked(); break; case 11: _t->onCopyLabelAction(); break; case 12: _t->onEditAction(); break; case 13: _t->on_exportButton_clicked(); break; case 14: _t->selectionChanged(); break; case 15: _t->contextualMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break; case 16: _t->selectNewAddress((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; default: ; } } } const QMetaObjectExtraData AddressBookPage::staticMetaObjectExtraData = { 0, qt_static_metacall }; const QMetaObject AddressBookPage::staticMetaObject = { { &QDialog::staticMetaObject, qt_meta_stringdata_AddressBookPage, qt_meta_data_AddressBookPage, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &AddressBookPage::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *AddressBookPage::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *AddressBookPage::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_AddressBookPage)) return static_cast<void*>(const_cast< AddressBookPage*>(this)); return QDialog::qt_metacast(_clname); } int AddressBookPage::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 17) qt_static_metacall(this, _c, _id, _a); _id -= 17; } return _id; } // SIGNAL 0 void AddressBookPage::signMessage(QString _t1) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 0, _a); } // SIGNAL 1 void AddressBookPage::verifyMessage(QString _t1) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 1, _a); } // SIGNAL 2 void AddressBookPage::sendCoins(QString _t1) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 2, _a); } QT_END_MOC_NAMESPACE
35.49375
168
0.619827
bitcrystal2
440eadb4249244c03db0b3fe9843fed07ecc809f
5,964
cpp
C++
luogu/4463/me.cpp
jinzhengyu1212/Clovers
0efbb0d87b5c035e548103409c67914a1f776752
[ "MIT" ]
null
null
null
luogu/4463/me.cpp
jinzhengyu1212/Clovers
0efbb0d87b5c035e548103409c67914a1f776752
[ "MIT" ]
null
null
null
luogu/4463/me.cpp
jinzhengyu1212/Clovers
0efbb0d87b5c035e548103409c67914a1f776752
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=530000; const int MOD=998244353; inline int read(){ int x=0,f=0; char ch=getchar(); while(ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar(); while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); return f==0 ? x : -x; } inline void write(int x){ if(x<0) {x=~(x-1); putchar('-');} if(x>9) write(x/10); putchar(x%10+'0'); } typedef vector<int> Poly; void write_Poly(Poly A){ for(register int i=0;i<(int)A.size();++i) write(A[i]),printf(" "); puts(""); } int add(int x,int y){x+=y; return x>=MOD ? x-MOD : x;} int sub(int x,int y){x-=y; return x<0 ? x+MOD : x;} #define mul(a,b) (ll)(a)*(b)%MOD void Add(int &x,int y){x+=y; if(x>=MOD) x-=MOD;} void Sub(int &x,int y){x-=y; if(x<0) x+=MOD;} void Mul(int &x,int y){x=1ll*x*y%MOD;} int qpow(int x,int y){ int ret=1; while(y){ if(y&1) ret=mul(ret,x); x=mul(x,x); y>>=1; } return ret; } int Inv(int x){return qpow(x,MOD-2);} int inv[N]; namespace FFT{ int rev[N<<1],G[N<<1],IG[N<<1]; int init(int n){ int len=1; while(len<n) len<<=1; rev[0]=0; rev[len-1]=len-1; for(register int i=1;i<len-1;++i) rev[i]=(rev[i>>1]>>1)+(i&1 ? len>>1 : 0); for(register int i=1;i<=len;i<<=1){ G[i]=qpow(3,(MOD-1)/i); IG[i]=qpow(G[i],MOD-2); } return len; } void ntt(int *a,int len,int flag){ for(register int i=0;i<len;++i) if(i<rev[i]) swap(a[i],a[rev[i]]); for(register int h=1;h<len;h<<=1){ int wn=(flag==1 ? G[h<<1] : IG[h<<1]); for(register int i=0;i<len;i+=(h<<1)){ int W=1,tmp1,tmp2; for(register int j=i;j<i+h;++j){ tmp1=a[j], tmp2=mul(a[j+h],W); a[j]=add(tmp1,tmp2); a[j+h]=sub(tmp1,tmp2); W=mul(W,wn); } } } if(flag==-1){ int invlen=qpow(len,MOD-2); for(register int i=0;i<len;++i) a[i]=mul(a[i],invlen); } } void multi(int *a,int *b,int len) { ntt(a,len,1); ntt(b,len,1); for(register int i=0;i<len;++i) a[i]=mul(a[i],b[i]); ntt(a,len,-1); } } Poly operator + (Poly A,Poly B){ int len=max((int)A.size(),(int)B.size()); A.resize(len); B.resize(len); for(register int i=0;i<len;++i) Add(A[i],B[i]); return A; } Poly operator - (Poly A,Poly B){ int len=max((int)A.size(),(int)B.size()); A.resize(len); B.resize(len); for(register int i=0;i<len;++i) Sub(A[i],B[i]); return A; } Poly operator * (Poly A,Poly B){ static int a[N<<1],b[N<<1]; int M=(int)A.size()+(int)B.size()-1; int len=FFT::init(M); A.resize(len); B.resize(len); for(register int i=0;i<len;++i) a[i]=A[i],b[i]=B[i]; FFT::multi(a,b,len); A.resize(M); for(register int i=0;i<M;++i) A[i]=a[i]; return A; } void reverse(Poly &A){ for(register int i=0;i<(int)A.size()/2;++i){ swap(A[i],A[(int)A.size()-1-i]); } } void Inverse(Poly A,Poly &B,int n){ static int a[N<<1],b[N<<1]; if(n==1){ B[0]=Inv(A[0]); return; } int mid=(n+1)/2; Inverse(A,B,mid); int len=FFT::init(n<<1); for(register int i=0;i<len;++i) a[i]=b[i]=0; for(register int i=0;i<n;++i) a[i]=A[i]; for(register int i=0;i<mid;++i) b[i]=B[i]; FFT::ntt(a,len,1); FFT::ntt(b,len,1); for(register int i=0;i<len;++i){ b[i]=mul(b[i],sub(2,mul(a[i],b[i]))); } FFT::ntt(b,len,-1); for(register int i=0;i<n;++i) B[i]=b[i]; } Poly Polynomial_Inverse(Poly A){ Poly B; B.resize(A.size()); Inverse(A,B,(int)A.size()); return B; } Poly operator / (Poly A,Poly B){ reverse(A); reverse(B); int Len=A.size()-B.size()+1; A.resize(Len); B.resize(Len); B=Polynomial_Inverse(B); Poly D=A*B; D.resize(Len); reverse(D); return D; } Poly operator % (Poly A,Poly B){ Poly D=A/B; D=D*B; Poly R=A-D; R.resize((int)B.size()-1); return R; } Poly Integral(Poly A){//jifen A.resize(A.size()+1); for(register int i=(int)A.size()-1;i>=1;i--) A[i]=mul(inv[i],A[i-1]); A[0]=0; return A; } Poly Derivate(Poly A){//qiudao for(register int i=0;i<(int)A.size()-1;++i) A[i]=mul(i+1,A[i+1]); A.resize(A.size()-1); return A; } Poly Polynomial_ln(Poly A){ Poly AA=Derivate(A); A=Polynomial_Inverse(A); Poly B=A*AA; B.resize(AA.size()); B=Integral(B); return B; } void EXP(Poly A,Poly &B,int n){ static int a[N<<1],b[N<<1],lnb[N<<1]; if(n==1){ B.push_back(1); return; } int mid=(n+1)/2; EXP(A,B,mid); B.resize(n); Poly lnB=Polynomial_ln(B); int len=FFT::init(n+n); for(register int i=0;i<len;++i) a[i]=0,b[i]=0,lnb[i]=0; for(register int i=0;i<n;++i) a[i]=A[i],lnb[i]=lnB[i];//important!! "ln in MOD x^n" for(register int i=0;i<mid;++i) b[i]=B[i]; FFT::ntt(a,len,1); FFT::ntt(b,len,1); FFT::ntt(lnb,len,1); for(register int i=0;i<len;++i){ b[i]=mul(b[i],sub(a[i]+1,lnb[i])); } FFT::ntt(b,len,-1); for(register int i=0;i<n;++i) B[i]=b[i]; } Poly Polynomial_Exp(Poly A){ Poly B; EXP(A,B,A.size()); return B; } int n,k,fac[N],ifac[N]; Poly f,f1; signed main(){ inv[0]=1; inv[1]=1; for(register int i=2;i<N;++i) inv[i]=mul(MOD-MOD/i,inv[MOD%i]); k=read(); n=read(); fac[0]=1; for(int i=1;i<=n+1;i++) fac[i]=mul(fac[i-1],i); ifac[0]=1; for(int i=1;i<=n+1;i++) ifac[i]=mul(ifac[i-1],inv[i]); f.resize(n+1); f1.resize(n+1); for(int i=0,tmp=k+1;i<=n;i++,Mul(tmp,k+1)) f1[i]=ifac[i+1],f[i]=mul(ifac[i+1],tmp); f=f*Polynomial_Inverse(f1); f[0]=0; f.resize(n+1); for(int i=1;i<=n;i++){ Mul(f[i],fac[i-1]);//*i!/i if(i&1^1) f[i]=MOD-f[i]; } f=Polynomial_Exp(f); printf("%lld\n",mul(f[n],fac[n])); return 0; }
26.986425
88
0.504359
jinzhengyu1212
440f30946cab250c0db8709e14985c206ca8c50e
3,501
cpp
C++
node/silkworm/downloader/messages/InboundNewBlockHashes.cpp
elmato/silkworm
711c73547cd1f7632ff02d5f86dfac5b0d249344
[ "Apache-2.0" ]
null
null
null
node/silkworm/downloader/messages/InboundNewBlockHashes.cpp
elmato/silkworm
711c73547cd1f7632ff02d5f86dfac5b0d249344
[ "Apache-2.0" ]
null
null
null
node/silkworm/downloader/messages/InboundNewBlockHashes.cpp
elmato/silkworm
711c73547cd1f7632ff02d5f86dfac5b0d249344
[ "Apache-2.0" ]
null
null
null
/* Copyright 2021 The Silkworm Authors 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 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. */ #include "InboundNewBlockHashes.hpp" #include <algorithm> #include <silkworm/common/log.hpp> #include <silkworm/downloader/internals/random_number.hpp> #include <silkworm/downloader/packets/RLPEth66PacketCoding.hpp> #include <silkworm/downloader/rpc/send_message_by_id.hpp> namespace silkworm { InboundNewBlockHashes::InboundNewBlockHashes(const sentry::InboundMessage& msg, WorkingChain& wc, SentryClient& s) : InboundMessage(), working_chain_(wc), sentry_(s) { if (msg.id() != sentry::MessageId::NEW_BLOCK_HASHES_66) throw std::logic_error("InboundNewBlockHashes received wrong InboundMessage"); reqId_ = RANDOM_NUMBER.generate_one(); // for trace purposes peerId_ = string_from_H512(msg.peer_id()); ByteView data = string_view_to_byte_view(msg.data()); // copy for consumption rlp::success_or_throw(rlp::decode(data, packet_)); SILK_TRACE << "Received message " << *this; } void InboundNewBlockHashes::execute() { using namespace std; SILK_TRACE << "Processing message " << *this; // todo: Erigon apparently processes this message even if it is not in a fetching phase BUT is in request-chaining // mode - do we need the same? BlockNum max = working_chain_.top_seen_block_height(); for (size_t i = 0; i < packet_.size(); i++) { Hash hash = packet_[i].hash; // save announcement working_chain_.save_external_announce(hash); if (working_chain_.has_link(hash)) continue; // request header GetBlockHeadersPacket66 reply; reply.requestId = RANDOM_NUMBER.generate_one(); reply.request.origin = hash; reply.request.amount = 1; reply.request.skip = 0; reply.request.reverse = false; Bytes rlp_encoding; rlp::encode(rlp_encoding, reply); auto msg_reply = std::make_unique<sentry::OutboundMessageData>(); msg_reply->set_id(sentry::MessageId::GET_BLOCK_HEADERS_66); msg_reply->set_data(rlp_encoding.data(), rlp_encoding.length()); // copy // send msg_reply SILK_TRACE << "Replying to " << identify(*this) << " with send_message_by_id, content: " << reply; rpc::SendMessageById rpc(peerId_, std::move(msg_reply)); rpc.do_not_throw_on_failure(); sentry_.exec_remotely(rpc); [[maybe_unused]] sentry::SentPeers peers = rpc.reply(); SILK_TRACE << "Received rpc result of " << identify(*this) << ": " << std::to_string(peers.peers_size()) + " peer(s)"; // calculate top seen block height max = std::max(max, packet_[i].number); } working_chain_.top_seen_block_height(max); } uint64_t InboundNewBlockHashes::reqId() const { return reqId_; } std::string InboundNewBlockHashes::content() const { std::stringstream content; content << packet_; return content.str(); } } // namespace silkworm
34.663366
118
0.690089
elmato
4413384da82d02d06b480f9a45319d7c23c375d5
11,826
cpp
C++
SwordsmanAndSpiders/Classes/common/SixCatsLogger.cpp
beardog-ukr/vigilant-couscous
57f00950b567cb6adf2e0a06f02925ee271012fe
[ "Unlicense" ]
null
null
null
SwordsmanAndSpiders/Classes/common/SixCatsLogger.cpp
beardog-ukr/vigilant-couscous
57f00950b567cb6adf2e0a06f02925ee271012fe
[ "Unlicense" ]
null
null
null
SwordsmanAndSpiders/Classes/common/SixCatsLogger.cpp
beardog-ukr/vigilant-couscous
57f00950b567cb6adf2e0a06f02925ee271012fe
[ "Unlicense" ]
null
null
null
#include "SixCatsLogger.h" #include <iostream> // cout using namespace std; #define LOCAL_C6_DEBUG 1 // --- ------------------------------------------------------------------------ SixCatsLogger::SixCatsLogger() { selfSetup(); } // --- ------------------------------------------------------------------------ SixCatsLogger::SixCatsLogger(LogLevel inLogLevel) { selfSetup(); logLevel = inLogLevel; } // --- ------------------------------------------------------------------------ SixCatsLogger::~SixCatsLogger() { #ifdef LOCAL_C6_DEBUG cout << "SixCatsLogger obj destroyed" << endl; #endif // ifdef LOCAL_C6_DEBUG } // --- ------------------------------------------------------------------------ void SixCatsLogger::selfSetup() { setLogLevel(SixCatsLogger::Critical); } // --- ------------------------------------------------------------------------ void SixCatsLogger::setLogLevel(LogLevel inLogLevel) { logLevel = inLogLevel; // } // --- ------------------------------------------------------------------------ void SixCatsLogger::write(LogLevel messageLevel, const string str) { if (messageLevel > logLevel) { return; } cout << str << endl; } // --- ------------------------------------------------------------------------ string SixCatsLogger::composeLine(const string& metaInfo, const string& message) const { const string tmps = metaInfo + " >> " + message; return tmps; } // --- ------------------------------------------------------------------------ void SixCatsLogger::c(const string& message) { write(Critical, message); } // --- ------------------------------------------------------------------------ void SixCatsLogger::c(const string& metaInfo, const string& message) { write(Critical, composeLine(metaInfo, message)); } // --- ------------------------------------------------------------------------ void SixCatsLogger::w(const string& message) { write(Warning, message); } // --- ------------------------------------------------------------------------ void SixCatsLogger::w(const string& metaInfo, const string& message) { write(Warning, composeLine(metaInfo, message)); } // --- ------------------------------------------------------------------------ void SixCatsLogger::i(const string& message) { write(Info, message); } // --- ------------------------------------------------------------------------ void SixCatsLogger::i(const string& metaInfo, const string& message) { write(Info, composeLine(metaInfo, message)); } // --- ------------------------------------------------------------------------ void SixCatsLogger::d(const string& message) { write(Debug, message); } // --- ------------------------------------------------------------------------ void SixCatsLogger::d(const string& metaInfo, const string& message) { write(Debug, composeLine(metaInfo, message)); } // --- ------------------------------------------------------------------------ void SixCatsLogger::t(const string& metaInfo, const string& message) { write(Trace, composeLine(metaInfo, message)); } // --- ------------------------------------------------------------------------ void SixCatsLogger::t(const string& message) { write(Trace, message); } // --- ------------------------------------------------------------------------ void SixCatsLogger::f(const string& metaInfo, const string& message) { write(Flood, composeLine(metaInfo, message)); } // --- ------------------------------------------------------------------------ void SixCatsLogger::f(const string& message) { write(Flood, message); } // --- ------------------------------------------------------------------------ void SixCatsLogger::writeL(LogLevel messageLevel, std::function<void(std::ostringstream&)>makeMessage) { if (messageLevel > logLevel) { return; } ostringstream s; makeMessage(s); write(messageLevel, s.str()); } void SixCatsLogger::writeL(LogLevel messageLevel, const string & metaInfo, std::function<void(std::ostringstream&)>makeMessage) { if (messageLevel > logLevel) { return; } ostringstream s; makeMessage(s); write(messageLevel, composeLine(metaInfo, s.str())); } // --- ------------------------------------------------------------------------ void SixCatsLogger::c(std::function<void(std::ostringstream&)>makeMessage) { writeL(Critical, makeMessage); } void SixCatsLogger::w(std::function<void(std::ostringstream&)>makeMessage) { writeL(Warning, makeMessage); } void SixCatsLogger::i(std::function<void(std::ostringstream&)>makeMessage) { writeL(Info, makeMessage); } void SixCatsLogger::d(std::function<void(std::ostringstream&)>makeMessage) { writeL(Debug, makeMessage); } void SixCatsLogger::t(std::function<void(std::ostringstream&)>makeMessage) { writeL(Trace, makeMessage); } void SixCatsLogger::f(std::function<void(std::ostringstream&)>makeMessage) { writeL(Flood, makeMessage); } // --- ------------------------------------------------------------------------ void SixCatsLogger::c(const string & metaInfo, std::function<void(std::ostringstream&)>makeMessage) { writeL(Critical, metaInfo, makeMessage); } void SixCatsLogger::w(const string & metaInfo, std::function<void(std::ostringstream&)>makeMessage) { writeL(Warning, metaInfo, makeMessage); } void SixCatsLogger::i(const string & metaInfo, std::function<void(std::ostringstream&)>makeMessage) { writeL(Info, metaInfo, makeMessage); } void SixCatsLogger::d(const string & metaInfo, std::function<void(std::ostringstream&)>makeMessage) { writeL(Debug, metaInfo, makeMessage); } void SixCatsLogger::t(const string & metaInfo, std::function<void(std::ostringstream&)>makeMessage) { writeL(Trace, metaInfo, makeMessage); } void SixCatsLogger::f(const string & metaInfo, std::function<void(std::ostringstream&)>makeMessage) { writeL(Flood, metaInfo, makeMessage); } // --- ------------------------------------------------------------------------ void c6c(SixCatsLogger *logger, const string message) { if (logger == 0) { return; } logger->c(message); } // --- ------------------------------------------------------------------------ void c6c(SixCatsLogger *logger, const string metaInfo, const string message) { if (logger == 0) { return; } logger->c(metaInfo, message); } // --- ------------------------------------------------------------------------ void c6w(SixCatsLogger *logger, const string message) { if (logger == 0) { return; } logger->w(message); } // --- ------------------------------------------------------------------------ void c6w(SixCatsLogger *logger, const string metaInfo, const string message) { if (logger == 0) { return; } logger->w(metaInfo, message); } // --- ------------------------------------------------------------------------ void c6i(SixCatsLogger *logger, const string message) { if (logger == 0) { return; } logger->i(message); } // --- ------------------------------------------------------------------------ void c6i(SixCatsLogger *logger, const string metaInfo, const string message) { if (logger == 0) { return; } logger->i(metaInfo, message); } // --- ------------------------------------------------------------------------ void c6d(SixCatsLogger *logger, const string message) { if (logger == 0) { return; } logger->d(message); } // --- ------------------------------------------------------------------------ void c6d(SixCatsLogger *logger, const string metaInfo, const string message) { if (logger == 0) { return; } logger->d(metaInfo, message); } // --- ------------------------------------------------------------------------ void c6t(SixCatsLogger *logger, const string message) { if (logger == 0) { return; } logger->t(message); } // --- ------------------------------------------------------------------------ void c6t(SixCatsLogger *logger, const string metaInfo, const string message) { if (logger == 0) { return; } logger->t(metaInfo, message); } // --- ------------------------------------------------------------------------ void c6f(SixCatsLogger *logger, const string message) { if (logger == 0) { return; } logger->f(message); } // --- ------------------------------------------------------------------------ void c6f(SixCatsLogger *logger, const string metaInfo, const string message) { if (logger == 0) { return; } logger->f(metaInfo, message); } // --- ------------------------------------------------------------------------ void c6c(SixCatsLogger *logger, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->c(makeMessage); } void c6w(SixCatsLogger *logger, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->w(makeMessage); } void c6i(SixCatsLogger *logger, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->i(makeMessage); } void c6d(SixCatsLogger *logger, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->d(makeMessage); } void c6t(SixCatsLogger *logger, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->t(makeMessage); } void c6f(SixCatsLogger *logger, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->f(makeMessage); } // --- ------------------------------------------------------------------------ void c6c(SixCatsLogger *logger, const string metaInfo, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->c(metaInfo, makeMessage); } void c6w(SixCatsLogger *logger, const string metaInfo, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->w(metaInfo, makeMessage); } void c6i(SixCatsLogger *logger, const string metaInfo, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->i(metaInfo, makeMessage); } void c6d(SixCatsLogger *logger, const string metaInfo, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->d(metaInfo, makeMessage); } void c6t(SixCatsLogger *logger, const string metaInfo, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->t(metaInfo, makeMessage); } void c6f(SixCatsLogger *logger, const string metaInfo, std::function<void(std::ostringstream&)>makeMessage) { if (logger == 0) { return; } logger->f(metaInfo, makeMessage); } // --- ------------------------------------------------------------------------ // --- ------------------------------------------------------------------------
26.635135
89
0.457551
beardog-ukr
4417d0ef2e9a7297d1318a1d2c05a48759ea1c43
27,908
cpp
C++
src/openms/source/FORMAT/IdXMLFile.cpp
liangoaix/OpenMS
cccbc5d872320f197091596db275f35b4d0458cd
[ "Zlib", "Apache-2.0" ]
null
null
null
src/openms/source/FORMAT/IdXMLFile.cpp
liangoaix/OpenMS
cccbc5d872320f197091596db275f35b4d0458cd
[ "Zlib", "Apache-2.0" ]
null
null
null
src/openms/source/FORMAT/IdXMLFile.cpp
liangoaix/OpenMS
cccbc5d872320f197091596db275f35b4d0458cd
[ "Zlib", "Apache-2.0" ]
null
null
null
// -------------------------------------------------------------------------- // OpenMS -- Open-Source Mass Spectrometry // -------------------------------------------------------------------------- // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen, // ETH Zurich, and Freie Universitaet Berlin 2002-2013. // // This software is released under a three-clause BSD license: // * 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 any author or any participating institution // may be used to endorse or promote products derived from this software // without specific prior written permission. // For a full list of authors, refer to the file AUTHORS. // -------------------------------------------------------------------------- // 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 ANY OF THE AUTHORS OR THE CONTRIBUTING // INSTITUTIONS 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. // // -------------------------------------------------------------------------- // $Maintainer: Andreas Bertsch $ // $Authors: Marc Sturm $ // -------------------------------------------------------------------------- #include <OpenMS/FORMAT/IdXMLFile.h> #include <OpenMS/SYSTEM/File.h> #include <OpenMS/CONCEPT/LogStream.h> #include <OpenMS/CONCEPT/PrecisionWrapper.h> #include <iostream> #include <fstream> #include <limits> using namespace std; using namespace OpenMS::Internal; namespace OpenMS { IdXMLFile::IdXMLFile() : XMLHandler("", "1.2"), XMLFile("/SCHEMAS/IdXML_1_2.xsd", "1.2"), last_meta_(0), document_id_(), prot_id_in_run_(false) { } void IdXMLFile::load(const String& filename, vector<ProteinIdentification>& protein_ids, vector<PeptideIdentification>& peptide_ids) { String document_id; load(filename, protein_ids, peptide_ids, document_id); } void IdXMLFile::load(const String& filename, vector<ProteinIdentification>& protein_ids, vector<PeptideIdentification>& peptide_ids, String& document_id) { //Filename for error messages in XMLHandler file_ = filename; protein_ids.clear(); peptide_ids.clear(); prot_ids_ = &protein_ids; pep_ids_ = &peptide_ids; document_id_ = &document_id; parse_(filename, this); //reset members prot_ids_ = 0; pep_ids_ = 0; last_meta_ = 0; parameters_.clear(); param_ = ProteinIdentification::SearchParameters(); id_ = ""; prot_id_ = ProteinIdentification(); pep_id_ = PeptideIdentification(); prot_hit_ = ProteinHit(); pep_hit_ = PeptideHit(); proteinid_to_accession_.clear(); } void IdXMLFile::store(String filename, const vector<ProteinIdentification>& protein_ids, const vector<PeptideIdentification>& peptide_ids, const String& document_id) { //open stream std::ofstream os(filename.c_str()); if (!os) { throw Exception::UnableToCreateFile(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename); } os.precision(writtenDigits<double>(0.0)); //write header os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; os << "<?xml-stylesheet type=\"text/xsl\" href=\"http://open-ms.sourceforge.net/XSL/IdXML.xsl\" ?>\n"; os << "<IdXML version=\"" << getVersion() << "\""; if (document_id != "") { os << " id=\"" << document_id << "\""; } os << " xsi:noNamespaceSchemaLocation=\"http://open-ms.sourceforge.net/SCHEMAS/IdXML_1_2.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; //look up different search parameters vector<ProteinIdentification::SearchParameters> params; for (vector<ProteinIdentification>::const_iterator it = protein_ids.begin(); it != protein_ids.end(); ++it) { if (find(params.begin(), params.end(), it->getSearchParameters()) == params.end()) { params.push_back(it->getSearchParameters()); } } //write search parameters for (Size i = 0; i != params.size(); ++i) { os << "\t<SearchParameters " << "id=\"SP_" << i << "\" " << "db=\"" << writeXMLEscape(params[i].db) << "\" " << "db_version=\"" << writeXMLEscape(params[i].db_version) << "\" " << "taxonomy=\"" << writeXMLEscape(params[i].taxonomy) << "\" "; if (params[i].mass_type == ProteinIdentification::MONOISOTOPIC) { os << "mass_type=\"monoisotopic\" "; } else if (params[i].mass_type == ProteinIdentification::AVERAGE) { os << "mass_type=\"average\" "; } os << "charges=\"" << params[i].charges << "\" "; if (params[i].enzyme == ProteinIdentification::TRYPSIN) { os << "enzyme=\"trypsin\" "; } if (params[i].enzyme == ProteinIdentification::PEPSIN_A) { os << "enzyme=\"pepsin_a\" "; } if (params[i].enzyme == ProteinIdentification::PROTEASE_K) { os << "enzyme=\"protease_k\" "; } if (params[i].enzyme == ProteinIdentification::CHYMOTRYPSIN) { os << "enzyme=\"chymotrypsin\" "; } else if (params[i].enzyme == ProteinIdentification::NO_ENZYME) { os << "enzyme=\"no_enzyme\" "; } else if (params[i].enzyme == ProteinIdentification::UNKNOWN_ENZYME) { os << "enzyme=\"unknown_enzyme\" "; } os << "missed_cleavages=\"" << params[i].missed_cleavages << "\" " << "precursor_peak_tolerance=\"" << params[i].precursor_tolerance << "\" " << "peak_mass_tolerance=\"" << params[i].peak_mass_tolerance << "\" " << ">\n"; //modifications for (Size j = 0; j != params[i].fixed_modifications.size(); ++j) { os << "\t\t<FixedModification name=\"" << writeXMLEscape(params[i].fixed_modifications[j]) << "\" />\n"; //Add MetaInfo, when modifications has it (Andreas) } for (Size j = 0; j != params[i].variable_modifications.size(); ++j) { os << "\t\t<VariableModification name=\"" << writeXMLEscape(params[i].variable_modifications[j]) << "\" />\n"; //Add MetaInfo, when modifications has it (Andreas) } writeUserParam_("UserParam", os, params[i], 4); os << "\t</SearchParameters>\n"; } //empty search parameters if (params.empty()) { os << "<SearchParameters charges=\"+0, +0\" id=\"ID_1\" db_version=\"0\" mass_type=\"monoisotopic\" peak_mass_tolerance=\"0.0\" precursor_peak_tolerance=\"0.0\" db=\"Unknown\"/>\n"; } UInt prot_count = 0; map<String, UInt> accession_to_id; //Identifiers of protein identifications that are already written vector<String> done_identifiers; //write ProteinIdentification Runs for (Size i = 0; i < protein_ids.size(); ++i) { done_identifiers.push_back(protein_ids[i].getIdentifier()); os << "\t<IdentificationRun "; os << "date=\"" << protein_ids[i].getDateTime().getDate() << "T" << protein_ids[i].getDateTime().getTime() << "\" "; os << "search_engine=\"" << writeXMLEscape(protein_ids[i].getSearchEngine()) << "\" "; os << "search_engine_version=\"" << writeXMLEscape(protein_ids[i].getSearchEngineVersion()) << "\" "; //identifier for (Size j = 0; j != params.size(); ++j) { if (params[j] == protein_ids[i].getSearchParameters()) { os << "search_parameters_ref=\"SP_" << j << "\" "; break; } } os << ">\n"; os << "\t\t<ProteinIdentification "; os << "score_type=\"" << writeXMLEscape(protein_ids[i].getScoreType()) << "\" "; if (protein_ids[i].isHigherScoreBetter()) { os << "higher_score_better=\"true\" "; } else { os << "higher_score_better=\"false\" "; } os << "significance_threshold=\"" << protein_ids[i].getSignificanceThreshold() << "\" >\n"; //write protein hits for (Size j = 0; j < protein_ids[i].getHits().size(); ++j) { os << "\t\t\t<ProteinHit "; os << "id=\"PH_" << prot_count << "\" "; accession_to_id[protein_ids[i].getHits()[j].getAccession()] = prot_count++; os << "accession=\"" << writeXMLEscape(protein_ids[i].getHits()[j].getAccession()) << "\" "; os << "score=\"" << protein_ids[i].getHits()[j].getScore() << "\" "; // os << "coverage=\"" << protein_ids[i].getHits()[j].getCoverage() // << "\" "; os << "sequence=\"" << writeXMLEscape(protein_ids[i].getHits()[j].getSequence()) << "\" >\n"; writeUserParam_("UserParam", os, protein_ids[i].getHits()[j], 4); os << "\t\t\t</ProteinHit>\n"; } // add ProteinGroup info to metavalues (hack) MetaInfoInterface meta = protein_ids[i]; addProteinGroups_(meta, protein_ids[i].getProteinGroups(), "protein_group", accession_to_id); addProteinGroups_(meta, protein_ids[i].getIndistinguishableProteins(), "indistinguishable_proteins", accession_to_id); writeUserParam_("UserParam", os, meta, 3); os << "\t\t</ProteinIdentification>\n"; //write PeptideIdentifications Size count_wrong_id(0); Size count_empty(0); for (Size l = 0; l < peptide_ids.size(); ++l) { if (peptide_ids[l].getIdentifier() != protein_ids[i].getIdentifier()) { ++count_wrong_id; continue; } else if (peptide_ids[l].getHits().size() == 0) { ++count_empty; continue; } os << "\t\t<PeptideIdentification "; os << "score_type=\"" << writeXMLEscape(peptide_ids[l].getScoreType()) << "\" "; if (peptide_ids[l].isHigherScoreBetter()) { os << "higher_score_better=\"true\" "; } else { os << "higher_score_better=\"false\" "; } os << "significance_threshold=\"" << peptide_ids[l].getSignificanceThreshold() << "\" "; // mz if (peptide_ids[l].hasMZ()) { os << "MZ=\"" << peptide_ids[l].getMZ() << "\" "; } // rt if (peptide_ids[l].hasRT()) { os << "RT=\"" << peptide_ids[l].getRT() << "\" "; } // spectrum_reference DataValue dv = peptide_ids[l].getMetaValue("spectrum_reference"); if (dv != DataValue::EMPTY) { os << "spectrum_reference=\"" << writeXMLEscape(dv.toString()) << "\" "; } os << ">\n"; // write peptide hits for (Size j = 0; j < peptide_ids[l].getHits().size(); ++j) { os << "\t\t\t<PeptideHit "; os << "score=\"" << precisionWrapper(peptide_ids[l].getHits()[j].getScore()) << "\" "; os << "sequence=\"" << peptide_ids[l].getHits()[j].getSequence() << "\" "; os << "charge=\"" << peptide_ids[l].getHits()[j].getCharge() << "\" "; if (peptide_ids[l].getHits()[j].getAABefore() != ' ') { os << "aa_before=\"" << writeXMLEscape(peptide_ids[l].getHits()[j].getAABefore()) << "\" "; } if (peptide_ids[l].getHits()[j].getAAAfter() != ' ') { os << "aa_after=\"" << writeXMLEscape(peptide_ids[l].getHits()[j].getAAAfter()) << "\" "; } if (peptide_ids[l].getHits()[j].getProteinAccessions().size() != 0) { String accs = ""; for (Size m = 0; m < peptide_ids[l].getHits()[j].getProteinAccessions().size(); ++m) { if (accs != "") { accs = accs + " "; } accs = accs + "PH_" + accession_to_id[peptide_ids[l].getHits()[j].getProteinAccessions()[m]]; } os << "protein_refs=\"" << accs << "\" "; } os << ">\n"; writeUserParam_("UserParam", os, peptide_ids[l].getHits()[j], 4); os << "\t\t\t</PeptideHit>\n"; } // do not write "spectrum_reference" since it is written as attribute already MetaInfoInterface tmp = peptide_ids[l]; tmp.removeMetaValue("spectrum_reference"); writeUserParam_("UserParam", os, tmp, 3); os << "\t\t</PeptideIdentification>\n"; } os << "\t</IdentificationRun>\n"; // on more than one protein Ids (=runs) there must be wrong mappings and the message would be useless. However, a single run should not have wrong mappings! if (count_wrong_id && protein_ids.size() == 1) LOG_WARN << "Omitted writing of " << count_wrong_id << " peptide identifications due to wrong protein mapping." << std::endl; if (count_empty) LOG_WARN << "Omitted writing of " << count_empty << " peptide identifications due to empty hits." << std::endl; } //empty protein ids parameters if (protein_ids.empty()) { os << "<IdentificationRun date=\"1900-01-01T01:01:01.0Z\" search_engine=\"Unknown\" search_parameters_ref=\"ID_1\" search_engine_version=\"0\"/>\n"; } for (Size i = 0; i < peptide_ids.size(); ++i) { if (find(done_identifiers.begin(), done_identifiers.end(), peptide_ids[i].getIdentifier()) == done_identifiers.end()) { warning(STORE, String("Omitting peptide identification because of missing ProteinIdentification with identifier '") + peptide_ids[i].getIdentifier() + "' while writing '" + filename + "'!"); } } //write footer os << "</IdXML>\n"; //close stream os.close(); //reset members prot_ids_ = 0; pep_ids_ = 0; last_meta_ = 0; parameters_.clear(); param_ = ProteinIdentification::SearchParameters(); id_ = ""; prot_id_ = ProteinIdentification(); pep_id_ = PeptideIdentification(); prot_hit_ = ProteinHit(); pep_hit_ = PeptideHit(); proteinid_to_accession_.clear(); } void IdXMLFile::startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const xercesc::Attributes& attributes) { String tag = sm_.convert(qname); //START if (tag == "IdXML") { //check file version against schema version String file_version = ""; prot_id_in_run_ = false; optionalAttributeAsString_(file_version, attributes, "version"); if (file_version == "") file_version = "1.0"; //default version is 1.0 if (file_version.toDouble() > version_.toDouble()) { warning(LOAD, "The XML file (" + file_version + ") is newer than the parser (" + version_ + "). This might lead to undefined program behavior."); } //document id String document_id = ""; optionalAttributeAsString_(document_id, attributes, "id"); (*document_id_) = document_id; } //SEARCH PARAMETERS else if (tag == "SearchParameters") { //store id id_ = attributeAsString_(attributes, "id"); //reset parameters param_ = ProteinIdentification::SearchParameters(); //load parameters param_.db = attributeAsString_(attributes, "db"); param_.db_version = attributeAsString_(attributes, "db_version"); optionalAttributeAsString_(param_.taxonomy, attributes, "taxonomy"); param_.charges = attributeAsString_(attributes, "charges"); optionalAttributeAsUInt_(param_.missed_cleavages, attributes, "missed_cleavages"); param_.peak_mass_tolerance = attributeAsDouble_(attributes, "peak_mass_tolerance"); param_.precursor_tolerance = attributeAsDouble_(attributes, "precursor_peak_tolerance"); //mass type String mass_type = attributeAsString_(attributes, "mass_type"); if (mass_type == "monoisotopic") { param_.mass_type = ProteinIdentification::MONOISOTOPIC; } else if (mass_type == "average") { param_.mass_type = ProteinIdentification::AVERAGE; } //enzyme String enzyme; optionalAttributeAsString_(enzyme, attributes, "enzyme"); if (enzyme == "trypsin") { param_.enzyme = ProteinIdentification::TRYPSIN; } else if (enzyme == "pepsin_a") { param_.enzyme = ProteinIdentification::PEPSIN_A; } else if (enzyme == "protease_k") { param_.enzyme = ProteinIdentification::PROTEASE_K; } else if (enzyme == "chymotrypsin") { param_.enzyme = ProteinIdentification::CHYMOTRYPSIN; } else if (enzyme == "no_enzyme") { param_.enzyme = ProteinIdentification::NO_ENZYME; } else if (enzyme == "unknown_enzyme") { param_.enzyme = ProteinIdentification::UNKNOWN_ENZYME; } last_meta_ = &param_; } else if (tag == "FixedModification") { param_.fixed_modifications.push_back(attributeAsString_(attributes, "name")); //change this line as soon as there is a MetaInfoInterface for modifications (Andreas) last_meta_ = 0; } else if (tag == "VariableModification") { param_.variable_modifications.push_back(attributeAsString_(attributes, "name")); //change this line as soon as there is a MetaInfoInterface for modifications (Andreas) last_meta_ = 0; } // RUN else if (tag == "IdentificationRun") { pep_id_ = PeptideIdentification(); prot_id_ = ProteinIdentification(); prot_id_.setSearchEngine(attributeAsString_(attributes, "search_engine")); prot_id_.setSearchEngineVersion(attributeAsString_(attributes, "search_engine_version")); //search parameters String ref = attributeAsString_(attributes, "search_parameters_ref"); if (parameters_.find(ref) == parameters_.end()) { fatalError(LOAD, String("Invalid search parameters reference '") + ref + "'"); } prot_id_.setSearchParameters(parameters_[ref]); //date prot_id_.setDateTime(DateTime::fromString(String(attributeAsString_(attributes, "date")).toQString(), "yyyy-MM-ddThh:mm:ss")); //set identifier prot_id_.setIdentifier(prot_id_.getSearchEngine() + '_' + attributeAsString_(attributes, "date")); } //PROTEINS else if (tag == "ProteinIdentification") { prot_id_.setScoreType(attributeAsString_(attributes, "score_type")); //optional significance threshold double tmp(0.0); optionalAttributeAsDouble_(tmp, attributes, "significance_threshold"); if (tmp != 0.0) { prot_id_.setSignificanceThreshold(tmp); } //score orientation prot_id_.setHigherScoreBetter(asBool_(attributeAsString_(attributes, "higher_score_better"))); last_meta_ = &prot_id_; } else if (tag == "ProteinHit") { prot_hit_ = ProteinHit(); String accession = attributeAsString_(attributes, "accession"); prot_hit_.setAccession(accession); prot_hit_.setScore(attributeAsDouble_(attributes, "score")); //sequence String tmp; optionalAttributeAsString_(tmp, attributes, "sequence"); prot_hit_.setSequence(tmp); last_meta_ = &prot_hit_; //insert id and accession to map proteinid_to_accession_[attributeAsString_(attributes, "id")] = accession; } //PEPTIDES else if (tag == "PeptideIdentification") { // check whether a prot id has been given, add "empty" one to list else if (!prot_id_in_run_) { prot_ids_->push_back(prot_id_); prot_id_in_run_ = true; // set to true, cause we have created one; will be reset for next run } //set identifier pep_id_.setIdentifier(prot_ids_->back().getIdentifier()); pep_id_.setScoreType(attributeAsString_(attributes, "score_type")); //optional significance threshold double tmp(0.0); optionalAttributeAsDouble_(tmp, attributes, "significance_threshold"); if (tmp != 0.0) { pep_id_.setSignificanceThreshold(tmp); } //score orientation pep_id_.setHigherScoreBetter(asBool_(attributeAsString_(attributes, "higher_score_better"))); //MZ double tmp2 = -numeric_limits<double>::max(); optionalAttributeAsDouble_(tmp2, attributes, "MZ"); if (tmp2 != -numeric_limits<double>::max()) { pep_id_.setMZ(tmp2); } //RT tmp2 = -numeric_limits<double>::max(); optionalAttributeAsDouble_(tmp2, attributes, "RT"); if (tmp2 != -numeric_limits<double>::max()) { pep_id_.setRT(tmp2); } Int tmp3 = -numeric_limits<Int>::max(); optionalAttributeAsInt_(tmp3, attributes, "spectrum_reference"); if (tmp3 != -numeric_limits<Int>::max()) { pep_id_.setMetaValue("spectrum_reference", tmp3); } last_meta_ = &pep_id_; } else if (tag == "PeptideHit") { pep_hit_ = PeptideHit(); pep_hit_.setCharge(attributeAsInt_(attributes, "charge")); pep_hit_.setScore(attributeAsDouble_(attributes, "score")); pep_hit_.setSequence(AASequence::fromString(String(attributeAsString_(attributes, "sequence")))); //aa_before String tmp; optionalAttributeAsString_(tmp, attributes, "aa_before"); if (!tmp.empty()) { pep_hit_.setAABefore(tmp[0]); } //aa_after tmp = ""; optionalAttributeAsString_(tmp, attributes, "aa_after"); if (!tmp.empty()) { pep_hit_.setAAAfter(tmp[0]); } //parse optional protein ids to determine accessions const XMLCh* refs = attributes.getValue(sm_.convert("protein_refs")); if (refs != 0) { String accession_string = sm_.convert(refs); accession_string.trim(); vector<String> accessions; accession_string.split(' ', accessions); if (accession_string != "" && accessions.empty()) { accessions.push_back(accession_string); } for (vector<String>::const_iterator it = accessions.begin(); it != accessions.end(); ++it) { map<String, String>::const_iterator it2 = proteinid_to_accession_.find(*it); if (it2 != proteinid_to_accession_.end()) { pep_hit_.addProteinAccession(it2->second); } else { fatalError(LOAD, String("Invalid protein reference '") + *it + "'"); } } } last_meta_ = &pep_hit_; } //USERPARAM else if (tag == "UserParam") { if (last_meta_ == 0) { fatalError(LOAD, "Unexpected tag 'UserParam'!"); } String name = attributeAsString_(attributes, "name"); String type = attributeAsString_(attributes, "type"); String value = attributeAsString_(attributes, "value"); if (type == "string") { last_meta_->setMetaValue(name, value); } else if (type == "float") { last_meta_->setMetaValue(name, value.toDouble()); } else if (type == "int") { last_meta_->setMetaValue(name, value.toInt()); } else { fatalError(LOAD, String("Invalid UserParam type '") + type + "' of parameter '" + name + "'"); } } } void IdXMLFile::endElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname) { String tag = sm_.convert(qname); // START if (tag == "IdXML") { prot_id_in_run_ = false; } // SEARCH PARAMETERS else if (tag == "SearchParameters") { last_meta_ = 0; parameters_[id_] = param_; } else if (tag == "FixedModification") { last_meta_ = &param_; } else if (tag == "VariableModification") { last_meta_ = &param_; } // PROTEIN IDENTIFICATIONS else if (tag == "ProteinIdentification") { // post processing of ProteinGroups (hack) getProteinGroups_(prot_id_.getProteinGroups(), "protein_group"); getProteinGroups_(prot_id_.getIndistinguishableProteins(), "indistinguishable_proteins"); prot_ids_->push_back(prot_id_); prot_id_ = ProteinIdentification(); last_meta_ = 0; prot_id_in_run_ = true; } else if (tag == "IdentificationRun") { if (prot_ids_->size() == 0) prot_ids_->push_back(prot_id_); // add empty <ProteinIdentification> if there was none so far (thats where the IdentificationRun parameters are stored) prot_id_ = ProteinIdentification(); last_meta_ = 0; prot_id_in_run_ = false; } else if (tag == "ProteinHit") { prot_id_.insertHit(prot_hit_); last_meta_ = &prot_id_; } //PEPTIDES else if (tag == "PeptideIdentification") { pep_ids_->push_back(pep_id_); pep_id_ = PeptideIdentification(); last_meta_ = 0; } else if (tag == "PeptideHit") { pep_id_.insertHit(pep_hit_); last_meta_ = &pep_id_; } } void IdXMLFile::addProteinGroups_( MetaInfoInterface& meta, const vector<ProteinIdentification::ProteinGroup>& groups, const String& group_name, const map<String, UInt>& accession_to_id) { for (Size g = 0; g < groups.size(); ++g) { String name = group_name + "_" + String(g); if (meta.metaValueExists(name)) { warning(LOAD, String("Metavalue '") + name + "' already exists. Overwriting..."); } String accessions; for (StringList::const_iterator acc_it = groups[g].accessions.begin(); acc_it != groups[g].accessions.end(); ++acc_it) { if (acc_it != groups[g].accessions.begin()) accessions += ","; map<String, UInt>::const_iterator pos = accession_to_id.find(*acc_it); if (pos != accession_to_id.end()) { accessions += "PH_" + String(pos->second); } else { fatalError(LOAD, String("Invalid protein reference '") + *acc_it + "'"); } } String value = String(groups[g].probability) + "," + accessions; meta.setMetaValue(name, value); } } void IdXMLFile::getProteinGroups_(vector<ProteinIdentification::ProteinGroup>& groups, const String& group_name) { groups.clear(); Size g_id = 0; String current_meta = group_name + "_" + String(g_id); while (last_meta_->metaValueExists(current_meta)) { // convert to proper ProteinGroup ProteinIdentification::ProteinGroup g; StringList values; String(last_meta_->getMetaValue(current_meta)).split(',', values); if (values.size() < 2) { fatalError(LOAD, String("Invalid UserParam for ProteinGroups (not enough values)'")); } g.probability = values[0].toDouble(); for (Size i_ind = 1; i_ind < values.size(); ++i_ind) { g.accessions.push_back(proteinid_to_accession_[values[i_ind]]); } groups.push_back(g); last_meta_->removeMetaValue(current_meta); current_meta = group_name + "_" + String(++g_id); } } } // namespace OpenMS
35.326582
198
0.597212
liangoaix
441b00f8c3305aaf2d905c922a5aa42be9464bb5
6,510
cpp
C++
src/utils.cpp
imikejackson/bingocpp
6ba00a490c8cb46edebfd78f56b1604a76d668e9
[ "Apache-2.0" ]
13
2019-03-14T09:54:02.000Z
2021-09-26T14:01:30.000Z
src/utils.cpp
imikejackson/bingocpp
6ba00a490c8cb46edebfd78f56b1604a76d668e9
[ "Apache-2.0" ]
35
2019-08-29T19:12:05.000Z
2021-07-15T22:17:53.000Z
src/utils.cpp
imikejackson/bingocpp
6ba00a490c8cb46edebfd78f56b1604a76d668e9
[ "Apache-2.0" ]
9
2018-10-18T02:43:03.000Z
2021-09-02T22:08:39.000Z
/*! * \file utils.cc * * \author Ethan Adams * \date * * This file contains utility functions for doing and testing * sybolic regression problems in the bingo package */ #include <vector> #include <numeric> #include "BingoCpp/utils.h" namespace bingo { const int kPartialWindowSize = 7; const int kPartialEdgeSize = 3; const int kDerivativeOrder = 1; void set_break_points(const Eigen::ArrayXXd &x, std::vector<int> *break_points) { for (int i = 0; i < x.rows(); ++i) { if (std::isnan(x(i))) { break_points->push_back(i); } } break_points->push_back(x.rows()); } void update_return_values (int start, const Eigen::ArrayXXd &x_segment, const Eigen::ArrayXXd &time_deriv, Eigen::ArrayXXd *x_return, Eigen::ArrayXXd *time_deriv_return) { if (start == 0) { x_return->resize(x_segment.rows(), x_segment.cols()); *x_return << x_segment; time_deriv_return->resize(time_deriv.rows(), time_deriv.cols()); *time_deriv_return << time_deriv; } else { Eigen::ArrayXXd x_temp = *x_return; x_return->resize(x_return->rows() + x_segment.rows(), x_return->cols()); *x_return << x_temp, x_segment; Eigen::ArrayXXd deriv_temp = *time_deriv_return; time_deriv_return->resize(time_deriv_return->rows() + time_deriv.rows(), time_deriv_return->cols()); *time_deriv_return << deriv_temp, time_deriv; } } Eigen::ArrayXXd shave_edges_and_nan_from_array ( const Eigen::ArrayXXd &filtered_data) { return filtered_data.block(kPartialEdgeSize, 0, filtered_data.rows() - kPartialWindowSize, filtered_data.cols()); } InputAndDeriviative CalculatePartials(const Eigen::ArrayXXd &x) { std::vector<int> break_points; set_break_points(x, &break_points); int start = 0; int return_value_rows = (x.rows() - kPartialEdgeSize) * break_points.size(); Eigen::ArrayXXd x_return(return_value_rows, x.cols()); Eigen::ArrayXXd time_deriv_return(x_return.rows(), x_return.cols()); for (std::vector<int>::iterator break_point = break_points.begin(); break_point != break_points.end(); break_point ++) { Eigen::ArrayXXd x_segment = x.block(start, 0, *break_point - start, x.cols()); Eigen::ArrayXXd time_deriv(x_segment.rows(), x_segment.cols()); for (int col = 0; col < x_segment.cols(); col ++) { time_deriv.col(col) = SavitzkyGolay(x_segment.col(col), kPartialWindowSize, kPartialEdgeSize, kDerivativeOrder); } Eigen::ArrayXXd deriv_temp = shave_edges_and_nan_from_array(time_deriv); Eigen::ArrayXXd x_temp = shave_edges_and_nan_from_array(x_segment); update_return_values(start, x_temp, deriv_temp, &x_return, &time_deriv_return); start = *break_point + 1; } return std::make_pair(x_return, time_deriv_return); } double GramPoly(double eval_point, double num_points, double polynomial_order, double derivative_order) { double result = 0; if (polynomial_order > 0) { result = (4. * polynomial_order - 2.) / (polynomial_order * (2. * num_points - polynomial_order + 1.)) * (eval_point * GramPoly(eval_point, num_points, polynomial_order - 1., derivative_order) + derivative_order * GramPoly(eval_point, num_points, polynomial_order - 1., derivative_order - 1.)) - ((polynomial_order - 1.) * (2. * num_points + polynomial_order)) / (polynomial_order * (2. * num_points - polynomial_order + 1.)) * GramPoly(eval_point, num_points, polynomial_order - 2, derivative_order); } else if (polynomial_order == 0 && derivative_order == 0) { result = 1.; } else { result = 0.; } return result; } double GenFact(double a, double b) { int fact = 1; for (int i = a - b + 1; i < a + 1; ++i) { fact *= i; } return fact; } double GramWeight(double eval_point_start, double eval_point_end, double num_points, double ploynomial_order, double derivative_order) { double weight = 0; for (int i = 0; i < ploynomial_order + 1; ++i) { weight += (2. * i + 1.) * GenFact(2. * num_points, i) / GenFact(2. * num_points + i + 1, i + 1) * GramPoly(eval_point_start, num_points, i, 0) * GramPoly(eval_point_end, num_points, i, derivative_order); } return weight; } Eigen::ArrayXXd convolution(const Eigen::ArrayXXd &data_points, int half_filter_size, const Eigen::ArrayXXd &weights) { int data_points_center = 0; int w_ind = 0; int data_points_len = data_points.rows(); Eigen::ArrayXXd convolution(data_points_len, 1); for (int i = 0; i < data_points_len; ++i) { if (i < half_filter_size) { data_points_center = half_filter_size; w_ind = i; } else if (data_points_len - i <= half_filter_size) { data_points_center = data_points_len - half_filter_size - 1; w_ind = 2 * half_filter_size + 1 - (data_points_len - i); } else { data_points_center = i; w_ind = half_filter_size; } convolution(i) = 0; for (int j = half_filter_size * -1; j < half_filter_size + 1; ++j) { convolution(i) += data_points(data_points_center + j) * weights(j + half_filter_size, w_ind); } } return convolution; } Eigen::ArrayXXd SavitzkyGolay(Eigen::ArrayXXd y, int window_size, int polynomial_order, int derivative_order) { int m = (window_size - 1) / 2; Eigen::ArrayXXd weights(2 * m + 1, 2 * m + 1); for (int i = m * -1; i < m + 1; ++i) { for (int j = m * -1; j < m + 1; ++j) { weights(i + m, j + m) = GramWeight(i, j, m, polynomial_order, derivative_order); } } return convolution(y, m, weights); } } // namespace bingo
34.812834
84
0.57235
imikejackson
441b4b5e949c2f83acb085cd7d0de23fc52b0032
4,831
hpp
C++
src/xalanc/XSLT/ElemVariable.hpp
ulisesten/xalanc
a722de08e61ce66965c4a828242f7d1250950621
[ "Apache-2.0" ]
24
2015-07-29T22:49:17.000Z
2022-03-25T10:14:17.000Z
src/xalanc/XSLT/ElemVariable.hpp
ulisesten/xalanc
a722de08e61ce66965c4a828242f7d1250950621
[ "Apache-2.0" ]
14
2019-05-10T16:25:50.000Z
2021-11-24T18:04:47.000Z
src/xalanc/XSLT/ElemVariable.hpp
ulisesten/xalanc
a722de08e61ce66965c4a828242f7d1250950621
[ "Apache-2.0" ]
28
2015-04-20T15:50:51.000Z
2022-01-26T14:56:55.000Z
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if !defined(XALAN_ELEMVARIABLE_HEADER_GUARD) #define XALAN_ELEMVARIABLE_HEADER_GUARD // Base include file. Must be first. #include "XSLTDefinitions.hpp" // Base class header file. #include "ElemTemplateElement.hpp" #include <xalanc/XPath/XObject.hpp> #include <xalanc/XSLT/Constants.hpp> namespace XALAN_CPP_NAMESPACE { class XPath; class ElemVariable : public ElemTemplateElement { public: typedef ElemTemplateElement ParentType; /** * Construct an object corresponding to an "xsl:variable" element * * @param constructionContext context for construction of object * @param stylesheetTree stylesheet containing element * @param atts list of attributes for element * @param lineNumber line number in document * @param columnNumber column number in document */ ElemVariable( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, XalanFileLoc lineNumber, XalanFileLoc columnNumber); virtual ~ElemVariable(); /** * Determines if this is a top level variable. * * @return true if it is a top level variable */ bool isTopLevel() const { return m_isTopLevel; } // These methods are inherited from ElemTemplateElement ... virtual const XalanQName& getNameAttribute() const; virtual void addToStylesheet( StylesheetConstructionContext& constructionContext, Stylesheet& theStylesheet); virtual const XalanDOMString& getElementName() const; #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) const ElemTemplateElement* startElement(StylesheetExecutionContext& executionContext) const; void endElement(StylesheetExecutionContext& executionContext) const; #else virtual void execute(StylesheetExecutionContext& executionContext) const; #endif const XObjectPtr getValue( StylesheetExecutionContext& executionContext, XalanNode* sourceNode) const; virtual void setParentNodeElem(ElemTemplateElement* theParent); virtual const XPath* getXPath(XalanSize_t index) const; protected: /** * Construct an object corresponding to an "xsl:variable" element * * @param constructionContext context for construction of object * @param stylesheetTree stylesheet containing element * @param atts list of attributes for element * @param lineNumber line number in document * @param columnNumber column number in document */ ElemVariable( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, XalanFileLoc lineNumber, XalanFileLoc columnNumber, int xslToken); /** * Do common initialization. * * @param constructionContext context for construction of object * @param stylesheetTree stylesheet containing element * @param atts list of attributes for element */ void init( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts); const XalanQName* m_qname; private: // not implemented ElemVariable(const ElemVariable &); ElemVariable& operator=(const ElemVariable &); const XPath* m_selectPattern; bool m_isTopLevel; XObjectPtr m_value; XalanNode* m_varContext; }; } #endif // XALAN_ELEMVARIABLE_HEADER_GUARD
27.293785
75
0.64438
ulisesten
441baafe9de38c21838a96f15a14d248a133ce2f
289
cc
C++
atcoder/arc118/a.cc
kamal1316/competitive-programming
1443fb4bd1c92c2acff64ba2828abb21b067e6e0
[ "WTFPL" ]
506
2018-08-22T10:30:38.000Z
2022-03-31T10:01:49.000Z
atcoder/arc118/a.cc
diegordzr/competitive-programming
1443fb4bd1c92c2acff64ba2828abb21b067e6e0
[ "WTFPL" ]
13
2019-08-07T18:31:18.000Z
2020-12-15T21:54:41.000Z
atcoder/arc118/a.cc
diegordzr/competitive-programming
1443fb4bd1c92c2acff64ba2828abb21b067e6e0
[ "WTFPL" ]
234
2018-08-06T17:11:41.000Z
2022-03-26T10:56:42.000Z
// https://atcoder.jp/contests/arc118/tasks/arc118_a #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<ll>; int main() { cin.tie(0), ios::sync_with_stdio(0); ll t, n; cin >> t >> n; ll m = (n * 100 - 1) / t + 1; cout << m + n - 1 << '\n'; }
19.266667
52
0.567474
kamal1316
441fe1eb48a9368cde796d97fb901abdda65153d
131
hxx
C++
src/Providers/UNIXProviders/StatisticsService/UNIX_StatisticsService_DARWIN.hxx
brunolauze/openpegasus-providers-old
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
[ "MIT" ]
1
2020-10-12T09:00:09.000Z
2020-10-12T09:00:09.000Z
src/Providers/UNIXProviders/StatisticsService/UNIX_StatisticsService_DARWIN.hxx
brunolauze/openpegasus-providers-old
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
[ "MIT" ]
null
null
null
src/Providers/UNIXProviders/StatisticsService/UNIX_StatisticsService_DARWIN.hxx
brunolauze/openpegasus-providers-old
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
[ "MIT" ]
null
null
null
#ifdef PEGASUS_OS_DARWIN #ifndef __UNIX_STATISTICSSERVICE_PRIVATE_H #define __UNIX_STATISTICSSERVICE_PRIVATE_H #endif #endif
10.916667
42
0.854962
brunolauze
4427ad39d40e59376a5945a389a38c6d6adad970
1,654
hpp
C++
include/mainMenu/CharacterSelector.hpp
LeandreBl/cautious-fiesta
21a08135253f6fea51835d81cce4a9920113fd18
[ "Apache-2.0" ]
3
2019-10-30T16:22:54.000Z
2020-12-10T20:23:40.000Z
include/mainMenu/CharacterSelector.hpp
LeandreBl/cautious-fiesta
21a08135253f6fea51835d81cce4a9920113fd18
[ "Apache-2.0" ]
63
2019-10-06T12:05:11.000Z
2019-12-09T16:22:46.000Z
include/mainMenu/CharacterSelector.hpp
LeandreBl/cautious-fiesta
21a08135253f6fea51835d81cce4a9920113fd18
[ "Apache-2.0" ]
null
null
null
#pragma once #include <vector> #include <filesystem> #include <Vnavbar.hpp> #include "CharacterCreator.hpp" namespace cf { class CharacterSelector : public sfs::GameObject { public: CharacterSelector(const std::string &directory, const std::string &filename) noexcept : _navbar(nullptr) , _image(nullptr) , _name(nullptr) , _creator(nullptr) , _directory(directory) , _filename(filename) , _hat(nullptr){}; void start(sfs::Scene &scene) noexcept; void update(sfs::Scene &scene) noexcept; Character charaterSelected() noexcept { if (_creator != nullptr) { auto newCharacter = _creator->createCharacter(); if (newCharacter.getName() != "noName") { addCharacter(newCharacter); writeCharacterInFile(); } return newCharacter; } float characterSelected = _characters.size() * _navbar->getValue(); return _characters.at((int)characterSelected); }; void addCharacter(const Character &character) noexcept { _characters.emplace_back(character); }; void loadCharactersFromFile() noexcept; void writeCharacterInFile() noexcept; void addCharacterFromCreateButton() noexcept { if (_creator != nullptr) { auto _new = _creator->createCharacter(); if (_new.getName() != "noName") { _characters.emplace_back(_new); writeCharacterInFile(); _creator->destroy(); _creator = nullptr; } } } protected: std::vector<Character> _characters; sfs::Vnavbar *_navbar; sfs::Sprite *_image; sfs::Text *_name; CharacterCreation *_creator; std::filesystem::path _directory; std::filesystem::path _filename; std::vector<Text *> _stats; sfs::Sprite *_hat; }; } // namespace cf
24.686567
86
0.709794
LeandreBl
442ab6973bd178895d04eb4c8bad071d6ce5c757
3,890
cpp
C++
DearPyGui/src/core/AppItems/basic/mvSelectable.cpp
liu-kan/DearPyGui
dbbf03519b4eff6fc3e8fc56e31c27aa29ac7a39
[ "MIT" ]
null
null
null
DearPyGui/src/core/AppItems/basic/mvSelectable.cpp
liu-kan/DearPyGui
dbbf03519b4eff6fc3e8fc56e31c27aa29ac7a39
[ "MIT" ]
null
null
null
DearPyGui/src/core/AppItems/basic/mvSelectable.cpp
liu-kan/DearPyGui
dbbf03519b4eff6fc3e8fc56e31c27aa29ac7a39
[ "MIT" ]
null
null
null
#include <utility> #include "mvSelectable.h" #include "mvApp.h" #include "mvItemRegistry.h" namespace Marvel { void mvSelectable::InsertParser(std::map<std::string, mvPythonParser>* parsers) { parsers->insert({ "add_selectable", mvPythonParser({ {mvPythonDataType::String, "name"}, {mvPythonDataType::KeywordOnly}, {mvPythonDataType::Bool, "default_value", "", "False"}, {mvPythonDataType::Callable, "callback", "Registers a callback", "None"}, {mvPythonDataType::Object, "callback_data", "Callback data", "None"}, {mvPythonDataType::String, "parent", "Parent this item will be added to. (runtime adding)", "''"}, {mvPythonDataType::String, "before", "This item will be displayed before the specified item in the parent. (runtime adding)", "''"}, {mvPythonDataType::String, "source", "", "''"}, {mvPythonDataType::Bool, "enabled", "Display grayed out text so selectable cannot be selected", "True"}, {mvPythonDataType::String, "label", "", "''"}, {mvPythonDataType::Bool, "show", "Attempt to render", "True"}, {mvPythonDataType::Bool, "span_columns", "span all columns", "False"}, }, "Adds a selectable.", "None", "Adding Widgets") }); } mvSelectable::mvSelectable(const std::string& name, bool default_value, const std::string& dataSource) : mvBoolPtrBase(name, default_value) { m_description.disableAllowed = true; } void mvSelectable::setEnabled(bool value) { if (value) m_flags &= ~ImGuiSelectableFlags_Disabled; else m_flags |= ImGuiSelectableFlags_Disabled; m_core_config.enabled = value; } void mvSelectable::draw() { auto styleManager = m_styleManager.getScopedStyleManager(); ScopedID id; mvImGuiThemeScope scope(this); if (ImGui::Selectable(m_label.c_str(), m_value.get(), m_flags)) mvApp::GetApp()->getCallbackRegistry().addCallback(m_core_config.callback, m_core_config.name, m_core_config.callback_data); } #ifndef MV_CPP void mvSelectable::setExtraConfigDict(PyObject* dict) { if (dict == nullptr) return; // helper for bit flipping auto flagop = [dict](const char* keyword, int flag, int& flags, bool flip) { if (PyObject* item = PyDict_GetItemString(dict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; }; // window flags flagop("span_columns", ImGuiSelectableFlags_SpanAllColumns, m_flags, false); } void mvSelectable::getExtraConfigDict(PyObject* dict) { if (dict == nullptr) return; // helper to check and set bit auto checkbitset = [dict](const char* keyword, int flag, const int& flags, bool flip) { PyDict_SetItemString(dict, keyword, ToPyBool(flags & flag)); }; // window flags checkbitset("span_columns", ImGuiSelectableFlags_SpanAllColumns, m_flags, false); } PyObject* add_selectable(PyObject* self, PyObject* args, PyObject* kwargs) { const char* name; int default_value = false; PyObject* callback = nullptr; PyObject* callback_data = nullptr; const char* before = ""; const char* parent = ""; const char* source = ""; int enabled = true; const char* label = ""; int show = true; int span_columns = false; //ImGuiSelectableFlags flags = ImGuiSelectableFlags_None; if (!(*mvApp::GetApp()->getParsers())["add_selectable"].parse(args, kwargs, __FUNCTION__, &name, &default_value, &callback, &callback_data, &parent, &before, &source, &enabled, &label, &show, &span_columns)) return ToPyBool(false); auto item = CreateRef<mvSelectable>(name, default_value, source); if (callback) Py_XINCREF(callback); item->setCallback(callback); if (callback_data) Py_XINCREF(callback_data); item->setCallbackData(callback_data); item->checkConfigDict(kwargs); item->setConfigDict(kwargs); item->setExtraConfigDict(kwargs); mvApp::GetApp()->getItemRegistry().addItemWithRuntimeChecks(item, parent, before); return GetPyNone(); } #endif // !MV_CPP }
30.155039
135
0.70437
liu-kan
442b8734c611d250bdd535cbb037af12fd964656
12,534
cpp
C++
src/sysGCU/P2DScreen.cpp
projectPiki/pikmin2
a431d992acde856d092889a515ecca0e07a3ea7c
[ "Unlicense" ]
33
2021-12-08T11:10:59.000Z
2022-03-26T19:59:37.000Z
src/sysGCU/P2DScreen.cpp
projectPiki/pikmin2
a431d992acde856d092889a515ecca0e07a3ea7c
[ "Unlicense" ]
6
2021-12-22T17:54:31.000Z
2022-01-07T21:43:18.000Z
src/sysGCU/P2DScreen.cpp
projectPiki/pikmin2
a431d992acde856d092889a515ecca0e07a3ea7c
[ "Unlicense" ]
2
2022-01-04T06:00:49.000Z
2022-01-26T07:27:28.000Z
#include "JSystem/JUT/JUTException.h" #include "P2DScreen.h" #include "System.h" #include "types.h" /* Generated from dpostproc .section .rodata # 0x804732E0 - 0x8049E220 .global lbl_8049A6C0 lbl_8049A6C0: .4byte 0x50324453 .4byte 0x63726565 .4byte 0x6E2E6370 .4byte 0x70000000 .global lbl_8049A6D0 lbl_8049A6D0: .asciz "P2Assert" .skip 3 .4byte 0x00000000 .section .data, "wa" # 0x8049E220 - 0x804EFC20 .global __vt__Q29P2DScreen10Mgr_tuning __vt__Q29P2DScreen10Mgr_tuning: .4byte 0 .4byte 0 .4byte __dt__Q29P2DScreen10Mgr_tuningFv .4byte getTypeID__9J2DScreenCFv .4byte move__7J2DPaneFff .4byte add__7J2DPaneFff .4byte resize__7J2DPaneFff .4byte setCullBack__7J2DPaneFb .4byte setCullBack__7J2DPaneF11_GXCullMode .4byte setAlpha__7J2DPaneFUc .4byte setConnectParent__7J2DPaneFb .4byte calcMtx__9J2DScreenFv .4byte update__Q29P2DScreen3MgrFv .4byte drawSelf__7J2DPaneFff .4byte drawSelf__9J2DScreenFffPA3_A4_f .4byte search__9J2DScreenFUx .4byte searchUserInfo__9J2DScreenFUx .4byte makeMatrix__7J2DPaneFff .4byte makeMatrix__7J2DPaneFffff .4byte isUsed__9J2DScreenFPC7ResTIMG .4byte isUsed__9J2DScreenFPC7ResFONT .4byte clearAnmTransform__9J2DScreenFv .4byte rewriteAlpha__7J2DPaneFv .4byte setAnimation__9J2DScreenFP10J2DAnmBase .4byte setAnimation__9J2DScreenFP15J2DAnmTransform .4byte setAnimation__9J2DScreenFP11J2DAnmColor .4byte setAnimation__9J2DScreenFP16J2DAnmTexPattern .4byte setAnimation__9J2DScreenFP19J2DAnmTextureSRTKey .4byte setAnimation__9J2DScreenFP15J2DAnmTevRegKey .4byte setAnimation__9J2DScreenFP20J2DAnmVisibilityFull .4byte setAnimation__9J2DScreenFP14J2DAnmVtxColor .4byte animationTransform__7J2DPaneFPC15J2DAnmTransform .4byte setVisibileAnimation__7J2DPaneFP20J2DAnmVisibilityFull .4byte setAnimationVF__9J2DScreenFP20J2DAnmVisibilityFull .4byte setVtxColorAnimation__7J2DPaneFP14J2DAnmVtxColor .4byte setAnimationVC__9J2DScreenFP14J2DAnmVtxColor .4byte animationPane__7J2DPaneFPC15J2DAnmTransform .4byte createPane__9J2DScreenFRC18J2DScrnBlockHeaderP20JSURandomInputStreamP7J2DPaneUl .4byte createPane__9J2DScreenFRC18J2DScrnBlockHeaderP20JSURandomInputStreamP7J2DPaneUlP10JKRArchive .4byte draw__Q29P2DScreen10Mgr_tuningFR8GraphicsR14J2DGrafContext .global __vt__Q29P2DScreen3Mgr __vt__Q29P2DScreen3Mgr: .4byte 0 .4byte 0 .4byte __dt__Q29P2DScreen3MgrFv .4byte getTypeID__9J2DScreenCFv .4byte move__7J2DPaneFff .4byte add__7J2DPaneFff .4byte resize__7J2DPaneFff .4byte setCullBack__7J2DPaneFb .4byte setCullBack__7J2DPaneF11_GXCullMode .4byte setAlpha__7J2DPaneFUc .4byte setConnectParent__7J2DPaneFb .4byte calcMtx__9J2DScreenFv .4byte update__Q29P2DScreen3MgrFv .4byte drawSelf__7J2DPaneFff .4byte drawSelf__9J2DScreenFffPA3_A4_f .4byte search__9J2DScreenFUx .4byte searchUserInfo__9J2DScreenFUx .4byte makeMatrix__7J2DPaneFff .4byte makeMatrix__7J2DPaneFffff .4byte isUsed__9J2DScreenFPC7ResTIMG .4byte isUsed__9J2DScreenFPC7ResFONT .4byte clearAnmTransform__9J2DScreenFv .4byte rewriteAlpha__7J2DPaneFv .4byte setAnimation__9J2DScreenFP10J2DAnmBase .4byte setAnimation__9J2DScreenFP15J2DAnmTransform .4byte setAnimation__9J2DScreenFP11J2DAnmColor .4byte setAnimation__9J2DScreenFP16J2DAnmTexPattern .4byte setAnimation__9J2DScreenFP19J2DAnmTextureSRTKey .4byte setAnimation__9J2DScreenFP15J2DAnmTevRegKey .4byte setAnimation__9J2DScreenFP20J2DAnmVisibilityFull .4byte setAnimation__9J2DScreenFP14J2DAnmVtxColor .4byte animationTransform__7J2DPaneFPC15J2DAnmTransform .4byte setVisibileAnimation__7J2DPaneFP20J2DAnmVisibilityFull .4byte setAnimationVF__9J2DScreenFP20J2DAnmVisibilityFull .4byte setVtxColorAnimation__7J2DPaneFP14J2DAnmVtxColor .4byte setAnimationVC__9J2DScreenFP14J2DAnmVtxColor .4byte animationPane__7J2DPaneFPC15J2DAnmTransform .4byte createPane__9J2DScreenFRC18J2DScrnBlockHeaderP20JSURandomInputStreamP7J2DPaneUl .4byte createPane__9J2DScreenFRC18J2DScrnBlockHeaderP20JSURandomInputStreamP7J2DPaneUlP10JKRArchive .4byte draw__Q29P2DScreen3MgrFR8GraphicsR14J2DGrafContext .section .sdata2, "a" # 0x80516360 - 0x80520E40 .global lbl_80520790 lbl_80520790: .4byte 0x00000000 .global mstTuningScaleX__Q29P2DScreen10Mgr_tuning mstTuningScaleX__Q29P2DScreen10Mgr_tuning: .4byte 0x3F733333 .global mstTuningScaleY__Q29P2DScreen10Mgr_tuning mstTuningScaleY__Q29P2DScreen10Mgr_tuning: .4byte 0x3F733333 .global mstTuningTransX__Q29P2DScreen10Mgr_tuning mstTuningTransX__Q29P2DScreen10Mgr_tuning: .4byte 0xC1733333 .global mstTuningTransY__Q29P2DScreen10Mgr_tuning mstTuningTransY__Q29P2DScreen10Mgr_tuning: .4byte 0xC1733333 .global lbl_805207A4 lbl_805207A4: .4byte 0x3F733333 .global lbl_805207A8 lbl_805207A8: .4byte 0xC1733333 .global lbl_805207AC lbl_805207AC: .float 0.5 .global lbl_805207B0 lbl_805207B0: .4byte 0x43300000 .4byte 0x00000000 */ /* __ct * --INFO-- * Address: 80434AC0 * Size: 000064 */ P2DScreen::Mgr::Mgr() : J2DScreen() , _118() { /* stwu r1, -0x10(r1) mflr r0 stw r0, 0x14(r1) stw r31, 0xc(r1) mr r31, r3 stw r30, 8(r1) bl __ct__9J2DScreenFv lis r3, __vt__Q29P2DScreen3Mgr@ha addi r30, r31, 0x118 addi r0, r3, __vt__Q29P2DScreen3Mgr@l stw r0, 0(r31) mr r3, r30 bl __ct__5CNodeFv lis r3, __vt__Q29P2DScreen4Node@ha li r0, 0 addi r4, r3, __vt__Q29P2DScreen4Node@l mr r3, r31 stw r4, 0(r30) stw r0, 0x18(r30) lwz r31, 0xc(r1) lwz r30, 8(r1) lwz r0, 0x14(r1) mtlr r0 addi r1, r1, 0x10 blr */ } /* * --INFO-- * Address: 80434B24 * Size: 000138 */ J2DPane* P2DScreen::Mgr::addCallBack(u64 tag, P2DScreen::Node* node) { P2ASSERTLINE(73, (node != nullptr)); J2DPane* pane = search(tag); if (pane != nullptr) { node->_18 = pane; node->doInit(); _118.add(node); } else { // TODO: There's stuff here... of some sort, at least. } return pane; /* stwu r1, -0x20(r1) mflr r0 stw r0, 0x24(r1) stw r31, 0x1c(r1) stw r30, 0x18(r1) or. r30, r7, r7 stw r29, 0x14(r1) mr r29, r3 stw r5, 8(r1) stw r6, 0xc(r1) bne lbl_80434B6C lis r3, lbl_8049A6C0@ha lis r5, lbl_8049A6D0@ha addi r3, r3, lbl_8049A6C0@l li r4, 0x49 addi r5, r5, lbl_8049A6D0@l crclr 6 bl panic_f__12JUTExceptionFPCciPCce lbl_80434B6C: mr r3, r29 lwz r5, 8(r1) lwz r12, 0(r29) lwz r6, 0xc(r1) lwz r12, 0x3c(r12) mtctr r12 bctrl or. r31, r3, r3 beq lbl_80434BB8 stw r31, 0x18(r30) mr r3, r30 lwz r12, 0(r30) lwz r12, 0x18(r12) mtctr r12 bctrl mr r4, r30 addi r3, r29, 0x118 bl add__5CNodeFP5CNode b lbl_80434C3C lbl_80434BB8: lbz r3, 8(r1) li r0, 0x3f extsb. r3, r3 bne lbl_80434BCC stb r0, 8(r1) lbl_80434BCC: lbz r3, 9(r1) extsb. r3, r3 bne lbl_80434BDC stb r0, 9(r1) lbl_80434BDC: lbz r3, 0xa(r1) extsb. r3, r3 bne lbl_80434BEC stb r0, 0xa(r1) lbl_80434BEC: lbz r3, 0xb(r1) extsb. r3, r3 bne lbl_80434BFC stb r0, 0xb(r1) lbl_80434BFC: lbz r3, 0xc(r1) extsb. r3, r3 bne lbl_80434C0C stb r0, 0xc(r1) lbl_80434C0C: lbz r3, 0xd(r1) extsb. r3, r3 bne lbl_80434C1C stb r0, 0xd(r1) lbl_80434C1C: lbz r3, 0xe(r1) extsb. r3, r3 bne lbl_80434C2C stb r0, 0xe(r1) lbl_80434C2C: lbz r3, 0xf(r1) extsb. r3, r3 bne lbl_80434C3C stb r0, 0xf(r1) lbl_80434C3C: lwz r0, 0x24(r1) mr r3, r31 lwz r31, 0x1c(r1) lwz r30, 0x18(r1) lwz r29, 0x14(r1) mtlr r0 addi r1, r1, 0x20 blr */ } /* * --INFO-- * Address: 80434C5C * Size: 000084 */ void P2DScreen::Mgr::addCallBackPane(J2DPane* pane, P2DScreen::Node* node) { P2ASSERTLINE(97, (node != nullptr)); node->_18 = pane; node->doInit(); _118.add(node); } /* * --INFO-- * Address: 80434CE0 * Size: 00004C */ void P2DScreen::Mgr::update(void) { for (Node* node = (Node*)_118.m_child; node != nullptr; node = (Node*)node->m_next) { node->update(); } } /* * --INFO-- * Address: 80434D2C * Size: 000080 */ void P2DScreen::Mgr::draw(Graphics& gfx, J2DGrafContext& context) { J2DScreen::draw(0.0f, 0.0f, &context); for (Node* node = (Node*)_118.m_child; node != nullptr; node = (Node*)node->m_next) { node->draw(gfx, context); } } /* * --INFO-- * Address: 80434DAC * Size: 000088 */ P2DScreen::Mgr_tuning::Mgr_tuning(void) : Mgr() , m_widthMaybe(0.95f) , m_heightMaybe(0.95f) , m_someX(-15.2f) , m_someY(-15.2f) { /* stwu r1, -0x10(r1) mflr r0 stw r0, 0x14(r1) stw r31, 0xc(r1) mr r31, r3 stw r30, 8(r1) bl __ct__9J2DScreenFv lis r3, __vt__Q29P2DScreen3Mgr@ha addi r30, r31, 0x118 addi r0, r3, __vt__Q29P2DScreen3Mgr@l stw r0, 0(r31) mr r3, r30 bl __ct__5CNodeFv lis r4, __vt__Q29P2DScreen4Node@ha lis r3, __vt__Q29P2DScreen10Mgr_tuning@ha addi r0, r4, __vt__Q29P2DScreen4Node@l li r4, 0 stw r0, 0(r30) addi r0, r3, __vt__Q29P2DScreen10Mgr_tuning@l lfs f1, lbl_805207A4@sda21(r2) mr r3, r31 stw r4, 0x18(r30) lfs f0, lbl_805207A8@sda21(r2) stw r0, 0(r31) stfs f1, 0x138(r31) stfs f1, 0x13c(r31) stfs f0, 0x140(r31) stfs f0, 0x144(r31) lwz r31, 0xc(r1) lwz r30, 8(r1) lwz r0, 0x14(r1) mtlr r0 addi r1, r1, 0x10 blr */ } /* draw__Q29P2DScreen10Mgr_tuningFR8GraphicsR14J2DGrafContext * --INFO-- * Address: 80434E34 * Size: 000128 */ void P2DScreen::Mgr_tuning::draw(Graphics& gfx, J2DGrafContext& context) { float xfb = (float)System::getRenderModeObj()->xfbHeight; float efb = (float)System::getRenderModeObj()->efbHeight; rotate(xfb * 0.5f, efb * 0.5f, 0x7A, 0.0f); m_scale.x = m_widthMaybe; m_scale.y = m_heightMaybe; calcMtx(); _0D4[0] = m_someX; _0D4[1] = m_someY; calcMtx(); Mgr::draw(gfx, context); /* stwu r1, -0x30(r1) mflr r0 stw r0, 0x34(r1) stw r31, 0x2c(r1) stw r30, 0x28(r1) mr r30, r5 stw r29, 0x24(r1) mr r29, r4 stw r28, 0x20(r1) mr r28, r3 bl getRenderModeObj__6SystemFv lhz r31, 4(r3) bl getRenderModeObj__6SystemFv lhz r5, 6(r3) lis r0, 0x4330 stw r31, 0xc(r1) mr r3, r28 lfd f2, lbl_805207B0@sda21(r2) li r4, 0x7a stw r0, 8(r1) lfs f4, lbl_805207AC@sda21(r2) lfd f0, 8(r1) stw r5, 0x14(r1) fsubs f1, f0, f2 lfs f3, lbl_80520790@sda21(r2) stw r0, 0x10(r1) lfd f0, 0x10(r1) fmuls f1, f4, f1 fsubs f0, f0, f2 fmuls f2, f4, f0 bl rotate__7J2DPaneFff13J2DRotateAxisf lfs f1, 0x13c(r28) mr r3, r28 lfs f0, 0x138(r28) stfs f0, 0xcc(r28) stfs f1, 0xd0(r28) lwz r12, 0(r28) lwz r12, 0x2c(r12) mtctr r12 bctrl lfs f1, 0x144(r28) mr r3, r28 lfs f0, 0x140(r28) stfs f0, 0xd4(r28) stfs f1, 0xd8(r28) lwz r12, 0(r28) lwz r12, 0x2c(r12) mtctr r12 bctrl lfs f1, lbl_80520790@sda21(r2) mr r3, r28 mr r4, r30 fmr f2, f1 bl draw__9J2DScreenFffPC14J2DGrafContext lwz r31, 0x128(r28) b lbl_80434F34 lbl_80434F14: mr r3, r31 mr r4, r29 lwz r12, 0(r31) mr r5, r30 lwz r12, 0x14(r12) mtctr r12 bctrl lwz r31, 4(r31) lbl_80434F34: cmplwi r31, 0 bne lbl_80434F14 lwz r0, 0x34(r1) lwz r31, 0x2c(r1) lwz r30, 0x28(r1) lwz r29, 0x24(r1) lwz r28, 0x20(r1) mtlr r0 addi r1, r1, 0x30 blr */ }
25.737166
95
0.655258
projectPiki
442d9a027b4d6a25aebd2c64f082ac438d192a60
3,960
cc
C++
tutorials/t1.cc
dianpeng/hge-unix
0cade62a3494f1508cdaaa620714e69ae151e0c1
[ "Zlib" ]
null
null
null
tutorials/t1.cc
dianpeng/hge-unix
0cade62a3494f1508cdaaa620714e69ae151e0c1
[ "Zlib" ]
null
null
null
tutorials/t1.cc
dianpeng/hge-unix
0cade62a3494f1508cdaaa620714e69ae151e0c1
[ "Zlib" ]
null
null
null
/* ** Haaf's Game Engine 1.8 ** Copyright (C) 2003-2007, Relish Games ** hge.relishgames.com ** ** hge_tut05 - Using distortion mesh */ // Copy the files "particles.png", "menu.wav", // "font1.fnt", "font1.png" and "trail.psi" from // the folder "precompiled" to the folder with // executable file. Also copy hge.dll and bass.dll // to the same folder. #include <hge/hge.h> #include <hge/hgefont.h> #include <hge/hgedistort.h> #include <math.h> // Pointer to the HGE interface. // Helper classes require this to work. HGE *hge=0; HTEXTURE tex; // Pointers to the HGE objects we will use hgeDistortionMesh* dis; hgeFont* fnt; // Some "gameplay" variables const int nRows=16; const int nCols=16; const float cellw=512.0f/(nCols-1); const float cellh=512.0f/(nRows-1); const float meshx=144; const float meshy=44; bool FrameFunc() { float dt=hge->Timer_GetDelta(); static float t=0.0f; static int trans=0; int i, j, col; float r, a, dx, dy; t+=dt; // Process keys switch(hge->Input_GetKey()) { case HGEK_ESCAPE: return true; case HGEK_SPACE: if(++trans > 2) trans=0; dis->Clear(0xFF000000); break; } // Calculate new displacements and coloring for one of the three effects switch(trans) { case 0: for(i=1;i<nRows-1;i++) for(j=1;j<nCols-1;j++) { dis->SetDisplacement(j,i,cosf(t*10+(i+j)/2)*5,sinf(t*10+(i+j)/2)*5,HGEDISP_NODE); } break; case 1: for(i=0;i<nRows;i++) for(j=1;j<nCols-1;j++) { dis->SetDisplacement(j,i,cosf(t*5+j/2)*15,0,HGEDISP_NODE); col=int((cosf(t*5+(i+j)/2)+1)*35); dis->SetColor(j,i,0xFF<<24 | col<<16 | col<<8 | col); } break; case 2: for(i=0;i<nRows;i++) for(j=0;j<nCols;j++) { r=sqrtf(powf(j-(float)nCols/2,2)+powf(i-(float)nRows/2,2)); a=r*cosf(t*2)*0.1f; dx=sinf(a)*(i*cellh-256)+cosf(a)*(j*cellw-256); dy=cosf(a)*(i*cellh-256)-sinf(a)*(j*cellw-256); dis->SetDisplacement(j,i,dx,dy,HGEDISP_CENTER); col=int((cos(r+t*4)+1)*40); dis->SetColor(j,i,0xFF<<24 | col<<16 | (col/2)<<8); } break; } return false; } bool RenderFunc() { // Render graphics hge->Gfx_BeginScene(); hge->Gfx_Clear(0); dis->Render(meshx, meshy); fnt->printf(5, 5, HGETEXT_LEFT, "dt:%.3f\nFPS:%d\n\nUse your\nSPACE!", hge->Timer_GetDelta(), hge->Timer_GetFPS()); hge->Gfx_EndScene(); return false; } #ifdef PLATFORM_UNIX int main(int argc, char *argv[]) #else int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) #endif { hge = hgeCreate(HGE_VERSION); hge->System_SetState(HGE_LOGFILE, "hge_tut05.log"); hge->System_SetState(HGE_FRAMEFUNC, FrameFunc); hge->System_SetState(HGE_RENDERFUNC, RenderFunc); hge->System_SetState(HGE_TITLE, "HGE Tutorial 05 - Using distortion mesh"); hge->System_SetState(HGE_WINDOWED, true); hge->System_SetState(HGE_SCREENWIDTH, 800); hge->System_SetState(HGE_SCREENHEIGHT, 600); hge->System_SetState(HGE_SCREENBPP, 32); hge->System_SetState(HGE_USESOUND, false); if(hge->System_Initiate()) { // Load sound and texture tex=hge->Texture_Load("texture.jpg"); if(!tex) { // If one of the data files is not found, display // an error message and shutdown. #ifdef PLATFORM_UNIX fprintf(stderr, "Error: Can't load texture.jpg\n"); #else MessageBox(NULL, "Can't load texture.jpg", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL); #endif hge->System_Shutdown(); hge->Release(); return 0; } // Create a distortion mesh dis=new hgeDistortionMesh(nCols, nRows); dis->SetTexture(tex); dis->SetTextureRect(0,0,512,512); dis->SetBlendMode(BLEND_COLORADD | BLEND_ALPHABLEND | BLEND_ZWRITE); dis->Clear(0xFF000000); // Load a font fnt=new hgeFont("font1.fnt"); // Let's rock now! hge->System_Start(); // Delete created objects and free loaded resources delete fnt; delete dis; hge->Texture_Free(tex); } // Clean up and shutdown hge->System_Shutdown(); hge->Release(); return 0; }
22.372881
116
0.658586
dianpeng
442f94ea5083e8f9b8e8d2d90652d22d4b0240d5
8,270
cpp
C++
process.cpp
mastmees/reflow_oven
87cd23341e7fd70a18ddf194d513ae281879e9f3
[ "MIT" ]
2
2019-02-22T18:41:05.000Z
2019-05-17T14:45:56.000Z
process.cpp
mastmees/reflow_oven
87cd23341e7fd70a18ddf194d513ae281879e9f3
[ "MIT" ]
null
null
null
process.cpp
mastmees/reflow_oven
87cd23341e7fd70a18ddf194d513ae281879e9f3
[ "MIT" ]
null
null
null
/* The MIT License (MIT) Copyright (c) 2017 Madis Kaal <mast@nomad.ee> 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 "process.hpp" #include "settings.hpp" extern Button startbutton; PID pidcontroller(10.0,0.0,0.0); extern Oven oven; #define SHOWPROFILE1() (PORTD|=_BV(PD4)) #define SHOWPROFILE0() (PORTD&=(~_BV(PD4))) #define FAULT_BLINK() (PORTD^=_BV(PD4)) // assume starting at 25degC // normal heating rate 2 degC/sec // normal cooling rate 3 degC/sec struct ProfileStep leadedsteps[] = { { ProfileStep::DOOR_CLOSE, 0}, { 100, 60 }, // heat up to 100, this will lag and overshoot { 120, 30 }, // ride the overshoot to up to 150 { 150, 40 }, // get to preheat temperature, still overshooting here { 150, 60 }, // stay at preheat { 185, 30 }, // ramp to reflow { 210, 20 }, // fast towards peak reflow, this will also overshoot { 228, 10 }, // reset controller then take last step { 228, 3 }, // reset controller then take last step { ProfileStep::DOOR_OPEN, 0}, { 60, 60 }, // rapid cooldown { ProfileStep::PROCESS_DONE, 0 } // done }; struct ProfileStep leadfreesteps[] = { { ProfileStep::DOOR_CLOSE,0 }, { 100, 60 }, { 125, 30 }, { 160, 20 }, { 180, 30 }, { 200,30 }, // preheat, ramp to 200 in 90 seconds { 200,5 }, // hold for 5 seconds { 210,25 }, // ramp up to reflow temp at nominal rate { 235,10 }, { 250,10 }, // ramp up to peak reflow at faster rate { 250,4 }, // stay at peak for 4 seconds { ProfileStep::DOOR_OPEN,0 }, { 60,60 }, // cool down to 60deg { ProfileStep::PROCESS_DONE, 0 } // done }; struct Profile leadedprofile = { &leadedsteps[0], 160, 200 }; struct Profile leadfreeprofile = { &leadfreesteps[0], 190, 215 }; void Process::SetProfile(Profile *p) { profile=p; step=&p->steps[0]; while (1) { if (step->temp==ProfileStep::PROCESS_DONE) { state=STOPPING; serial.print("#no steps in process?\n"); return; } if (step->temp==ProfileStep::DOOR_OPEN) { oven.CoolerOn(); serial.print("#opening door\n"); step++; continue; } if (step->temp==ProfileStep::DOOR_CLOSE) { oven.CoolerOff(); serial.print("#closing door\n"); step++; continue; } if (step->temp>0) break; step++; // safeguard for special steps not handled here } targettemp=step->temp; setpoint=oven.Temperature(); if (step->seconds==0) setpointstep=targettemp-setpoint; else setpointstep=(targettemp-setpoint)/step->seconds; pidcontroller.SetSetPoint(setpoint); pidcontroller.Reset(); runningtime=0; } void Process::ProcessTick() { float v=oven.Temperature(); if (step->seconds>runningtime) { // minimum time not expired yet setpoint+=setpointstep; pidcontroller.SetSetPoint(setpoint); } else { pidcontroller.SetSetPoint(targettemp); setpoint=targettemp; if (setpointstep>=0.0) { // ramping upwards if (v>=targettemp) { while (1) { step++; if (step->temp==ProfileStep::PROCESS_DONE) { state=STOPPING; serial.print("#last step reached\n"); return; } if (step->temp==ProfileStep::DOOR_OPEN) { oven.CoolerOn(); serial.print("#opening door\n"); continue; } if (step->temp==ProfileStep::DOOR_CLOSE) { oven.CoolerOff(); serial.print("#closing door\n"); continue; } if (step->temp>0) break; } if (step->temp==targettemp) setpointstep=0.0; else { targettemp=step->temp; if (step->seconds) setpointstep=(targettemp-v)/step->seconds; else setpointstep=(targettemp-v); } runningtime=0; pidcontroller.Reset(); } } else { // ramping downwards or steady if (v<=targettemp) { while (1) { step++; if (step->temp==ProfileStep::PROCESS_DONE) { state=STOPPING; serial.print("#last step reached\n"); return; } if (step->temp==ProfileStep::DOOR_OPEN) { oven.CoolerOn(); serial.print("#opening door\n"); continue; } if (step->temp==ProfileStep::DOOR_CLOSE) { oven.CoolerOff(); serial.print("#closing door\n"); continue; } if (step->temp>0) break; } if (step->temp==targettemp) setpointstep=0.0; else { targettemp=step->temp; if (step->seconds) setpointstep=(targettemp-v)/step->seconds; else setpointstep=targettemp-v; } runningtime=0; pidcontroller.Reset(); } } } runningtime++; } Process::Process() { state=STOPPING; timestamp=(unsigned int)-1; pidoutput=0; profile=NULL; pwmcounter=0; targettemp=0.0; setpointstep=0.0; setpoint=0.0; } void Process::Run() { float v; switch (state) { case STOPPING: serial.print("Stopping\n"); oven.Reset(); startbutton.Clear(); state=STOPPED; break; case STOPPED: if (oven.IsFaulty()) { state=FAULT; break; } if (profilebutton.Pressed()) SHOWPROFILE1(); else SHOWPROFILE0(); if (startbutton.Read()) state=STARTING; break; case STARTING: pidcontroller.SetOutputLimits(-127,127); pidcontroller.SetCoefficents(settings.P,settings.I,settings.D); if (profilebutton.Pressed()) { serial.print("#Lead-free profile\n"); SetProfile(&leadfreeprofile); SHOWPROFILE1(); } else { serial.print("#Leaded profile\n"); SetProfile(&leadedprofile); SHOWPROFILE0(); } serial.print("Starting\n"); serial.print("time#i4,target#f4,setpoint#f4,temperature#f4,pidoutput#i4\n"); second_counter=0; oven.ConvectionOn(); oven.CoolerOff(); state=RUNNING; break; case RUNNING: if (oven.IsFaulty()) { state=FAULT; break; } // if (startbutton.Read()) state=STOPPING; // if (timestamp!=second_counter && targettemp>=0.0) { v=oven.Temperature(); pidoutput=pidcontroller.ProcessInput(v); if (pidoutput>=0) { oven.SetPWM(pidoutput); } else { oven.SetPWM(0); } ProcessTick(); serial.print(second_counter); serial.send(','); serial.print(targettemp); serial.send(','); serial.print(setpoint); serial.send(','); serial.print(v); serial.send(','); serial.print((int32_t)pidoutput); serial.send('\n'); } break; case FAULT: serial.print("#Fault\n"); oven.Reset(); state=BLINKING; break; case BLINKING: if (timestamp!=second_counter) { FAULT_BLINK(); } if (!oven.IsFaulty()) { serial.print("#Fault cleared\n"); state=STOPPING; } break; } timestamp=second_counter; }
26.850649
82
0.586699
mastmees
443291baa2a8a1f8c4d2c2d3e4a7761b7f1eae63
2,922
hpp
C++
Programming Guide/Headers/Siv3D/GUITextField.hpp
Reputeless/Siv3D-Reference
d58e92885241d11612007fb9187ce0289a7ee9cb
[ "MIT" ]
38
2016-01-14T13:51:13.000Z
2021-12-29T01:49:30.000Z
Programming Guide/Headers/Siv3D/GUITextField.hpp
Reputeless/Siv3D-Reference
d58e92885241d11612007fb9187ce0289a7ee9cb
[ "MIT" ]
null
null
null
Programming Guide/Headers/Siv3D/GUITextField.hpp
Reputeless/Siv3D-Reference
d58e92885241d11612007fb9187ce0289a7ee9cb
[ "MIT" ]
16
2016-01-15T11:07:51.000Z
2021-12-29T01:49:37.000Z
//----------------------------------------------- // // This file is part of the Siv3D Engine. // // Copyright (C) 2008-2016 Ryo Suzuki // // Licensed under the MIT License. // //----------------------------------------------- # pragma once # include "Fwd.hpp" # include "IWidget.hpp" # include "WidgetStyle.hpp" namespace s3d { class GUITextField : public IWidget { private: Optional<size_t> m_maxLength; size_t m_cursorPos = 0; String m_text; double m_pressedPressure = 0.0; double m_scaling = 0.0; bool m_mouseOver = false; bool m_hasChanged = false; bool m_enabled = true; bool m_active = false; Point ItemSize() const; Point TextRegion() const; Rect MarginBox(const Point& offset) const; Rect PaddingBox(const Point& offset) const; Rect ItemBox(const Point& offset) const; public: static const String& Name() { static const String name = L"TextField"; return name; } static std::shared_ptr<GUITextField> Create(const Optional<size_t>& maxLength, const WidgetStyle& style = WidgetStyle()) { return std::make_shared<GUITextField>(maxLength, true, style); } static std::shared_ptr<GUITextField> Create(const Optional<size_t>& maxLength, bool enabled, const WidgetStyle& style = WidgetStyle()) { return std::make_shared<GUITextField>(maxLength, enabled, style); } GUITextField() {} GUITextField(const Optional<size_t>& maxLength, bool enabled, const WidgetStyle& style); const String& getWidgetName() const override; Size getSize() const override; bool forceNewLineBefore() const override; bool forceNewLineAfter() const override; void update(const WidgetState& state) override; void draw(const WidgetState& state) const override; bool& getEnabled(); bool& getActive(); const String& getText() const; void setText(const String& text); const Optional<size_t>& getMaxLength() const; void setMaxLength(const Optional<size_t>& length); Property_Get(bool, mouseOver) const; Property_Get(bool, hasChanged) const; }; class GUITextFieldWrapper { public: using WidgetType = GUITextField; private: friend class GUI; std::shared_ptr<WidgetType> m_widget; GUITextFieldWrapper(const std::shared_ptr<WidgetType>& widget) : m_widget(widget ? widget : std::make_shared<WidgetType>()) , enabled(m_widget->getEnabled()) , active(m_widget->getActive()) , style(m_widget->m_style) {} GUITextFieldWrapper& operator = (const GUITextFieldWrapper&) = delete; static const String& WidgetTypeName() { return WidgetType::Name(); } public: bool& enabled; bool& active; WidgetStyle& style; Property_Get(bool, mouseOver) const; Property_Get(bool, hasChanged) const; Property_Get(const String&, text) const; void setText(const String& text); Property_Get(Optional<size_t>, maxLength) const; void setMaxLength(const Optional<size_t>& length); }; }
19.877551
136
0.689254
Reputeless
4433de13cab58b0713671dab27b56af01cbcca59
3,282
cpp
C++
Crossy_Roads/WaterParticles.cpp
Daryan7/Crossy_Roads
af816aa73ba29241fb1db4722940e42be8a76102
[ "MIT" ]
1
2018-04-18T12:54:33.000Z
2018-04-18T12:54:33.000Z
Crossy_Roads/WaterParticles.cpp
Daryan7/Crossy_Roads
af816aa73ba29241fb1db4722940e42be8a76102
[ "MIT" ]
null
null
null
Crossy_Roads/WaterParticles.cpp
Daryan7/Crossy_Roads
af816aa73ba29241fb1db4722940e42be8a76102
[ "MIT" ]
null
null
null
#include "WaterParticles.h" #include "Utils.h" #include "Object.h" using namespace glm; inline void compileShader(ShaderProgram& program, const string& fileName) { Shader vShader, fShader; string path = "shaders/" + fileName; vShader.initFromFile(VERTEX_SHADER, path + ".vert"); if (!vShader.isCompiled()) { cout << "Vertex Shader " + fileName + " Error" << endl; cout << "" << vShader.log() << endl << endl; } fShader.initFromFile(FRAGMENT_SHADER, path + ".frag"); if (!fShader.isCompiled()) { cout << "Fragment Shader " + fileName + " Error" << endl; cout << "" << fShader.log() << endl << endl; } program.init(); program.addShader(vShader); program.addShader(fShader); program.link(); if (!program.isLinked()) { cout << "Shader " + fileName + " Linking Error" << endl; cout << "" << program.log() << endl << endl; } vShader.free(); fShader.free(); for (uint i = 0; i < sizeof(uniformOrder) / sizeof(string); ++i) { program.addUniform(uniformOrder[i]); } } void WaterParticleSystem::firstInit() { compileShader(program, "simpleColor"); program.bindFragmentOutput("outColor"); colorLoc = program.addUniform("color"); lightLoc = program.addUniform("lightDir"); } void WaterParticleSystem::init(const Assets & assets) { GameObject::init(); mesh = assets.getCubeMesh(); texture = assets.getTexture("water_plane"); } void WaterParticleSystem::trigger(vec3 pos, uint numParticles, vec4 color) { this->color = color; pos.y += mesh->getbbSize().y*0.3f/2; this->pos = pos; uint nParticles = numParticles + between(-5, 5); particles.resize(nParticles); for (uint i = 0; i < nParticles; ++i) { float horzAngle = between(0.f, 2 * PI); float vertAngle = between(0.f, PI / 2); particles[i].position = pos; particles[i].speed = vec3(cos(horzAngle)*0.2f, sin(vertAngle), sin(horzAngle)*0.2f); particles[i].lifetime = (uint)ceil(2 * (-particles[i].speed.y / g)); particles[i].scale = 0.3f; particles[i].state = Falling; } } void WaterParticleSystem::update() { uint j = 0; for (uint i = 0; i < particles.size(); i++) { particles[i].lifetime -= 1; switch (particles[i].state) { case Falling: particles[i] = particles[j]; if (particles[j].lifetime > 0) { particles[j].speed.y += g; particles[j].position += particles[j].speed; } else { particles[j].position.y = pos.y; particles[j].state = Stopped; particles[j].lifetime = uint(particles[i].scale / 0.01f); } ++j; break; case Stopped: if (particles[i].lifetime > 0) { particles[j] = particles[i]; particles[j].scale += -0.01f; ++j; } break; } } particles.resize(j); } void WaterParticleSystem::render(const mat4& VP, vec3 lightDir) { if (particles.size() == 0) return; program.use(); program.setUniformMatrix4f(viewProjectionLoc, VP); program.setUniform4f(colorLoc, color); program.setUniform3f(lightLoc, lightDir); Object object; mesh->setProgramParams(program); texture->use(); for (uint i = 0; i < particles.size(); ++i) { object.setPos(particles[i].position); object.setScale(vec3(particles[i].scale)); program.setUniformMatrix4f(modelLoc, *object.getModel()); mesh->render(); } } WaterParticleSystem::WaterParticleSystem() { } WaterParticleSystem::~WaterParticleSystem() { }
26.467742
86
0.661792
Daryan7
443473d3a57398771341de47c25e2c5042956da2
6,187
cpp
C++
src/geometry/FilePLY.cpp
mgradysaunders/precept
966eb19d3c8b713e11be0885cabda632cefe9878
[ "BSD-2-Clause" ]
null
null
null
src/geometry/FilePLY.cpp
mgradysaunders/precept
966eb19d3c8b713e11be0885cabda632cefe9878
[ "BSD-2-Clause" ]
null
null
null
src/geometry/FilePLY.cpp
mgradysaunders/precept
966eb19d3c8b713e11be0885cabda632cefe9878
[ "BSD-2-Clause" ]
null
null
null
#include <pre/geometry/FilePLY> #include <pre/string> #include "rply.h" namespace pre { static void error_cb(p_ply, const char* message) { throw std::runtime_error(message); } static int vertex2_cb(p_ply_argument arg) { void* pointer = nullptr; long index = 0; ply_get_argument_user_data(arg, &pointer, &index); FilePLY::Buffer2* buffer = static_cast<FilePLY::Buffer2*>(pointer); if (index == 0) buffer->emplace_back(); buffer->back()[index] = ply_get_argument_value(arg); return 1; } static int vertex3_cb(p_ply_argument arg) { void* pointer = nullptr; long index = 0; ply_get_argument_user_data(arg, &pointer, &index); FilePLY::Buffer3* buffer = static_cast<FilePLY::Buffer3*>(pointer); if (index == 0) buffer->emplace_back(); buffer->back()[index] = ply_get_argument_value(arg); return 1; } static int face_cb(p_ply_argument arg) { void* pointer = nullptr; long count = 0; long index = 0; ply_get_argument_user_data(arg, &pointer, nullptr); ply_get_argument_property(arg, nullptr, &count, &index); FilePLY* ply = static_cast<FilePLY*>(pointer); if (index == -1) ply->face_sizes.push_back(count); else { double value = ply_get_argument_value(arg); if (not(value >= 0 and value == std::uint32_t(value))) throw std::runtime_error("Bad index"); ply->face_indexes.push_back(std::uint32_t(value)); } return 1; } void FilePLY::read(const std::string& filename) { clear(); p_ply ply = ply_open(filename.c_str(), error_cb, 0, nullptr); Scoped remember_to_close([] {}, [&] { ply_close(ply); }); if (not ply) throw make_exception("can't open "s + quote(filename)); try { if (not ply_read_header(ply)) throw std::runtime_error("Bad header"); ply_set_read_cb(ply, "vertex", "x", vertex3_cb, &positions, 0); ply_set_read_cb(ply, "vertex", "y", vertex3_cb, &positions, 1); ply_set_read_cb(ply, "vertex", "z", vertex3_cb, &positions, 2); ply_set_read_cb(ply, "vertex", "nx", vertex3_cb, &normals, 0); ply_set_read_cb(ply, "vertex", "ny", vertex3_cb, &normals, 1); ply_set_read_cb(ply, "vertex", "nz", vertex3_cb, &normals, 2); ply_set_read_cb(ply, "vertex", "s", vertex2_cb, &uvs, 0); ply_set_read_cb(ply, "vertex", "t", vertex2_cb, &uvs, 1); ply_set_read_cb(ply, "vertex", "r", vertex3_cb, &colors, 0); ply_set_read_cb(ply, "vertex", "g", vertex3_cb, &colors, 1); ply_set_read_cb(ply, "vertex", "b", vertex3_cb, &colors, 2); ply_set_read_cb(ply, "face", "vertex_indices", face_cb, this, 0); if (not ply_read(ply)) throw std::runtime_error("Unknown failure reason"); } catch (const std::runtime_error& error) { throw make_exception( "can't read "s + quote(filename) + " ("s + error.what() + ")"s); } } void FilePLY::write(const std::string& filename) const { p_ply ply = ply_create(filename.c_str(), PLY_LITTLE_ENDIAN, error_cb, 0, nullptr); Scoped remember_to_close([] {}, [&] { ply_close(ply); }); try { ply_add_element(ply, "vertex", positions.size()); ply_add_scalar_property(ply, "x", PLY_FLOAT); ply_add_scalar_property(ply, "y", PLY_FLOAT); ply_add_scalar_property(ply, "z", PLY_FLOAT); if (normals.size() > 0) { ply_add_scalar_property(ply, "nx", PLY_FLOAT); ply_add_scalar_property(ply, "ny", PLY_FLOAT); ply_add_scalar_property(ply, "nz", PLY_FLOAT); } if (uvs.size() > 0) { ply_add_scalar_property(ply, "s", PLY_FLOAT); ply_add_scalar_property(ply, "t", PLY_FLOAT); } if (colors.size() > 0) { ply_add_scalar_property(ply, "r", PLY_FLOAT); ply_add_scalar_property(ply, "g", PLY_FLOAT); ply_add_scalar_property(ply, "b", PLY_FLOAT); } ply_add_element(ply, "face", face_sizes.size()); ply_add_list_property(ply, "vertex_indices", PLY_UCHAR, PLY_UINT); if (not ply_write_header(ply)) throw std::runtime_error("Bad header"); for (size_t index = 0; index < positions.size(); index++) { ply_write(ply, positions[index][0]); ply_write(ply, positions[index][1]); ply_write(ply, positions[index][2]); if (normals.size() > 0) { ply_write(ply, normals[index][0]); ply_write(ply, normals[index][1]); ply_write(ply, normals[index][2]); } if (uvs.size() > 0) { ply_write(ply, uvs[index][0]); ply_write(ply, uvs[index][1]); } if (colors.size() > 0) { ply_write(ply, colors[index][0]); ply_write(ply, colors[index][1]); ply_write(ply, colors[index][2]); } } auto face_index = face_indexes.begin(); for (size_t face_size : face_sizes) { ply_write(ply, face_size); while (face_size-- != 0) ply_write(ply, *face_index++); } } catch (const std::runtime_error& error) { throw make_exception( "can't write "s + quote(filename) + " ("s + error.what() + ")"s); } } void FilePLY::triangulate() { std::uint32_t offset = 0; std::vector<std::uint8_t> new_face_sizes; std::vector<std::uint32_t> new_face_indexes; new_face_sizes.reserve(face_sizes.size()); new_face_indexes.reserve(face_indexes.size()); for (std::uint8_t face_size : face_sizes) { for (std::uint8_t local = 1; local + 1 < face_size; local++) { new_face_indexes.push_back(face_indexes[offset]); new_face_indexes.push_back(face_indexes[offset + local]); new_face_indexes.push_back(face_indexes[offset + local + 1]); new_face_sizes.push_back(3); } offset += face_size; } std::swap(face_sizes, new_face_sizes); std::swap(face_indexes, new_face_indexes); } void FilePLY::normalize_normals() { for (Vec3<float>& v : normals) v = normalize(v); } } // namespace pre
38.91195
78
0.604008
mgradysaunders
4439fbfbae24e450c574bb98996663db71c45fcd
1,568
cpp
C++
src/main.cpp
waneon/magfy
2ebb905cf1730a5e6f66ad9164248e303bd051c4
[ "MIT" ]
1
2022-02-27T17:41:18.000Z
2022-02-27T17:41:18.000Z
src/main.cpp
waneon/magfy
2ebb905cf1730a5e6f66ad9164248e303bd051c4
[ "MIT" ]
null
null
null
src/main.cpp
waneon/magfy
2ebb905cf1730a5e6f66ad9164248e303bd051c4
[ "MIT" ]
null
null
null
#include <fstream> #include <spdlog/spdlog.h> #include <yaml-cpp/exceptions.h> #include <yaml-cpp/yaml.h> #if defined(MAGFY_WINDOWS) #include <spdlog/sinks/basic_file_sink.h> #include <windows.h> #else #include <spdlog/sinks/stdout_color_sinks.h> #endif #include "Config.h" #include "core.h" // global logger object std::shared_ptr<spdlog::logger> logger; // global hInstance object for Windows #if defined(MAGFY_WINDOWS) HINSTANCE g_hInstance = NULL; #endif #if defined(MAGFY_WINDOWS) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) { #else int main() { #endif // vendor-specific configure #if defined(MAGFY_WINDOWS) logger = spdlog::basic_logger_mt("magfy", get_log_file()); spdlog::flush_every(std::chrono::seconds(3)); g_hInstance = hInstance; #else logger = spdlog::stderr_color_mt("magfy"); #endif // parse config.yaml file Config config; try { YAML::Node root = YAML::LoadFile(get_config_file()); config = root.as<Config>(); } catch (YAML::BadFile ex) { logger->error("Config file must be placed in proper directory."); return 1; } catch (YAML::Exception ex) { logger->error("Parse error => {}", ex.msg); return 1; } logger->info("Successfully loaded the config file."); // run magfy try { run(config); logger->info("Terminated normally."); return 0; } catch (std::exception ex) { logger->error("Terminated abnormally."); return 1; } }
24.888889
80
0.654337
waneon
443c8776f2e1c50afd1b5db3494cc0b27f391644
3,381
cpp
C++
src/pos_normalizer.cpp
andre-nguyen/an_ros_tools
ddfd99405821065cc811c8698c3bfb84880a8c78
[ "MIT" ]
null
null
null
src/pos_normalizer.cpp
andre-nguyen/an_ros_tools
ddfd99405821065cc811c8698c3bfb84880a8c78
[ "MIT" ]
null
null
null
src/pos_normalizer.cpp
andre-nguyen/an_ros_tools
ddfd99405821065cc811c8698c3bfb84880a8c78
[ "MIT" ]
null
null
null
#include <ros/ros.h> #include <message_filters/subscriber.h> #include <message_filters/synchronizer.h> #include <message_filters/sync_policies/approximate_time.h> #include <dji_sdk/GlobalPosition.h> #include <dji_sdk/LocalPosition.h> #include <nav_msgs/Odometry.h> #include <eigen3/Eigen/Dense> #include "transform.h" dji_sdk::GlobalPosition global_pos_ref; dji_sdk::LocalPosition local_pos_ref; bool first_pos_rcvd = false; ros::Publisher odom_norm_pub, odom_norm_ENU_pub; void callback(const dji_sdk::GlobalPositionConstPtr& global_pos, const nav_msgs::OdometryConstPtr& odometry) { if(!first_pos_rcvd) { global_pos_ref = *global_pos; first_pos_rcvd = true; } nav_msgs::Odometry odom_norm = *odometry; local_pos_ref = gps_convert_ned(*global_pos, global_pos_ref); odom_norm.pose.pose.position.x = local_pos_ref.x; odom_norm.pose.pose.position.y = local_pos_ref.y; odom_norm.pose.pose.position.z = -local_pos_ref.z; odom_norm.twist.twist.linear.z *= -1; odom_norm_pub.publish(odom_norm); // god dammit dji nav_msgs::Odometry odom_norm_ENU = *odometry; // The code above was for NED now convert to ENU Eigen::Vector3d position_ENU = ned2enu(Eigen::Vector3d(local_pos_ref.x, local_pos_ref.y, -local_pos_ref.z)); Eigen::Quaterniond orientation_ENU = ned2enu(Eigen::Quaterniond( odom_norm.pose.pose.orientation.w, odom_norm.pose.pose.orientation.x, odom_norm.pose.pose.orientation.y, odom_norm.pose.pose.orientation.z)); // wtf is this NEU? NED? Eigen::Vector3d velocity_ENU = ned2enu(Eigen::Vector3d( odom_norm.twist.twist.linear.x, odom_norm.twist.twist.linear.y, -odom_norm.twist.twist.linear.z)); odom_norm_ENU.pose.pose.position.x = position_ENU(0); odom_norm_ENU.pose.pose.position.y = position_ENU(1); odom_norm_ENU.pose.pose.position.z = position_ENU(2); odom_norm_ENU.pose.pose.orientation.w = orientation_ENU.w(); odom_norm_ENU.pose.pose.orientation.x = orientation_ENU.x(); odom_norm_ENU.pose.pose.orientation.y = orientation_ENU.y(); odom_norm_ENU.pose.pose.orientation.z = orientation_ENU.z(); odom_norm_ENU.twist.twist.linear.x = velocity_ENU(0); odom_norm_ENU.twist.twist.linear.y = velocity_ENU(1); odom_norm_ENU.twist.twist.linear.z = velocity_ENU(2); odom_norm_ENU_pub.publish(odom_norm_ENU); } int main(int argc, char** argv) { ros::init(argc, argv, "pos_normalizer"); ros::NodeHandle nh; odom_norm_pub = nh.advertise<nav_msgs::Odometry> ("/dji_sdk/odometry_normalized_NED", 10); odom_norm_ENU_pub = nh.advertise<nav_msgs::Odometry> ("/dji_sdk/odometry_normalized_ENU", 10); message_filters::Subscriber<dji_sdk::GlobalPosition> global_sub(nh, "/dji_sdk/global_position", 10); message_filters::Subscriber<nav_msgs::Odometry> odom_sub (nh, "/dji_sdk/odometry", 10); typedef message_filters::sync_policies::ApproximateTime <dji_sdk::GlobalPosition, nav_msgs::Odometry> MySyncPolicy; message_filters::Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), global_sub, odom_sub); sync.registerCallback(boost::bind(&callback, _1, _2)); ros::spin(); return 0; }
40.25
79
0.699201
andre-nguyen
443d71fbc939af001e7c7c70bdc863a830b41e26
8,085
cpp
C++
src/common/network_manager.cpp
blackccpie/neurocl
cfbb1978ba92d5085796330846d997944f604c93
[ "MIT" ]
2
2016-01-01T22:19:04.000Z
2018-12-12T19:06:24.000Z
src/common/network_manager.cpp
blackccpie/neurocl
cfbb1978ba92d5085796330846d997944f604c93
[ "MIT" ]
null
null
null
src/common/network_manager.cpp
blackccpie/neurocl
cfbb1978ba92d5085796330846d997944f604c93
[ "MIT" ]
1
2020-10-19T08:17:54.000Z
2020-10-19T08:17:54.000Z
/* The MIT License Copyright (c) 2015-2017 Albert Murienne 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 "network_manager.h" #include "interfaces/network_interface.h" #include "interfaces/network_file_handler_interface.h" #include "common/network_exception.h" #include "common/samples_manager.h" #include "common/logger.h" #include <chrono> #include <iostream> //#define TRAIN_CHRONO namespace neurocl { class scoped_training { public: scoped_training( std::shared_ptr<network_interface> net ) : m_net( net ) { m_net->set_training( true ); } virtual ~scoped_training() { m_net->set_training( false ); } private: std::shared_ptr<network_interface> m_net; }; void network_manager::_assert_loaded() { if ( !m_network_loaded ) throw network_exception( "no network loaded!" ); } void network_manager::set_training( bool training, key_training ) { m_net->set_training( training ); } void network_manager::load_network( const std::string& topology_path, const std::string& weights_path ) { m_net_file_handler->load_network_topology( topology_path ); m_net_file_handler->load_network_weights( weights_path ); m_network_loaded = true; LOGGER(info) << "network_manager::load_network - network loaded" << std::endl; } void network_manager::save_network() { _assert_loaded(); m_net_file_handler->save_network_weights(); } void network_manager::batch_train( const samples_manager& smp_manager, const size_t& epoch_size, const size_t& batch_size, t_progress_fct progress_fct ) { _assert_loaded(); scoped_training _scoped_training( m_net ); std::shared_ptr<samples_augmenter> smp_augmenter;// = smp_manager.get_augmenter(); size_t progress_size = 0; const size_t pbm_size = epoch_size * smp_manager.samples_size(); for ( size_t i=0; i<epoch_size; i++ ) { while ( true ) { std::vector<neurocl::sample> samples = smp_manager.get_next_batch( batch_size ); // end of training set management if ( samples.empty() ) break; prepare_training_epoch(); _train_batch( samples, smp_augmenter ); finalize_training_epoch(); progress_size += samples.size(); int progress = ( ( 100 * progress_size ) / pbm_size ); if ( progress_fct ) progress_fct( progress ); std::cout << "\rnetwork_manager::batch_train - progress: " << progress << "% loss: " << m_net->loss(); } std::cout << "\r"; LOGGER(info) << "network_manager::batch_train - EPOCH " << (i+1) << "/" << epoch_size << " loss: " << m_net->loss() << std::endl; smp_manager.rewind(); smp_manager.shuffle(); } std::cout << std::endl; save_network(); } void network_manager::prepare_training_epoch() { m_net->clear_gradients(); } void network_manager::finalize_training_epoch() { m_net->gradient_descent(); } void network_manager::train( const sample& s, key_training ) { _assert_loaded(); _train_single( s ); } void network_manager::_train_batch( const std::vector<sample>& training_set, const std::shared_ptr<samples_augmenter>& smp_augmenter ) { _assert_loaded(); size_t index = 0; for( const auto& s : training_set ) { //LOGGER(info) << "network_manager::_train_batch - training sample " << (index+1) << "/" << training_set.size() << std::endl; if ( !smp_augmenter ) { _train_single( s ); } else { //sample _s = smp_augmenter->translate( s, samples_augmenter::rand_shift(), samples_augmenter::rand_shift() ); sample _s = smp_augmenter->rotate( s, samples_augmenter::rand_shift() ); _train_single( _s ); } ++index; } } void network_manager::_train_single( const sample& s ) { #ifdef TRAIN_CHRONO namespace sc = std::chrono; sc::system_clock::time_point start = sc::system_clock::now(); sc::milliseconds duration; #endif // set input/output m_net->set_input( s.isample_size, s.isample ); m_net->set_output( s.osample_size, s.osample ); // forward/backward propagation m_net->feed_forward(); m_net->back_propagate(); #ifdef TRAIN_CHRONO duration = sc::duration_cast<sc::milliseconds>( sc::system_clock::now() - start ); LOGGER(info) << "network_manager::_train_single - training successfull in " << duration.count() << "ms"<< std::endl; #endif } void network_manager::compute_augmented_output( sample& s, const std::shared_ptr<samples_augmenter>& smp_augmenter ) { // ONLY ROTATION AUGMENTATION IS IMPLEMENTED YET std::vector<int> rotations{ -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 }; std::vector<output_ptr> outputs; for ( auto& rot : rotations ) { sample _s = smp_augmenter->rotate( s, rot ); m_net->set_input( _s.isample_size, _s.isample ); m_net->feed_forward(); outputs.emplace_back( m_net->output() ); //output_layer += m_net->output(); } // TODO-CNN : not very proud of the efficiency of this code section... // still it is temporary as computing a mean image alos makes sense! int i = 0; int l = 0; float max = std::numeric_limits<float>::min(); for ( const auto& output : outputs ) { float _tmp_max = output.max_comp_val(); LOGGER(info) << "network_manager::compute_augmented_output - " << _tmp_max << " " << output.max_comp_idx() << std::endl; if ( _tmp_max > max ) { l = i; max = _tmp_max; } i++; } std::copy( outputs[l].outputs.get(), outputs[l].outputs.get() + outputs[l].num_outputs, const_cast<float*>( s.osample ) ); } void network_manager::compute_output( sample& s ) { _assert_loaded(); m_net->set_input( s.isample_size, s.isample ); m_net->feed_forward(); output_ptr output_layer = m_net->output(); std::copy( output_layer.outputs.get(), output_layer.outputs.get() + output_layer.num_outputs, const_cast<float*>( s.osample ) ); } void network_manager::compute_output( std::vector<sample>& s ) { _assert_loaded(); // NOT IMPLEMENTED YET //m_net->batch_feed_forward( std::vector<input_ptr>&, std::vector<output_ptr>& ); } void network_manager::gradient_check( const sample& s ) { _assert_loaded(); m_net->set_input( s.isample_size, s.isample ); m_net->set_output( s.osample_size, s.osample ); output_ptr out_ref( s.osample_size ); std::copy( s.osample, s.osample + s.osample_size, out_ref.outputs.get() ); m_net->gradient_check( out_ref ); } void network_manager::dump_weights() { _assert_loaded(); std::cout << m_net->dump_weights(); } void network_manager::dump_bias() { _assert_loaded(); std::cout << m_net->dump_bias(); } void network_manager::dump_activations() { _assert_loaded(); std::cout << m_net->dump_activations(); } } /*namespace neurocl*/
27.688356
137
0.660977
blackccpie
443df983b7b87d5189021884753eae575099751f
1,080
cpp
C++
src/timereference.cpp
hrxcodes/cbftp
bf2784007dcc4cc42775a2d40157c51b80383f81
[ "MIT" ]
8
2019-04-30T00:37:00.000Z
2022-02-03T13:35:31.000Z
src/timereference.cpp
Xtravaganz/cbftp
31a3465e2cd539f6cf35a5d9a0bb9c5c2f639cd5
[ "MIT" ]
2
2019-11-19T12:46:13.000Z
2019-12-20T22:13:57.000Z
src/timereference.cpp
Xtravaganz/cbftp
31a3465e2cd539f6cf35a5d9a0bb9c5c2f639cd5
[ "MIT" ]
9
2020-01-15T02:38:36.000Z
2022-02-15T20:05:20.000Z
#include "timereference.h" #include <ctime> #include "core/tickpoke.h" #include "globalcontext.h" #define INTERVAL 50 static int currentyear = 0; static int currentmonth = 0; static int currentday = 0; TimeReference::TimeReference() { global->getTickPoke()->startPoke(this, "TimeReference", INTERVAL, 0); } void TimeReference::tick(int) { timeticker += INTERVAL; } unsigned long long TimeReference::timeReference() const { return timeticker; } unsigned long long TimeReference::timePassedSince(unsigned long long timestamp) const { if (timestamp > timeticker) { return 0 - timestamp + timeticker; } return timeticker - timestamp; } void TimeReference::updateTime() { time_t rawtime; time(&rawtime); struct tm timedata; localtime_r(&rawtime, &timedata); currentyear = timedata.tm_year + 1900; currentmonth = timedata.tm_mon + 1; currentday = timedata.tm_mday; } int TimeReference::currentYear() { return currentyear; } int TimeReference::currentMonth() { return currentmonth; } int TimeReference::currentDay() { return currentday; }
20
87
0.730556
hrxcodes
443e0803e8359c4d4a766b9033599397bebf7154
155
cpp
C++
regression/esbmc-cpp/try_catch/try-catch_pointer_01/main.cpp
shmarovfedor/esbmc
3226a3d68b009d44b9535a993ac0f25e1a1fbedd
[ "BSD-3-Clause" ]
143
2015-06-22T12:30:01.000Z
2022-03-21T08:41:17.000Z
regression/esbmc-cpp/try_catch/try-catch_pointer_01/main.cpp
shmarovfedor/esbmc
3226a3d68b009d44b9535a993ac0f25e1a1fbedd
[ "BSD-3-Clause" ]
542
2017-06-02T13:46:26.000Z
2022-03-31T16:35:17.000Z
regression/esbmc-cpp/try_catch/try-catch_pointer_01/main.cpp
shmarovfedor/esbmc
3226a3d68b009d44b9535a993ac0f25e1a1fbedd
[ "BSD-3-Clause" ]
81
2015-10-21T22:21:59.000Z
2022-03-24T14:07:55.000Z
#include<cassert> int main() { try { int x = 5; int *py = &x; throw py; } catch(int*) { } catch(void*) { assert(0); } return 0; }
10.333333
29
0.470968
shmarovfedor
4441450f2bde5590471e665b70f77992f4e9d033
2,192
cpp
C++
Linux/Ubuntu/64bit/AVAPI/AvapiExamples/MIDPOINT_Example.cpp
AvapiDotNet/AvapiCpp
2157ccbe750cac077098a6f1aa401d80fc943ff5
[ "MIT" ]
15
2018-01-31T16:58:36.000Z
2021-08-19T21:37:08.000Z
Linux/Ubuntu/64bit/AVAPI/AvapiExamples/MIDPOINT_Example.cpp
AvapiDotNet/AvapiCpp
2157ccbe750cac077098a6f1aa401d80fc943ff5
[ "MIT" ]
null
null
null
Linux/Ubuntu/64bit/AVAPI/AvapiExamples/MIDPOINT_Example.cpp
AvapiDotNet/AvapiCpp
2157ccbe750cac077098a6f1aa401d80fc943ff5
[ "MIT" ]
4
2018-01-31T17:06:26.000Z
2020-05-03T20:59:27.000Z
#include <string> #include <iostream> #include <sstream> #include "Avapi/AvapiConnection.hpp" #include "Avapi/TECHNICAL_INDICATOR/MIDPOINT.hpp" using namespace std; using namespace Avapi; int main() { string lastHttpRequest = ""; AvapiConnection* avapi_connection; try { avapi_connection = AvapiConnection::getInstance(); avapi_connection->set_ApiKey("Your Alpha Vantage API Key !!!!"); } catch(AvapiConnectionError& e) { cout << e.get_error() << endl; return EXIT_FAILURE; } auto& QueryObject = avapi_connection->GetQueryObject_MIDPOINT(); auto Response = QueryObject.Query( "MSFT" ,Const_MIDPOINT_interval::n_60min ,"10" ,Const_MIDPOINT_series_type::close); cout << endl << "******** RAW DATA MIDPOINT ********"<< endl; cout << Response.get_RawData() << endl << endl; cout << "******** STRUCTURED DATA MIDPOINT ********"<< endl; if(Response.get_Data().isError()) { cerr << Response.get_Data().get_ErrorMessage() << endl; } else { auto& MetaData = Response.get_Data().get_MetaData(); auto& TechnicalIndicator = Response.get_Data().get_TechnicalIndicator(); cout << "========================" << endl; cout << "Symbol: " << MetaData.get_Symbol() << endl; cout << "Indicator: " << MetaData.get_Indicator() << endl; cout << "LastRefreshed: " << MetaData.get_LastRefreshed() << endl; cout << "Interval: " << MetaData.get_Interval() << endl; cout << "TimePeriod: " << MetaData.get_TimePeriod() << endl; cout << "SeriesType: " << MetaData.get_SeriesType() << endl; cout << "TimeZone: " << MetaData.get_TimeZone() << endl; cout << "========================" << endl; cout << "========================" << endl; for(auto& element : TechnicalIndicator) { cout << "MIDPOINT: " << element.get_MIDPOINT() << endl; cout << "DateTime: " << element.get_DateTime() << endl; cout << "========================" << endl; } } return EXIT_SUCCESS; }
31.768116
80
0.542883
AvapiDotNet
4444a57baf0d204dd179fa6c987b85c9d5c67f9a
1,038
cpp
C++
CodeForces/879/C - Short Program.cpp
QAQrz/ACM-Code
7f7b6fd315e7d84ed606dd48d666da07fc4d0ae7
[ "Unlicense" ]
2
2018-02-24T06:45:56.000Z
2018-05-29T04:47:39.000Z
CodeForces/879/C - Short Program.cpp
QAQrz/ACM-Code
7f7b6fd315e7d84ed606dd48d666da07fc4d0ae7
[ "Unlicense" ]
null
null
null
CodeForces/879/C - Short Program.cpp
QAQrz/ACM-Code
7f7b6fd315e7d84ed606dd48d666da07fc4d0ae7
[ "Unlicense" ]
2
2018-06-28T09:53:27.000Z
2022-03-23T13:29:57.000Z
#include <bits/stdc++.h> using namespace std; #pragma comment(linker,"/stack:1024000000,1024000000") #define db(x) cout<<(x)<<endl #define pf(x) push_front(x) #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define ms(x,y) memset(x,y,sizeof x) typedef long long LL; const double pi=acos(-1),eps=1e-9; const LL inf=0x3f3f3f3f,mod=1e9+7,maxn=512345; struct node{ char s[5]; int x; }p[maxn],ans[12]; int n,t,a,b=1023,x=1023,y,z; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i=0;i<n;i++){ cin>>p[i].s>>p[i].x; if(p[i].s[0]=='&') a&=p[i].x,b&=p[i].x; else if(p[i].s[0]=='|') a|=p[i].x,b|=p[i].x; else a^=p[i].x,b^=p[i].x; } for(int i=0;i<10;i++) if(((a>>i)&1)&&!((b>>i)&1)) z^=1<<i; else if(((a>>i)&1)&&((b>>i)&1)) y|=1<<i; else if(!((a>>i)&1)&&!((b>>i)&1)) x&=~(1<<i); if(x<1023) ans[t].s[0]='&',ans[t++].x=x; if(y) ans[t].s[0]='|',ans[t++].x=y; if(z) ans[t].s[0]='^',ans[t++].x=z; db(t); for(int i=0;i<t;i++) printf("%s %d\n",ans[i].s,ans[i].x); return 0; }
22.085106
54
0.528902
QAQrz
4445f4fe81631651dbad0e6e04930d0403ac9f9a
4,061
cpp
C++
LibFFmpeg/demo/FFplayer2/player.cpp
sim9108/SDKS
2823124fa0a22f8a77d131e7a2fb7f4aba59129c
[ "MIT" ]
2
2015-03-23T01:08:49.000Z
2015-03-23T02:28:17.000Z
LibFFmpeg/demo/FFplayer2/player.cpp
sim9108/SDKS
2823124fa0a22f8a77d131e7a2fb7f4aba59129c
[ "MIT" ]
null
null
null
LibFFmpeg/demo/FFplayer2/player.cpp
sim9108/SDKS
2823124fa0a22f8a77d131e7a2fb7f4aba59129c
[ "MIT" ]
null
null
null
#include "player.h" #include <chrono> #include <iostream> #include <algorithm> extern "C" { #include <libavutil/time.h> } using std::string; using std::unique_ptr; using std::function; using std::thread; using std::chrono::milliseconds; using std::this_thread::sleep_for; using std::exception; using std::cerr; using std::endl; using std::runtime_error; using std::max; Player::Player(const string &file_name) : container_(new Container(file_name)), display_(new Display(container_->get_width(), container_->get_height())), timer_(new Timer), packet_queue_(new PacketQueue(queue_size_)), frame_queue_(new FrameQueue(queue_size_)) { stages_.push_back(thread(&Player::demultiplex, this)); stages_.push_back(thread(&Player::decode_video, this)); video(); } Player::~Player() { frame_queue_->quit(); packet_queue_->quit(); for (auto &stage : stages_) { stage.join(); } } void Player::demultiplex() { try { for (;;) { // Create AVPacket unique_ptr<AVPacket, function<void(AVPacket*)>> packet( new AVPacket, [](AVPacket* p){ av_free_packet(p); delete p; }); av_init_packet(packet.get()); packet->data = nullptr; // Read frame into AVPacket if (!container_->read_frame(*packet)) { packet_queue_->finished(); break; } // Move into queue if first video stream if (packet->stream_index == container_->get_video_stream()) { if (!packet_queue_->push(move(packet))) { break; } } } } catch (exception &e) { cerr << "Demuxing error: " << e.what() << endl; exit(1); } } void Player::decode_video() { const AVRational microseconds = {1, 1000000}; try { for (;;) { // Create AVFrame and AVQueue unique_ptr<AVFrame, function<void(AVFrame*)>> frame_decoded( av_frame_alloc(), [](AVFrame* f){ av_frame_free(&f); }); unique_ptr<AVPacket, function<void(AVPacket*)>> packet( nullptr, [](AVPacket* p){ av_free_packet(p); delete p; }); // Read packet from queue if (!packet_queue_->pop(packet)) { frame_queue_->finished(); break; } // Decode packet int finished_frame; container_->decode_frame( frame_decoded.get(), finished_frame, packet.get()); // If a whole frame has been decoded, // adjust time stamps and add to queue if (finished_frame) { frame_decoded->pts = av_rescale_q( frame_decoded->pkt_dts, container_->get_container_time_base(), microseconds); unique_ptr<AVFrame, function<void(AVFrame*)>> frame_converted( av_frame_alloc(), [](AVFrame* f){ avpicture_free( reinterpret_cast<AVPicture*>(f)); av_frame_free(&f); }); if (av_frame_copy_props(frame_converted.get(), frame_decoded.get()) < 0) { throw runtime_error("Copying frame properties"); } if (avpicture_alloc( reinterpret_cast<AVPicture*>(frame_converted.get()), container_->get_pixel_format(), container_->get_width(), container_->get_height()) < 0) { throw runtime_error("Allocating picture"); } container_->convert_frame( frame_decoded.get(), frame_converted.get()); if (!frame_queue_->push(move(frame_converted))) { break; } } } } catch (exception &e) { cerr << "Decoding error: " << e.what() << endl; exit(1); } } void Player::video() { try { int64_t last_pts = 0; for (uint64_t frame_number = 0;; ++frame_number) { display_->input(); if (display_->get_quit()) { break; } else if (display_->get_play()) { unique_ptr<AVFrame, function<void(AVFrame*)>> frame( nullptr, [](AVFrame* f){ av_frame_free(&f); }); if (!frame_queue_->pop(frame)) { break; } if (frame_number) { int64_t frame_delay = frame->pts - last_pts; last_pts = frame->pts; timer_->wait(frame_delay); } else { last_pts = frame->pts; timer_->update(); } display_->refresh(*frame); } else { milliseconds sleep(10); sleep_for(sleep); timer_->update(); } } } catch (exception &e) { cerr << "Display error: " << e.what() << endl; exit(1); } }
22.814607
75
0.642206
sim9108
4446ef31fa0e31a790a26a26e115c2a9c225ef3c
2,730
cpp
C++
World/PolygonBackground.cpp
jess22664/x3ogre
9de430859d877407ae0308908390c9fa004b0e84
[ "MIT" ]
1
2021-09-18T12:50:35.000Z
2021-09-18T12:50:35.000Z
World/PolygonBackground.cpp
jess22664/x3ogre
9de430859d877407ae0308908390c9fa004b0e84
[ "MIT" ]
null
null
null
World/PolygonBackground.cpp
jess22664/x3ogre
9de430859d877407ae0308908390c9fa004b0e84
[ "MIT" ]
null
null
null
/* * ImageBackground.cpp * * Created on: 08.09.2014 * Author: baudenri */ #include "PolygonBackground.h" #include <World/Scene.h> #include <OgreMaterialManager.h> #include <OgrePass.h> #include <OgreRenderQueue.h> #include <OgreAxisAlignedBox.h> #include <OgreSceneNode.h> #include <OgreTechnique.h> #include <OgreLogManager.h> using namespace X3D; const std::string PolygonBackground::_sceneNodeName = "X3D_PolygonBackground_SceneNode"; void PolygonBackground::initialise(World& world) { if (_init) { return; } if (not _appearance) { // If no appearance present, ImageBackground cann't be initialised. return; } // Create Appearance for Polygon background _appearance->initialise(world); _appearance->create(); // Create background rectangle covering the whole screen _rect.reset(new Ogre::Rectangle2D(true)); _rect->setCorners(-1, 1, 1, -1); _rect->setMaterial(_appearance->getOgreMaterial()); // Render the background before everything else _rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // Render everything even if background is closer to camera than other objects _appearance->pass()->setDepthCheckEnabled(false); _appearance->pass()->setDepthWriteEnabled(false); // Apply texCoordinates if (_appearance->getTexture()) { // Set Lighting disabled only for Texture Background // Otherwise the pass will not be rendered which results in a white background _appearance->pass()->setLightingEnabled(false); if (_texCoords.size()==4) { _rect->setUVs(Ogre::Vector2(_texCoords[3].x,_texCoords[3].y), Ogre::Vector2(_texCoords[0].x,_texCoords[0].y), Ogre::Vector2(_texCoords[2].x,_texCoords[2].y), Ogre::Vector2(_texCoords[1].x,_texCoords[1].y) ); } else { if (not _texCoords.empty()) { Ogre::LogManager::getSingleton().logMessage("PolygonBackground: Texture Coordinates have wrong size", Ogre::LML_NORMAL); } _rect->setUVs(Ogre::Vector2(0,1),Ogre::Vector2(0,0), Ogre::Vector2(1,1), Ogre::Vector2(1,0)); } } // Use infinite AAB to always stay visible. Ogre::AxisAlignedBox aabInf; aabInf.setInfinite(); _rect->setBoundingBox(aabInf); // Attach background to the scene _root = world.sceneManager()->getRootSceneNode(); BindableNode<PolygonBackground>::initialise(world); _init = true; } void PolygonBackground::texCoords(const std::vector<Ogre::Vector3>& textureCoords) { _texCoords = textureCoords; } void PolygonBackground::setAppearance(const std::shared_ptr<Appearance>& appearance) { _appearance = appearance; } void PolygonBackground::onBound(Scene& scene) { if (_root) _root->attachObject(_rect.get()); } void PolygonBackground::onUnbound(Scene& scene) { if (_root) _root->detachObject(_rect.get()); }
28.14433
127
0.734432
jess22664
444787f8524a6cd27193bf0c6eff4521bd785e45
4,453
cpp
C++
openstudiocore/src/utilities/units/test/BTUUnit_GTest.cpp
ORNL-BTRIC/OpenStudio
878f94bebf6f025445d1373e8b2304ececac16d8
[ "blessing" ]
null
null
null
openstudiocore/src/utilities/units/test/BTUUnit_GTest.cpp
ORNL-BTRIC/OpenStudio
878f94bebf6f025445d1373e8b2304ececac16d8
[ "blessing" ]
null
null
null
openstudiocore/src/utilities/units/test/BTUUnit_GTest.cpp
ORNL-BTRIC/OpenStudio
878f94bebf6f025445d1373e8b2304ececac16d8
[ "blessing" ]
null
null
null
/********************************************************************** * Copyright (c) 2008-2014, Alliance for Sustainable Energy. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA **********************************************************************/ #include <gtest/gtest.h> #include <utilities/units/test/UnitsFixture.hpp> #include <utilities/units/BTUUnit.hpp> #include <utilities/units/Scale.hpp> #include <utilities/core/Exception.hpp> using openstudio::Unit; using openstudio::UnitSystem; using openstudio::BTUExpnt; using openstudio::BTUUnit; using openstudio::Exception; using openstudio::createBTULength; using openstudio::createBTUTime; using openstudio::createBTUTemperature; using openstudio::createBTUPeople; using openstudio::createBTUEnergy; using openstudio::createBTUPower; TEST_F(UnitsFixture,BTUUnit_Constructors) { LOG(Debug,"BTUUnit_Constructors"); BTUUnit l1(BTUExpnt(0,1)); BTUUnit P1(BTUExpnt(1,0,-1,0),-3); // mBtu/h BTUUnit E1("k",BTUExpnt(1)); // kBtu EXPECT_EQ(0,l1.baseUnitExponent("Btu")); EXPECT_EQ(1,l1.baseUnitExponent("ft")); l1.setBaseUnitExponent("R",-1); EXPECT_EQ(-1,l1.baseUnitExponent("R")); EXPECT_THROW(l1.setBaseUnitExponent("m",1),Exception); EXPECT_EQ("Btu/h",P1.standardString(false)); EXPECT_EQ("mBtu/h",P1.standardString()); EXPECT_EQ(UnitSystem::BTU,P1.system().value()); EXPECT_EQ(0,P1.baseUnitExponent("R")); BTUUnit P2(P1); EXPECT_EQ(UnitSystem::BTU,P2.system().value()); EXPECT_EQ("",E1.prettyString()); EXPECT_EQ("kBtu",E1.standardString()); EXPECT_EQ(0,E1.baseUnitExponent("ft")); } TEST_F(UnitsFixture,BTUUnit_ArithmeticOperators) { LOG(Debug,"BTUUnit_ArithmeticOperators"); // /= BTUUnit P1(BTUExpnt(1)); BTUUnit t1(BTUExpnt(0,0,1)); P1 /= t1; EXPECT_EQ("Btu/h",P1.standardString(false)); EXPECT_EQ(1,P1.baseUnitExponent("Btu")); EXPECT_EQ(-1,P1.baseUnitExponent("h")); EXPECT_EQ(0,P1.baseUnitExponent("ft")); EXPECT_EQ(0,P1.baseUnitExponent("m")); // * Unit E1 = P1 * t1; EXPECT_TRUE(E1.system() == UnitSystem::BTU); EXPECT_EQ("Btu",E1.standardString(false)); EXPECT_EQ("",E1.prettyString()); // / Unit u = P1/E1; u /= t1; EXPECT_TRUE(u.system() == UnitSystem::BTU); EXPECT_EQ("1/h^2",u.standardString(false)); EXPECT_EQ(-2,u.baseUnitExponent("h")); EXPECT_EQ(0,u.baseUnitExponent("Btu")); // pow u.pow(-1,2); EXPECT_EQ("h",u.standardString(false)); EXPECT_EQ(1,u.baseUnitExponent("h")); } TEST_F(UnitsFixture,BTUUnit_CreateFunctions) { BTUUnit u; u = createBTULength(); EXPECT_EQ(1,u.baseUnitExponent("ft")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("ft",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUTime(); EXPECT_EQ(1,u.baseUnitExponent("h")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("h",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUTemperature(); EXPECT_EQ(1,u.baseUnitExponent("R")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("R",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUPeople(); EXPECT_EQ(1,u.baseUnitExponent("people")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("people",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u.pow(-1); EXPECT_EQ("1/person",u.standardString(false)); u = createBTUEnergy(); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("Btu",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUPower(); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("Btu/h",u.standardString(false)); EXPECT_EQ("",u.prettyString()); }
30.710345
82
0.665619
ORNL-BTRIC
44483bc7c56dcad829971fef6fc2e2e9028614aa
209
cpp
C++
id1068_Sum/main.cpp
adogadaev/timus
eeadeb3ac60b7259988fe579422d386b95c4ca9d
[ "Apache-2.0" ]
null
null
null
id1068_Sum/main.cpp
adogadaev/timus
eeadeb3ac60b7259988fe579422d386b95c4ca9d
[ "Apache-2.0" ]
null
null
null
id1068_Sum/main.cpp
adogadaev/timus
eeadeb3ac60b7259988fe579422d386b95c4ca9d
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <cmath> using namespace std; int main() { int nNum; int nSize; cin >> nNum; nSize = (nNum <= 0) ? (abs(nNum) + 2) : nNum; cout << nSize*(1+nNum)/2 << endl; return 0; }
12.294118
46
0.578947
adogadaev
4448d909d1fc488f10a97031e0c10101927d739d
940
cc
C++
quiche/spdy/core/spdy_pinnable_buffer_piece.cc
ktprime/quiche-1
abf85ce22e1409a870b1bf470cb5a68cbdb28e50
[ "BSD-3-Clause" ]
null
null
null
quiche/spdy/core/spdy_pinnable_buffer_piece.cc
ktprime/quiche-1
abf85ce22e1409a870b1bf470cb5a68cbdb28e50
[ "BSD-3-Clause" ]
null
null
null
quiche/spdy/core/spdy_pinnable_buffer_piece.cc
ktprime/quiche-1
abf85ce22e1409a870b1bf470cb5a68cbdb28e50
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2014 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. #include "quiche/spdy/core/spdy_pinnable_buffer_piece.h" #include <new> namespace spdy { SpdyPinnableBufferPiece::SpdyPinnableBufferPiece() : buffer_(nullptr), length_(0) {} SpdyPinnableBufferPiece::~SpdyPinnableBufferPiece() = default; void SpdyPinnableBufferPiece::Pin() { if (!storage_ && buffer_ != nullptr && length_ != 0) { storage_.reset(new char[length_]); std::copy(buffer_, buffer_ + length_, storage_.get()); buffer_ = storage_.get(); } } void SpdyPinnableBufferPiece::Swap(SpdyPinnableBufferPiece* other) { size_t length = length_; length_ = other->length_; other->length_ = length; const char* buffer = buffer_; buffer_ = other->buffer_; other->buffer_ = buffer; storage_.swap(other->storage_); } } // namespace spdy
25.405405
73
0.718085
ktprime
444d04dea76bdfbaccccc24835f7a78694f004b3
158
hpp
C++
include/mockitopp/mockitopp.hpp
tpounds/mockitopp
775b151fa746c81c8762faea2de3429d6f3f46af
[ "MIT" ]
82
2015-03-19T06:28:00.000Z
2021-08-20T17:40:11.000Z
include/mockitopp/mockitopp.hpp
tpounds/mockitopp
775b151fa746c81c8762faea2de3429d6f3f46af
[ "MIT" ]
6
2015-03-19T08:46:46.000Z
2019-06-04T14:24:52.000Z
include/mockitopp/mockitopp.hpp
tpounds/mockitopp
775b151fa746c81c8762faea2de3429d6f3f46af
[ "MIT" ]
12
2015-03-19T08:15:32.000Z
2021-02-04T11:53:16.000Z
#ifndef __MOCKITOPP_HPP__ #define __MOCKITOPP_HPP__ #include "exceptions.hpp" #include "matchers.hpp" #include "mock_object.hpp" #endif //__MOCKITOPP_HPP__
17.555556
26
0.803797
tpounds
444e6554949ac26cb677efaea689b392b5c1b935
446
cpp
C++
src/system/system_details_to_json_converter.cpp
connected-digital-energy-meter/connected-digital-energy-meter
e3ce164a10a261efc1d34486abeb0e047f11f31b
[ "MIT" ]
1
2021-06-06T21:25:31.000Z
2021-06-06T21:25:31.000Z
src/system/system_details_to_json_converter.cpp
connected-digital-energy-meter/connected-digital-energy-meter
e3ce164a10a261efc1d34486abeb0e047f11f31b
[ "MIT" ]
10
2021-06-04T07:56:41.000Z
2021-12-20T18:12:06.000Z
src/system/system_details_to_json_converter.cpp
connected-digital-energy-meter/connected-digital-energy-meter
e3ce164a10a261efc1d34486abeb0e047f11f31b
[ "MIT" ]
null
null
null
#include "system_details_to_json_converter.h" #include <ArduinoJson.h> namespace CDEM { String SystemDetailsToJsonConverter::to_json_string(String ip, String mac, String libVersion, String pcbVersion) { StaticJsonDocument<128> json; json["ip"] = ip; json["mac"] = mac; json["lib-version"] = libVersion; json["pcb-version"] = pcbVersion; String result = ""; serializeJson(json, result); return result; } };
23.473684
116
0.688341
connected-digital-energy-meter
44505eaf01b941f116f412cecad8c862c80ebec4
20,448
cpp
C++
routing/routing_tests/index_graph_test.cpp
romanblanco/omim
62321c2c51b6cbb677278a6a68d15c73ae3f086e
[ "Apache-2.0" ]
null
null
null
routing/routing_tests/index_graph_test.cpp
romanblanco/omim
62321c2c51b6cbb677278a6a68d15c73ae3f086e
[ "Apache-2.0" ]
null
null
null
routing/routing_tests/index_graph_test.cpp
romanblanco/omim
62321c2c51b6cbb677278a6a68d15c73ae3f086e
[ "Apache-2.0" ]
null
null
null
#include "testing/testing.hpp" #include "routing/base/astar_algorithm.hpp" #include "routing/edge_estimator.hpp" #include "routing/index_graph.hpp" #include "routing/index_graph_serialization.hpp" #include "routing/index_graph_starter.hpp" #include "routing/vehicle_mask.hpp" #include "routing/routing_tests/index_graph_tools.hpp" #include "routing_common/car_model.hpp" #include "geometry/point2d.hpp" #include "coding/reader.hpp" #include "coding/writer.hpp" #include "base/assert.hpp" #include "base/math.hpp" #include "std/algorithm.hpp" #include "std/cstdint.hpp" #include "std/unique_ptr.hpp" #include "std/unordered_map.hpp" #include "std/vector.hpp" using namespace std; namespace { using namespace routing; using namespace routing_test; using Edge = TestIndexGraphTopology::Edge; void TestRoute(IndexGraphStarter::FakeVertex const & start, IndexGraphStarter::FakeVertex const & finish, size_t expectedLength, vector<Segment> const * expectedRoute, WorldGraph & graph) { IndexGraphStarter starter(start, finish, graph); vector<Segment> route; double timeSec; auto const resultCode = CalculateRoute(starter, route, timeSec); TEST_EQUAL(resultCode, AStarAlgorithm<IndexGraphStarter>::Result::OK, ()); TEST_GREATER(route.size(), 2, ()); // Erase fake points. route.erase(route.begin()); route.pop_back(); TEST_EQUAL(route.size(), expectedLength, ("route =", route)); if (expectedRoute) TEST_EQUAL(route, *expectedRoute, ()); } void TestEdges(IndexGraph & graph, Segment const & segment, vector<Segment> const & expectedTargets, bool isOutgoing) { ASSERT(segment.IsForward() || !graph.GetGeometry().GetRoad(segment.GetFeatureId()).IsOneWay(), ()); vector<SegmentEdge> edges; graph.GetEdgeList(segment, isOutgoing, edges); vector<Segment> targets; for (SegmentEdge const & edge : edges) targets.push_back(edge.GetTarget()); sort(targets.begin(), targets.end()); vector<Segment> sortedExpectedTargets(expectedTargets); sort(sortedExpectedTargets.begin(), sortedExpectedTargets.end()); TEST_EQUAL(targets, sortedExpectedTargets, ()); } void TestOutgoingEdges(IndexGraph & graph, Segment const & segment, vector<Segment> const & expectedTargets) { TestEdges(graph, segment, expectedTargets, true /* isOutgoing */); } void TestIngoingEdges(IndexGraph & graph, Segment const & segment, vector<Segment> const & expectedTargets) { TestEdges(graph, segment, expectedTargets, false /* isOutgoing */); } uint32_t AbsDelta(uint32_t v0, uint32_t v1) { return v0 > v1 ? v0 - v1 : v1 - v0; } } // namespace namespace routing_test { // R4 (one way down) // // R1 J2--------J3 -1 // ^ v // ^ v // R0 *---J0----*---J1----* 0 // ^ v // ^ v // R2 J4--------J5 1 // // R3 (one way up) y // // x: 0 1 2 3 4 // UNIT_TEST(EdgesTest) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad( 0 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {3.0, 0.0}, {4.0, 0.0}})); loader->AddRoad(1 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{1.0, -1.0}, {3.0, -1.0}})); loader->AddRoad(2 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{1.0, -1.0}, {3.0, -1.0}})); loader->AddRoad(3 /* featureId */, true, 1.0 /* speed */, RoadGeometry::Points({{1.0, 1.0}, {1.0, 0.0}, {1.0, -1.0}})); loader->AddRoad(4 /* featureId */, true, 1.0 /* speed */, RoadGeometry::Points({{3.0, -1.0}, {3.0, 0.0}, {3.0, 1.0}})); traffic::TrafficCache const trafficCache; IndexGraph graph(move(loader), CreateEstimatorForCar(trafficCache)); vector<Joint> joints; joints.emplace_back(MakeJoint({{0, 1}, {3, 1}})); // J0 joints.emplace_back(MakeJoint({{0, 3}, {4, 1}})); // J1 joints.emplace_back(MakeJoint({{1, 0}, {3, 2}})); // J2 joints.emplace_back(MakeJoint({{1, 1}, {4, 0}})); // J3 joints.emplace_back(MakeJoint({{2, 0}, {3, 0}})); // J4 joints.emplace_back(MakeJoint({{2, 1}, {4, 2}})); // J5 graph.Import(joints); TestOutgoingEdges( graph, {kTestNumMwmId, 0 /* featureId */, 0 /* segmentIdx */, true /* forward */}, {{kTestNumMwmId, 0, 0, false}, {kTestNumMwmId, 0, 1, true}, {kTestNumMwmId, 3, 1, true}}); TestIngoingEdges(graph, {kTestNumMwmId, 0, 0, true}, {{kTestNumMwmId, 0, 0, false}}); TestOutgoingEdges(graph, {kTestNumMwmId, 0, 0, false}, {{kTestNumMwmId, 0, 0, true}}); TestIngoingEdges( graph, {kTestNumMwmId, 0, 0, false}, {{kTestNumMwmId, 0, 0, true}, {kTestNumMwmId, 0, 1, false}, {kTestNumMwmId, 3, 0, true}}); TestOutgoingEdges( graph, {kTestNumMwmId, 0, 2, true}, {{kTestNumMwmId, 0, 2, false}, {kTestNumMwmId, 0, 3, true}, {kTestNumMwmId, 4, 1, true}}); TestIngoingEdges(graph, {kTestNumMwmId, 0, 2, true}, {{kTestNumMwmId, 0, 1, true}}); TestOutgoingEdges(graph, {kTestNumMwmId, 0, 2, false}, {{kTestNumMwmId, 0, 1, false}}); TestIngoingEdges( graph, {kTestNumMwmId, 0, 2, false}, {{kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, false}, {kTestNumMwmId, 4, 0, true}}); TestOutgoingEdges( graph, {kTestNumMwmId, 3, 0, true}, {{kTestNumMwmId, 3, 1, true}, {kTestNumMwmId, 0, 0, false}, {kTestNumMwmId, 0, 1, true}}); TestIngoingEdges(graph, {kTestNumMwmId, 3, 0, true}, {{kTestNumMwmId, 2, 0, false}}); TestOutgoingEdges(graph, {kTestNumMwmId, 4, 1, true}, {{kTestNumMwmId, 2, 0, false}}); TestIngoingEdges( graph, {kTestNumMwmId, 4, 1, true}, {{kTestNumMwmId, 4, 0, true}, {kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, false}}); } // Roads R1: // // -2 // -1 // R0 -2 -1 0 1 2 // 1 // 2 // UNIT_TEST(FindPathCross) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad( 0 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{-2.0, 0.0}, {-1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}})); loader->AddRoad( 1 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, -2.0}, {0.0, -1.0}, {0.0, 0.0}, {0.0, 1.0}, {0.0, 2.0}})); traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, {MakeJoint({{0, 2}, {1, 2}})}); vector<IndexGraphStarter::FakeVertex> endPoints; for (uint32_t i = 0; i < 4; ++i) { endPoints.emplace_back(kTestNumMwmId, 0, i, m2::PointD(-1.5 + i, 0.0)); endPoints.emplace_back(kTestNumMwmId, 1, i, m2::PointD(0.0, -1.5 + i)); } for (auto const & start : endPoints) { for (auto const & finish : endPoints) { uint32_t expectedLength = 0; if (start.GetFeatureId() == finish.GetFeatureId()) { expectedLength = AbsDelta(start.GetSegmentIdxForTesting(), finish.GetSegmentIdxForTesting()) + 1; } else { if (start.GetSegmentIdxForTesting() < 2) expectedLength += 2 - start.GetSegmentIdxForTesting(); else expectedLength += start.GetSegmentIdxForTesting() - 1; if (finish.GetSegmentIdxForTesting() < 2) expectedLength += 2 - finish.GetSegmentIdxForTesting(); else expectedLength += finish.GetSegmentIdxForTesting() - 1; } TestRoute(start, finish, expectedLength, nullptr, *worldGraph); } } } // Roads R4 R5 R6 R7 // // R0 0 - * - * - * // | | | | // R1 * - 1 - * - * // | | | | // R2 * - * - 2 - * // | | | | // R3 * - * - * - 3 // UNIT_TEST(FindPathManhattan) { uint32_t constexpr kCitySize = 4; unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); for (uint32_t i = 0; i < kCitySize; ++i) { RoadGeometry::Points street; RoadGeometry::Points avenue; for (uint32_t j = 0; j < kCitySize; ++j) { street.emplace_back(static_cast<double>(j), static_cast<double>(i)); avenue.emplace_back(static_cast<double>(i), static_cast<double>(j)); } loader->AddRoad(i, false, 1.0 /* speed */, street); loader->AddRoad(i + kCitySize, false, 1.0 /* speed */, avenue); } traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); vector<Joint> joints; for (uint32_t i = 0; i < kCitySize; ++i) { for (uint32_t j = 0; j < kCitySize; ++j) joints.emplace_back(MakeJoint({{i, j}, {j + kCitySize, i}})); } unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, joints); vector<IndexGraphStarter::FakeVertex> endPoints; for (uint32_t featureId = 0; featureId < kCitySize; ++featureId) { for (uint32_t segmentId = 0; segmentId < kCitySize - 1; ++segmentId) { endPoints.emplace_back(kTestNumMwmId, featureId, segmentId, m2::PointD(0.5 + segmentId, featureId)); endPoints.emplace_back(kTestNumMwmId, featureId + kCitySize, segmentId, m2::PointD(featureId, 0.5 + segmentId)); } } for (auto const & start : endPoints) { for (auto const & finish : endPoints) { uint32_t expectedLength = 0; auto const startFeatureOffset = start.GetFeatureId() < kCitySize ? start.GetFeatureId() : start.GetFeatureId() - kCitySize; auto const finishFeatureOffset = finish.GetFeatureId() < kCitySize ? finish.GetFeatureId() : finish.GetFeatureId() - kCitySize; if (start.GetFeatureId() < kCitySize == finish.GetFeatureId() < kCitySize) { uint32_t segDelta = AbsDelta(start.GetSegmentIdxForTesting(), finish.GetSegmentIdxForTesting()); if (segDelta == 0 && start.GetFeatureId() != finish.GetFeatureId()) segDelta = 1; expectedLength += segDelta; expectedLength += AbsDelta(startFeatureOffset, finishFeatureOffset) + 1; } else { if (start.GetSegmentIdxForTesting() < finishFeatureOffset) expectedLength += finishFeatureOffset - start.GetSegmentIdxForTesting(); else expectedLength += start.GetSegmentIdxForTesting() - finishFeatureOffset + 1; if (finish.GetSegmentIdxForTesting() < startFeatureOffset) expectedLength += startFeatureOffset - finish.GetSegmentIdxForTesting(); else expectedLength += finish.GetSegmentIdxForTesting() - startFeatureOffset + 1; } TestRoute(start, finish, expectedLength, nullptr, *worldGraph); } } } // Roads y: // // fast road R0 * - * - * -1 // / \ // slow road R1 * - - * - - * - - * - - * 0 // J0 J1 // // x: 0 1 2 3 4 5 6 // UNIT_TEST(RoadSpeed) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad( 0 /* featureId */, false, 10.0 /* speed */, RoadGeometry::Points({{1.0, 0.0}, {2.0, -1.0}, {3.0, -1.0}, {4.0, -1.0}, {5.0, 0.0}})); loader->AddRoad( 1 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}, {3.0, 0.0}, {5.0, 0.0}, {6.0, 0.0}})); traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); vector<Joint> joints; joints.emplace_back(MakeJoint({{0, 0}, {1, 1}})); // J0 joints.emplace_back(MakeJoint({{0, 4}, {1, 3}})); // J1 unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, joints); IndexGraphStarter::FakeVertex const start(kTestNumMwmId, 1, 0, m2::PointD(0.5, 0)); IndexGraphStarter::FakeVertex const finish(kTestNumMwmId, 1, 3, m2::PointD(5.5, 0)); vector<Segment> const expectedRoute({{kTestNumMwmId, 1, 0, true}, {kTestNumMwmId, 0, 0, true}, {kTestNumMwmId, 0, 1, true}, {kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, true}, {kTestNumMwmId, 1, 3, true}}); TestRoute(start, finish, 6, &expectedRoute, *worldGraph); } // Roads y: // // R0 * - - - - - - - - * 0 // ^ ^ // start finish // // x: 0 1 2 3 // UNIT_TEST(OneSegmentWay) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad(0 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, 0.0}, {3.0, 0.0}})); traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, vector<Joint>()); IndexGraphStarter::FakeVertex const start(kTestNumMwmId, 0, 0, m2::PointD(1, 0)); IndexGraphStarter::FakeVertex const finish(kTestNumMwmId, 0, 0, m2::PointD(2, 0)); vector<Segment> const expectedRoute({{kTestNumMwmId, 0, 0, true}}); TestRoute(start, finish, 1 /* expectedLength */, &expectedRoute, *worldGraph); } // // Road R0 (ped) R1 (car) R2 (car) // 0----------1 * 0----------1 * 0----------1 // Joints J0 J1 // UNIT_TEST(SerializeSimpleGraph) { vector<uint8_t> buffer; { IndexGraph graph; vector<Joint> joints = { MakeJoint({{0, 1}, {1, 0}}), MakeJoint({{1, 1}, {2, 0}}), }; graph.Import(joints); unordered_map<uint32_t, VehicleMask> masks; masks[0] = kPedestrianMask; masks[1] = kCarMask; masks[2] = kCarMask; MemWriter<vector<uint8_t>> writer(buffer); IndexGraphSerializer::Serialize(graph, masks, writer); } { IndexGraph graph; MemReader reader(buffer.data(), buffer.size()); ReaderSource<MemReader> source(reader); IndexGraphSerializer::Deserialize(graph, source, kAllVehiclesMask); TEST_EQUAL(graph.GetNumRoads(), 3, ()); TEST_EQUAL(graph.GetNumJoints(), 2, ()); TEST_EQUAL(graph.GetNumPoints(), 4, ()); TEST_EQUAL(graph.GetJointId({0, 0}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({0, 1}), 1, ()); TEST_EQUAL(graph.GetJointId({1, 0}), 1, ()); TEST_EQUAL(graph.GetJointId({1, 1}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 0}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 1}), Joint::kInvalidId, ()); } { IndexGraph graph; MemReader reader(buffer.data(), buffer.size()); ReaderSource<MemReader> source(reader); IndexGraphSerializer::Deserialize(graph, source, kCarMask); TEST_EQUAL(graph.GetNumRoads(), 2, ()); TEST_EQUAL(graph.GetNumJoints(), 1, ()); TEST_EQUAL(graph.GetNumPoints(), 2, ()); TEST_EQUAL(graph.GetJointId({0, 0}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({0, 1}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({1, 0}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({1, 1}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 0}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 1}), Joint::kInvalidId, ()); } } // Finish // 0.0004 * // ^ // | // F2 // | // | // 0.0003 6*---------*5 // | | // | | // | | // | | // | | // 0.0002 7* *4 // | | // | | // 0.00015 8* F0 *3 // \ / // \ / 1 0 // 0.0001 9*---F0-*----* // 2 ^ // | // F1 // | // | // 0 * Start // 0 0.0001 0.0002 // F0 is a two-way feature with a loop and F1 and F2 are an one-way one-segment features. unique_ptr<WorldGraph> BuildLoopGraph() { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad(0 /* feature id */, false /* one way */, 100.0 /* speed */, RoadGeometry::Points({{0.0002, 0.0001}, {0.00015, 0.0001}, {0.0001, 0.0001}, {0.00015, 0.00015}, {0.00015, 0.0002}, {0.00015, 0.0003}, {0.00005, 0.0003}, {0.00005, 0.0002}, {0.00005, 0.00015}, {0.0001, 0.0001}})); loader->AddRoad(1 /* feature id */, true /* one way */, 100.0 /* speed */, RoadGeometry::Points({{0.0002, 0.0}, {0.0002, 0.0001}})); loader->AddRoad(2 /* feature id */, true /* one way */, 100.0 /* speed */, RoadGeometry::Points({{0.00005, 0.0003}, {0.00005, 0.0004}})); vector<Joint> const joints = { MakeJoint({{0 /* feature id */, 2 /* point id */}, {0, 9}}), /* joint at point (0.0002, 0) */ MakeJoint({{1, 1}, {0, 0}}), /* joint at point (0.0002, 0.0001) */ MakeJoint({{0, 6}, {2, 0}}), /* joint at point (0.00005, 0.0003) */ MakeJoint({{2, 1}}), /* joint at point (0.00005, 0.0004) */ }; traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); return BuildWorldGraph(move(loader), estimator, joints); } // This test checks that the route from Start to Finish doesn't make an extra loop in F0. // If it was so the route time had been much more. UNIT_CLASS_TEST(RestrictionTest, LoopGraph) { Init(BuildLoopGraph()); SetStarter(routing::IndexGraphStarter::FakeVertex(kTestNumMwmId, 1, 0 /* seg id */, m2::PointD(0.0002, 0)) /* start */, routing::IndexGraphStarter::FakeVertex(kTestNumMwmId, 2, 0 /* seg id */, m2::PointD(0.00005, 0.0004)) /* finish */); vector<Segment> const expectedRoute = {{kTestNumMwmId, 1, 0, true}, {kTestNumMwmId, 0, 0, true}, {kTestNumMwmId, 0, 1, true}, {kTestNumMwmId, 0, 8, false}, {kTestNumMwmId, 0, 7, false}, {kTestNumMwmId, 0, 6, false}, {kTestNumMwmId, 2, 0, true}}; TestRoute(m_starter->GetStartVertex(), m_starter->GetFinishVertex(), 7, &expectedRoute, m_starter->GetGraph()); } UNIT_TEST(IndexGraph_OnlyTopology_1) { // Add edges to the graph in the following format: (from, to, weight). uint32_t const numVertices = 5; TestIndexGraphTopology graph(numVertices); graph.AddDirectedEdge(0, 1, 1.0); graph.AddDirectedEdge(0, 2, 2.0); graph.AddDirectedEdge(1, 3, 1.0); graph.AddDirectedEdge(2, 3, 2.0); double const expectedWeight = 2.0; vector<Edge> const expectedEdges = {{0, 1}, {1, 3}}; TestTopologyGraph(graph, 0, 3, true /* pathFound */, expectedWeight, expectedEdges); TestTopologyGraph(graph, 0, 4, false /* pathFound */, 0.0, {}); } UNIT_TEST(IndexGraph_OnlyTopology_2) { uint32_t const numVertices = 1; TestIndexGraphTopology graph(numVertices); graph.AddDirectedEdge(0, 0, 100.0); double const expectedWeight = 0.0; vector<Edge> const expectedEdges = {}; TestTopologyGraph(graph, 0, 0, true /* pathFound */, expectedWeight, expectedEdges); } UNIT_TEST(IndexGraph_OnlyTopology_3) { uint32_t const numVertices = 2; TestIndexGraphTopology graph(numVertices); graph.AddDirectedEdge(0, 1, 1.0); graph.AddDirectedEdge(1, 0, 1.0); double const expectedWeight = 1.0; vector<Edge> const expectedEdges = {{0, 1}}; TestTopologyGraph(graph, 0, 1, true /* pathFound */, expectedWeight, expectedEdges); } } // namespace routing_test
36.319716
100
0.574237
romanblanco
44537f53f1daf89001b5c70fa6f6854aeef40f10
1,479
hpp
C++
include/lexy/input/range_input.hpp
IohannRabeson/lexy
881beb56f030e8f4761514e70cb50d809ac4ad17
[ "BSL-1.0" ]
null
null
null
include/lexy/input/range_input.hpp
IohannRabeson/lexy
881beb56f030e8f4761514e70cb50d809ac4ad17
[ "BSL-1.0" ]
null
null
null
include/lexy/input/range_input.hpp
IohannRabeson/lexy
881beb56f030e8f4761514e70cb50d809ac4ad17
[ "BSL-1.0" ]
null
null
null
// Copyright (C) 2020-2021 Jonathan Müller <jonathanmueller.dev@gmail.com> // This file is subject to the license terms in the LICENSE file // found in the top-level directory of this distribution. #ifndef LEXY_INPUT_RANGE_INPUT_HPP_INCLUDED #define LEXY_INPUT_RANGE_INPUT_HPP_INCLUDED #include <lexy/error.hpp> #include <lexy/input/base.hpp> #include <lexy/lexeme.hpp> namespace lexy { template <typename Encoding, typename Iterator, typename Sentinel = Iterator> class range_input { public: using encoding = Encoding; using char_type = typename encoding::char_type; using iterator = Iterator; //=== constructors ===// constexpr range_input() noexcept : _begin(), _end() {} constexpr range_input(Iterator begin, Sentinel end) noexcept : _begin(begin), _end(end) {} //=== access ===// constexpr iterator begin() const noexcept { return _begin; } constexpr iterator end() const noexcept { return _end; } //=== reader ===// constexpr auto reader() const& noexcept { return _detail::range_reader<Encoding, Iterator, Sentinel>(_begin, _end); } private: Iterator _begin; LEXY_EMPTY_MEMBER Sentinel _end; }; template <typename Iterator, typename Sentinel> range_input(Iterator begin, Sentinel end) -> range_input<deduce_encoding<std::decay_t<decltype(*begin)>>, Iterator, Sentinel>; } // namespace lexy #endif // LEXY_INPUT_RANGE_INPUT_HPP_INCLUDED
25.947368
94
0.698445
IohannRabeson
4453e435c0123f74a599736a86a840844104da98
10,278
hpp
C++
libuavcan/include/uavcan/util/templates.hpp
hsteinhaus/uavcan
e2e358bb069be4d52442e590fb14a6ceb1b9d65f
[ "MIT" ]
null
null
null
libuavcan/include/uavcan/util/templates.hpp
hsteinhaus/uavcan
e2e358bb069be4d52442e590fb14a6ceb1b9d65f
[ "MIT" ]
null
null
null
libuavcan/include/uavcan/util/templates.hpp
hsteinhaus/uavcan
e2e358bb069be4d52442e590fb14a6ceb1b9d65f
[ "MIT" ]
null
null
null
/* * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com> */ #pragma once #include <climits> #include <cstddef> #include <cmath> #include <uavcan/build_config.hpp> #ifndef UAVCAN_CPP_VERSION # error UAVCAN_CPP_VERSION #endif #if UAVCAN_CPP_VERSION < UAVCAN_CPP11 # include <float.h> // cfloat may not be available #else # include <cfloat> // C++11 mode assumes that all standard headers are available #endif namespace uavcan { /** * Usage: * StaticAssert<expression>::check(); */ template <bool Value> struct UAVCAN_EXPORT StaticAssert; template <> struct UAVCAN_EXPORT StaticAssert<true> { static void check() { } }; /** * Usage: * ShowIntegerAsError<integer_expression>::foobar(); */ template <long N> struct ShowIntegerAsError; /** * Prevents copying when inherited */ class UAVCAN_EXPORT Noncopyable { Noncopyable(const Noncopyable&); Noncopyable& operator=(const Noncopyable&); protected: Noncopyable() { } ~Noncopyable() { } }; /** * Compile time conditions */ template <bool B, typename T = void> struct UAVCAN_EXPORT EnableIf { }; template <typename T> struct UAVCAN_EXPORT EnableIf<true, T> { typedef T Type; }; /** * Lightweight type categorization. */ template <typename T, typename R = void> struct UAVCAN_EXPORT EnableIfType { typedef R Type; }; /** * Compile-time type selection (Alexandrescu) */ template <bool Condition, typename TrueType, typename FalseType> struct UAVCAN_EXPORT Select; template <typename TrueType, typename FalseType> struct UAVCAN_EXPORT Select<true, TrueType, FalseType> { typedef TrueType Result; }; template <typename TrueType, typename FalseType> struct UAVCAN_EXPORT Select<false, TrueType, FalseType> { typedef FalseType Result; }; /** * Value types */ template <bool> struct UAVCAN_EXPORT BooleanType { }; typedef BooleanType<true> TrueType; typedef BooleanType<false> FalseType; /** * Relations */ template <typename T1, typename T2> class UAVCAN_EXPORT IsImplicitlyConvertibleFromTo { template <typename U> static U returner(); struct True_ { char x[2]; }; struct False_ { }; static True_ test(const T2 &); static False_ test(...); public: enum { Result = sizeof(True_) == sizeof(IsImplicitlyConvertibleFromTo<T1, T2>::test(returner<T1>())) }; }; /** * try_implicit_cast<>(From) * try_implicit_cast<>(From, To) * @{ */ template <typename From, typename To> struct UAVCAN_EXPORT TryImplicitCastImpl { static To impl(const From& from, const To&, TrueType) { return To(from); } static To impl(const From&, const To& default_, FalseType) { return default_; } }; /** * If possible, performs an implicit cast from the type From to the type To. * If the cast is not possible, returns default_ of type To. */ template <typename To, typename From> UAVCAN_EXPORT To try_implicit_cast(const From& from, const To& default_) { return TryImplicitCastImpl<From, To>::impl(from, default_, BooleanType<IsImplicitlyConvertibleFromTo<From, To>::Result>()); } /** * If possible, performs an implicit cast from the type From to the type To. * If the cast is not possible, returns a default constructed object of the type To. */ template <typename To, typename From> UAVCAN_EXPORT To try_implicit_cast(const From& from) { return TryImplicitCastImpl<From, To>::impl(from, To(), BooleanType<IsImplicitlyConvertibleFromTo<From, To>::Result>()); } /** * @} */ /** * Compile time square root for integers. * Useful for operations on square matrices. */ template <unsigned Value> struct UAVCAN_EXPORT CompileTimeIntSqrt; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<4> { enum { Result = 2 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<9> { enum { Result = 3 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<16> { enum { Result = 4 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<25> { enum { Result = 5 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<36> { enum { Result = 6 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<49> { enum { Result = 7 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<64> { enum { Result = 8 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<81> { enum { Result = 9 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<100> { enum { Result = 10 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<121> { enum { Result = 11 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<144> { enum { Result = 12 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<169> { enum { Result = 13 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<196> { enum { Result = 14 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<225> { enum { Result = 15 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<256> { enum { Result = 16 }; }; /** * Replacement for std::copy(..) */ template <typename InputIt, typename OutputIt> UAVCAN_EXPORT OutputIt copy(InputIt first, InputIt last, OutputIt result) { while (first != last) { *result = *first; ++first; ++result; } return result; } /** * Replacement for std::fill(..) */ template <typename ForwardIt, typename T> UAVCAN_EXPORT void fill(ForwardIt first, ForwardIt last, const T& value) { while (first != last) { *first = value; ++first; } } /** * Replacement for std::fill_n(..) */ template<typename OutputIt, typename T> UAVCAN_EXPORT void fill_n(OutputIt first, std::size_t n, const T& value) { while (n--) { *first++ = value; } } /** * Replacement for std::min(..) */ template <typename T> UAVCAN_EXPORT const T& min(const T& a, const T& b) { return (b < a) ? b : a; } /** * Replacement for std::max(..) */ template <typename T> UAVCAN_EXPORT const T& max(const T& a, const T& b) { return (a < b) ? b : a; } /** * Replacement for std::lexicographical_compare(..) */ template<typename InputIt1, typename InputIt2> UAVCAN_EXPORT bool lexicographical_compare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) { while ((first1 != last1) && (first2 != last2)) { if (*first1 < *first2) { return true; } if (*first2 < *first1) { return false; } ++first1; ++first2; } return (first1 == last1) && (first2 != last2); } /** * Replacement for std::equal(..) */ template<typename InputIt1, typename InputIt2> UAVCAN_EXPORT bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) { while (first1 != last1) { if (*first1 != *first2) { return false; } ++first1; ++first2; } return true; } /** * Numeric traits, like std::numeric_limits<> */ template <typename T> struct UAVCAN_EXPORT NumericTraits; /// char template <> struct UAVCAN_EXPORT NumericTraits<char> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static char max() { return CHAR_MAX; } static char min() { return CHAR_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<signed char> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static signed char max() { return SCHAR_MAX; } static signed char min() { return SCHAR_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned char> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned char max() { return UCHAR_MAX; } static unsigned char min() { return 0; } }; /// short template <> struct UAVCAN_EXPORT NumericTraits<short> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static short max() { return SHRT_MAX; } static short min() { return SHRT_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned short> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned short max() { return USHRT_MAX; } static unsigned short min() { return 0; } }; /// int template <> struct UAVCAN_EXPORT NumericTraits<int> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static int max() { return INT_MAX; } static int min() { return INT_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned int> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned int max() { return UINT_MAX; } static unsigned int min() { return 0; } }; /// long template <> struct UAVCAN_EXPORT NumericTraits<long> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static long max() { return LONG_MAX; } static long min() { return LONG_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned long> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned long max() { return ULONG_MAX; } static unsigned long min() { return 0; } }; /// long long template <> struct UAVCAN_EXPORT NumericTraits<long long> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static long long max() { return LLONG_MAX; } static long long min() { return LLONG_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned long long> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned long long max() { return ULLONG_MAX; } static unsigned long long min() { return 0; } }; /// float template <> struct UAVCAN_EXPORT NumericTraits<float> { enum { IsSigned = 1 }; enum { IsInteger = 0 }; static float max() { return FLT_MAX; } static float min() { return FLT_MIN; } static float infinity() { return INFINITY; } }; /// double template <> struct UAVCAN_EXPORT NumericTraits<double> { enum { IsSigned = 1 }; enum { IsInteger = 0 }; static double max() { return DBL_MAX; } static double min() { return DBL_MIN; } static double infinity() { return static_cast<double>(INFINITY) * static_cast<double>(INFINITY); } }; /// long double template <> struct UAVCAN_EXPORT NumericTraits<long double> { enum { IsSigned = 1 }; enum { IsInteger = 0 }; static long double max() { return LDBL_MAX; } static long double min() { return LDBL_MIN; } static long double infinity() { return static_cast<long double>(INFINITY) * static_cast<long double>(INFINITY); } }; }
24.413302
117
0.659759
hsteinhaus
445537ca757d1ff5e980bf6addabe0fe56aa9cfe
531
hpp
C++
include/RED4ext/Scripting/Natives/Generated/ink/anim/TextReplaceInterpolator.hpp
WSSDude420/RED4ext.SDK
eaca8bdf7b92c48422b18431ed8cd0876f53bdb3
[ "MIT" ]
null
null
null
include/RED4ext/Scripting/Natives/Generated/ink/anim/TextReplaceInterpolator.hpp
WSSDude420/RED4ext.SDK
eaca8bdf7b92c48422b18431ed8cd0876f53bdb3
[ "MIT" ]
null
null
null
include/RED4ext/Scripting/Natives/Generated/ink/anim/TextReplaceInterpolator.hpp
WSSDude420/RED4ext.SDK
eaca8bdf7b92c48422b18431ed8cd0876f53bdb3
[ "MIT" ]
null
null
null
#pragma once // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/Scripting/Natives/Generated/ink/anim/TextInterpolator.hpp> namespace RED4ext { namespace ink::anim { struct TextReplaceInterpolator : ink::anim::TextInterpolator { static constexpr const char* NAME = "inkanimTextReplaceInterpolator"; static constexpr const char* ALIAS = NAME; }; RED4EXT_ASSERT_SIZE(TextReplaceInterpolator, 0x70); } // namespace ink::anim } // namespace RED4ext
25.285714
76
0.772128
WSSDude420
4457cfae8f4457d78b023463a8041c603db490b8
5,671
hpp
C++
modules/gapi/include/opencv2/gapi/gcomputation.hpp
satnamsingh8912/opencv
9c23f2f1a682faa9f0b2c2223a857c7d93ba65a6
[ "BSD-3-Clause" ]
9
2018-11-30T08:06:41.000Z
2020-09-10T09:03:07.000Z
modules/gapi/include/opencv2/gapi/gcomputation.hpp
satnamsingh8912/opencv
9c23f2f1a682faa9f0b2c2223a857c7d93ba65a6
[ "BSD-3-Clause" ]
3
2020-07-08T01:07:18.000Z
2020-07-08T02:11:11.000Z
modules/gapi/include/opencv2/gapi/gcomputation.hpp
satnamsingh8912/opencv
9c23f2f1a682faa9f0b2c2223a857c7d93ba65a6
[ "BSD-3-Clause" ]
3
2018-11-30T08:17:58.000Z
2019-02-23T11:13:48.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) 2018 Intel Corporation #ifndef OPENCV_GAPI_GCOMPUTATION_HPP #define OPENCV_GAPI_GCOMPUTATION_HPP #include <functional> #include "opencv2/gapi/util/util.hpp" #include "opencv2/gapi/gcommon.hpp" #include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/gcompiled.hpp" namespace cv { namespace detail { // FIXME: move to algorithm, cover with separate tests // FIXME: replace with O(1) version (both memory and compilation time) template<typename...> struct last_type; template<typename T> struct last_type<T> { using type = T;}; template<typename T, typename... Ts> struct last_type<T, Ts...> { using type = typename last_type<Ts...>::type; }; template<typename... Ts> using last_type_t = typename last_type<Ts...>::type; } class GAPI_EXPORTS GComputation { public: class Priv; typedef std::function<GComputation()> Generator; // Various constructors enable different ways to define a computation: ///// // 1. Generic constructors GComputation(const Generator& gen); // Generator overload GComputation(GProtoInputArgs &&ins, GProtoOutputArgs &&outs); // Arg-to-arg overload // 2. Syntax sugar and compatibility overloads GComputation(GMat in, GMat out); // Unary overload GComputation(GMat in, GScalar out); // Unary overload (scalar) GComputation(GMat in1, GMat in2, GMat out); // Binary overload GComputation(GMat in1, GMat in2, GScalar out); // Binary overload (scalar) GComputation(const std::vector<GMat> &ins, // Compatibility overload const std::vector<GMat> &outs); // Various versions of apply(): //////////////////////////////////////////// // 1. Generic apply() void apply(GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); // Arg-to-arg overload void apply(const std::vector<cv::gapi::own::Mat>& ins, // Compatibility overload const std::vector<cv::gapi::own::Mat>& outs, GCompileArgs &&args = {}); // 2. Syntax sugar and compatibility overloads #if !defined(GAPI_STANDALONE) void apply(cv::Mat in, cv::Mat &out, GCompileArgs &&args = {}); // Unary overload void apply(cv::Mat in, cv::Scalar &out, GCompileArgs &&args = {}); // Unary overload (scalar) void apply(cv::Mat in1, cv::Mat in2, cv::Mat &out, GCompileArgs &&args = {}); // Binary overload void apply(cv::Mat in1, cv::Mat in2, cv::Scalar &out, GCompileArgs &&args = {}); // Binary overload (scalar) void apply(const std::vector<cv::Mat>& ins, // Compatibility overload const std::vector<cv::Mat>& outs, GCompileArgs &&args = {}); #endif // !defined(GAPI_STANDALONE) // Various versions of compile(): ////////////////////////////////////////// // 1. Generic compile() - requires metas to be passed as vector GCompiled compile(GMetaArgs &&in_metas, GCompileArgs &&args = {}); // 2. Syntax sugar - variadic list of metas, no extra compile args template<typename... Ts> auto compile(const Ts&... metas) -> typename std::enable_if<detail::are_meta_descrs<Ts...>::value, GCompiled>::type { return compile(GMetaArgs{GMetaArg(metas)...}, GCompileArgs()); } // 3. Syntax sugar - variadic list of metas, extra compile args // (seems optional parameters don't work well when there's an variadic template // comes first) // // Ideally it should look like: // // template<typename... Ts> // GCompiled compile(const Ts&... metas, GCompileArgs &&args) // // But not all compilers can hande this (and seems they shouldn't be able to). template<typename... Ts> auto compile(const Ts&... meta_and_compile_args) -> typename std::enable_if<detail::are_meta_descrs_but_last<Ts...>::value && std::is_same<GCompileArgs, detail::last_type_t<Ts...> >::value, GCompiled>::type { //FIXME: wrapping meta_and_compile_args into a tuple to unwrap them inside a helper function is the overkill return compile(std::make_tuple(meta_and_compile_args...), typename detail::MkSeq<sizeof...(Ts)-1>::type()); } // Internal use only Priv& priv(); const Priv& priv() const; protected: // 4. Helper method for (3) template<typename... Ts, int... IIs> GCompiled compile(const std::tuple<Ts...> &meta_and_compile_args, detail::Seq<IIs...>) { GMetaArgs meta_args = {GMetaArg(std::get<IIs>(meta_and_compile_args))...}; GCompileArgs comp_args = std::get<sizeof...(Ts)-1>(meta_and_compile_args); return compile(std::move(meta_args), std::move(comp_args)); } std::shared_ptr<Priv> m_priv; }; namespace gapi { // Declare an Island tagged with `name` and defined from `ins` to `outs` // (exclusively, as ins/outs are data objects, and regioning is done on // operations level). // Throws if any operation between `ins` and `outs` are already assigned // to another island. void GAPI_EXPORTS island(const std::string &name, GProtoInputArgs &&ins, GProtoOutputArgs &&outs); } // namespace gapi } // namespace cv #endif // OPENCV_GAPI_GCOMPUTATION_HPP
40.507143
116
0.623347
satnamsingh8912
445c1d637e995b4dc455720fc9c006232d0307db
312,429
cpp
C++
test/tailoring_rule_test_zh_big5han_012.cpp
jan-moeller/text
c61e51c82dfb0ae6e74200c01ce040fa6db730c4
[ "BSL-1.0" ]
null
null
null
test/tailoring_rule_test_zh_big5han_012.cpp
jan-moeller/text
c61e51c82dfb0ae6e74200c01ce040fa6db730c4
[ "BSL-1.0" ]
1
2021-03-05T12:56:59.000Z
2021-03-05T13:11:53.000Z
test/tailoring_rule_test_zh_big5han_012.cpp
jan-moeller/text
c61e51c82dfb0ae6e74200c01ce040fa6db730c4
[ "BSL-1.0" ]
3
2019-10-30T18:38:15.000Z
2021-03-05T12:10:13.000Z
// Warning! This file is autogenerated. #include <boost/text/collation_table.hpp> #include <boost/text/collate.hpp> #include <boost/text/data/all.hpp> #ifndef LIMIT_TESTING_FOR_CI #include <boost/text/save_load_table.hpp> #include <boost/filesystem.hpp> #endif #include <gtest/gtest.h> using namespace boost::text; auto const error = [](string const & s) { std::cout << s; }; auto const warning = [](string const & s) {}; collation_table make_save_load_table() { #ifdef LIMIT_TESTING_FOR_CI string const table_str(data::zh::big5han_collation_tailoring()); return tailored_collation_table( table_str, "zh::big5han_collation_tailoring()", error, warning); #else if (!exists(boost::filesystem::path("zh_big5han.table"))) { string const table_str(data::zh::big5han_collation_tailoring()); collation_table table = tailored_collation_table( table_str, "zh::big5han_collation_tailoring()", error, warning); save_table(table, "zh_big5han.table.12"); boost::filesystem::rename("zh_big5han.table.12", "zh_big5han.table"); } return load_table("zh_big5han.table"); #endif } collation_table const & table() { static collation_table retval = make_save_load_table(); return retval; } TEST(tailoring, zh_big5han_011_000) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9beb); auto const rel = std::vector<uint32_t>(1, 0x9be0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be0); auto const rel = std::vector<uint32_t>(1, 0x9bde); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bde); auto const rel = std::vector<uint32_t>(1, 0x9be4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be4); auto const rel = std::vector<uint32_t>(1, 0x9be6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be6); auto const rel = std::vector<uint32_t>(1, 0x9be2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be2); auto const rel = std::vector<uint32_t>(1, 0x9bf0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bf0); auto const rel = std::vector<uint32_t>(1, 0x9bd4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd4); auto const rel = std::vector<uint32_t>(1, 0x9bd7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd7); auto const rel = std::vector<uint32_t>(1, 0x9bec); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bec); auto const rel = std::vector<uint32_t>(1, 0x9bdc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bdc); auto const rel = std::vector<uint32_t>(1, 0x9bd9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd9); auto const rel = std::vector<uint32_t>(1, 0x9be5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be5); auto const rel = std::vector<uint32_t>(1, 0x9bd5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd5); auto const rel = std::vector<uint32_t>(1, 0x9be1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be1); auto const rel = std::vector<uint32_t>(1, 0x9bda); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bda); auto const rel = std::vector<uint32_t>(1, 0x9d77); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d77); auto const rel = std::vector<uint32_t>(1, 0x9d81); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d81); auto const rel = std::vector<uint32_t>(1, 0x9d8a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d8a); auto const rel = std::vector<uint32_t>(1, 0x9d84); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d84); auto const rel = std::vector<uint32_t>(1, 0x9d88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d88); auto const rel = std::vector<uint32_t>(1, 0x9d71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d71); auto const rel = std::vector<uint32_t>(1, 0x9d80); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d80); auto const rel = std::vector<uint32_t>(1, 0x9d78); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d78); auto const rel = std::vector<uint32_t>(1, 0x9d86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d86); auto const rel = std::vector<uint32_t>(1, 0x9d8b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d8b); auto const rel = std::vector<uint32_t>(1, 0x9d8c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d8c); auto const rel = std::vector<uint32_t>(1, 0x9d7d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d7d); auto const rel = std::vector<uint32_t>(1, 0x9d6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d6b); auto const rel = std::vector<uint32_t>(1, 0x9d74); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d74); auto const rel = std::vector<uint32_t>(1, 0x9d75); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d75); auto const rel = std::vector<uint32_t>(1, 0x9d70); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d70); auto const rel = std::vector<uint32_t>(1, 0x9d69); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d69); auto const rel = std::vector<uint32_t>(1, 0x9d85); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d85); auto const rel = std::vector<uint32_t>(1, 0x9d73); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d73); auto const rel = std::vector<uint32_t>(1, 0x9d7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d7b); auto const rel = std::vector<uint32_t>(1, 0x9d82); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d82); auto const rel = std::vector<uint32_t>(1, 0x9d6f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d6f); auto const rel = std::vector<uint32_t>(1, 0x9d79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d79); auto const rel = std::vector<uint32_t>(1, 0x9d7f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d7f); auto const rel = std::vector<uint32_t>(1, 0x9d87); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d87); auto const rel = std::vector<uint32_t>(1, 0x9d68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d68); auto const rel = std::vector<uint32_t>(1, 0x9e94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e94); auto const rel = std::vector<uint32_t>(1, 0x9e91); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e91); auto const rel = std::vector<uint32_t>(1, 0x9ec0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ec0); auto const rel = std::vector<uint32_t>(1, 0x9efc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9efc); auto const rel = std::vector<uint32_t>(1, 0x9f2d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f2d); auto const rel = std::vector<uint32_t>(1, 0x9f40); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f40); auto const rel = std::vector<uint32_t>(1, 0x9f41); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f41); auto const rel = std::vector<uint32_t>(1, 0x9f4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f4d); auto const rel = std::vector<uint32_t>(1, 0x9f56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f56); auto const rel = std::vector<uint32_t>(1, 0x9f57); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_001) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f57); auto const rel = std::vector<uint32_t>(1, 0x9f58); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f58); auto const rel = std::vector<uint32_t>(1, 0x5337); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5337); auto const rel = std::vector<uint32_t>(1, 0x56b2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56b2); auto const rel = std::vector<uint32_t>(1, 0x56b5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56b5); auto const rel = std::vector<uint32_t>(1, 0x56b3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56b3); auto const rel = std::vector<uint32_t>(1, 0x58e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58e3); auto const rel = std::vector<uint32_t>(1, 0x5b45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b45); auto const rel = std::vector<uint32_t>(1, 0x5dc6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dc6); auto const rel = std::vector<uint32_t>(1, 0x5dc7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dc7); auto const rel = std::vector<uint32_t>(1, 0x5eee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5eee); auto const rel = std::vector<uint32_t>(1, 0x5eef); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5eef); auto const rel = std::vector<uint32_t>(1, 0x5fc0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fc0); auto const rel = std::vector<uint32_t>(1, 0x5fc1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fc1); auto const rel = std::vector<uint32_t>(1, 0x61f9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61f9); auto const rel = std::vector<uint32_t>(1, 0x6517); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6517); auto const rel = std::vector<uint32_t>(1, 0x6516); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6516); auto const rel = std::vector<uint32_t>(1, 0x6515); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6515); auto const rel = std::vector<uint32_t>(1, 0x6513); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6513); auto const rel = std::vector<uint32_t>(1, 0x65df); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65df); auto const rel = std::vector<uint32_t>(1, 0x66e8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66e8); auto const rel = std::vector<uint32_t>(1, 0x66e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66e3); auto const rel = std::vector<uint32_t>(1, 0x66e4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66e4); auto const rel = std::vector<uint32_t>(1, 0x6af3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af3); auto const rel = std::vector<uint32_t>(1, 0x6af0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af0); auto const rel = std::vector<uint32_t>(1, 0x6aea); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aea); auto const rel = std::vector<uint32_t>(1, 0x6ae8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ae8); auto const rel = std::vector<uint32_t>(1, 0x6af9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af9); auto const rel = std::vector<uint32_t>(1, 0x6af1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af1); auto const rel = std::vector<uint32_t>(1, 0x6aee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aee); auto const rel = std::vector<uint32_t>(1, 0x6aef); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aef); auto const rel = std::vector<uint32_t>(1, 0x703c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703c); auto const rel = std::vector<uint32_t>(1, 0x7035); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7035); auto const rel = std::vector<uint32_t>(1, 0x702f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x702f); auto const rel = std::vector<uint32_t>(1, 0x7037); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7037); auto const rel = std::vector<uint32_t>(1, 0x7034); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7034); auto const rel = std::vector<uint32_t>(1, 0x7031); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7031); auto const rel = std::vector<uint32_t>(1, 0x7042); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7042); auto const rel = std::vector<uint32_t>(1, 0x7038); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7038); auto const rel = std::vector<uint32_t>(1, 0x703f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703f); auto const rel = std::vector<uint32_t>(1, 0x703a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703a); auto const rel = std::vector<uint32_t>(1, 0x7039); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7039); auto const rel = std::vector<uint32_t>(1, 0x7040); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7040); auto const rel = std::vector<uint32_t>(1, 0x703b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703b); auto const rel = std::vector<uint32_t>(1, 0x7033); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7033); auto const rel = std::vector<uint32_t>(1, 0x7041); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7041); auto const rel = std::vector<uint32_t>(1, 0x7213); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7213); auto const rel = std::vector<uint32_t>(1, 0x7214); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7214); auto const rel = std::vector<uint32_t>(1, 0x72a8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72a8); auto const rel = std::vector<uint32_t>(1, 0x737d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737d); auto const rel = std::vector<uint32_t>(1, 0x737c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737c); auto const rel = std::vector<uint32_t>(1, 0x74ba); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_002) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74ba); auto const rel = std::vector<uint32_t>(1, 0x76ab); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ab); auto const rel = std::vector<uint32_t>(1, 0x76aa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76aa); auto const rel = std::vector<uint32_t>(1, 0x76be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76be); auto const rel = std::vector<uint32_t>(1, 0x76ed); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ed); auto const rel = std::vector<uint32_t>(1, 0x77cc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77cc); auto const rel = std::vector<uint32_t>(1, 0x77ce); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77ce); auto const rel = std::vector<uint32_t>(1, 0x77cf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77cf); auto const rel = std::vector<uint32_t>(1, 0x77cd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77cd); auto const rel = std::vector<uint32_t>(1, 0x77f2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77f2); auto const rel = std::vector<uint32_t>(1, 0x7925); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7925); auto const rel = std::vector<uint32_t>(1, 0x7923); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7923); auto const rel = std::vector<uint32_t>(1, 0x7927); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7927); auto const rel = std::vector<uint32_t>(1, 0x7928); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7928); auto const rel = std::vector<uint32_t>(1, 0x7924); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7924); auto const rel = std::vector<uint32_t>(1, 0x7929); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7929); auto const rel = std::vector<uint32_t>(1, 0x79b2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b2); auto const rel = std::vector<uint32_t>(1, 0x7a6e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a6e); auto const rel = std::vector<uint32_t>(1, 0x7a6c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a6c); auto const rel = std::vector<uint32_t>(1, 0x7a6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a6d); auto const rel = std::vector<uint32_t>(1, 0x7af7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7af7); auto const rel = std::vector<uint32_t>(1, 0x7c49); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c49); auto const rel = std::vector<uint32_t>(1, 0x7c48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c48); auto const rel = std::vector<uint32_t>(1, 0x7c4a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c4a); auto const rel = std::vector<uint32_t>(1, 0x7c47); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c47); auto const rel = std::vector<uint32_t>(1, 0x7c45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c45); auto const rel = std::vector<uint32_t>(1, 0x7cee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cee); auto const rel = std::vector<uint32_t>(1, 0x7e7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e7b); auto const rel = std::vector<uint32_t>(1, 0x7e7e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e7e); auto const rel = std::vector<uint32_t>(1, 0x7e81); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e81); auto const rel = std::vector<uint32_t>(1, 0x7e80); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e80); auto const rel = std::vector<uint32_t>(1, 0x7fba); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fba); auto const rel = std::vector<uint32_t>(1, 0x7fff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fff); auto const rel = std::vector<uint32_t>(1, 0x8079); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8079); auto const rel = std::vector<uint32_t>(1, 0x81db); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81db); auto const rel = std::vector<uint32_t>(1, 0x81d9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81d9); auto const rel = std::vector<uint32_t>(1, 0x820b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x820b); auto const rel = std::vector<uint32_t>(1, 0x8268); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8268); auto const rel = std::vector<uint32_t>(1, 0x8269); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8269); auto const rel = std::vector<uint32_t>(1, 0x8622); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8622); auto const rel = std::vector<uint32_t>(1, 0x85ff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85ff); auto const rel = std::vector<uint32_t>(1, 0x8601); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8601); auto const rel = std::vector<uint32_t>(1, 0x85fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85fe); auto const rel = std::vector<uint32_t>(1, 0x861b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861b); auto const rel = std::vector<uint32_t>(1, 0x8600); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8600); auto const rel = std::vector<uint32_t>(1, 0x85f6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85f6); auto const rel = std::vector<uint32_t>(1, 0x8604); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8604); auto const rel = std::vector<uint32_t>(1, 0x8609); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8609); auto const rel = std::vector<uint32_t>(1, 0x8605); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8605); auto const rel = std::vector<uint32_t>(1, 0x860c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x860c); auto const rel = std::vector<uint32_t>(1, 0x85fd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85fd); auto const rel = std::vector<uint32_t>(1, 0x8819); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_003) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8819); auto const rel = std::vector<uint32_t>(1, 0x8810); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8810); auto const rel = std::vector<uint32_t>(1, 0x8811); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8811); auto const rel = std::vector<uint32_t>(1, 0x8817); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8817); auto const rel = std::vector<uint32_t>(1, 0x8813); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8813); auto const rel = std::vector<uint32_t>(1, 0x8816); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8816); auto const rel = std::vector<uint32_t>(1, 0x8963); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8963); auto const rel = std::vector<uint32_t>(1, 0x8966); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8966); auto const rel = std::vector<uint32_t>(1, 0x89b9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89b9); auto const rel = std::vector<uint32_t>(1, 0x89f7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89f7); auto const rel = std::vector<uint32_t>(1, 0x8b60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b60); auto const rel = std::vector<uint32_t>(1, 0x8b6a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b6a); auto const rel = std::vector<uint32_t>(1, 0x8b5d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b5d); auto const rel = std::vector<uint32_t>(1, 0x8b68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b68); auto const rel = std::vector<uint32_t>(1, 0x8b63); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b63); auto const rel = std::vector<uint32_t>(1, 0x8b65); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b65); auto const rel = std::vector<uint32_t>(1, 0x8b67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b67); auto const rel = std::vector<uint32_t>(1, 0x8b6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b6d); auto const rel = std::vector<uint32_t>(1, 0x8dae); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dae); auto const rel = std::vector<uint32_t>(1, 0x8e86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e86); auto const rel = std::vector<uint32_t>(1, 0x8e88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e88); auto const rel = std::vector<uint32_t>(1, 0x8e84); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e84); auto const rel = std::vector<uint32_t>(1, 0x8f59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f59); auto const rel = std::vector<uint32_t>(1, 0x8f56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f56); auto const rel = std::vector<uint32_t>(1, 0x8f57); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f57); auto const rel = std::vector<uint32_t>(1, 0x8f55); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f55); auto const rel = std::vector<uint32_t>(1, 0x8f58); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f58); auto const rel = std::vector<uint32_t>(1, 0x8f5a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5a); auto const rel = std::vector<uint32_t>(1, 0x908d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x908d); auto const rel = std::vector<uint32_t>(1, 0x9143); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9143); auto const rel = std::vector<uint32_t>(1, 0x9141); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9141); auto const rel = std::vector<uint32_t>(1, 0x91b7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b7); auto const rel = std::vector<uint32_t>(1, 0x91b5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b5); auto const rel = std::vector<uint32_t>(1, 0x91b2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b2); auto const rel = std::vector<uint32_t>(1, 0x91b3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b3); auto const rel = std::vector<uint32_t>(1, 0x940b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940b); auto const rel = std::vector<uint32_t>(1, 0x9413); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9413); auto const rel = std::vector<uint32_t>(1, 0x93fb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fb); auto const rel = std::vector<uint32_t>(1, 0x9420); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9420); auto const rel = std::vector<uint32_t>(1, 0x940f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940f); auto const rel = std::vector<uint32_t>(1, 0x9414); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9414); auto const rel = std::vector<uint32_t>(1, 0x93fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fe); auto const rel = std::vector<uint32_t>(1, 0x9415); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9415); auto const rel = std::vector<uint32_t>(1, 0x9410); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9410); auto const rel = std::vector<uint32_t>(1, 0x9428); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9428); auto const rel = std::vector<uint32_t>(1, 0x9419); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9419); auto const rel = std::vector<uint32_t>(1, 0x940d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940d); auto const rel = std::vector<uint32_t>(1, 0x93f5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f5); auto const rel = std::vector<uint32_t>(1, 0x9400); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9400); auto const rel = std::vector<uint32_t>(1, 0x93f7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f7); auto const rel = std::vector<uint32_t>(1, 0x9407); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9407); auto const rel = std::vector<uint32_t>(1, 0x940e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_004) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940e); auto const rel = std::vector<uint32_t>(1, 0x9416); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9416); auto const rel = std::vector<uint32_t>(1, 0x9412); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9412); auto const rel = std::vector<uint32_t>(1, 0x93fa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fa); auto const rel = std::vector<uint32_t>(1, 0x9409); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9409); auto const rel = std::vector<uint32_t>(1, 0x93f8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f8); auto const rel = std::vector<uint32_t>(1, 0x940a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940a); auto const rel = std::vector<uint32_t>(1, 0x93ff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93ff); auto const rel = std::vector<uint32_t>(1, 0x93fc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fc); auto const rel = std::vector<uint32_t>(1, 0x940c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940c); auto const rel = std::vector<uint32_t>(1, 0x93f6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f6); auto const rel = std::vector<uint32_t>(1, 0x9411); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9411); auto const rel = std::vector<uint32_t>(1, 0x9406); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9406); auto const rel = std::vector<uint32_t>(1, 0x95de); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95de); auto const rel = std::vector<uint32_t>(1, 0x95e0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e0); auto const rel = std::vector<uint32_t>(1, 0x95df); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95df); auto const rel = std::vector<uint32_t>(1, 0x972e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x972e); auto const rel = std::vector<uint32_t>(1, 0x972f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x972f); auto const rel = std::vector<uint32_t>(1, 0x97b9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97b9); auto const rel = std::vector<uint32_t>(1, 0x97bb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97bb); auto const rel = std::vector<uint32_t>(1, 0x97fd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97fd); auto const rel = std::vector<uint32_t>(1, 0x97fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97fe); auto const rel = std::vector<uint32_t>(1, 0x9860); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9860); auto const rel = std::vector<uint32_t>(1, 0x9862); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9862); auto const rel = std::vector<uint32_t>(1, 0x9863); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9863); auto const rel = std::vector<uint32_t>(1, 0x985f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x985f); auto const rel = std::vector<uint32_t>(1, 0x98c1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c1); auto const rel = std::vector<uint32_t>(1, 0x98c2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c2); auto const rel = std::vector<uint32_t>(1, 0x9950); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9950); auto const rel = std::vector<uint32_t>(1, 0x994e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x994e); auto const rel = std::vector<uint32_t>(1, 0x9959); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9959); auto const rel = std::vector<uint32_t>(1, 0x994c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x994c); auto const rel = std::vector<uint32_t>(1, 0x994b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x994b); auto const rel = std::vector<uint32_t>(1, 0x9953); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9953); auto const rel = std::vector<uint32_t>(1, 0x9a32); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a32); auto const rel = std::vector<uint32_t>(1, 0x9a34); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a34); auto const rel = std::vector<uint32_t>(1, 0x9a31); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a31); auto const rel = std::vector<uint32_t>(1, 0x9a2c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2c); auto const rel = std::vector<uint32_t>(1, 0x9a2a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2a); auto const rel = std::vector<uint32_t>(1, 0x9a36); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a36); auto const rel = std::vector<uint32_t>(1, 0x9a29); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a29); auto const rel = std::vector<uint32_t>(1, 0x9a2e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2e); auto const rel = std::vector<uint32_t>(1, 0x9a38); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a38); auto const rel = std::vector<uint32_t>(1, 0x9a2d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2d); auto const rel = std::vector<uint32_t>(1, 0x9ac7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ac7); auto const rel = std::vector<uint32_t>(1, 0x9aca); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9aca); auto const rel = std::vector<uint32_t>(1, 0x9ac6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ac6); auto const rel = std::vector<uint32_t>(1, 0x9b10); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b10); auto const rel = std::vector<uint32_t>(1, 0x9b12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b12); auto const rel = std::vector<uint32_t>(1, 0x9b11); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b11); auto const rel = std::vector<uint32_t>(1, 0x9c0b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c0b); auto const rel = std::vector<uint32_t>(1, 0x9c08); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_005) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c08); auto const rel = std::vector<uint32_t>(1, 0x9bf7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bf7); auto const rel = std::vector<uint32_t>(1, 0x9c05); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c05); auto const rel = std::vector<uint32_t>(1, 0x9c12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c12); auto const rel = std::vector<uint32_t>(1, 0x9bf8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bf8); auto const rel = std::vector<uint32_t>(1, 0x9c40); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c40); auto const rel = std::vector<uint32_t>(1, 0x9c07); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c07); auto const rel = std::vector<uint32_t>(1, 0x9c0e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c0e); auto const rel = std::vector<uint32_t>(1, 0x9c06); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c06); auto const rel = std::vector<uint32_t>(1, 0x9c17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c17); auto const rel = std::vector<uint32_t>(1, 0x9c14); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c14); auto const rel = std::vector<uint32_t>(1, 0x9c09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c09); auto const rel = std::vector<uint32_t>(1, 0x9d9f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9f); auto const rel = std::vector<uint32_t>(1, 0x9d99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d99); auto const rel = std::vector<uint32_t>(1, 0x9da4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da4); auto const rel = std::vector<uint32_t>(1, 0x9d9d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9d); auto const rel = std::vector<uint32_t>(1, 0x9d92); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d92); auto const rel = std::vector<uint32_t>(1, 0x9d98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d98); auto const rel = std::vector<uint32_t>(1, 0x9d90); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d90); auto const rel = std::vector<uint32_t>(1, 0x9d9b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9b); auto const rel = std::vector<uint32_t>(1, 0x9da0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da0); auto const rel = std::vector<uint32_t>(1, 0x9d94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d94); auto const rel = std::vector<uint32_t>(1, 0x9d9c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9c); auto const rel = std::vector<uint32_t>(1, 0x9daa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9daa); auto const rel = std::vector<uint32_t>(1, 0x9d97); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d97); auto const rel = std::vector<uint32_t>(1, 0x9da1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da1); auto const rel = std::vector<uint32_t>(1, 0x9d9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9a); auto const rel = std::vector<uint32_t>(1, 0x9da2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da2); auto const rel = std::vector<uint32_t>(1, 0x9da8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da8); auto const rel = std::vector<uint32_t>(1, 0x9d9e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9e); auto const rel = std::vector<uint32_t>(1, 0x9da3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da3); auto const rel = std::vector<uint32_t>(1, 0x9dbf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbf); auto const rel = std::vector<uint32_t>(1, 0x9da9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da9); auto const rel = std::vector<uint32_t>(1, 0x9d96); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d96); auto const rel = std::vector<uint32_t>(1, 0x9da6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da6); auto const rel = std::vector<uint32_t>(1, 0x9da7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da7); auto const rel = std::vector<uint32_t>(1, 0x9e99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e99); auto const rel = std::vector<uint32_t>(1, 0x9e9b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e9b); auto const rel = std::vector<uint32_t>(1, 0x9e9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e9a); auto const rel = std::vector<uint32_t>(1, 0x9ee5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee5); auto const rel = std::vector<uint32_t>(1, 0x9ee4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee4); auto const rel = std::vector<uint32_t>(1, 0x9ee7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee7); auto const rel = std::vector<uint32_t>(1, 0x9ee6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee6); auto const rel = std::vector<uint32_t>(1, 0x9f30); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f30); auto const rel = std::vector<uint32_t>(1, 0x9f2e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f2e); auto const rel = std::vector<uint32_t>(1, 0x9f5b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f5b); auto const rel = std::vector<uint32_t>(1, 0x9f60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f60); auto const rel = std::vector<uint32_t>(1, 0x9f5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f5e); auto const rel = std::vector<uint32_t>(1, 0x9f5d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f5d); auto const rel = std::vector<uint32_t>(1, 0x9f59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f59); auto const rel = std::vector<uint32_t>(1, 0x9f91); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f91); auto const rel = std::vector<uint32_t>(1, 0x513a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_006) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x513a); auto const rel = std::vector<uint32_t>(1, 0x5139); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5139); auto const rel = std::vector<uint32_t>(1, 0x5298); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5298); auto const rel = std::vector<uint32_t>(1, 0x5297); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5297); auto const rel = std::vector<uint32_t>(1, 0x56c3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56c3); auto const rel = std::vector<uint32_t>(1, 0x56bd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56bd); auto const rel = std::vector<uint32_t>(1, 0x56be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56be); auto const rel = std::vector<uint32_t>(1, 0x5b48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b48); auto const rel = std::vector<uint32_t>(1, 0x5b47); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b47); auto const rel = std::vector<uint32_t>(1, 0x5dcb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dcb); auto const rel = std::vector<uint32_t>(1, 0x5dcf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dcf); auto const rel = std::vector<uint32_t>(1, 0x5ef1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ef1); auto const rel = std::vector<uint32_t>(1, 0x61fd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61fd); auto const rel = std::vector<uint32_t>(1, 0x651b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x651b); auto const rel = std::vector<uint32_t>(1, 0x6b02); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b02); auto const rel = std::vector<uint32_t>(1, 0x6afc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6afc); auto const rel = std::vector<uint32_t>(1, 0x6b03); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b03); auto const rel = std::vector<uint32_t>(1, 0x6af8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af8); auto const rel = std::vector<uint32_t>(1, 0x6b00); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b00); auto const rel = std::vector<uint32_t>(1, 0x7043); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7043); auto const rel = std::vector<uint32_t>(1, 0x7044); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7044); auto const rel = std::vector<uint32_t>(1, 0x704a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x704a); auto const rel = std::vector<uint32_t>(1, 0x7048); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7048); auto const rel = std::vector<uint32_t>(1, 0x7049); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7049); auto const rel = std::vector<uint32_t>(1, 0x7045); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7045); auto const rel = std::vector<uint32_t>(1, 0x7046); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7046); auto const rel = std::vector<uint32_t>(1, 0x721d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721d); auto const rel = std::vector<uint32_t>(1, 0x721a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721a); auto const rel = std::vector<uint32_t>(1, 0x7219); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7219); auto const rel = std::vector<uint32_t>(1, 0x737e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737e); auto const rel = std::vector<uint32_t>(1, 0x7517); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7517); auto const rel = std::vector<uint32_t>(1, 0x766a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x766a); auto const rel = std::vector<uint32_t>(1, 0x77d0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d0); auto const rel = std::vector<uint32_t>(1, 0x792d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x792d); auto const rel = std::vector<uint32_t>(1, 0x7931); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7931); auto const rel = std::vector<uint32_t>(1, 0x792f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x792f); auto const rel = std::vector<uint32_t>(1, 0x7c54); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c54); auto const rel = std::vector<uint32_t>(1, 0x7c53); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c53); auto const rel = std::vector<uint32_t>(1, 0x7cf2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf2); auto const rel = std::vector<uint32_t>(1, 0x7e8a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e8a); auto const rel = std::vector<uint32_t>(1, 0x7e87); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e87); auto const rel = std::vector<uint32_t>(1, 0x7e88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e88); auto const rel = std::vector<uint32_t>(1, 0x7e8b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e8b); auto const rel = std::vector<uint32_t>(1, 0x7e86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e86); auto const rel = std::vector<uint32_t>(1, 0x7e8d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e8d); auto const rel = std::vector<uint32_t>(1, 0x7f4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f4d); auto const rel = std::vector<uint32_t>(1, 0x7fbb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fbb); auto const rel = std::vector<uint32_t>(1, 0x8030); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8030); auto const rel = std::vector<uint32_t>(1, 0x81dd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81dd); auto const rel = std::vector<uint32_t>(1, 0x8618); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8618); auto const rel = std::vector<uint32_t>(1, 0x862a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x862a); auto const rel = std::vector<uint32_t>(1, 0x8626); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_007) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8626); auto const rel = std::vector<uint32_t>(1, 0x861f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861f); auto const rel = std::vector<uint32_t>(1, 0x8623); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8623); auto const rel = std::vector<uint32_t>(1, 0x861c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861c); auto const rel = std::vector<uint32_t>(1, 0x8619); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8619); auto const rel = std::vector<uint32_t>(1, 0x8627); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8627); auto const rel = std::vector<uint32_t>(1, 0x862e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x862e); auto const rel = std::vector<uint32_t>(1, 0x8621); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8621); auto const rel = std::vector<uint32_t>(1, 0x8620); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8620); auto const rel = std::vector<uint32_t>(1, 0x8629); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8629); auto const rel = std::vector<uint32_t>(1, 0x861e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861e); auto const rel = std::vector<uint32_t>(1, 0x8625); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8625); auto const rel = std::vector<uint32_t>(1, 0x8829); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8829); auto const rel = std::vector<uint32_t>(1, 0x881d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x881d); auto const rel = std::vector<uint32_t>(1, 0x881b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x881b); auto const rel = std::vector<uint32_t>(1, 0x8820); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8820); auto const rel = std::vector<uint32_t>(1, 0x8824); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8824); auto const rel = std::vector<uint32_t>(1, 0x881c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x881c); auto const rel = std::vector<uint32_t>(1, 0x882b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882b); auto const rel = std::vector<uint32_t>(1, 0x884a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x884a); auto const rel = std::vector<uint32_t>(1, 0x896d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x896d); auto const rel = std::vector<uint32_t>(1, 0x8969); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8969); auto const rel = std::vector<uint32_t>(1, 0x896e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x896e); auto const rel = std::vector<uint32_t>(1, 0x896b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x896b); auto const rel = std::vector<uint32_t>(1, 0x89fa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89fa); auto const rel = std::vector<uint32_t>(1, 0x8b79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b79); auto const rel = std::vector<uint32_t>(1, 0x8b78); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b78); auto const rel = std::vector<uint32_t>(1, 0x8b45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b45); auto const rel = std::vector<uint32_t>(1, 0x8b7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7a); auto const rel = std::vector<uint32_t>(1, 0x8b7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7b); auto const rel = std::vector<uint32_t>(1, 0x8d10); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d10); auto const rel = std::vector<uint32_t>(1, 0x8d14); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d14); auto const rel = std::vector<uint32_t>(1, 0x8daf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8daf); auto const rel = std::vector<uint32_t>(1, 0x8e8e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e8e); auto const rel = std::vector<uint32_t>(1, 0x8e8c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e8c); auto const rel = std::vector<uint32_t>(1, 0x8f5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5e); auto const rel = std::vector<uint32_t>(1, 0x8f5b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5b); auto const rel = std::vector<uint32_t>(1, 0x8f5d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5d); auto const rel = std::vector<uint32_t>(1, 0x9146); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9146); auto const rel = std::vector<uint32_t>(1, 0x9144); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9144); auto const rel = std::vector<uint32_t>(1, 0x9145); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9145); auto const rel = std::vector<uint32_t>(1, 0x91b9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b9); auto const rel = std::vector<uint32_t>(1, 0x943f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943f); auto const rel = std::vector<uint32_t>(1, 0x943b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943b); auto const rel = std::vector<uint32_t>(1, 0x9436); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9436); auto const rel = std::vector<uint32_t>(1, 0x9429); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9429); auto const rel = std::vector<uint32_t>(1, 0x943d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943d); auto const rel = std::vector<uint32_t>(1, 0x943c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943c); auto const rel = std::vector<uint32_t>(1, 0x9430); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9430); auto const rel = std::vector<uint32_t>(1, 0x9439); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9439); auto const rel = std::vector<uint32_t>(1, 0x942a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x942a); auto const rel = std::vector<uint32_t>(1, 0x9437); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_008) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9437); auto const rel = std::vector<uint32_t>(1, 0x942c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x942c); auto const rel = std::vector<uint32_t>(1, 0x9440); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9440); auto const rel = std::vector<uint32_t>(1, 0x9431); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9431); auto const rel = std::vector<uint32_t>(1, 0x95e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e5); auto const rel = std::vector<uint32_t>(1, 0x95e4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e4); auto const rel = std::vector<uint32_t>(1, 0x95e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e3); auto const rel = std::vector<uint32_t>(1, 0x9735); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9735); auto const rel = std::vector<uint32_t>(1, 0x973a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x973a); auto const rel = std::vector<uint32_t>(1, 0x97bf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97bf); auto const rel = std::vector<uint32_t>(1, 0x97e1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97e1); auto const rel = std::vector<uint32_t>(1, 0x9864); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9864); auto const rel = std::vector<uint32_t>(1, 0x98c9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c9); auto const rel = std::vector<uint32_t>(1, 0x98c6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c6); auto const rel = std::vector<uint32_t>(1, 0x98c0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c0); auto const rel = std::vector<uint32_t>(1, 0x9958); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9958); auto const rel = std::vector<uint32_t>(1, 0x9956); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9956); auto const rel = std::vector<uint32_t>(1, 0x9a39); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a39); auto const rel = std::vector<uint32_t>(1, 0x9a3d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a3d); auto const rel = std::vector<uint32_t>(1, 0x9a46); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a46); auto const rel = std::vector<uint32_t>(1, 0x9a44); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a44); auto const rel = std::vector<uint32_t>(1, 0x9a42); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a42); auto const rel = std::vector<uint32_t>(1, 0x9a41); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a41); auto const rel = std::vector<uint32_t>(1, 0x9a3a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a3a); auto const rel = std::vector<uint32_t>(1, 0x9a3f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a3f); auto const rel = std::vector<uint32_t>(1, 0x9acd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9acd); auto const rel = std::vector<uint32_t>(1, 0x9b15); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b15); auto const rel = std::vector<uint32_t>(1, 0x9b17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b17); auto const rel = std::vector<uint32_t>(1, 0x9b18); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b18); auto const rel = std::vector<uint32_t>(1, 0x9b16); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b16); auto const rel = std::vector<uint32_t>(1, 0x9b3a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b3a); auto const rel = std::vector<uint32_t>(1, 0x9b52); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b52); auto const rel = std::vector<uint32_t>(1, 0x9c2b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c2b); auto const rel = std::vector<uint32_t>(1, 0x9c1d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c1d); auto const rel = std::vector<uint32_t>(1, 0x9c1c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c1c); auto const rel = std::vector<uint32_t>(1, 0x9c2c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c2c); auto const rel = std::vector<uint32_t>(1, 0x9c23); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c23); auto const rel = std::vector<uint32_t>(1, 0x9c28); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c28); auto const rel = std::vector<uint32_t>(1, 0x9c29); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c29); auto const rel = std::vector<uint32_t>(1, 0x9c24); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c24); auto const rel = std::vector<uint32_t>(1, 0x9c21); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c21); auto const rel = std::vector<uint32_t>(1, 0x9db7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db7); auto const rel = std::vector<uint32_t>(1, 0x9db6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db6); auto const rel = std::vector<uint32_t>(1, 0x9dbc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbc); auto const rel = std::vector<uint32_t>(1, 0x9dc1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc1); auto const rel = std::vector<uint32_t>(1, 0x9dc7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc7); auto const rel = std::vector<uint32_t>(1, 0x9dca); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dca); auto const rel = std::vector<uint32_t>(1, 0x9dcf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcf); auto const rel = std::vector<uint32_t>(1, 0x9dbe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbe); auto const rel = std::vector<uint32_t>(1, 0x9dc5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc5); auto const rel = std::vector<uint32_t>(1, 0x9dc3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc3); auto const rel = std::vector<uint32_t>(1, 0x9dbb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_009) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbb); auto const rel = std::vector<uint32_t>(1, 0x9db5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db5); auto const rel = std::vector<uint32_t>(1, 0x9dce); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dce); auto const rel = std::vector<uint32_t>(1, 0x9db9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db9); auto const rel = std::vector<uint32_t>(1, 0x9dba); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dba); auto const rel = std::vector<uint32_t>(1, 0x9dac); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dac); auto const rel = std::vector<uint32_t>(1, 0x9dc8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc8); auto const rel = std::vector<uint32_t>(1, 0x9db1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db1); auto const rel = std::vector<uint32_t>(1, 0x9dad); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dad); auto const rel = std::vector<uint32_t>(1, 0x9dcc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcc); auto const rel = std::vector<uint32_t>(1, 0x9db3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db3); auto const rel = std::vector<uint32_t>(1, 0x9dcd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcd); auto const rel = std::vector<uint32_t>(1, 0x9db2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db2); auto const rel = std::vector<uint32_t>(1, 0x9e7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e7a); auto const rel = std::vector<uint32_t>(1, 0x9e9c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e9c); auto const rel = std::vector<uint32_t>(1, 0x9eeb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eeb); auto const rel = std::vector<uint32_t>(1, 0x9eee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eee); auto const rel = std::vector<uint32_t>(1, 0x9eed); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eed); auto const rel = std::vector<uint32_t>(1, 0x9f1b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1b); auto const rel = std::vector<uint32_t>(1, 0x9f18); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f18); auto const rel = std::vector<uint32_t>(1, 0x9f1a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1a); auto const rel = std::vector<uint32_t>(1, 0x9f31); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f31); auto const rel = std::vector<uint32_t>(1, 0x9f4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f4e); auto const rel = std::vector<uint32_t>(1, 0x9f65); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f65); auto const rel = std::vector<uint32_t>(1, 0x9f64); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f64); auto const rel = std::vector<uint32_t>(1, 0x9f92); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f92); auto const rel = std::vector<uint32_t>(1, 0x4eb9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4eb9); auto const rel = std::vector<uint32_t>(1, 0x56c6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56c6); auto const rel = std::vector<uint32_t>(1, 0x56c5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56c5); auto const rel = std::vector<uint32_t>(1, 0x56cb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56cb); auto const rel = std::vector<uint32_t>(1, 0x5971); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5971); auto const rel = std::vector<uint32_t>(1, 0x5b4b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4b); auto const rel = std::vector<uint32_t>(1, 0x5b4c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4c); auto const rel = std::vector<uint32_t>(1, 0x5dd5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dd5); auto const rel = std::vector<uint32_t>(1, 0x5dd1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dd1); auto const rel = std::vector<uint32_t>(1, 0x5ef2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ef2); auto const rel = std::vector<uint32_t>(1, 0x6521); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6521); auto const rel = std::vector<uint32_t>(1, 0x6520); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6520); auto const rel = std::vector<uint32_t>(1, 0x6526); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6526); auto const rel = std::vector<uint32_t>(1, 0x6522); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6522); auto const rel = std::vector<uint32_t>(1, 0x6b0b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b0b); auto const rel = std::vector<uint32_t>(1, 0x6b08); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b08); auto const rel = std::vector<uint32_t>(1, 0x6b09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b09); auto const rel = std::vector<uint32_t>(1, 0x6c0d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c0d); auto const rel = std::vector<uint32_t>(1, 0x7055); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7055); auto const rel = std::vector<uint32_t>(1, 0x7056); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7056); auto const rel = std::vector<uint32_t>(1, 0x7057); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7057); auto const rel = std::vector<uint32_t>(1, 0x7052); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7052); auto const rel = std::vector<uint32_t>(1, 0x721e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721e); auto const rel = std::vector<uint32_t>(1, 0x721f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721f); auto const rel = std::vector<uint32_t>(1, 0x72a9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72a9); auto const rel = std::vector<uint32_t>(1, 0x737f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_010) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737f); auto const rel = std::vector<uint32_t>(1, 0x74d8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d8); auto const rel = std::vector<uint32_t>(1, 0x74d5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d5); auto const rel = std::vector<uint32_t>(1, 0x74d9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d9); auto const rel = std::vector<uint32_t>(1, 0x74d7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d7); auto const rel = std::vector<uint32_t>(1, 0x766d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x766d); auto const rel = std::vector<uint32_t>(1, 0x76ad); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ad); auto const rel = std::vector<uint32_t>(1, 0x7935); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7935); auto const rel = std::vector<uint32_t>(1, 0x79b4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b4); auto const rel = std::vector<uint32_t>(1, 0x7a70); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a70); auto const rel = std::vector<uint32_t>(1, 0x7a71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a71); auto const rel = std::vector<uint32_t>(1, 0x7c57); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c57); auto const rel = std::vector<uint32_t>(1, 0x7c5c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c5c); auto const rel = std::vector<uint32_t>(1, 0x7c59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c59); auto const rel = std::vector<uint32_t>(1, 0x7c5b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c5b); auto const rel = std::vector<uint32_t>(1, 0x7c5a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c5a); auto const rel = std::vector<uint32_t>(1, 0x7cf4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf4); auto const rel = std::vector<uint32_t>(1, 0x7cf1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf1); auto const rel = std::vector<uint32_t>(1, 0x7e91); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e91); auto const rel = std::vector<uint32_t>(1, 0x7f4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f4f); auto const rel = std::vector<uint32_t>(1, 0x7f87); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f87); auto const rel = std::vector<uint32_t>(1, 0x81de); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81de); auto const rel = std::vector<uint32_t>(1, 0x826b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x826b); auto const rel = std::vector<uint32_t>(1, 0x8634); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8634); auto const rel = std::vector<uint32_t>(1, 0x8635); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8635); auto const rel = std::vector<uint32_t>(1, 0x8633); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8633); auto const rel = std::vector<uint32_t>(1, 0x862c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x862c); auto const rel = std::vector<uint32_t>(1, 0x8632); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8632); auto const rel = std::vector<uint32_t>(1, 0x8636); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8636); auto const rel = std::vector<uint32_t>(1, 0x882c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882c); auto const rel = std::vector<uint32_t>(1, 0x8828); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8828); auto const rel = std::vector<uint32_t>(1, 0x8826); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8826); auto const rel = std::vector<uint32_t>(1, 0x882a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882a); auto const rel = std::vector<uint32_t>(1, 0x8825); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8825); auto const rel = std::vector<uint32_t>(1, 0x8971); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8971); auto const rel = std::vector<uint32_t>(1, 0x89bf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89bf); auto const rel = std::vector<uint32_t>(1, 0x89be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89be); auto const rel = std::vector<uint32_t>(1, 0x89fb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89fb); auto const rel = std::vector<uint32_t>(1, 0x8b7e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7e); auto const rel = std::vector<uint32_t>(1, 0x8b84); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b84); auto const rel = std::vector<uint32_t>(1, 0x8b82); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b82); auto const rel = std::vector<uint32_t>(1, 0x8b86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b86); auto const rel = std::vector<uint32_t>(1, 0x8b85); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b85); auto const rel = std::vector<uint32_t>(1, 0x8b7f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7f); auto const rel = std::vector<uint32_t>(1, 0x8d15); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d15); auto const rel = std::vector<uint32_t>(1, 0x8e95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e95); auto const rel = std::vector<uint32_t>(1, 0x8e94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e94); auto const rel = std::vector<uint32_t>(1, 0x8e9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9a); auto const rel = std::vector<uint32_t>(1, 0x8e92); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e92); auto const rel = std::vector<uint32_t>(1, 0x8e90); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e90); auto const rel = std::vector<uint32_t>(1, 0x8e96); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e96); auto const rel = std::vector<uint32_t>(1, 0x8e97); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_011) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e97); auto const rel = std::vector<uint32_t>(1, 0x8f60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f60); auto const rel = std::vector<uint32_t>(1, 0x8f62); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f62); auto const rel = std::vector<uint32_t>(1, 0x9147); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9147); auto const rel = std::vector<uint32_t>(1, 0x944c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944c); auto const rel = std::vector<uint32_t>(1, 0x9450); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9450); auto const rel = std::vector<uint32_t>(1, 0x944a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944a); auto const rel = std::vector<uint32_t>(1, 0x944b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944b); auto const rel = std::vector<uint32_t>(1, 0x944f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944f); auto const rel = std::vector<uint32_t>(1, 0x9447); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9447); auto const rel = std::vector<uint32_t>(1, 0x9445); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9445); auto const rel = std::vector<uint32_t>(1, 0x9448); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9448); auto const rel = std::vector<uint32_t>(1, 0x9449); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9449); auto const rel = std::vector<uint32_t>(1, 0x9446); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9446); auto const rel = std::vector<uint32_t>(1, 0x973f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x973f); auto const rel = std::vector<uint32_t>(1, 0x97e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97e3); auto const rel = std::vector<uint32_t>(1, 0x986a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x986a); auto const rel = std::vector<uint32_t>(1, 0x9869); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9869); auto const rel = std::vector<uint32_t>(1, 0x98cb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98cb); auto const rel = std::vector<uint32_t>(1, 0x9954); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9954); auto const rel = std::vector<uint32_t>(1, 0x995b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x995b); auto const rel = std::vector<uint32_t>(1, 0x9a4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4e); auto const rel = std::vector<uint32_t>(1, 0x9a53); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a53); auto const rel = std::vector<uint32_t>(1, 0x9a54); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a54); auto const rel = std::vector<uint32_t>(1, 0x9a4c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4c); auto const rel = std::vector<uint32_t>(1, 0x9a4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4f); auto const rel = std::vector<uint32_t>(1, 0x9a48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a48); auto const rel = std::vector<uint32_t>(1, 0x9a4a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4a); auto const rel = std::vector<uint32_t>(1, 0x9a49); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a49); auto const rel = std::vector<uint32_t>(1, 0x9a52); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a52); auto const rel = std::vector<uint32_t>(1, 0x9a50); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a50); auto const rel = std::vector<uint32_t>(1, 0x9ad0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ad0); auto const rel = std::vector<uint32_t>(1, 0x9b19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b19); auto const rel = std::vector<uint32_t>(1, 0x9b2b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b2b); auto const rel = std::vector<uint32_t>(1, 0x9b3b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b3b); auto const rel = std::vector<uint32_t>(1, 0x9b56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b56); auto const rel = std::vector<uint32_t>(1, 0x9b55); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b55); auto const rel = std::vector<uint32_t>(1, 0x9c46); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c46); auto const rel = std::vector<uint32_t>(1, 0x9c48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c48); auto const rel = std::vector<uint32_t>(1, 0x9c3f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c3f); auto const rel = std::vector<uint32_t>(1, 0x9c44); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c44); auto const rel = std::vector<uint32_t>(1, 0x9c39); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c39); auto const rel = std::vector<uint32_t>(1, 0x9c33); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c33); auto const rel = std::vector<uint32_t>(1, 0x9c41); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c41); auto const rel = std::vector<uint32_t>(1, 0x9c3c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c3c); auto const rel = std::vector<uint32_t>(1, 0x9c37); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c37); auto const rel = std::vector<uint32_t>(1, 0x9c34); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c34); auto const rel = std::vector<uint32_t>(1, 0x9c32); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c32); auto const rel = std::vector<uint32_t>(1, 0x9c3d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c3d); auto const rel = std::vector<uint32_t>(1, 0x9c36); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c36); auto const rel = std::vector<uint32_t>(1, 0x9ddb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddb); auto const rel = std::vector<uint32_t>(1, 0x9dd2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_012) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd2); auto const rel = std::vector<uint32_t>(1, 0x9dde); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dde); auto const rel = std::vector<uint32_t>(1, 0x9dda); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dda); auto const rel = std::vector<uint32_t>(1, 0x9dcb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcb); auto const rel = std::vector<uint32_t>(1, 0x9dd0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd0); auto const rel = std::vector<uint32_t>(1, 0x9ddc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddc); auto const rel = std::vector<uint32_t>(1, 0x9dd1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd1); auto const rel = std::vector<uint32_t>(1, 0x9ddf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddf); auto const rel = std::vector<uint32_t>(1, 0x9de9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de9); auto const rel = std::vector<uint32_t>(1, 0x9dd9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd9); auto const rel = std::vector<uint32_t>(1, 0x9dd8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd8); auto const rel = std::vector<uint32_t>(1, 0x9dd6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd6); auto const rel = std::vector<uint32_t>(1, 0x9df5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df5); auto const rel = std::vector<uint32_t>(1, 0x9dd5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd5); auto const rel = std::vector<uint32_t>(1, 0x9ddd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddd); auto const rel = std::vector<uint32_t>(1, 0x9eb6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eb6); auto const rel = std::vector<uint32_t>(1, 0x9ef0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef0); auto const rel = std::vector<uint32_t>(1, 0x9f35); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f35); auto const rel = std::vector<uint32_t>(1, 0x9f33); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f33); auto const rel = std::vector<uint32_t>(1, 0x9f32); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f32); auto const rel = std::vector<uint32_t>(1, 0x9f42); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f42); auto const rel = std::vector<uint32_t>(1, 0x9f6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f6b); auto const rel = std::vector<uint32_t>(1, 0x9f95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f95); auto const rel = std::vector<uint32_t>(1, 0x9fa2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9fa2); auto const rel = std::vector<uint32_t>(1, 0x513d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x513d); auto const rel = std::vector<uint32_t>(1, 0x5299); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5299); auto const rel = std::vector<uint32_t>(1, 0x58e8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58e8); auto const rel = std::vector<uint32_t>(1, 0x58e7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58e7); auto const rel = std::vector<uint32_t>(1, 0x5972); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5972); auto const rel = std::vector<uint32_t>(1, 0x5b4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4d); auto const rel = std::vector<uint32_t>(1, 0x5dd8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dd8); auto const rel = std::vector<uint32_t>(1, 0x882f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882f); auto const rel = std::vector<uint32_t>(1, 0x5f4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f4f); auto const rel = std::vector<uint32_t>(1, 0x6201); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6201); auto const rel = std::vector<uint32_t>(1, 0x6203); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6203); auto const rel = std::vector<uint32_t>(1, 0x6204); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6204); auto const rel = std::vector<uint32_t>(1, 0x6529); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6529); auto const rel = std::vector<uint32_t>(1, 0x6525); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6525); auto const rel = std::vector<uint32_t>(1, 0x6596); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6596); auto const rel = std::vector<uint32_t>(1, 0x66eb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66eb); auto const rel = std::vector<uint32_t>(1, 0x6b11); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b11); auto const rel = std::vector<uint32_t>(1, 0x6b12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b12); auto const rel = std::vector<uint32_t>(1, 0x6b0f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b0f); auto const rel = std::vector<uint32_t>(1, 0x6bca); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bca); auto const rel = std::vector<uint32_t>(1, 0x705b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705b); auto const rel = std::vector<uint32_t>(1, 0x705a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705a); auto const rel = std::vector<uint32_t>(1, 0x7222); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7222); auto const rel = std::vector<uint32_t>(1, 0x7382); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7382); auto const rel = std::vector<uint32_t>(1, 0x7381); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7381); auto const rel = std::vector<uint32_t>(1, 0x7383); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7383); auto const rel = std::vector<uint32_t>(1, 0x7670); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7670); auto const rel = std::vector<uint32_t>(1, 0x77d4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_013) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d4); auto const rel = std::vector<uint32_t>(1, 0x7c67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c67); auto const rel = std::vector<uint32_t>(1, 0x7c66); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c66); auto const rel = std::vector<uint32_t>(1, 0x7e95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e95); auto const rel = std::vector<uint32_t>(1, 0x826c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x826c); auto const rel = std::vector<uint32_t>(1, 0x863a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863a); auto const rel = std::vector<uint32_t>(1, 0x8640); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8640); auto const rel = std::vector<uint32_t>(1, 0x8639); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8639); auto const rel = std::vector<uint32_t>(1, 0x863c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863c); auto const rel = std::vector<uint32_t>(1, 0x8631); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8631); auto const rel = std::vector<uint32_t>(1, 0x863b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863b); auto const rel = std::vector<uint32_t>(1, 0x863e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863e); auto const rel = std::vector<uint32_t>(1, 0x8830); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8830); auto const rel = std::vector<uint32_t>(1, 0x8832); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8832); auto const rel = std::vector<uint32_t>(1, 0x882e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882e); auto const rel = std::vector<uint32_t>(1, 0x8833); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8833); auto const rel = std::vector<uint32_t>(1, 0x8976); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8976); auto const rel = std::vector<uint32_t>(1, 0x8974); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8974); auto const rel = std::vector<uint32_t>(1, 0x8973); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8973); auto const rel = std::vector<uint32_t>(1, 0x89fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89fe); auto const rel = std::vector<uint32_t>(1, 0x8b8c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b8c); auto const rel = std::vector<uint32_t>(1, 0x8b8e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b8e); auto const rel = std::vector<uint32_t>(1, 0x8b8b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b8b); auto const rel = std::vector<uint32_t>(1, 0x8b88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b88); auto const rel = std::vector<uint32_t>(1, 0x8c45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c45); auto const rel = std::vector<uint32_t>(1, 0x8d19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d19); auto const rel = std::vector<uint32_t>(1, 0x8e98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e98); auto const rel = std::vector<uint32_t>(1, 0x8f64); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f64); auto const rel = std::vector<uint32_t>(1, 0x8f63); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f63); auto const rel = std::vector<uint32_t>(1, 0x91bc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91bc); auto const rel = std::vector<uint32_t>(1, 0x9462); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9462); auto const rel = std::vector<uint32_t>(1, 0x9455); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9455); auto const rel = std::vector<uint32_t>(1, 0x945d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x945d); auto const rel = std::vector<uint32_t>(1, 0x9457); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9457); auto const rel = std::vector<uint32_t>(1, 0x945e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x945e); auto const rel = std::vector<uint32_t>(1, 0x97c4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97c4); auto const rel = std::vector<uint32_t>(1, 0x97c5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97c5); auto const rel = std::vector<uint32_t>(1, 0x9800); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9800); auto const rel = std::vector<uint32_t>(1, 0x9a56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a56); auto const rel = std::vector<uint32_t>(1, 0x9a59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a59); auto const rel = std::vector<uint32_t>(1, 0x9b1e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b1e); auto const rel = std::vector<uint32_t>(1, 0x9b1f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b1f); auto const rel = std::vector<uint32_t>(1, 0x9b20); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b20); auto const rel = std::vector<uint32_t>(1, 0x9c52); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c52); auto const rel = std::vector<uint32_t>(1, 0x9c58); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c58); auto const rel = std::vector<uint32_t>(1, 0x9c50); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c50); auto const rel = std::vector<uint32_t>(1, 0x9c4a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4a); auto const rel = std::vector<uint32_t>(1, 0x9c4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4d); auto const rel = std::vector<uint32_t>(1, 0x9c4b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4b); auto const rel = std::vector<uint32_t>(1, 0x9c55); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c55); auto const rel = std::vector<uint32_t>(1, 0x9c59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c59); auto const rel = std::vector<uint32_t>(1, 0x9c4c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_014) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4c); auto const rel = std::vector<uint32_t>(1, 0x9c4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4e); auto const rel = std::vector<uint32_t>(1, 0x9dfb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dfb); auto const rel = std::vector<uint32_t>(1, 0x9df7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df7); auto const rel = std::vector<uint32_t>(1, 0x9def); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9def); auto const rel = std::vector<uint32_t>(1, 0x9de3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de3); auto const rel = std::vector<uint32_t>(1, 0x9deb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9deb); auto const rel = std::vector<uint32_t>(1, 0x9df8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df8); auto const rel = std::vector<uint32_t>(1, 0x9de4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de4); auto const rel = std::vector<uint32_t>(1, 0x9df6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df6); auto const rel = std::vector<uint32_t>(1, 0x9de1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de1); auto const rel = std::vector<uint32_t>(1, 0x9dee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dee); auto const rel = std::vector<uint32_t>(1, 0x9de6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de6); auto const rel = std::vector<uint32_t>(1, 0x9df2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df2); auto const rel = std::vector<uint32_t>(1, 0x9df0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df0); auto const rel = std::vector<uint32_t>(1, 0x9de2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de2); auto const rel = std::vector<uint32_t>(1, 0x9dec); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dec); auto const rel = std::vector<uint32_t>(1, 0x9df4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df4); auto const rel = std::vector<uint32_t>(1, 0x9df3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df3); auto const rel = std::vector<uint32_t>(1, 0x9de8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de8); auto const rel = std::vector<uint32_t>(1, 0x9ded); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ded); auto const rel = std::vector<uint32_t>(1, 0x9ec2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ec2); auto const rel = std::vector<uint32_t>(1, 0x9ed0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ed0); auto const rel = std::vector<uint32_t>(1, 0x9ef2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef2); auto const rel = std::vector<uint32_t>(1, 0x9ef3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef3); auto const rel = std::vector<uint32_t>(1, 0x9f06); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f06); auto const rel = std::vector<uint32_t>(1, 0x9f1c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1c); auto const rel = std::vector<uint32_t>(1, 0x9f38); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f38); auto const rel = std::vector<uint32_t>(1, 0x9f37); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f37); auto const rel = std::vector<uint32_t>(1, 0x9f36); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f36); auto const rel = std::vector<uint32_t>(1, 0x9f43); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f43); auto const rel = std::vector<uint32_t>(1, 0x9f4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f4f); auto const rel = std::vector<uint32_t>(1, 0x9f71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f71); auto const rel = std::vector<uint32_t>(1, 0x9f70); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f70); auto const rel = std::vector<uint32_t>(1, 0x9f6e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f6e); auto const rel = std::vector<uint32_t>(1, 0x9f6f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f6f); auto const rel = std::vector<uint32_t>(1, 0x56d3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56d3); auto const rel = std::vector<uint32_t>(1, 0x56cd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56cd); auto const rel = std::vector<uint32_t>(1, 0x5b4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4e); auto const rel = std::vector<uint32_t>(1, 0x5c6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c6d); auto const rel = std::vector<uint32_t>(1, 0x652d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x652d); auto const rel = std::vector<uint32_t>(1, 0x66ed); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66ed); auto const rel = std::vector<uint32_t>(1, 0x66ee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66ee); auto const rel = std::vector<uint32_t>(1, 0x6b13); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b13); auto const rel = std::vector<uint32_t>(1, 0x705f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705f); auto const rel = std::vector<uint32_t>(1, 0x7061); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7061); auto const rel = std::vector<uint32_t>(1, 0x705d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705d); auto const rel = std::vector<uint32_t>(1, 0x7060); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7060); auto const rel = std::vector<uint32_t>(1, 0x7223); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7223); auto const rel = std::vector<uint32_t>(1, 0x74db); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74db); auto const rel = std::vector<uint32_t>(1, 0x74e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74e5); auto const rel = std::vector<uint32_t>(1, 0x77d5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_015) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d5); auto const rel = std::vector<uint32_t>(1, 0x7938); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7938); auto const rel = std::vector<uint32_t>(1, 0x79b7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b7); auto const rel = std::vector<uint32_t>(1, 0x79b6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b6); auto const rel = std::vector<uint32_t>(1, 0x7c6a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c6a); auto const rel = std::vector<uint32_t>(1, 0x7e97); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e97); auto const rel = std::vector<uint32_t>(1, 0x7f89); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f89); auto const rel = std::vector<uint32_t>(1, 0x826d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x826d); auto const rel = std::vector<uint32_t>(1, 0x8643); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8643); auto const rel = std::vector<uint32_t>(1, 0x8838); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8838); auto const rel = std::vector<uint32_t>(1, 0x8837); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8837); auto const rel = std::vector<uint32_t>(1, 0x8835); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8835); auto const rel = std::vector<uint32_t>(1, 0x884b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x884b); auto const rel = std::vector<uint32_t>(1, 0x8b94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b94); auto const rel = std::vector<uint32_t>(1, 0x8b95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b95); auto const rel = std::vector<uint32_t>(1, 0x8e9e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9e); auto const rel = std::vector<uint32_t>(1, 0x8e9f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9f); auto const rel = std::vector<uint32_t>(1, 0x8ea0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea0); auto const rel = std::vector<uint32_t>(1, 0x8e9d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9d); auto const rel = std::vector<uint32_t>(1, 0x91be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91be); auto const rel = std::vector<uint32_t>(1, 0x91bd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91bd); auto const rel = std::vector<uint32_t>(1, 0x91c2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91c2); auto const rel = std::vector<uint32_t>(1, 0x946b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946b); auto const rel = std::vector<uint32_t>(1, 0x9468); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9468); auto const rel = std::vector<uint32_t>(1, 0x9469); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9469); auto const rel = std::vector<uint32_t>(1, 0x96e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96e5); auto const rel = std::vector<uint32_t>(1, 0x9746); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9746); auto const rel = std::vector<uint32_t>(1, 0x9743); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9743); auto const rel = std::vector<uint32_t>(1, 0x9747); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9747); auto const rel = std::vector<uint32_t>(1, 0x97c7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97c7); auto const rel = std::vector<uint32_t>(1, 0x97e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97e5); auto const rel = std::vector<uint32_t>(1, 0x9a5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a5e); auto const rel = std::vector<uint32_t>(1, 0x9ad5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ad5); auto const rel = std::vector<uint32_t>(1, 0x9b59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b59); auto const rel = std::vector<uint32_t>(1, 0x9c63); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c63); auto const rel = std::vector<uint32_t>(1, 0x9c67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c67); auto const rel = std::vector<uint32_t>(1, 0x9c66); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c66); auto const rel = std::vector<uint32_t>(1, 0x9c62); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c62); auto const rel = std::vector<uint32_t>(1, 0x9c5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c5e); auto const rel = std::vector<uint32_t>(1, 0x9c60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c60); auto const rel = std::vector<uint32_t>(1, 0x9e02); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e02); auto const rel = std::vector<uint32_t>(1, 0x9dfe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dfe); auto const rel = std::vector<uint32_t>(1, 0x9e07); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e07); auto const rel = std::vector<uint32_t>(1, 0x9e03); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e03); auto const rel = std::vector<uint32_t>(1, 0x9e06); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e06); auto const rel = std::vector<uint32_t>(1, 0x9e05); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e05); auto const rel = std::vector<uint32_t>(1, 0x9e00); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e00); auto const rel = std::vector<uint32_t>(1, 0x9e01); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e01); auto const rel = std::vector<uint32_t>(1, 0x9e09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e09); auto const rel = std::vector<uint32_t>(1, 0x9dff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dff); auto const rel = std::vector<uint32_t>(1, 0x9dfd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dfd); auto const rel = std::vector<uint32_t>(1, 0x9e04); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_016) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e04); auto const rel = std::vector<uint32_t>(1, 0x9ea0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ea0); auto const rel = std::vector<uint32_t>(1, 0x9f1e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1e); auto const rel = std::vector<uint32_t>(1, 0x9f46); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f46); auto const rel = std::vector<uint32_t>(1, 0x9f74); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f74); auto const rel = std::vector<uint32_t>(1, 0x9f75); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f75); auto const rel = std::vector<uint32_t>(1, 0x9f76); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f76); auto const rel = std::vector<uint32_t>(1, 0x56d4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56d4); auto const rel = std::vector<uint32_t>(1, 0x652e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x652e); auto const rel = std::vector<uint32_t>(1, 0x65b8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65b8); auto const rel = std::vector<uint32_t>(1, 0x6b18); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b18); auto const rel = std::vector<uint32_t>(1, 0x6b19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b19); auto const rel = std::vector<uint32_t>(1, 0x6b17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b17); auto const rel = std::vector<uint32_t>(1, 0x6b1a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b1a); auto const rel = std::vector<uint32_t>(1, 0x7062); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7062); auto const rel = std::vector<uint32_t>(1, 0x7226); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7226); auto const rel = std::vector<uint32_t>(1, 0x72aa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72aa); auto const rel = std::vector<uint32_t>(1, 0x77d8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d8); auto const rel = std::vector<uint32_t>(1, 0x77d9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d9); auto const rel = std::vector<uint32_t>(1, 0x7939); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7939); auto const rel = std::vector<uint32_t>(1, 0x7c69); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c69); auto const rel = std::vector<uint32_t>(1, 0x7c6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c6b); auto const rel = std::vector<uint32_t>(1, 0x7cf6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf6); auto const rel = std::vector<uint32_t>(1, 0x7e9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e9a); auto const rel = std::vector<uint32_t>(1, 0x7e98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e98); auto const rel = std::vector<uint32_t>(1, 0x7e9b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e9b); auto const rel = std::vector<uint32_t>(1, 0x7e99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e99); auto const rel = std::vector<uint32_t>(1, 0x81e0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81e0); auto const rel = std::vector<uint32_t>(1, 0x81e1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81e1); auto const rel = std::vector<uint32_t>(1, 0x8646); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8646); auto const rel = std::vector<uint32_t>(1, 0x8647); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8647); auto const rel = std::vector<uint32_t>(1, 0x8648); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8648); auto const rel = std::vector<uint32_t>(1, 0x8979); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8979); auto const rel = std::vector<uint32_t>(1, 0x897a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897a); auto const rel = std::vector<uint32_t>(1, 0x897c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897c); auto const rel = std::vector<uint32_t>(1, 0x897b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897b); auto const rel = std::vector<uint32_t>(1, 0x89ff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89ff); auto const rel = std::vector<uint32_t>(1, 0x8b98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b98); auto const rel = std::vector<uint32_t>(1, 0x8b99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b99); auto const rel = std::vector<uint32_t>(1, 0x8ea5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea5); auto const rel = std::vector<uint32_t>(1, 0x8ea4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea4); auto const rel = std::vector<uint32_t>(1, 0x8ea3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea3); auto const rel = std::vector<uint32_t>(1, 0x946e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946e); auto const rel = std::vector<uint32_t>(1, 0x946d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946d); auto const rel = std::vector<uint32_t>(1, 0x946f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946f); auto const rel = std::vector<uint32_t>(1, 0x9471); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9471); auto const rel = std::vector<uint32_t>(1, 0x9473); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9473); auto const rel = std::vector<uint32_t>(1, 0x9749); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9749); auto const rel = std::vector<uint32_t>(1, 0x9872); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9872); auto const rel = std::vector<uint32_t>(1, 0x995f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x995f); auto const rel = std::vector<uint32_t>(1, 0x9c68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c68); auto const rel = std::vector<uint32_t>(1, 0x9c6e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_017) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c6e); auto const rel = std::vector<uint32_t>(1, 0x9c6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c6d); auto const rel = std::vector<uint32_t>(1, 0x9e0b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e0b); auto const rel = std::vector<uint32_t>(1, 0x9e0d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e0d); auto const rel = std::vector<uint32_t>(1, 0x9e10); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e10); auto const rel = std::vector<uint32_t>(1, 0x9e0f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e0f); auto const rel = std::vector<uint32_t>(1, 0x9e12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e12); auto const rel = std::vector<uint32_t>(1, 0x9e11); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e11); auto const rel = std::vector<uint32_t>(1, 0x9ea1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ea1); auto const rel = std::vector<uint32_t>(1, 0x9ef5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef5); auto const rel = std::vector<uint32_t>(1, 0x9f09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f09); auto const rel = std::vector<uint32_t>(1, 0x9f47); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f47); auto const rel = std::vector<uint32_t>(1, 0x9f78); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f78); auto const rel = std::vector<uint32_t>(1, 0x9f7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f7b); auto const rel = std::vector<uint32_t>(1, 0x9f7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f7a); auto const rel = std::vector<uint32_t>(1, 0x9f79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f79); auto const rel = std::vector<uint32_t>(1, 0x571e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x571e); auto const rel = std::vector<uint32_t>(1, 0x7066); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7066); auto const rel = std::vector<uint32_t>(1, 0x7c6f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c6f); auto const rel = std::vector<uint32_t>(1, 0x883c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883c); auto const rel = std::vector<uint32_t>(1, 0x8db2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8db2); auto const rel = std::vector<uint32_t>(1, 0x8ea6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea6); auto const rel = std::vector<uint32_t>(1, 0x91c3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91c3); auto const rel = std::vector<uint32_t>(1, 0x9474); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9474); auto const rel = std::vector<uint32_t>(1, 0x9478); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9478); auto const rel = std::vector<uint32_t>(1, 0x9476); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9476); auto const rel = std::vector<uint32_t>(1, 0x9475); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9475); auto const rel = std::vector<uint32_t>(1, 0x9a60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a60); auto const rel = std::vector<uint32_t>(1, 0x9c74); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c74); auto const rel = std::vector<uint32_t>(1, 0x9c73); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c73); auto const rel = std::vector<uint32_t>(1, 0x9c71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c71); auto const rel = std::vector<uint32_t>(1, 0x9c75); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c75); auto const rel = std::vector<uint32_t>(1, 0x9e14); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e14); auto const rel = std::vector<uint32_t>(1, 0x9e13); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e13); auto const rel = std::vector<uint32_t>(1, 0x9ef6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef6); auto const rel = std::vector<uint32_t>(1, 0x9f0a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f0a); auto const rel = std::vector<uint32_t>(1, 0x9fa4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9fa4); auto const rel = std::vector<uint32_t>(1, 0x7068); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7068); auto const rel = std::vector<uint32_t>(1, 0x7065); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7065); auto const rel = std::vector<uint32_t>(1, 0x7cf7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf7); auto const rel = std::vector<uint32_t>(1, 0x866a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x866a); auto const rel = std::vector<uint32_t>(1, 0x883e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883e); auto const rel = std::vector<uint32_t>(1, 0x883d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883d); auto const rel = std::vector<uint32_t>(1, 0x883f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883f); auto const rel = std::vector<uint32_t>(1, 0x8b9e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b9e); auto const rel = std::vector<uint32_t>(1, 0x8c9c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c9c); auto const rel = std::vector<uint32_t>(1, 0x8ea9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea9); auto const rel = std::vector<uint32_t>(1, 0x8ec9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ec9); auto const rel = std::vector<uint32_t>(1, 0x974b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x974b); auto const rel = std::vector<uint32_t>(1, 0x9873); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9873); auto const rel = std::vector<uint32_t>(1, 0x9874); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9874); auto const rel = std::vector<uint32_t>(1, 0x98cc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_018) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98cc); auto const rel = std::vector<uint32_t>(1, 0x9961); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9961); auto const rel = std::vector<uint32_t>(1, 0x99ab); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99ab); auto const rel = std::vector<uint32_t>(1, 0x9a64); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a64); auto const rel = std::vector<uint32_t>(1, 0x9a66); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a66); auto const rel = std::vector<uint32_t>(1, 0x9a67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a67); auto const rel = std::vector<uint32_t>(1, 0x9b24); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b24); auto const rel = std::vector<uint32_t>(1, 0x9e15); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e15); auto const rel = std::vector<uint32_t>(1, 0x9e17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e17); auto const rel = std::vector<uint32_t>(1, 0x9f48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f48); auto const rel = std::vector<uint32_t>(1, 0x6207); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6207); auto const rel = std::vector<uint32_t>(1, 0x6b1e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b1e); auto const rel = std::vector<uint32_t>(1, 0x7227); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7227); auto const rel = std::vector<uint32_t>(1, 0x864c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x864c); auto const rel = std::vector<uint32_t>(1, 0x8ea8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea8); auto const rel = std::vector<uint32_t>(1, 0x9482); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9482); auto const rel = std::vector<uint32_t>(1, 0x9480); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9480); auto const rel = std::vector<uint32_t>(1, 0x9481); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9481); auto const rel = std::vector<uint32_t>(1, 0x9a69); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a69); auto const rel = std::vector<uint32_t>(1, 0x9a68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a68); auto const rel = std::vector<uint32_t>(1, 0x9b2e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b2e); auto const rel = std::vector<uint32_t>(1, 0x9e19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e19); auto const rel = std::vector<uint32_t>(1, 0x7229); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7229); auto const rel = std::vector<uint32_t>(1, 0x864b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x864b); auto const rel = std::vector<uint32_t>(1, 0x8b9f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b9f); auto const rel = std::vector<uint32_t>(1, 0x9483); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9483); auto const rel = std::vector<uint32_t>(1, 0x9c79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c79); auto const rel = std::vector<uint32_t>(1, 0x9eb7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eb7); auto const rel = std::vector<uint32_t>(1, 0x7675); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7675); auto const rel = std::vector<uint32_t>(1, 0x9a6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a6b); auto const rel = std::vector<uint32_t>(1, 0x9c7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c7a); auto const rel = std::vector<uint32_t>(1, 0x9e1d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e1d); auto const rel = std::vector<uint32_t>(1, 0x7069); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7069); auto const rel = std::vector<uint32_t>(1, 0x706a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x706a); auto const rel = std::vector<uint32_t>(1, 0x9ea4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ea4); auto const rel = std::vector<uint32_t>(1, 0x9f7e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f7e); auto const rel = std::vector<uint32_t>(1, 0x9f49); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f49); auto const rel = std::vector<uint32_t>(1, 0x9f98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } }
32.312442
77
0.564141
jan-moeller
44610cf127b3f8fa4ef5ac32e46ded27ec671314
3,371
hpp
C++
rocprim/include/rocprim/device/device_merge_sort_config.hpp
arsenm/rocPRIM
02d6006a7951c53ecfd245200d58809d3eee0b48
[ "MIT" ]
null
null
null
rocprim/include/rocprim/device/device_merge_sort_config.hpp
arsenm/rocPRIM
02d6006a7951c53ecfd245200d58809d3eee0b48
[ "MIT" ]
null
null
null
rocprim/include/rocprim/device/device_merge_sort_config.hpp
arsenm/rocPRIM
02d6006a7951c53ecfd245200d58809d3eee0b48
[ "MIT" ]
null
null
null
// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #ifndef ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_ #define ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_ #include <type_traits> #include "../config.hpp" #include "../detail/various.hpp" #include "config_types.hpp" /// \addtogroup primitivesmodule_deviceconfigs /// @{ BEGIN_ROCPRIM_NAMESPACE /// \brief Configuration of device-level merge primitives. /// /// \tparam BlockSize - block size used in merge sort. template<unsigned int BlockSize> using merge_sort_config = kernel_config<BlockSize, 1>; namespace detail { template<class Key, class Value> struct merge_sort_config_803 { static constexpr size_t key_value_size = sizeof(Key) + sizeof(Value); static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(key_value_size, 8); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<class Key> struct merge_sort_config_803<Key, empty_type> { static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(sizeof(Key), 8); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<class Key, class Value> struct merge_sort_config_900 { static constexpr size_t key_value_size = sizeof(Key) + sizeof(Value); static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(key_value_size, 16); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<class Key> struct merge_sort_config_900<Key, empty_type> { static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(sizeof(Key), 16); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<unsigned int TargetArch, class Key, class Value> struct default_merge_sort_config : select_arch< TargetArch, select_arch_case<803, merge_sort_config_803<Key, Value>>, select_arch_case<900, merge_sort_config_900<Key, Value>>, merge_sort_config_900<Key, Value> > { }; } // end namespace detail END_ROCPRIM_NAMESPACE /// @} // end of group primitivesmodule_deviceconfigs #endif // ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_
33.71
80
0.750816
arsenm
446236206dc9c12d0027e3f086606c1adfcaa482
934
cpp
C++
POJ/1321/12854802_AC_63ms_708kB.cpp
BakaErii/ACM_Collection
d368b15c7f1c84472424d5e61e5ebc667f589025
[ "WTFPL" ]
null
null
null
POJ/1321/12854802_AC_63ms_708kB.cpp
BakaErii/ACM_Collection
d368b15c7f1c84472424d5e61e5ebc667f589025
[ "WTFPL" ]
null
null
null
POJ/1321/12854802_AC_63ms_708kB.cpp
BakaErii/ACM_Collection
d368b15c7f1c84472424d5e61e5ebc667f589025
[ "WTFPL" ]
null
null
null
/** * @author Moe_Sakiya sakiya@tun.moe * @date 2018-03-01 00:07:15 * */ #include <iostream> #include <string> #include <algorithm> #include <set> #include <map> #include <vector> #include <stack> #include <queue> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> using namespace std; char arr[8][9]; int n, k, ans; bool vis[8]; void dfs(int nowRow, int nowCnt) { int i; if (nowCnt == k) { ans++; return; } if (nowRow == n) return; for (i = 0; i < n; i++) if (arr[nowRow][i] == '#' && vis[i] == false) { vis[i] = true; dfs(nowRow + 1, nowCnt + 1); vis[i] = false; } dfs(nowRow + 1, nowCnt); } int main(void) { ios::sync_with_stdio(false); while (~scanf("%d %d", &n, &k)) { if (n == -1 && k == -1) break; getchar(); //init ans = 0; for (int i = 0; i < n; i++) { gets(arr[i]); vis[i] = false; } dfs(0, 0); printf("%d\n", ans ); } return 0; }
15.566667
49
0.543897
BakaErii
44639c0bf345059cb6f2fe1868bb02c818ac2759
2,425
cpp
C++
gpmp2/obstacle/tests/testPlanarSDF.cpp
Cryptum169/gpmp2
f361baac4917b9a4d1220411e9c69dc9f96f4277
[ "BSD-3-Clause" ]
null
null
null
gpmp2/obstacle/tests/testPlanarSDF.cpp
Cryptum169/gpmp2
f361baac4917b9a4d1220411e9c69dc9f96f4277
[ "BSD-3-Clause" ]
null
null
null
gpmp2/obstacle/tests/testPlanarSDF.cpp
Cryptum169/gpmp2
f361baac4917b9a4d1220411e9c69dc9f96f4277
[ "BSD-3-Clause" ]
null
null
null
/** * @file testPlanarSDFutils.cpp * @author Jing Dong * @date May 8 2016 **/ #include <CppUnitLite/TestHarness.h> #include <gtsam/base/numericalDerivative.h> #include <gtsam/base/Matrix.h> #include <gpmp2/obstacle/PlanarSDF.h> #include <iostream> using namespace std; using namespace gtsam; using namespace gpmp2; double sdf_wrapper(const PlanarSDF& field, const Point2& p) { return field.getSignedDistance(p); } /* ************************************************************************** */ TEST(PlanarSDFutils, test1) { // data Matrix data; data = (Matrix(5, 5) << 1.7321, 1.4142, 1.4142, 1.4142, 1.7321, 1.4142, 1, 1, 1, 1.4142, 1.4142, 1, 1, 1, 1.4142, 1.4142, 1, 1, 1, 1.4142, 1.7321, 1.4142, 1.4142, 1.4142, 1.7321).finished(); Point2 origin(-0.2, -0.2); double cell_size = 0.1; // constructor PlanarSDF field(origin, cell_size, data); EXPECT_LONGS_EQUAL(5, field.x_count()); EXPECT_LONGS_EQUAL(5, field.y_count()); EXPECT_DOUBLES_EQUAL(0.1, field.cell_size(), 1e-9); EXPECT(assert_equal(origin, field.origin())); // access PlanarSDF::float_index idx; idx = field.convertPoint2toCell(Point2(0, 0)); EXPECT_DOUBLES_EQUAL(2, idx.get<0>(), 1e-9); EXPECT_DOUBLES_EQUAL(2, idx.get<1>(), 1e-9); EXPECT_DOUBLES_EQUAL(1, field.signed_distance(idx), 1e-9) idx = field.convertPoint2toCell(Point2(0.18, -0.17)); // tri-linear interpolation EXPECT_DOUBLES_EQUAL(0.3, idx.get<0>(), 1e-9); EXPECT_DOUBLES_EQUAL(3.8, idx.get<1>(), 1e-9); EXPECT_DOUBLES_EQUAL(1.567372, field.signed_distance(idx), 1e-9) idx = boost::make_tuple(1.0, 2.0); EXPECT(assert_equal(Point2(0.0, -0.1), field.convertCelltoPoint2(idx))); // gradient Vector2 grad_act, grad_exp; Point2 p; p = Point2(-0.13, -0.14); field.getSignedDistance(p, grad_act); grad_exp = numericalDerivative11(std::function<double(const Point2&)>( boost::bind(sdf_wrapper, field, _1)), p, 1e-6); EXPECT(assert_equal(grad_exp, grad_act, 1e-6)); p = Point2(0.18, 0.12); field.getSignedDistance(p, grad_act); grad_exp = numericalDerivative11(std::function<double(const Point2&)>( boost::bind(sdf_wrapper, field, _1)), p, 1e-6); EXPECT(assert_equal(grad_exp, grad_act, 1e-6)); } /* ************************************************************************** */ /* main function */ int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
28.529412
85
0.635876
Cryptum169
44695e046a9f88c516e457a8f7684087f889ddb6
12,464
hpp
C++
include/behemoth/enumerator.hpp
gian21391/behemoth
923bf18a686603022bbab7ce8674dec4c59cdcde
[ "MIT" ]
null
null
null
include/behemoth/enumerator.hpp
gian21391/behemoth
923bf18a686603022bbab7ce8674dec4c59cdcde
[ "MIT" ]
null
null
null
include/behemoth/enumerator.hpp
gian21391/behemoth
923bf18a686603022bbab7ce8674dec4c59cdcde
[ "MIT" ]
null
null
null
/* behemoth: A syntax-guided synthesis library * Copyright (C) 2018 EPFL * * 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. */ #pragma once #include <behemoth/expr.hpp> #include <cassert> #include <fmt/format.h> #include <iostream> #include <queue> #include <algorithm> #include <map> #include <utility> namespace behemoth { struct rule_t { unsigned match; unsigned replace; unsigned cost = 1; }; using rules_t = std::vector<rule_t>; /* expression with associated cost */ using cexpr_t = std::pair<unsigned,unsigned>; struct expr_greater_than { expr_greater_than( context& ctx ) : _ctx( ctx ) {} bool operator()(const cexpr_t& a, const cexpr_t& b) const { /* higher costs means greater */ if ( a.second > b.second ) return true; if ( a.second < b.second ) return false; /* more non-terminals means greater */ if ( _ctx.count_nonterminals( a.first ) > _ctx.count_nonterminals( b.first ) ) return true; if ( _ctx.count_nonterminals( a.first ) < _ctx.count_nonterminals( b.first ) ) return false; /* more nodes means greater */ if ( _ctx.count_nodes( a.first ) > _ctx.count_nodes( b.first ) ) return true; if ( _ctx.count_nodes( a.first ) < _ctx.count_nodes( b.first ) ) return false; return false; } context& _ctx; }; // expr_greater_than struct path_t { path_t ( unsigned initial_depth = std::numeric_limits<unsigned>::max() ) : depth( initial_depth ) {} bool operator<( const path_t& other ) const { return ( depth < other.depth ); } std::string as_string() const { std::string s = "["; for ( auto i = 0u; i < indices.size(); ++i ) { s += fmt::format( "%s", indices[indices.size()-1u-i] ); } s += "] "; s += invalid() ? "∞" : ( fmt::format( "%d", depth ) ); return s; } inline unsigned operator[]( std::size_t i ) { return indices[indices.size()-1u-i]; } inline void push_front( unsigned v ) { indices.push_back( v ); } inline void pop_front() { indices.pop_back(); } inline void incr_depth() { ++depth; } inline bool invalid() const { return indices.empty() && depth == std::numeric_limits<unsigned>::max(); } inline bool valid() const { return !invalid(); } /* indices in reverse order */ std::vector<unsigned> indices; unsigned depth; }; // path_t std::vector<std::pair<unsigned,unsigned>> refine_expression_recurse( context& ctx, unsigned e, path_t path, const rules_t& rules ) { if ( path.indices.empty() ) { /* apply all rules */ std::vector<std::pair<unsigned,unsigned>> results; for ( const auto& r : rules ) { if ( e == r.match ) { results.emplace_back( r.replace, r.cost ); } } return results; } auto index = path[ 0u ]; path.pop_front(); auto candidates = refine_expression_recurse( ctx, ctx._exprs[ e ]._children[ index ], path, rules ); std::vector<std::pair<unsigned,unsigned>> results; for ( const auto& c : candidates ) { std::vector<unsigned> new_children; /* copy the children before index */ for ( auto i = 0u; i < index; ++i ) { new_children.push_back( ctx._exprs[ e ]._children[ i ] ); } /* add new instantiation */ new_children.push_back( c.first ); /* copy the children after index */ for ( auto i = index+1; i < ctx._exprs[ e ]._children.size(); ++i ) { new_children.push_back( ctx._exprs[ e ]._children[ i ] ); } results.emplace_back( ctx.make_fun( ctx._exprs[ e ]._name, new_children, ctx._exprs[ e ]._attr ), c.second ); } return results; } path_t get_path_to_concretizable_element( context& ctx, unsigned e ) { /* non-terminal */ if ( ctx._exprs[ e ]._name[0] == '_' ) { return path_t( 0u ); } /* variable or constant */ if ( ctx._exprs[ e ]._children.empty() ) { return path_t( std::numeric_limits<unsigned>::max() ); } /* others */ path_t min_path; min_path.depth = std::numeric_limits<unsigned>::max(); for ( auto i = 0u; i < ctx._exprs[e]._children.size(); ++i ) { auto path = get_path_to_concretizable_element( ctx, ctx._exprs[e]._children[ i ] ); if ( path < min_path ) { auto new_path = path; new_path.push_front( i ); min_path = new_path; } } if ( min_path < std::numeric_limits<unsigned>::max() ) { min_path.incr_depth(); } return min_path; } bool is_concrete( context& ctx, unsigned e ) { return get_path_to_concretizable_element( ctx, e ).invalid(); } class enumerator { public: using expr_queue_t = std::priority_queue<cexpr_t, std::vector<cexpr_t>, expr_greater_than>; public: enumerator( context& ctx, rules_t rules, int max_cost ) : ctx( ctx ) , rules(std::move( rules )) , max_cost( max_cost ) , candidate_expressions( ctx ) /* pass ctx to the expr_greater_than */ {} virtual ~enumerator() = default; void add_expression( unsigned e ); void deduce( unsigned number_of_steps = 1u ); virtual bool is_redundant_in_search_order( unsigned e ) const; bool check_double_application( unsigned e ) const; bool check_idempotence_and_commutative( unsigned e ) const; bool check_idempotence( unsigned e ) const; bool check_commutativity( unsigned e ) const; virtual void on_expression( cexpr_t e ) { (void)e; } virtual void on_concrete_expression( cexpr_t e ) { (void)e; } virtual void on_abstract_expression( cexpr_t e ) { candidate_expressions.push( e ); } void signal_termination() { quit_enumeration = true; } bool is_running() const { return !quit_enumeration; } protected: context& ctx; bool quit_enumeration = false; rules_t rules; unsigned max_cost; expr_queue_t candidate_expressions; unsigned current_costs = 0u; }; void enumerator::add_expression( unsigned e ) { candidate_expressions.push( { e, 0u } ); } void enumerator::deduce( unsigned number_of_steps ) { for ( auto i = 0u; i < number_of_steps; ++i ) { if ( candidate_expressions.empty() ) { quit_enumeration = true; } if ( !is_running() ) { return; } auto next_candidate = candidate_expressions.top(); candidate_expressions.pop(); if ( next_candidate.second > current_costs ) { std::cout << "[i] finished considering expressions of cost " << (current_costs+1u) << std::endl; current_costs = next_candidate.second; } if ( next_candidate.second >= max_cost ) { quit_enumeration = true; continue; } auto p = get_path_to_concretizable_element( ctx, next_candidate.first ); auto new_candidates = refine_expression_recurse( ctx, next_candidate.first, p, rules ); for ( const auto& c : new_candidates ) { if ( !is_running() ) break; if ( is_redundant_in_search_order( c.first ) ) continue; auto cc = cexpr_t{ c.first, next_candidate.second + c.second }; on_expression( cc ); if ( is_concrete( ctx, c.first ) ) { on_concrete_expression(cc); } else { on_abstract_expression(cc); } } } } bool enumerator::check_double_application( unsigned e ) const { const auto expr = ctx._exprs[ e ]; /* no double-negation */ if ( expr._name[0] != '_' && (expr._attr & expr_attr_enum::_no_double_application) == expr_attr_enum::_no_double_application ) { assert( expr._children.size() == 1u ); const auto child0 = ctx._exprs[ expr._children[0u] ]; if ( child0._name == expr._name && child0._attr == expr_attr_enum::_no_double_application ) { return true; } } for ( const auto& c : expr._children ) { if ( check_double_application( c ) ) { return true; } } return false; } void get_leaves_of_same_op_impl( context& ctx, unsigned e, const std::string& op, std::vector<unsigned>& leaves ) { const auto expr = ctx._exprs[e]; for ( const auto& c : expr._children ) { if ( ctx._exprs[c]._children.empty() && ctx._exprs[c]._name[0] != '_' ) { leaves.emplace_back( c ); } if ( ctx._exprs[c]._name == op ) { get_leaves_of_same_op_impl( ctx, c, op, leaves ); } } } // this function gets all the leaves of the chains of the same operation std::vector<unsigned> get_leaves_of_same_op( context& ctx, unsigned e ) { std::vector<unsigned> leaves; const auto expr = ctx._exprs[e]; for ( const auto& c : expr._children ) { if ( ctx._exprs[c]._children.empty() && ctx._exprs[c]._name[0] != '_' ) { leaves.emplace_back( c ); } if ( ctx._exprs[c]._name == expr._name ) { get_leaves_of_same_op_impl( ctx, c, expr._name, leaves ); } } return leaves; } bool enumerator::check_idempotence( unsigned e ) const { // get all chains of same op starting from e auto leaves = get_leaves_of_same_op( ctx, e ); // check for equal elements if ( leaves.size() < 2 ) { return false; } std::map<unsigned, unsigned> dup; std::for_each( leaves.begin(), leaves.end(), [&dup]( unsigned val ) { dup[val]++; } ); auto result = std::find_if( dup.begin(), dup.end(), []( std::pair<const unsigned int, unsigned int> val ) { return val.second > 1; } ); return result != dup.end(); } bool enumerator::check_commutativity( unsigned e ) const { // get all chains of same op starting from e auto leaves = get_leaves_of_same_op( ctx, e ); // check ordering of elements if ( leaves.size() < 2 ) { return false; } if ( !std::is_sorted( leaves.begin(), leaves.end() ) ) { return true; } return false; } bool enumerator::check_idempotence_and_commutative( unsigned e ) const { const auto is_set = []( unsigned value, unsigned flag ) { return ( ( value & flag ) == flag ); }; const auto expr = ctx._exprs[ e ]; if ( expr._name[0] != '_' && expr._children.size() == 2u && (ctx.count_nonterminals( expr._children[0u] ) == 0) && (ctx.count_nonterminals( expr._children[1u] ) == 0) ) { if ( is_set( expr._attr, expr_attr_enum::_idempotent | expr_attr_enum::_commutative ) && expr._children[0u] >= expr._children[1u] ) { return true; } else if ( is_set( expr._attr, expr_attr_enum::_commutative ) && expr._children[0u] > expr._children[1u] ) { return true; } else if ( is_set( expr._attr, expr_attr_enum::_idempotent ) && expr._children[0u] == expr._children[1u] ) { return true; } } if ( expr._name[0] != '_' && expr._children.size() == 2u && is_set( expr._attr, expr_attr_enum::_idempotent ) ) { if ( check_idempotence( e ) ) { return true; } } if ( expr._name[0] != '_' && expr._children.size() == 2u && is_set( expr._attr, expr_attr_enum::_commutative ) ) { if ( check_commutativity( e ) ) { return true; } } for ( const auto& c : expr._children ) { if ( check_idempotence_and_commutative( c ) ) { return true; } } return false; } bool enumerator::is_redundant_in_search_order( unsigned e ) const { if ( check_double_application( e ) ) { return true; } if ( check_idempotence_and_commutative( e ) ) { return true; } /* keep all other expressions */ return false; } } // namespace behemoth // Local Variables: // c-basic-offset: 2 // eval: (c-set-offset 'substatement-open 0) // eval: (c-set-offset 'innamespace 0) // End:
24.391389
137
0.638639
gian21391
446fe89cefa2483f6898bf6ff5c1d9a4eeecfa20
4,379
cpp
C++
rviz_default_plugins/src/rviz_default_plugins/tools/focus/focus_tool.cpp
romi2002/rviz
8b2fcc1838e079d0e365894abd7cfd7b255b8d8b
[ "BSD-3-Clause-Clear" ]
null
null
null
rviz_default_plugins/src/rviz_default_plugins/tools/focus/focus_tool.cpp
romi2002/rviz
8b2fcc1838e079d0e365894abd7cfd7b255b8d8b
[ "BSD-3-Clause-Clear" ]
null
null
null
rviz_default_plugins/src/rviz_default_plugins/tools/focus/focus_tool.cpp
romi2002/rviz
8b2fcc1838e079d0e365894abd7cfd7b255b8d8b
[ "BSD-3-Clause-Clear" ]
1
2020-04-29T07:08:07.000Z
2020-04-29T07:08:07.000Z
/* * Copyright (c) 2013, Willow Garage, 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: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <sstream> #ifndef _WIN32 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-parameter" # pragma GCC diagnostic ignored "-Wpedantic" #else #pragma warning(push) #pragma warning(disable : 4996) #endif #include <OgreCamera.h> #include <OgreRay.h> #include <OgreVector3.h> #include <OgreViewport.h> #ifndef _WIN32 # pragma GCC diagnostic pop #else # pragma warning(pop) #endif #include "rviz_common/display_context.hpp" #include "rviz_common/interaction/view_picker_iface.hpp" #include "rviz_common/load_resource.hpp" #include "rviz_common/render_panel.hpp" #include "rviz_common/viewport_mouse_event.hpp" #include "rviz_common/view_controller.hpp" #include "rviz_rendering/render_window.hpp" #include "rviz_default_plugins/tools/focus/focus_tool.hpp" namespace rviz_default_plugins { namespace tools { FocusTool::FocusTool() : Tool() { shortcut_key_ = 'c'; } FocusTool::~FocusTool() = default; void FocusTool::onInitialize() { std_cursor_ = rviz_common::getDefaultCursor(); hit_cursor_ = rviz_common::makeIconCursor("package://rviz_common/icons/crosshair.svg"); } void FocusTool::activate() {} void FocusTool::deactivate() {} int FocusTool::processMouseEvent(rviz_common::ViewportMouseEvent & event) { int flags = 0; Ogre::Vector3 position; bool success = context_->getViewPicker()->get3DPoint(event.panel, event.x, event.y, position); setCursor(success ? hit_cursor_ : std_cursor_); if (!success) { computePositionForDirection(event, position); setStatus("<b>Left-Click:</b> Look in this direction."); } else { setStatusFrom(position); } if (event.leftUp()) { if (event.panel->getViewController()) { event.panel->getViewController()->lookAt(position); } flags |= Finished; } return flags; } void FocusTool::setStatusFrom(const Ogre::Vector3 & position) { std::ostringstream s; s << "<b>Left-Click:</b> Focus on this point."; s.precision(3); s << " [" << position.x << "," << position.y << "," << position.z << "]"; setStatus(s.str().c_str()); } void FocusTool::computePositionForDirection( const rviz_common::ViewportMouseEvent & event, Ogre::Vector3 & position) { auto viewport = rviz_rendering::RenderWindowOgreAdapter::getOgreViewport(event.panel->getRenderWindow()); Ogre::Ray mouse_ray = viewport->getCamera()->getCameraToViewportRay( static_cast<float>(event.x) / static_cast<float>(viewport->getActualWidth()), static_cast<float>(event.y) / static_cast<float>(viewport->getActualHeight())); position = mouse_ray.getPoint(1.0); } } // namespace tools } // namespace rviz_default_plugins #include <pluginlib/class_list_macros.hpp> // NOLINT PLUGINLIB_EXPORT_CLASS(rviz_default_plugins::tools::FocusTool, rviz_common::Tool)
31.278571
96
0.738982
romi2002
4476251d4084b04d1d79b25f1d4cb70694b07750
14,334
ipp
C++
boost/test/impl/framework.ipp
jonstewart/boost-svn
7f6dc0c0cb807b28072c7bdd3d77bb01ab290c59
[ "BSL-1.0" ]
1
2017-04-08T10:44:28.000Z
2017-04-08T10:44:28.000Z
boost/test/impl/framework.ipp
jonstewart/boost-svn
7f6dc0c0cb807b28072c7bdd3d77bb01ab290c59
[ "BSL-1.0" ]
null
null
null
boost/test/impl/framework.ipp
jonstewart/boost-svn
7f6dc0c0cb807b28072c7bdd3d77bb01ab290c59
[ "BSL-1.0" ]
null
null
null
// (C) Copyright Gennadiy Rozental 2005-2008. // 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) // See http://www.boost.org/libs/test for the library home page. // // File : $RCSfile$ // // Version : $Revision$ // // Description : implements framework API - main driver for the test // *************************************************************************** #ifndef BOOST_TEST_FRAMEWORK_IPP_021005GER #define BOOST_TEST_FRAMEWORK_IPP_021005GER // Boost.Test #include <boost/test/framework.hpp> #include <boost/test/execution_monitor.hpp> #include <boost/test/debug.hpp> #include <boost/test/unit_test_suite_impl.hpp> #include <boost/test/unit_test_log.hpp> #include <boost/test/unit_test_monitor.hpp> #include <boost/test/test_observer.hpp> #include <boost/test/results_collector.hpp> #include <boost/test/progress_monitor.hpp> #include <boost/test/results_reporter.hpp> #include <boost/test/test_tools.hpp> #include <boost/test/detail/unit_test_parameters.hpp> #include <boost/test/detail/global_typedef.hpp> #include <boost/test/utils/foreach.hpp> // Boost #include <boost/timer.hpp> // STL #include <map> #include <set> #include <cstdlib> #include <ctime> #ifdef BOOST_NO_STDC_NAMESPACE namespace std { using ::time; using ::srand; } #endif #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// namespace boost { namespace unit_test { // ************************************************************************** // // ************** test_start calls wrapper ************** // // ************************************************************************** // namespace ut_detail { struct test_start_caller { test_start_caller( test_observer* to, counter_t tc_amount ) : m_to( to ) , m_tc_amount( tc_amount ) {} int operator()() { m_to->test_start( m_tc_amount ); return 0; } private: // Data members test_observer* m_to; counter_t m_tc_amount; }; //____________________________________________________________________________// struct test_init_caller { explicit test_init_caller( init_unit_test_func init_func ) : m_init_func( init_func ) {} int operator()() { #ifdef BOOST_TEST_ALTERNATIVE_INIT_API if( !(*m_init_func)() ) throw std::runtime_error( "test module initialization failed" ); #else test_suite* manual_test_units = (*m_init_func)( framework::master_test_suite().argc, framework::master_test_suite().argv ); if( manual_test_units ) framework::master_test_suite().add( manual_test_units ); #endif return 0; } // Data members init_unit_test_func m_init_func; }; } // ************************************************************************** // // ************** framework ************** // // ************************************************************************** // class framework_impl : public test_tree_visitor { public: framework_impl() : m_master_test_suite( 0 ) , m_curr_test_case( INV_TEST_UNIT_ID ) , m_next_test_case_id( MIN_TEST_CASE_ID ) , m_next_test_suite_id( MIN_TEST_SUITE_ID ) , m_is_initialized( false ) , m_test_in_progress( false ) {} ~framework_impl() { clear(); } void clear() { while( !m_test_units.empty() ) { test_unit_store::value_type const& tu = *m_test_units.begin(); test_unit const* tu_ptr = tu.second; // the delete will erase this element from map if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == tut_suite ) delete static_cast<test_suite const*>(tu_ptr); else delete static_cast<test_case const*>(tu_ptr); } } void set_tu_id( test_unit& tu, test_unit_id id ) { tu.p_id.value = id; } // test_tree_visitor interface implementation void visit( test_case const& tc ) { if( !tc.check_dependencies() ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_skipped( tc ); return; } BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_start( tc ); boost::timer tc_timer; test_unit_id bkup = m_curr_test_case; m_curr_test_case = tc.p_id; unit_test_monitor_t::error_level run_result = unit_test_monitor.execute_and_translate( tc ); unsigned long elapsed = static_cast<unsigned long>( tc_timer.elapsed() * 1e6 ); if( unit_test_monitor.is_critical_error( run_result ) ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_aborted(); } BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_finish( tc, elapsed ); m_curr_test_case = bkup; if( unit_test_monitor.is_critical_error( run_result ) ) throw test_being_aborted(); } bool test_suite_start( test_suite const& ts ) { if( !ts.check_dependencies() ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_skipped( ts ); return false; } BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_start( ts ); return true; } void test_suite_finish( test_suite const& ts ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_finish( ts, 0 ); } ////////////////////////////////////////////////////////////////// struct priority_order { bool operator()( test_observer* lhs, test_observer* rhs ) const { return (lhs->priority() < rhs->priority()) || ((lhs->priority() == rhs->priority()) && (lhs < rhs)); } }; typedef std::map<test_unit_id,test_unit*> test_unit_store; typedef std::set<test_observer*,priority_order> observer_store; master_test_suite_t* m_master_test_suite; test_unit_id m_curr_test_case; test_unit_store m_test_units; test_unit_id m_next_test_case_id; test_unit_id m_next_test_suite_id; bool m_is_initialized; bool m_test_in_progress; observer_store m_observers; }; //____________________________________________________________________________// namespace { #if defined(__CYGWIN__) framework_impl& s_frk_impl() { static framework_impl* the_inst = 0; if(!the_inst) the_inst = new framework_impl; return *the_inst; } #else framework_impl& s_frk_impl() { static framework_impl the_inst; return the_inst; } #endif } // local namespace //____________________________________________________________________________// namespace framework { void init( init_unit_test_func init_func, int argc, char* argv[] ) { runtime_config::init( argc, argv ); // set the log level and format unit_test_log.set_threshold_level( runtime_config::log_level() ); unit_test_log.set_format( runtime_config::log_format() ); // set the report level and format results_reporter::set_level( runtime_config::report_level() ); results_reporter::set_format( runtime_config::report_format() ); register_observer( results_collector ); register_observer( unit_test_log ); if( runtime_config::show_progress() ) register_observer( progress_monitor ); if( runtime_config::detect_memory_leaks() > 0 ) { debug::detect_memory_leaks( true ); debug::break_memory_alloc( runtime_config::detect_memory_leaks() ); } // init master unit test suite master_test_suite().argc = argc; master_test_suite().argv = argv; try { boost::execution_monitor em; ut_detail::test_init_caller tic( init_func ); em.execute( tic ); } catch( execution_exception const& ex ) { throw setup_error( ex.what() ); } s_frk_impl().m_is_initialized = true; } //____________________________________________________________________________// bool is_initialized() { return s_frk_impl().m_is_initialized; } //____________________________________________________________________________// void register_test_unit( test_case* tc ) { BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) ); test_unit_id new_id = s_frk_impl().m_next_test_case_id; BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) ); typedef framework_impl::test_unit_store::value_type map_value_type; s_frk_impl().m_test_units.insert( map_value_type( new_id, tc ) ); s_frk_impl().m_next_test_case_id++; s_frk_impl().set_tu_id( *tc, new_id ); } //____________________________________________________________________________// void register_test_unit( test_suite* ts ) { BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) ); test_unit_id new_id = s_frk_impl().m_next_test_suite_id; BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) ); typedef framework_impl::test_unit_store::value_type map_value_type; s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) ); s_frk_impl().m_next_test_suite_id++; s_frk_impl().set_tu_id( *ts, new_id ); } //____________________________________________________________________________// void deregister_test_unit( test_unit* tu ) { s_frk_impl().m_test_units.erase( tu->p_id ); } //____________________________________________________________________________// void clear() { s_frk_impl().clear(); } //____________________________________________________________________________// void register_observer( test_observer& to ) { s_frk_impl().m_observers.insert( &to ); } //____________________________________________________________________________// void deregister_observer( test_observer& to ) { s_frk_impl().m_observers.erase( &to ); } //____________________________________________________________________________// void reset_observers() { s_frk_impl().m_observers.clear(); } //____________________________________________________________________________// master_test_suite_t& master_test_suite() { if( !s_frk_impl().m_master_test_suite ) s_frk_impl().m_master_test_suite = new master_test_suite_t; return *s_frk_impl().m_master_test_suite; } //____________________________________________________________________________// test_case const& current_test_case() { return get<test_case>( s_frk_impl().m_curr_test_case ); } //____________________________________________________________________________// test_unit& get( test_unit_id id, test_unit_type t ) { test_unit* res = s_frk_impl().m_test_units[id]; if( (res->p_type & t) == 0 ) throw internal_error( "Invalid test unit type" ); return *res; } //____________________________________________________________________________// void run( test_unit_id id, bool continue_test ) { if( id == INV_TEST_UNIT_ID ) id = master_test_suite().p_id; test_case_counter tcc; traverse_test_tree( id, tcc ); BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().is_empty() ? BOOST_TEST_L( "test tree is empty" ) : BOOST_TEST_L( "no test cases matching filter" ) ); bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress; bool was_in_progress = s_frk_impl().m_test_in_progress; s_frk_impl().m_test_in_progress = true; if( call_start_finish ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) { boost::execution_monitor em; try { em.execute( ut_detail::test_start_caller( to, tcc.p_count ) ); } catch( execution_exception const& ex ) { throw setup_error( ex.what() ); } } } switch( runtime_config::random_seed() ) { case 0: break; case 1: { unsigned int seed = static_cast<unsigned int>( std::time( 0 ) ); BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << seed ); std::srand( seed ); break; } default: BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << runtime_config::random_seed() ); std::srand( runtime_config::random_seed() ); } try { traverse_test_tree( id, s_frk_impl() ); } catch( test_being_aborted const& ) { // abort already reported } if( call_start_finish ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->test_finish(); } s_frk_impl().m_test_in_progress = was_in_progress; } //____________________________________________________________________________// void run( test_unit const* tu, bool continue_test ) { run( tu->p_id, continue_test ); } //____________________________________________________________________________// void assertion_result( bool passed ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->assertion_result( passed ); } //____________________________________________________________________________// void exception_caught( execution_exception const& ex ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->exception_caught( ex ); } //____________________________________________________________________________// void test_unit_aborted( test_unit const& tu ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->test_unit_aborted( tu ); } //____________________________________________________________________________// } // namespace framework } // namespace unit_test } // namespace boost //____________________________________________________________________________// #include <boost/test/detail/enable_warnings.hpp> #endif // BOOST_TEST_FRAMEWORK_IPP_021005GER
28.440476
132
0.66876
jonstewart
447794b296f1ca47c7dc73cb484dced1c00fa0e4
1,043
cpp
C++
editor/src/editorcommands/addspatialentitycommand.cpp
gameraccoon/HideAndSeek
bc1e9c8dd725968ad4bc204877d8ddca2132ace7
[ "MIT" ]
null
null
null
editor/src/editorcommands/addspatialentitycommand.cpp
gameraccoon/HideAndSeek
bc1e9c8dd725968ad4bc204877d8ddca2132ace7
[ "MIT" ]
null
null
null
editor/src/editorcommands/addspatialentitycommand.cpp
gameraccoon/HideAndSeek
bc1e9c8dd725968ad4bc204877d8ddca2132ace7
[ "MIT" ]
null
null
null
#include "addspatialentitycommand.h" #include <QtWidgets/qcombobox.h> #include "GameData/Components/TransformComponent.generated.h" #include "GameData/World.h" AddSpatialEntityCommand::AddSpatialEntityCommand(const SpatialEntity& entity, const Vector2D& location) : EditorCommand(EffectBitset(EffectType::Entities)) , mEntity(entity) , mLocation(location) { } void AddSpatialEntityCommand::doCommand(World* world) { WorldCell& cell = world->getSpatialData().getOrCreateCell(mEntity.cell); EntityManager& cellEnttiyManager = cell.getEntityManager(); cellEnttiyManager.addExistingEntityUnsafe(mEntity.entity.getEntity()); TransformComponent* transform = cellEnttiyManager.addComponent<TransformComponent>(mEntity.entity.getEntity()); transform->setLocation(mLocation); } void AddSpatialEntityCommand::undoCommand(World* world) { if (WorldCell* cell = world->getSpatialData().getCell(mEntity.cell)) { EntityManager& cellEnttiyManager = cell->getEntityManager(); cellEnttiyManager.removeEntity(mEntity.entity.getEntity()); } }
32.59375
112
0.802493
gameraccoon
4477bee1e72e9cab5d423d1d989799ea66e26d96
5,195
cpp
C++
code/szen/src/System/Window.cpp
Sonaza/scyori
a894a9c7bd45a68ea1b6ff14877cdbe47ddd39cf
[ "BSD-3-Clause" ]
null
null
null
code/szen/src/System/Window.cpp
Sonaza/scyori
a894a9c7bd45a68ea1b6ff14877cdbe47ddd39cf
[ "BSD-3-Clause" ]
null
null
null
code/szen/src/System/Window.cpp
Sonaza/scyori
a894a9c7bd45a68ea1b6ff14877cdbe47ddd39cf
[ "BSD-3-Clause" ]
null
null
null
#include <szen/System/Window.hpp> #include <szen/Game/Camera.hpp> #include <sstream> #ifdef SFML_SYSTEM_WINDOWS #include <Windows.h> #endif using namespace sz; namespace { sf::RenderWindow* m_window = NULL; float m_aspectRatio; sf::Uint32 m_virtualWidth = 1920; sf::View m_view; std::string m_title; sf::Uint32 m_antialiasing; } //////////////////////////////////////////////////// void Window::open(sf::VideoMode videomode, const std::string &title, const sf::Uint32 style, const sf::Uint32 antialias, const sf::Uint32 virtualWidth) { assert(!m_window && "Window is already open"); sf::ContextSettings settings; settings.antialiasingLevel = antialias; // Create new window instance m_window = new(std::nothrow) sf::RenderWindow(videomode, title, style, settings); assert(m_window && "Allocation failed"); m_title = title; m_antialiasing = antialias; m_aspectRatio = videomode.width / static_cast<float>(videomode.height); // Set virtual width m_virtualWidth = (virtualWidth == 0 ? videomode.width : virtualWidth); m_window->setVerticalSyncEnabled(true); m_window->clear(sf::Color::Black); m_window->display(); Camera::updateScreenSize(); } //////////////////////////////////////////////////// void Window::changeMode(sf::VideoMode videomode, const sf::Uint32 style) { if(!m_window) return; // Delete old window and create new instead delete m_window; sf::ContextSettings settings; settings.antialiasingLevel = m_antialiasing; m_window = new sf::RenderWindow(videomode, m_title, style, settings); m_aspectRatio = videomode.width / static_cast<float>(videomode.height); m_window->setVerticalSyncEnabled(true); m_window->clear(sf::Color::Black); m_window->display(); Camera::updateScreenSize(); } //////////////////////////////////////////////////// void Window::close() { if(m_window) { m_window->close(); delete m_window; m_window = NULL; } } //////////////////////////////////////////////////// sf::Vector2u Window::getSize() { return m_window->getSize(); } //////////////////////////////////////////////////// void Window::setVirtualWidth(const sf::Uint32 width) { m_virtualWidth = width; Camera::updateScreenSize(); } //////////////////////////////////////////////////// sf::Vector2u Window::getVirtualSize() { return sf::Vector2u( m_virtualWidth, static_cast<sf::Uint32>(ceil(m_virtualWidth * (1.f / m_aspectRatio)))); } //////////////////////////////////////////////////// sf::RenderWindow* Window::getRenderWindow() { return m_window; } //////////////////////////////////////////////////// bool Window::isActive() { // Windows implementation return m_window->getSystemHandle() == GetActiveWindow(); } //////////////////////////////////////////////////////////// sf::VideoMode Window::getOptimalResolution(const bool fullscreen) { sf::VideoMode native = sf::VideoMode::getDesktopMode(); std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes(); sf::VideoMode videomode = native; if(fullscreen && native == modes[0]) return videomode; float nativeRatio = native.width / static_cast<float>(native.height); float ratio; for(std::vector<sf::VideoMode>::iterator it = modes.begin(); it != modes.end(); ++it) { sf::VideoMode mode = *it; if(mode.bitsPerPixel != native.bitsPerPixel) continue; if(mode.width >= native.width) continue; ratio = mode.width / static_cast<float>(mode.height); if(fabs(nativeRatio - ratio) <= 0.001f) { videomode = mode; break; } } return videomode; } #include <iostream> //////////////////////////////////////////////////////////// int calculateGCD(int a, int b) { return (b == 0) ? a : calculateGCD (b, a%b); } //////////////////////////////////////////////////////////// std::vector<sf::VideoMode> Window::getSupportedResolutions(const bool fullscreen) { sf::VideoMode native = sf::VideoMode::getDesktopMode(); float nativeAspect = native.width / (float)native.height; std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes(); std::vector<sf::VideoMode> result; for(int i=0; i < modes.size(); ++i) { sf::VideoMode mode = modes[i]; bool cond = true; float ratio = mode.width / (float)mode.height; cond &= mode.bitsPerPixel == modes[0].bitsPerPixel; cond &= mode.width >= 1024; cond &= mode.width <= native.width && mode.height <= native.height; //cond &= nativeAspect == ratio; if(cond) { result.push_back(mode); } } std::sort(result.begin(), result.end(), [](sf::VideoMode& a, sf::VideoMode& b) -> bool { /*float ra = a.width / (float)a.height; float rb = b.width / (float)b.height; */ return (a.width * a.height) < (b.width * b.height); } ); std::cout << "============================================================\n"; for(int i=0; i < result.size(); ++i) { sf::VideoMode mode = result[i]; std::stringstream aspect; int gcd = calculateGCD(mode.width, mode.height); sf::Vector2i ratio(mode.width, mode.height); ratio /= gcd; if(ratio.x == 8 && ratio.y == 5) ratio *= 2; aspect << ratio.x << ":" << ratio.y; std::cout << mode.width << " x " << mode.height << " (" << aspect.str() << ")\n"; } return result; }
23.506787
86
0.596535
Sonaza
4478f21af676c7a08c1b77f5ec68f64e89aed5b3
1,814
cpp
C++
src/lib/CatenaBase_NetSave.cpp
dhineshkumarmcci/Catena-Arduino-Platform
478ad23318a7646f2e03170e9294b0ea69885da4
[ "MIT" ]
1
2021-11-27T22:56:25.000Z
2021-11-27T22:56:25.000Z
src/lib/CatenaBase_NetSave.cpp
dhineshkumarmcci/Catena-Arduino-Platform
478ad23318a7646f2e03170e9294b0ea69885da4
[ "MIT" ]
null
null
null
src/lib/CatenaBase_NetSave.cpp
dhineshkumarmcci/Catena-Arduino-Platform
478ad23318a7646f2e03170e9294b0ea69885da4
[ "MIT" ]
1
2021-04-03T09:56:13.000Z
2021-04-03T09:56:13.000Z
/* CatenaBase_NetSave.cpp Mon Dec 03 2018 13:21:28 chwon */ /* Module: CatenaBase_NetSave.cpp Function: Interface from LoRaWAN to FRAM. Version: V0.12.0 Mon Dec 03 2018 13:21:28 chwon Edit level 1 Copyright notice: This file copyright (C) 2018 by MCCI Corporation 3520 Krums Corners Road Ithaca, NY 14850 An unpublished work. All rights reserved. This file is proprietary information, and may not be disclosed or copied without the prior permission of MCCI Corporation Author: ChaeHee Won, MCCI Corporation December 2018 Revision history: 0.12.0 Mon Dec 03 2018 13:21:28 chwon Module created. */ #include <CatenaBase.h> #include <Catena_Fram.h> #include <Catena_Log.h> using namespace McciCatena; void CatenaBase::NetSaveFCntUp( uint32_t uFCntUp ) { auto const pFram = this->getFram(); if (pFram != nullptr) pFram->saveField(cFramStorage::kFCntUp, uFCntUp); } void CatenaBase::NetSaveFCntDown( uint32_t uFCntDown ) { auto const pFram = this->getFram(); if (pFram != nullptr) pFram->saveField(cFramStorage::kFCntDown, uFCntDown); } void CatenaBase::NetSaveSessionInfo( const Arduino_LoRaWAN::SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo ) { auto const pFram = this->getFram(); if (pFram != nullptr) { pFram->saveField(cFramStorage::kNetID, Info.V1.NetID); pFram->saveField(cFramStorage::kDevAddr, Info.V1.DevAddr); pFram->saveField(cFramStorage::kNwkSKey, Info.V1.NwkSKey); pFram->saveField(cFramStorage::kAppSKey, Info.V1.AppSKey); pFram->saveField(cFramStorage::kFCntUp, Info.V1.FCntUp); pFram->saveField(cFramStorage::kFCntDown, Info.V1.FCntDown); } gLog.printf( gLog.kAlways, "NwkID: %08x " "DevAddr: %08x\n", Info.V1.NetID, Info.V1.DevAddr ); } /**** end of CatenaBase_NetSave.cpp ****/
19.717391
66
0.723264
dhineshkumarmcci
447aa6c8ff6b0ec4345b7687a3fc26f3c5f4d156
42,601
cc
C++
src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
Sohei-Suzuki-Nexty/sdl_core
68f082169e0a40fccd9eb0db3c83911c28870f07
[ "BSD-3-Clause" ]
249
2015-01-15T16:50:53.000Z
2022-03-24T13:23:34.000Z
src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
Sohei-Suzuki-Nexty/sdl_core
68f082169e0a40fccd9eb0db3c83911c28870f07
[ "BSD-3-Clause" ]
2,917
2015-01-12T16:17:49.000Z
2022-03-31T11:57:47.000Z
src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc
Sohei-Suzuki-Nexty/sdl_core
68f082169e0a40fccd9eb0db3c83911c28870f07
[ "BSD-3-Clause" ]
306
2015-01-12T09:23:20.000Z
2022-01-28T18:06:30.000Z
/* * Copyright (c) 2017, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following * disclaimer in the documentation and/or other materials provided with the * distribution. * * Neither the name of the Ford Motor Company 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 HOLDER 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 "config_profile/profile.h" #include "utils/helpers.h" #include "utils/logger.h" #include "utils/timer_task_impl.h" #include "transport_manager/transport_adapter/client_connection_listener.h" #include "transport_manager/transport_adapter/device_scanner.h" #include "transport_manager/transport_adapter/server_connection_factory.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" #include "transport_manager/transport_adapter/transport_adapter_listener.h" #ifdef WEBSOCKET_SERVER_TRANSPORT_SUPPORT #include "transport_manager/websocket_server/websocket_device.h" #endif namespace transport_manager { namespace transport_adapter { const char* tc_enabled = "enabled"; const char* tc_tcp_port = "tcp_port"; const char* tc_tcp_ip_address = "tcp_ip_address"; SDL_CREATE_LOG_VARIABLE("TransportManager") namespace { DeviceTypes devicesType = { std::make_pair(DeviceType::AOA, std::string("USB_AOA")), std::make_pair(DeviceType::BLUETOOTH, std::string("BLUETOOTH")), std::make_pair(DeviceType::IOS_BT, std::string("BLUETOOTH_IOS")), std::make_pair(DeviceType::IOS_USB, std::string("USB_IOS")), std::make_pair(DeviceType::TCP, std::string("WIFI")), std::make_pair(DeviceType::IOS_USB_HOST_MODE, std::string("USB_IOS_HOST_MODE")), std::make_pair(DeviceType::IOS_USB_DEVICE_MODE, std::string("USB_IOS_DEVICE_MODE")), std::make_pair(DeviceType::IOS_CARPLAY_WIRELESS, std::string("CARPLAY_WIRELESS_IOS")), std::make_pair(DeviceType::CLOUD_WEBSOCKET, std::string("CLOUD_WEBSOCKET")), std::make_pair(DeviceType::WEBENGINE_WEBSOCKET, std::string("WEBENGINE_WEBSOCKET"))}; } TransportAdapterImpl::TransportAdapterImpl( DeviceScanner* device_scanner, ServerConnectionFactory* server_connection_factory, ClientConnectionListener* client_connection_listener, resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings) : listeners_() , initialised_(0) , devices_() , devices_mutex_() , connections_() , connections_lock_() , #ifdef TELEMETRY_MONITOR metric_observer_(NULL) , #endif // TELEMETRY_MONITOR device_scanner_(device_scanner) , server_connection_factory_(server_connection_factory) , client_connection_listener_(client_connection_listener) , last_state_wrapper_(last_state_wrapper) , settings_(settings) { } TransportAdapterImpl::~TransportAdapterImpl() { listeners_.clear(); Terminate(); if (device_scanner_) { SDL_LOG_DEBUG("Deleting device_scanner_ " << device_scanner_); delete device_scanner_; SDL_LOG_DEBUG("device_scanner_ deleted."); } if (server_connection_factory_) { SDL_LOG_DEBUG("Deleting server_connection_factory " << server_connection_factory_); delete server_connection_factory_; SDL_LOG_DEBUG("server_connection_factory deleted."); } if (client_connection_listener_) { SDL_LOG_DEBUG("Deleting client_connection_listener_ " << client_connection_listener_); delete client_connection_listener_; SDL_LOG_DEBUG("client_connection_listener_ deleted."); } } void TransportAdapterImpl::Terminate() { if (device_scanner_) { device_scanner_->Terminate(); SDL_LOG_DEBUG("device_scanner_ " << device_scanner_ << " terminated."); } if (server_connection_factory_) { server_connection_factory_->Terminate(); SDL_LOG_DEBUG("server_connection_factory " << server_connection_factory_ << " terminated."); } if (client_connection_listener_) { client_connection_listener_->Terminate(); SDL_LOG_DEBUG("client_connection_listener_ " << client_connection_listener_ << " terminated."); } ConnectionMap connections; connections_lock_.AcquireForWriting(); std::swap(connections, connections_); connections_lock_.Release(); for (const auto& connection : connections) { auto& info = connection.second; if (info.connection) { info.connection->Terminate(); } } connections.clear(); SDL_LOG_DEBUG("Connections deleted"); DeviceMap devices; devices_mutex_.Acquire(); std::swap(devices, devices_); devices_mutex_.Release(); devices.clear(); SDL_LOG_DEBUG("Devices deleted"); } TransportAdapter::Error TransportAdapterImpl::Init() { SDL_LOG_TRACE("enter"); Error error = OK; if ((error == OK) && device_scanner_) { error = device_scanner_->Init(); } if ((error == OK) && server_connection_factory_) { error = server_connection_factory_->Init(); } if ((error == OK) && client_connection_listener_) { error = client_connection_listener_->Init(); } initialised_ = (error == OK); if (get_settings().use_last_state() && initialised_) { if (!Restore()) { SDL_LOG_WARN("could not restore transport adapter state"); } } SDL_LOG_TRACE("exit with error: " << error); return error; } TransportAdapter::Error TransportAdapterImpl::SearchDevices() { SDL_LOG_TRACE("enter"); if (device_scanner_ == NULL) { SDL_LOG_TRACE("exit with NOT_SUPPORTED"); return NOT_SUPPORTED; } else if (!device_scanner_->IsInitialised()) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } TransportAdapter::Error er = device_scanner_->Scan(); SDL_LOG_TRACE("exit with error: " << er); return er; } TransportAdapter::Error TransportAdapterImpl::Connect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_TRACE("enter. DeviceUID " << device_id << " ApplicationHandle " << app_handle); if (server_connection_factory_ == 0) { SDL_LOG_TRACE("exit with NOT_SUPPORTED"); return NOT_SUPPORTED; } if (!server_connection_factory_->IsInitialised()) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } connections_lock_.AcquireForWriting(); std::pair<DeviceUID, ApplicationHandle> connection_key = std::make_pair(device_id, app_handle); const bool already_exists = connections_.end() != connections_.find(connection_key); ConnectionInfo& info = connections_[connection_key]; if (!already_exists) { info.app_handle = app_handle; info.device_id = device_id; info.state = ConnectionInfo::NEW; } const bool pending_app = ConnectionInfo::PENDING == info.state; connections_lock_.Release(); if (already_exists && !pending_app) { SDL_LOG_TRACE("exit with ALREADY_EXISTS"); return ALREADY_EXISTS; } const TransportAdapter::Error err = server_connection_factory_->CreateConnection(device_id, app_handle); if (TransportAdapter::OK != err) { if (!pending_app) { RemoveConnection(device_id, app_handle); } } SDL_LOG_TRACE("exit with error: " << err); return err; } TransportAdapter::Error TransportAdapterImpl::ConnectDevice( const DeviceUID& device_handle) { SDL_LOG_TRACE("enter with device_handle: " << &device_handle); DeviceSptr device = FindDevice(device_handle); if (device) { TransportAdapter::Error err = ConnectDevice(device); if (FAIL == err && GetDeviceType() == DeviceType::CLOUD_WEBSOCKET) { SDL_LOG_TRACE("Error occurred while connecting cloud app: " << err); // Update retry count if (device->retry_count() >= get_settings().cloud_app_max_retry_attempts()) { device->reset_retry_count(); ConnectionStatusUpdated(device, ConnectionStatus::PENDING); return err; } else if (device->connection_status() == ConnectionStatus::PENDING) { ConnectionStatusUpdated(device, ConnectionStatus::RETRY); } device->next_retry(); // Start timer for next retry TimerSPtr retry_timer(std::make_shared<timer::Timer>( "RetryConnectionTimer", new timer::TimerTaskImpl<TransportAdapterImpl>( this, &TransportAdapterImpl::RetryConnection))); sync_primitives::AutoLock locker(retry_timer_pool_lock_); retry_timer_pool_.push(std::make_pair(retry_timer, device_handle)); retry_timer->Start(get_settings().cloud_app_retry_timeout(), timer::kSingleShot); } else if (OK == err) { ConnectionStatusUpdated(device, ConnectionStatus::CONNECTED); } SDL_LOG_TRACE("exit with error: " << err); return err; } else { SDL_LOG_TRACE("exit with BAD_PARAM"); return BAD_PARAM; } } void TransportAdapterImpl::RetryConnection() { ClearCompletedTimers(); const DeviceUID device_id = GetNextRetryDevice(); if (device_id.empty()) { SDL_LOG_ERROR("Unable to find timer, ignoring RetryConnection request"); return; } ConnectDevice(device_id); } void TransportAdapterImpl::ClearCompletedTimers() { // Cleanup any retry timers which have completed execution sync_primitives::AutoLock locker(completed_timer_pool_lock_); while (!completed_timer_pool_.empty()) { auto timer_entry = completed_timer_pool_.front(); if (timer_entry.first->is_completed()) { completed_timer_pool_.pop(); } } } DeviceUID TransportAdapterImpl::GetNextRetryDevice() { sync_primitives::AutoLock retry_locker(retry_timer_pool_lock_); if (retry_timer_pool_.empty()) { return std::string(); } auto timer_entry = retry_timer_pool_.front(); retry_timer_pool_.pop(); // Store reference for cleanup later sync_primitives::AutoLock completed_locker(completed_timer_pool_lock_); completed_timer_pool_.push(timer_entry); return timer_entry.second; } ConnectionStatus TransportAdapterImpl::GetConnectionStatus( const DeviceUID& device_handle) const { DeviceSptr device = FindDevice(device_handle); return device.use_count() == 0 ? ConnectionStatus::INVALID : device->connection_status(); } void TransportAdapterImpl::ConnectionStatusUpdated(DeviceSptr device, ConnectionStatus status) { device->set_connection_status(status); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectionStatusUpdated(this); } } TransportAdapter::Error TransportAdapterImpl::Disconnect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", device_id: " << &device_id); if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } ConnectionSPtr connection = FindEstablishedConnection(device_id, app_handle); if (connection) { TransportAdapter::Error err = connection->Disconnect(); SDL_LOG_TRACE("exit with error: " << err); return err; } else { SDL_LOG_TRACE("exit with BAD_PARAM"); return BAD_PARAM; } } TransportAdapter::Error TransportAdapterImpl::DisconnectDevice( const DeviceUID& device_id) { SDL_LOG_TRACE("enter. device_id: " << &device_id); if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } Error error = OK; DeviceSptr device = FindDevice(device_id); if (!device) { SDL_LOG_WARN("Device with id: " << device_id << " Not found"); return BAD_PARAM; } ConnectionStatusUpdated(device, ConnectionStatus::CLOSING); std::vector<ConnectionInfo> to_disconnect; connections_lock_.AcquireForReading(); for (ConnectionMap::const_iterator i = connections_.begin(); i != connections_.end(); ++i) { ConnectionInfo info = i->second; if (info.device_id == device_id && info.state != ConnectionInfo::FINALISING) { to_disconnect.push_back(info); } } connections_lock_.Release(); for (std::vector<ConnectionInfo>::const_iterator j = to_disconnect.begin(); j != to_disconnect.end(); ++j) { ConnectionInfo info = *j; if (OK != info.connection->Disconnect()) { error = FAIL; SDL_LOG_ERROR("Error on disconnect " << error); } } return error; } TransportAdapter::Error TransportAdapterImpl::SendData( const DeviceUID& device_id, const ApplicationHandle& app_handle, const ::protocol_handler::RawMessagePtr data) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle << ", data: " << data); if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } ConnectionSPtr connection = FindEstablishedConnection(device_id, app_handle); if (connection) { TransportAdapter::Error err = connection->SendData(data); SDL_LOG_TRACE("exit with error: " << err); return err; } else { SDL_LOG_TRACE("exit with BAD_PARAM"); return BAD_PARAM; } } TransportAdapter::Error TransportAdapterImpl::ChangeClientListening( TransportAction required_change) { SDL_LOG_AUTO_TRACE(); if (client_connection_listener_ == 0) { SDL_LOG_TRACE("exit with NOT_SUPPORTED"); return NOT_SUPPORTED; } if (!client_connection_listener_->IsInitialised()) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } TransportAdapter::Error err = TransportAdapter::Error::UNKNOWN; switch (required_change) { case transport_manager::TransportAction::kVisibilityOn: err = client_connection_listener_->StartListening(); break; case transport_manager::TransportAction::kListeningOn: err = client_connection_listener_->ResumeListening(); break; case transport_manager::TransportAction::kListeningOff: err = client_connection_listener_->SuspendListening(); { sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); ++it) { it->second->Stop(); } } break; case transport_manager::TransportAction::kVisibilityOff: err = client_connection_listener_->StopListening(); { sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); ++it) { it->second->Stop(); } } break; default: NOTREACHED(); } SDL_LOG_TRACE("Exit with error: " << err); return err; } DeviceList TransportAdapterImpl::GetDeviceList() const { SDL_LOG_AUTO_TRACE(); DeviceList devices; sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::const_iterator it = devices_.begin(); it != devices_.end(); ++it) { devices.push_back(it->first); } SDL_LOG_TRACE("exit with DeviceList. It's' size = " << devices.size()); return devices; } DeviceSptr TransportAdapterImpl::GetWebEngineDevice() const { #ifndef WEBSOCKET_SERVER_TRANSPORT_SUPPORT SDL_LOG_TRACE("Web engine support is disabled. Device does not exist"); return DeviceSptr(); #else SDL_LOG_AUTO_TRACE(); sync_primitives::AutoLock locker(devices_mutex_); auto web_engine_device = std::find_if(devices_.begin(), devices_.end(), [](const std::pair<DeviceUID, DeviceSptr> device) { return webengine_constants::kWebEngineDeviceName == device.second->name(); }); if (devices_.end() != web_engine_device) { return web_engine_device->second; } SDL_LOG_ERROR("WebEngine device not found!"); return std::make_shared<transport_adapter::WebSocketDevice>("", ""); #endif } DeviceSptr TransportAdapterImpl::AddDevice(DeviceSptr device) { SDL_LOG_AUTO_TRACE(); SDL_LOG_TRACE("enter. device: " << device); DeviceSptr existing_device; bool same_device_found = false; devices_mutex_.Acquire(); for (DeviceMap::const_iterator i = devices_.begin(); i != devices_.end(); ++i) { existing_device = i->second; if (device->IsSameAs(existing_device.get())) { same_device_found = true; SDL_LOG_DEBUG("Device " << device << " already exists"); break; } } if (!same_device_found) { devices_[device->unique_device_id()] = device; } devices_mutex_.Release(); if (same_device_found) { SDL_LOG_TRACE("Exit with TRUE. Condition: same_device_found"); return existing_device; } else { device->set_connection_status(ConnectionStatus::PENDING); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDeviceListUpdated(this); } if (ToBeAutoConnected(device)) { ConnectDevice(device); } SDL_LOG_TRACE("exit with DeviceSptr " << device); return device; } } void TransportAdapterImpl::SearchDeviceDone(const DeviceVector& devices) { SDL_LOG_TRACE("enter. devices: " << &devices); DeviceMap new_devices; for (DeviceVector::const_iterator it = devices.begin(); it != devices.end(); ++it) { DeviceSptr device = *it; bool device_found = false; devices_mutex_.Acquire(); for (DeviceMap::iterator iter = devices_.begin(); iter != devices_.end(); ++iter) { DeviceSptr existing_device = iter->second; if (device->IsSameAs(existing_device.get())) { existing_device->set_keep_on_disconnect(true); device_found = true; SDL_LOG_DEBUG("device found. DeviceSptr" << iter->second); break; } } devices_mutex_.Release(); if (!device_found) { SDL_LOG_INFO("Adding new device " << device->unique_device_id() << " (\"" << device->name() << "\")"); } device->set_keep_on_disconnect(true); new_devices[device->unique_device_id()] = device; } connections_lock_.AcquireForReading(); std::set<DeviceUID> connected_devices; for (ConnectionMap::const_iterator it = connections_.begin(); it != connections_.end(); ++it) { const ConnectionInfo& info = it->second; if (info.state != ConnectionInfo::FINALISING) { connected_devices.insert(info.device_id); } } connections_lock_.Release(); DeviceMap all_devices = new_devices; devices_mutex_.Acquire(); for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); ++it) { DeviceSptr existing_device = it->second; if (all_devices.end() == all_devices.find(it->first)) { if (connected_devices.end() != connected_devices.find(it->first)) { existing_device->set_keep_on_disconnect(false); all_devices[it->first] = existing_device; } } } devices_ = all_devices; devices_mutex_.Release(); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDeviceListUpdated(this); (*it)->OnSearchDeviceDone(this); } for (DeviceMap::iterator it = new_devices.begin(); it != new_devices.end(); ++it) { DeviceSptr device = it->second; if (ToBeAutoConnected(device)) { ConnectDevice(device); } } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::ApplicationListUpdated( const DeviceUID& device_handle) { // default implementation does nothing // and is reimplemented in MME transport adapter only } void TransportAdapterImpl::FindNewApplicationsRequest() { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator i = listeners_.begin(); i != listeners_.end(); ++i) { TransportAdapterListener* listener = *i; listener->OnFindNewApplicationsRequest(this); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::SearchDeviceFailed(const SearchDeviceError& error) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnSearchDeviceFailed(this, error); } SDL_LOG_TRACE("exit"); } bool TransportAdapterImpl::IsSearchDevicesSupported() const { SDL_LOG_AUTO_TRACE(); return device_scanner_ != 0; } bool TransportAdapterImpl::IsServerOriginatedConnectSupported() const { SDL_LOG_AUTO_TRACE(); return server_connection_factory_ != 0; } bool TransportAdapterImpl::IsClientOriginatedConnectSupported() const { SDL_LOG_AUTO_TRACE(); return client_connection_listener_ != 0; } void TransportAdapterImpl::ConnectionCreated( ConnectionSPtr connection, const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); SDL_LOG_TRACE("enter connection:" << connection << ", device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionInfo& info = connections_[std::make_pair(device_id, app_handle)]; info.app_handle = app_handle; info.device_id = device_id; info.connection = connection; info.state = ConnectionInfo::NEW; connections_lock_.Release(); } void TransportAdapterImpl::DeviceDisconnected( const DeviceUID& device_handle, const DisconnectDeviceError& error) { SDL_LOG_AUTO_TRACE(); const DeviceUID device_uid = device_handle; SDL_LOG_TRACE("enter. device_handle: " << &device_uid << ", error: " << &error); ApplicationList app_list = GetApplicationList(device_uid); for (ApplicationList::const_iterator i = app_list.begin(); i != app_list.end(); ++i) { ApplicationHandle app_handle = *i; for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnUnexpectedDisconnect( this, device_uid, app_handle, CommunicationError()); } } for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnDisconnectDeviceDone(this, device_uid); } for (ApplicationList::const_iterator i = app_list.begin(); i != app_list.end(); ++i) { ApplicationHandle app_handle = *i; RemoveConnection(device_uid, app_handle); } RemoveDevice(device_uid); SDL_LOG_TRACE("exit"); } bool TransportAdapterImpl::IsSingleApplication( const DeviceUID& device_uid, const ApplicationHandle& app_uid) { SDL_LOG_AUTO_TRACE(); sync_primitives::AutoReadLock locker(connections_lock_); for (ConnectionMap::const_iterator it = connections_.begin(); it != connections_.end(); ++it) { const DeviceUID& current_device_id = it->first.first; const ApplicationHandle& current_app_handle = it->first.second; if (current_device_id == device_uid && current_app_handle != app_uid) { SDL_LOG_DEBUG( "break. Condition: current_device_id == device_id && " "current_app_handle != app_handle"); return false; } } return true; } void TransportAdapterImpl::DisconnectDone(const DeviceUID& device_handle, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); const DeviceUID device_uid = device_handle; const ApplicationHandle app_uid = app_handle; SDL_LOG_TRACE("enter. device_id: " << &device_uid << ", app_handle: " << &app_uid); DeviceSptr device = FindDevice(device_handle); if (!device) { SDL_LOG_WARN("Device: uid " << &device_uid << " not found"); return; } bool device_disconnected = ToBeAutoDisconnected(device) && IsSingleApplication(device_uid, app_uid); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnDisconnectDone(this, device_uid, app_uid); if (device_disconnected) { listener->OnDisconnectDeviceDone(this, device_uid); } } RemoveConnection(device_uid, app_uid); if (device_disconnected) { SDL_LOG_DEBUG("Removing device..."); RemoveDevice(device_uid); } Store(); SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataReceiveDone( const DeviceUID& device_id, const ApplicationHandle& app_handle, ::protocol_handler::RawMessagePtr message) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle << ", message: " << message); #ifdef TELEMETRY_MONITOR if (metric_observer_) { metric_observer_->StartRawMsg(message.get()); } #endif // TELEMETRY_MONITOR for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataReceiveDone(this, device_id, app_handle, message); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataReceiveFailed( const DeviceUID& device_id, const ApplicationHandle& app_handle, const DataReceiveError& error) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataReceiveFailed(this, device_id, app_handle, error); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataSendDone( const DeviceUID& device_id, const ApplicationHandle& app_handle, ::protocol_handler::RawMessagePtr message) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataSendDone(this, device_id, app_handle, message); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataSendFailed( const DeviceUID& device_id, const ApplicationHandle& app_handle, ::protocol_handler::RawMessagePtr message, const DataSendError& error) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataSendFailed(this, device_id, app_handle, message, error); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::TransportConfigUpdated( const TransportConfig& new_config) { SDL_LOG_AUTO_TRACE(); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnTransportConfigUpdated(this); } } void TransportAdapterImpl::DoTransportSwitch() const { SDL_LOG_AUTO_TRACE(); std::for_each( listeners_.begin(), listeners_.end(), std::bind2nd( std::mem_fun(&TransportAdapterListener::OnTransportSwitchRequested), this)); } void TransportAdapterImpl::DeviceSwitched(const DeviceUID& device_handle) { SDL_LOG_DEBUG("Switching is not implemented for that adapter type " << GetConnectionType().c_str()); UNUSED(device_handle); } ConnectionSPtr TransportAdapterImpl::FindPendingConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) const { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); ConnectionSPtr connection; connections_lock_.AcquireForReading(); ConnectionMap::const_iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { const ConnectionInfo& info = it->second; if (info.state == ConnectionInfo::PENDING) { connection = info.connection; } } connections_lock_.Release(); SDL_LOG_TRACE("exit with Connection: " << connection); return connection; } DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const { SDL_LOG_TRACE("enter. device_id: " << &device_id); DeviceSptr ret; sync_primitives::AutoLock locker(devices_mutex_); SDL_LOG_DEBUG("devices_.size() = " << devices_.size()); DeviceMap::const_iterator it = devices_.find(device_id); if (it != devices_.end()) { ret = it->second; } else { SDL_LOG_WARN("Device " << device_id << " not found."); } SDL_LOG_TRACE("exit with DeviceSptr: " << ret); return ret; } void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); connections_lock_.AcquireForWriting(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); if (it_conn != connections_.end()) { ConnectionInfo& info = it_conn->second; info.state = ConnectionInfo::PENDING; } connections_lock_.Release(); DeviceSptr device = FindDevice(device_id); if (device.use_count() == 0) { SDL_LOG_ERROR( "Unable to find device, cannot set connection pending status"); return; } else { device->set_connection_status(ConnectionStatus::PENDING); } for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectPending(this, device_id, app_handle); } } void TransportAdapterImpl::ConnectDone(const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); if (it_conn != connections_.end()) { ConnectionInfo& info = it_conn->second; info.state = ConnectionInfo::ESTABLISHED; } connections_lock_.Release(); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectDone(this, device_id, app_handle); } Store(); SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::ConnectFailed(const DeviceUID& device_handle, const ApplicationHandle& app_handle, const ConnectError& error) { const DeviceUID device_uid = device_handle; const ApplicationHandle app_uid = app_handle; SDL_LOG_TRACE("enter. device_id: " << &device_uid << ", app_handle: " << &app_uid << ", error: " << &error); RemoveConnection(device_uid, app_uid); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectFailed(this, device_uid, app_uid, error); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::RemoveFinalizedConnection( const DeviceUID& device_handle, const ApplicationHandle& app_handle) { const DeviceUID device_uid = device_handle; SDL_LOG_AUTO_TRACE(); { connections_lock_.AcquireForWriting(); auto it_conn = connections_.find(std::make_pair(device_uid, app_handle)); if (connections_.end() == it_conn) { SDL_LOG_WARN("Device_id: " << &device_uid << ", app_handle: " << &app_handle << " connection not found"); connections_lock_.Release(); return; } const ConnectionInfo& info = it_conn->second; if (ConnectionInfo::FINALISING != info.state) { SDL_LOG_WARN("Device_id: " << &device_uid << ", app_handle: " << &app_handle << " connection not finalized"); connections_lock_.Release(); return; } // By copying the info.connection shared pointer into this local variable, // we can delay the connection's destructor until after // connections_lock_.Release. SDL_LOG_DEBUG( "RemoveFinalizedConnection copying connection with Device_id: " << &device_uid << ", app_handle: " << &app_handle); ConnectionSPtr connection = info.connection; connections_.erase(it_conn); connections_lock_.Release(); SDL_LOG_DEBUG("RemoveFinalizedConnection Connections Lock Released"); } DeviceSptr device = FindDevice(device_handle); if (!device) { SDL_LOG_WARN("Device: uid " << &device_uid << " not found"); return; } if (ToBeAutoDisconnected(device) && IsSingleApplication(device_handle, app_handle)) { RemoveDevice(device_uid); } } void TransportAdapterImpl::RemoveConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); ConnectionSPtr connection; connections_lock_.AcquireForWriting(); ConnectionMap::const_iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { // By copying the connection from the map to this shared pointer, // we can erase the object from the map without triggering the destructor SDL_LOG_DEBUG("Copying connection with Device_id: " << &device_id << ", app_handle: " << &app_handle); connection = it->second.connection; connections_.erase(it); } connections_lock_.Release(); SDL_LOG_DEBUG("Connections Lock Released"); // And now, "connection" goes out of scope, triggering the destructor outside // of the "connections_lock_" } void TransportAdapterImpl::AddListener(TransportAdapterListener* listener) { SDL_LOG_TRACE("enter"); listeners_.push_back(listener); SDL_LOG_TRACE("exit"); } ApplicationList TransportAdapterImpl::GetApplicationList( const DeviceUID& device_id) const { SDL_LOG_TRACE("enter. device_id: " << &device_id); DeviceSptr device = FindDevice(device_id); if (device.use_count() != 0) { ApplicationList lst = device->GetApplicationList(); SDL_LOG_TRACE("exit with ApplicationList. It's size = " << lst.size() << " Condition: device.use_count() != 0"); return lst; } SDL_LOG_TRACE( "exit with empty ApplicationList. Condition: NOT " "device.use_count() != 0"); return ApplicationList(); } void TransportAdapterImpl::ConnectionFinished( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionMap::iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { ConnectionInfo& info = it->second; info.state = ConnectionInfo::FINALISING; } connections_lock_.Release(); } void TransportAdapterImpl::ConnectionAborted( const DeviceUID& device_id, const ApplicationHandle& app_handle, const CommunicationError& error) { SDL_LOG_AUTO_TRACE(); ConnectionFinished(device_id, app_handle); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnUnexpectedDisconnect(this, device_id, app_handle, error); } } bool TransportAdapterImpl::IsInitialised() const { SDL_LOG_TRACE("enter"); if (!initialised_) { SDL_LOG_TRACE("exit with FALSE. Condition: !initialised_"); return false; } if (device_scanner_ && !device_scanner_->IsInitialised()) { SDL_LOG_TRACE( "exit with FALSE. Condition: device_scanner_ && " "!device_scanner_->IsInitialised()"); return false; } if (server_connection_factory_ && !server_connection_factory_->IsInitialised()) { SDL_LOG_TRACE( "exit with FALSE. Condition: server_connection_factory_ && " "!server_connection_factory_->IsInitialised()"); return false; } if (client_connection_listener_ && !client_connection_listener_->IsInitialised()) { SDL_LOG_TRACE( "exit with FALSE. Condition: client_connection_listener_ && " "!client_connection_listener_->IsInitialised()"); return false; } SDL_LOG_TRACE("exit with TRUE"); return true; } std::string TransportAdapterImpl::DeviceName(const DeviceUID& device_id) const { DeviceSptr device = FindDevice(device_id); if (device.use_count() != 0) { return device->name(); } else { return ""; } } void TransportAdapterImpl::StopDevice(const DeviceUID& device_id) const { SDL_LOG_AUTO_TRACE(); DeviceSptr device = FindDevice(device_id); if (device) { device->Stop(); } } std::string TransportAdapterImpl::GetConnectionType() const { return devicesType[GetDeviceType()]; } SwitchableDevices TransportAdapterImpl::GetSwitchableDevices() const { SDL_LOG_AUTO_TRACE(); SwitchableDevices devices; sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::const_iterator it = devices_.begin(); it != devices_.end(); ++it) { const auto device_uid = it->first; const auto device = it->second; const auto transport_switch_id = device->transport_switch_id(); if (transport_switch_id.empty()) { SDL_LOG_DEBUG("Device is not suitable for switching: " << device_uid); continue; } SDL_LOG_DEBUG("Device is suitable for switching: " << device_uid); devices.insert(std::make_pair(device_uid, transport_switch_id)); } SDL_LOG_INFO("Found number of switchable devices: " << devices.size()); return devices; } #ifdef TELEMETRY_MONITOR void TransportAdapterImpl::SetTelemetryObserver(TMTelemetryObserver* observer) { metric_observer_ = observer; } #endif // TELEMETRY_MONITOR #ifdef TELEMETRY_MONITOR TMTelemetryObserver* TransportAdapterImpl::GetTelemetryObserver() { return metric_observer_; } #endif // TELEMETRY_MONITOR void TransportAdapterImpl::Store() const {} bool TransportAdapterImpl::Restore() { return true; } bool TransportAdapterImpl::ToBeAutoConnected(DeviceSptr device) const { return false; } bool TransportAdapterImpl::ToBeAutoDisconnected(DeviceSptr device) const { SDL_LOG_AUTO_TRACE(); return true; } ConnectionSPtr TransportAdapterImpl::FindEstablishedConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) const { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); ConnectionSPtr connection; connections_lock_.AcquireForReading(); ConnectionMap::const_iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { const ConnectionInfo& info = it->second; if (info.state == ConnectionInfo::ESTABLISHED) { connection = info.connection; } } connections_lock_.Release(); SDL_LOG_TRACE("exit with Connection: " << connection); return connection; } TransportAdapter::Error TransportAdapterImpl::ConnectDevice(DeviceSptr device) { SDL_LOG_TRACE("enter. device: " << device); DeviceUID device_id = device->unique_device_id(); ApplicationList app_list = device->GetApplicationList(); SDL_LOG_INFO("Device " << device->name() << " has " << app_list.size() << " applications."); bool errors_occurred = false; for (ApplicationList::iterator it = app_list.begin(); it != app_list.end(); ++it) { const ApplicationHandle app_handle = *it; SDL_LOG_DEBUG("Attempt to connect device " << device_id << ", channel " << app_handle); const Error error = Connect(device_id, app_handle); switch (error) { case OK: SDL_LOG_DEBUG("error = OK"); break; case ALREADY_EXISTS: SDL_LOG_DEBUG("error = ALREADY_EXISTS"); break; default: SDL_LOG_ERROR("Connect to device " << device_id << ", channel " << app_handle << " failed with error " << error); errors_occurred = true; SDL_LOG_DEBUG("switch (error), default case"); break; } } if (errors_occurred) { SDL_LOG_TRACE("exit with error:FAIL"); return FAIL; } else { SDL_LOG_TRACE("exit with error:OK"); return OK; } } void TransportAdapterImpl::RunAppOnDevice(const DeviceUID& device_uid, const std::string& bundle_id) { SDL_LOG_AUTO_TRACE(); DeviceSptr device = FindDevice(device_uid); if (!device) { SDL_LOG_WARN("Device with id: " << device_uid << " Not found" << "withing list of connected deviced"); return; } device->LaunchApp(bundle_id); } void TransportAdapterImpl::RemoveDevice(const DeviceUID& device_handle) { SDL_LOG_AUTO_TRACE(); SDL_LOG_DEBUG("Remove Device_handle: " << &device_handle); sync_primitives::AutoLock locker(devices_mutex_); DeviceMap::iterator i = devices_.find(device_handle); if (i != devices_.end()) { DeviceSptr device = i->second; bool is_cloud_device = (GetDeviceType() == DeviceType::CLOUD_WEBSOCKET); if (!device->keep_on_disconnect() || is_cloud_device) { devices_.erase(i); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnDeviceListUpdated(this); } } } } } // namespace transport_adapter } // namespace transport_manager
33.517703
80
0.682284
Sohei-Suzuki-Nexty
4484654fc9ccf6f86d73476a16d233513532cfec
2,099
cc
C++
leet_code/Multiply_Strings/solve.cc
ldy121/algorithm
7939cb4c15e2bc655219c934f00c2bb74ddb4eec
[ "Apache-2.0" ]
1
2020-04-11T22:04:23.000Z
2020-04-11T22:04:23.000Z
leet_code/Multiply_Strings/solve.cc
ldy121/algorithm
7939cb4c15e2bc655219c934f00c2bb74ddb4eec
[ "Apache-2.0" ]
null
null
null
leet_code/Multiply_Strings/solve.cc
ldy121/algorithm
7939cb4c15e2bc655219c934f00c2bb74ddb4eec
[ "Apache-2.0" ]
null
null
null
class Solution { public: string multiply(string num1, string num2) { vector<string> partial_result; string digit = ""; for_each(num2.rbegin(), num2.rend(), [&num1, &digit, &partial_result](const auto ch2) { const auto op2 = ch2 - '0'; auto carry = 0; string val = digit; for_each(num1.rbegin(), num1.rend(), [&carry, &val, &op2](const auto ch1){ const auto op1 = ch1 - '0'; const auto digit_result = op1 * op2 + carry; val = val + (char)(digit_result % 10 + '0'); carry = digit_result / 10; }); if (carry > 0) { val = val + (char)(carry + '0'); } partial_result.push_back(val); digit += "0"; }); string ret = partial_result[partial_result.size() - 1]; for (int i = partial_result.size() - 2; i >= 0; --i) { auto j = 0; auto carry = 0; while (j < ret.length() && j < partial_result[i].length()) { auto op1 = ret[j] - '0'; auto op2 = partial_result[i][j] - '0'; auto val = op1 + op2 + carry; carry = val / 10; ret[j++] = (char)(val % 10 + '0'); } while (carry > 0) { if (j == ret.length()) { ret.push_back((char)(carry + '0')); break; } else { auto op = ret[j] - '0'; auto val = op + carry; ret[j] = (char)(val % 10 + '0'); carry = val / 10; } ++j; } } reverse(ret.begin(), ret.end()); for (auto i = 0; i <= ret.length(); ++i) { if (i == ret.length()) { ret = "0"; break; } if (ret[i] != '0') { break; } } return ret; } };
31.80303
95
0.370176
ldy121
44880f86d0d5604e40a1f2a807b1b29becbc23f0
5,080
hpp
C++
src/multimap.hpp
nfagan/categorical
4a309a07debd654d4e69cb80b58fd9c31cf888cc
[ "MIT" ]
null
null
null
src/multimap.hpp
nfagan/categorical
4a309a07debd654d4e69cb80b58fd9c31cf888cc
[ "MIT" ]
null
null
null
src/multimap.hpp
nfagan/categorical
4a309a07debd654d4e69cb80b58fd9c31cf888cc
[ "MIT" ]
null
null
null
// // multimap.hpp // bit_array-test // // Created by Nick Fagan on 3/12/18. // #pragma once #include <unordered_map> #include <stdexcept> #include <vector> #include <cstdint> namespace util { template<typename K, typename V> class multimap; } template<typename K, typename V> class util::multimap { public: multimap() = default; ~multimap() = default; multimap(const util::multimap<K, V>& other); multimap(multimap&& rhs) noexcept; multimap& operator=(const multimap& other); multimap& operator=(multimap&& rhs) noexcept; auto find(const K& key) const; auto find(const V& key) const; auto endk() const; auto endv() const; std::vector<K> keys() const; std::vector<V> values() const; V at(const K& key) const; K at(const V& key) const; const V& ref_at(const K& key) const; const K& ref_at(const V& key) const; size_t erase(K key); size_t erase(V key); size_t size() const; bool contains(const K& key) const; bool contains(const V& key) const; void insert(K key, V value); private: std::unordered_map<K, V> m_kv; std::unordered_map<V, K> m_vk; }; // // impl // template<typename K, typename V> util::multimap<K, V>::multimap(const util::multimap<K, V>& rhs) : m_kv(rhs.m_kv), m_vk(rhs.m_vk) { // } template<typename K, typename V> util::multimap<K, V>& util::multimap<K, V>::operator=(const util::multimap<K, V>& rhs) { util::multimap<K, V> tmp(rhs); *this = std::move(tmp); return *this; } template<typename K, typename V> util::multimap<K, V>::multimap(util::multimap<K, V>&& rhs) noexcept : m_kv(std::move(rhs.m_kv)), m_vk(std::move(rhs.m_vk)) { // } template<typename K, typename V> util::multimap<K, V>& util::multimap<K, V>::operator=(util::multimap<K, V>&& rhs) noexcept { m_kv = std::move(rhs.m_kv); m_vk = std::move(rhs.m_vk); return *this; } template<typename K, typename V> V util::multimap<K, V>::at(const K& key) const { auto it = m_kv.find(key); if (it == m_kv.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> K util::multimap<K, V>::at(const V& key) const { auto it = m_vk.find(key); if (it == m_vk.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> const V& util::multimap<K, V>::ref_at(const K &key) const { const auto it = m_kv.find(key); if (it == m_kv.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> const K& util::multimap<K, V>::ref_at(const V &key) const { const auto it = m_vk.find(key); if (it == m_vk.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> void util::multimap<K, V>::insert(K key, V value) { auto ita = m_kv.find(key); auto itb = m_vk.find(value); if (ita != m_kv.end()) { m_vk.erase(ita->second); } if (itb != m_vk.end()) { m_kv.erase(itb->second); } m_kv[key] = value; m_vk[value] = key; } template<typename K, typename V> bool util::multimap<K, V>::contains(const K& key) const { return m_kv.find(key) != m_kv.end(); } template<typename K, typename V> bool util::multimap<K, V>::contains(const V& key) const { return m_vk.find(key) != m_vk.end(); } template<typename K, typename V> std::vector<K> util::multimap<K, V>::keys() const { std::vector<K> res; for (const auto& it : m_kv) { res.push_back(it.first); } return res; } template<typename K, typename V> std::vector<V> util::multimap<K, V>::values() const { std::vector<V> res; for (const auto& it : m_kv) { res.push_back(it.second); } return res; } template<typename K, typename V> size_t util::multimap<K, V>::erase(K key) { auto it = m_kv.find(key); if (it == m_kv.end()) { return 0; } m_vk.erase(it->second); m_kv.erase(key); return 1; } template<typename K, typename V> size_t util::multimap<K, V>::erase(V key) { auto it = m_vk.find(key); if (it == m_vk.end()) { return 0; } m_kv.erase(it->second); m_vk.erase(key); return 1; } template<typename K, typename V> size_t util::multimap<K, V>::size() const { return m_kv.size(); } template<typename K, typename V> auto util::multimap<K, V>::find(const K& key) const { return m_kv.find(key); } template<typename K, typename V> auto util::multimap<K, V>::find(const V& key) const { return m_vk.find(key); } template<typename K, typename V> auto util::multimap<K, V>::endk() const { return m_kv.end(); } template<typename K, typename V> auto util::multimap<K, V>::endv() const { return m_vk.end(); }
18.608059
90
0.58878
nfagan
44893b29c83a6e917f4d6f2b35baf0c92b912a41
6,472
cpp
C++
external/rapidcheck/test/state/IntegrationTests.cpp
XzoRit/cpp_rapidcheck
292c9943569e52e29fbd11abd31a965efc699a8e
[ "BSL-1.0" ]
876
2015-01-29T00:48:46.000Z
2022-03-23T00:24:34.000Z
test/state/IntegrationTests.cpp
wuerges/rapidcheck
d2e0481b28b77fcd0c7ead9af1e8227ee9982739
[ "BSD-2-Clause" ]
199
2015-05-18T07:04:40.000Z
2022-03-23T02:37:15.000Z
test/state/IntegrationTests.cpp
wuerges/rapidcheck
d2e0481b28b77fcd0c7ead9af1e8227ee9982739
[ "BSD-2-Clause" ]
162
2015-03-12T20:19:31.000Z
2022-03-14T08:42:52.000Z
#include <catch2/catch.hpp> #include <rapidcheck/catch.h> #include <rapidcheck/state.h> #include "util/GenUtils.h" using namespace rc; using namespace rc::test; namespace { struct Bag { std::vector<int> items; bool open = false; }; using BagCommand = state::Command<Bag, Bag>; struct Open : public BagCommand { void checkPreconditions(const Model &s0) const override { RC_PRE(!s0.open); } void apply(Model &s0) const override { s0.open = true; } void run(const Model &s0, Sut &sut) const override { sut.open = true; } void show(std::ostream &os) const override { os << "Open"; } }; struct Close : public BagCommand { void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); } void apply(Model &s0) const override { s0.open = false; } void run(const Model &s0, Sut &sut) const override { sut.open = false; } void show(std::ostream &os) const override { os << "Close"; } }; struct Add : public BagCommand { int item = *gen::inRange<int>(0, 10); void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); } void apply(Model &s0) const override { s0.items.push_back(item); } void run(const Model &s0, Sut &sut) const override { sut.items.push_back(item); } void show(std::ostream &os) const override { os << "Add(" << item << ")"; } }; struct Del : public BagCommand { std::size_t index; explicit Del(const Bag &s0) { index = *gen::inRange<std::size_t>(0, s0.items.size()); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(index < s0.items.size()); } void apply(Model &s0) const override { auto s1 = s0; s0.items.erase(begin(s0.items) + index); } void run(const Model &s0, Sut &sut) const override { sut.items.erase(begin(sut.items) + index); } void show(std::ostream &os) const override { os << "Del(" << index << ")"; } }; struct BuggyGet : public BagCommand { std::size_t index; explicit BuggyGet(const Bag &s0) { index = *gen::inRange<std::size_t>(0, s0.items.size()); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(index < s0.items.size()); } void run(const Model &s0, Sut &sut) const override { RC_ASSERT(sut.items.size() < 2U); RC_ASSERT(sut.items[index] == s0.items[index]); } void show(std::ostream &os) const override { os << "BuggyGet(" << index << ")"; } }; struct BuggyDelAll : public BagCommand { int value; explicit BuggyDelAll(const Bag &s0) { value = *gen::elementOf(s0.items); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(std::find(begin(s0.items), end(s0.items), value) != end(s0.items)); } void apply(Model &s0) const override { s0.items.erase(std::remove(begin(s0.items), end(s0.items), value), end(s0.items)); } void run(const Model &s0, Sut &sut) const override { RC_FAIL("Bug!"); } void show(std::ostream &os) const override { os << "BuggyDelAll(" << value << ")"; } }; struct SneakyBuggyGet : public BagCommand { int value; explicit SneakyBuggyGet(const Bag &s0) { value = *gen::elementOf(s0.items); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(std::find(begin(s0.items), end(s0.items), value) != end(s0.items)); } void run(const Model &s0, Sut &sut) const override { RC_ASSERT(value != 2); } void show(std::ostream &os) const override { os << "SneakyBuggyGet(" << value << ")"; } }; template <typename Cmd> std::vector<std::string> showCommands(const state::Commands<Cmd> &commands) { std::vector<std::string> cmdStrings; cmdStrings.reserve(commands.size()); for (const auto &cmd : commands) { std::ostringstream ss; cmd->show(ss); cmdStrings.push_back(ss.str()); } return cmdStrings; } template <typename Cmd> state::Commands<Cmd> findMinCommands(const GenParams &params, const Gen<state::Commands<Cmd>> &gen, const typename Cmd::Model &s0) { return searchGen(params.random, params.size, gen, [=](const state::Commands<Cmd> &cmds) { try { typename Cmd::Sut sut; runAll(cmds, s0, sut); } catch (...) { return true; } return false; }); } } // namespace TEST_CASE("state integration tests") { prop( "should find minimum when some commands might fail to generate while " "shrinking", [](const GenParams &params) { Bag s0; const auto gen = state::gen::commands( s0, state::gen::execOneOfWithArgs<Open, Close, Add, Del, BuggyGet>()); const auto commands = findMinCommands(params, gen, s0); const auto cmdStrings = showCommands(commands); RC_ASSERT(cmdStrings.size() == 4U); RC_ASSERT(cmdStrings[0] == "Open"); RC_ASSERT(cmdStrings[1] == "Add(0)"); RC_ASSERT(cmdStrings[2] == "Add(0)"); RC_ASSERT((cmdStrings[3] == "BuggyGet(0)") || (cmdStrings[3] == "BuggyGet(1)")); }); prop( "should find minimum when later commands depend on the shrunk values of " "previous commands", [](const GenParams &params) { Bag s0; const auto gen = state::gen::commands( s0, state::gen:: execOneOfWithArgs<Open, Close, Add, Del, BuggyDelAll>()); const auto commands = findMinCommands(params, gen, s0); const auto cmdStrings = showCommands(commands); std::vector<std::string> expected{"Open", "Add(0)", "BuggyDelAll(0)"}; RC_ASSERT(cmdStrings == expected); }); prop( "should find minimum when later commands depend on the specific values " "of previous commands", [](const GenParams &params) { Bag s0; const auto gen = state::gen::commands( s0, state::gen:: execOneOfWithArgs<Open, Close, Add, Del, SneakyBuggyGet>()); const auto commands = findMinCommands(params, gen, s0); const auto cmdStrings = showCommands(commands); std::vector<std::string> expected{ "Open", "Add(2)", "SneakyBuggyGet(2)"}; RC_ASSERT(cmdStrings == expected); }); }
29.285068
79
0.599197
XzoRit
448974faa03164e424ded9451b92a2d0f1423ab7
10,608
hpp
C++
source/Leaderboard.hpp
acodcha/catan-stratification
12c45cbf0f97727cc1c8d8c243ce5d0f2468843b
[ "MIT" ]
1
2020-10-07T01:03:32.000Z
2020-10-07T01:03:32.000Z
source/Leaderboard.hpp
acodcha/catan-stratification
12c45cbf0f97727cc1c8d8c243ce5d0f2468843b
[ "MIT" ]
null
null
null
source/Leaderboard.hpp
acodcha/catan-stratification
12c45cbf0f97727cc1c8d8c243ce5d0f2468843b
[ "MIT" ]
1
2021-09-22T03:02:41.000Z
2021-09-22T03:02:41.000Z
#pragma once #include "DataFileWriter.hpp" #include "GlobalAveragePointsGnuplotFileWriter.hpp" #include "GlobalEloRatingGnuplotFileWriter.hpp" #include "GlobalPlacePercentageGnuplotFileWriter.hpp" #include "IndividualAveragePointsGnuplotFileWriter.hpp" #include "IndividualEloRatingGnuplotFileWriter.hpp" #include "IndividualPlacePercentageGnuplotFileWriter.hpp" #include "LeaderboardGlobalFileWriter.hpp" #include "LeaderboardIndividualFileWriter.hpp" namespace CatanRanker { /// \brief Class that writes all leaderboard files given games and players data. class Leaderboard { public: Leaderboard(const std::experimental::filesystem::path& base_directory, const Games& games, const Players& players) { if (!base_directory.empty()) { create_directories(base_directory, players); write_data_files(base_directory, players); write_global_gnuplot_files(base_directory, players); write_player_gnuplot_files(base_directory, players); write_global_leaderboard_file(base_directory, games, players); write_player_leaderboard_files(base_directory, games, players); generate_global_plots(base_directory); generate_player_plots(base_directory, players); } } protected: void create_directories(const std::experimental::filesystem::path& base_directory, const Players& players) { create(base_directory); create(base_directory / Path::PlayersDirectoryName); create(base_directory / Path::MainPlotsDirectoryName); for (const Player& player : players) { create(base_directory / player.name().directory_name()); create(base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName); create(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName); } } void write_data_files(const std::experimental::filesystem::path& base_directory, const Players& players) noexcept { for (const Player& player : players) { for (const GameCategory game_category : GameCategories) { if (!player[game_category].empty()) { DataFileWriter{ base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(game_category), player_table(player, game_category) }; } } } message("Wrote the data files."); } void write_global_gnuplot_files(const std::experimental::filesystem::path& base_directory, const Players& players) noexcept { for (const GameCategory game_category : GameCategories) { std::map<PlayerName, std::experimental::filesystem::path, PlayerName::sort> data_paths; for (const Player& player : players) { if (!player[game_category].empty() && !player.color().empty()) { data_paths.insert({ player.name(), base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(game_category) }); } } if (!data_paths.empty()) { GlobalEloRatingVsGameNumberGnuplotFileWriter{ base_directory / Path::MainPlotsDirectoryName / Path::global_elo_rating_vs_game_number_file_name(game_category), players, data_paths, game_category }; GlobalAveragePointsVsGameNumberGnuplotFileWriter{ base_directory / Path::MainPlotsDirectoryName / Path::global_average_points_vs_game_number_file_name(game_category), players, data_paths }; GlobalPlacePercentageVsGameNumberGnuplotFileWriter{ base_directory / Path::MainPlotsDirectoryName / Path::global_place_percentage_vs_game_number_file_name(game_category, {1}), players, data_paths, game_category, {1} }; } } message("Wrote the global Gnuplot files."); } void write_player_gnuplot_files(const std::experimental::filesystem::path& base_directory, const Players& players) noexcept { for (const Player& player : players) { std::map<GameCategory, std::experimental::filesystem::path> data_paths; for (const GameCategory game_category : GameCategories) { // Only generate a plot if this player has at least 2 games in this game category. if (player[game_category].size() >= 2) { data_paths.insert({ game_category, base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(game_category) }); } } if (!data_paths.empty()) { IndividualEloRatingVsGameNumberGnuplotFileWriter{ base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerEloRatingVsGameNumberFileName, data_paths, player.lowest_elo_rating(), player.highest_elo_rating() }; IndividualAveragePointsVsGameNumberGnuplotFileWriter{ base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerAveragePointsVsGameNumberFileName, data_paths }; } if (player[GameCategory::AnyNumberOfPlayers].size() >= 2) { IndividualPlacePercentageVsGameNumberGnuplotFileWriter{ base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::individual_place_percentage_vs_game_number_file_name(GameCategory::AnyNumberOfPlayers), base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(GameCategory::AnyNumberOfPlayers), GameCategory::AnyNumberOfPlayers }; } } message("Wrote the individual player Gnuplot files."); } void write_global_leaderboard_file(const std::experimental::filesystem::path& base_directory, const Games& games, const Players& players) noexcept { LeaderboardGlobalFileWriter{base_directory, games, players}; message("Wrote the global leaderboard Markdown file."); } void write_player_leaderboard_files(const std::experimental::filesystem::path& base_directory, const Games& games, const Players& players) noexcept { for (const Player& player : players) { LeaderboardIndividualFileWriter{base_directory, games, player}; } message("Wrote the individual player leaderboard Markdown files."); } void generate_global_plots(const std::experimental::filesystem::path& base_directory) const { message("Generating the global plots..."); for (const GameCategory game_category : GameCategories) { generate_plot(base_directory / Path::MainPlotsDirectoryName / Path::global_elo_rating_vs_game_number_file_name(game_category)); generate_plot(base_directory / Path::MainPlotsDirectoryName / Path::global_average_points_vs_game_number_file_name(game_category)); for (const Place& place : PlacesFirstSecondThird) { generate_plot(base_directory / Path::MainPlotsDirectoryName / Path::global_place_percentage_vs_game_number_file_name(game_category, place)); } } message("Generated the global plots."); } void generate_player_plots(const std::experimental::filesystem::path& base_directory, const Players& players) const { message("Generating the individual player plots..."); for (const Player& player : players) { generate_plot(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerAveragePointsVsGameNumberFileName); generate_plot(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerEloRatingVsGameNumberFileName); for (const GameCategory game_category : GameCategories) { generate_plot(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::individual_place_percentage_vs_game_number_file_name(game_category)); } } message("Generated the individual player plots."); } /// \brief Generate a plot using Gnuplot. If the path points to a file that does not exist, no plot is generated. void generate_plot(const std::experimental::filesystem::path& path) const { if (std::experimental::filesystem::exists(path)) { const std::string command{"gnuplot " + path.string()}; const int outcome{std::system(command.c_str())}; if (outcome != 0) { error("Could not run the command: " + command); } } } Table player_table(const Player& player, const GameCategory game_category) const noexcept { Column game_number{"Game#"}; Column game_category_game_number{"GameCategory#"}; Column player_game_number{"PlayerGame#"}; Column player_game_category_game_number{"PlayerCategoryGame#"}; Column date{"Date"}; Column average_elo_rating{"AvgRating"}; Column elo_rating{"CurrentRating"}; Column average_points_per_game{"AvgPoints"}; Column first_place_percentage{"1stPlace%"}; Column second_place_percentage{"2ndPlace%"}; Column third_place_percentage{"3rdPlace%"}; Column first_or_second_place_percentage{"1stOr2ndPlace%"}; Column first_or_second_or_third_place_percentage{"1stOr2ndOr3rdPlace%"}; if (!player[game_category].empty()) { for (const PlayerProperties& properties : player[game_category]) { game_number.add_row(properties.game_number()); game_category_game_number.add_row(properties.game_category_game_number()); player_game_number.add_row(properties.player_game_number()); player_game_category_game_number.add_row(properties.player_game_category_game_number()); date.add_row(properties.date()); average_elo_rating.add_row(properties.average_elo_rating()); elo_rating.add_row(properties.elo_rating()); average_points_per_game.add_row(properties.average_points_per_game(), 7); first_place_percentage.add_row(properties.place_percentage({1}), 5); second_place_percentage.add_row(properties.place_percentage({2}), 5); third_place_percentage.add_row(properties.place_percentage({3}), 5); first_or_second_place_percentage.add_row(properties.place_percentage({1}) + properties.place_percentage({2}), 5); first_or_second_or_third_place_percentage.add_row(properties.place_percentage({1}) + properties.place_percentage({2}) + properties.place_percentage({3}), 5); } } return {{game_number, game_category_game_number, player_game_number, player_game_category_game_number, date, average_elo_rating, elo_rating, average_points_per_game, first_place_percentage, second_place_percentage, third_place_percentage, first_or_second_place_percentage, first_or_second_or_third_place_percentage}}; } }; } // namespace CatanRanker
51.495146
321
0.737651
acodcha
44899f636f113100199f92c07fd982e9ff82d266
2,160
cpp
C++
src/energy/soft_volume_constraint.cpp
Conrekatsu/repulsive-surfaces
74d6a16e6ca55c8296fa5a49757c2318bea62a84
[ "MIT" ]
35
2021-12-13T09:58:08.000Z
2022-03-30T11:03:01.000Z
src/energy/soft_volume_constraint.cpp
Conrekatsu/repulsive-surfaces
74d6a16e6ca55c8296fa5a49757c2318bea62a84
[ "MIT" ]
null
null
null
src/energy/soft_volume_constraint.cpp
Conrekatsu/repulsive-surfaces
74d6a16e6ca55c8296fa5a49757c2318bea62a84
[ "MIT" ]
3
2022-02-25T06:46:34.000Z
2022-03-16T05:46:53.000Z
#include "energy/soft_volume_constraint.h" #include "matrix_utils.h" #include "surface_derivatives.h" namespace rsurfaces { SoftVolumeConstraint::SoftVolumeConstraint(MeshPtr mesh_, GeomPtr geom_, double weight_) { mesh = mesh_; geom = geom_; weight = weight_; initialVolume = totalVolume(geom, mesh); } inline double volumeDeviation(MeshPtr mesh, GeomPtr geom, double initialValue) { return (totalVolume(geom, mesh) - initialValue) / initialValue; } // Returns the current value of the energy. double SoftVolumeConstraint::Value() { double volDev = volumeDeviation(mesh, geom, initialVolume); return weight * (volDev * volDev); } // Returns the current differential of the energy, stored in the given // V x 3 matrix, where each row holds the differential (a 3-vector) with // respect to the corresponding vertex. void SoftVolumeConstraint::Differential(Eigen::MatrixXd &output) { double volDev = volumeDeviation(mesh, geom, initialVolume); VertexIndices inds = mesh->getVertexIndices(); for (size_t i = 0; i < mesh->nVertices(); i++) { GCVertex v_i = mesh->vertex(i); // Derivative of local volume is just the area weighted normal Vector3 deriv_v = areaWeightedNormal(geom, v_i); // Derivative of V^2 = 2 V (dV/dx) deriv_v = 2 * volDev * deriv_v / initialVolume; MatrixUtils::addToRow(output, inds[v_i], weight * deriv_v); } } // Get the exponents of this energy; only applies to tangent-point energies. Vector2 SoftVolumeConstraint::GetExponents() { return Vector2{1, 0}; } // Get a pointer to the current BVH for this energy. // Return 0 if the energy doesn't use a BVH. OptimizedClusterTree *SoftVolumeConstraint::GetBVH() { return 0; } // Return the separation parameter for this energy. // Return 0 if this energy doesn't do hierarchical approximation. double SoftVolumeConstraint::GetTheta() { return 0; } } // namespace rsurfaces
32.238806
92
0.647222
Conrekatsu
448bc7db01bcfd3c2d5c1a5c6fcb052917d460a5
5,934
cpp
C++
src/planner/Query.cpp
yixinglu/nebula-graph
faf9cd44d818b953da98b5c922999560c89867bd
[ "Apache-2.0" ]
1
2021-08-23T05:55:55.000Z
2021-08-23T05:55:55.000Z
src/planner/Query.cpp
yixinglu/nebula-graph
faf9cd44d818b953da98b5c922999560c89867bd
[ "Apache-2.0" ]
null
null
null
src/planner/Query.cpp
yixinglu/nebula-graph
faf9cd44d818b953da98b5c922999560c89867bd
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2020 vesoft inc. All rights reserved. * * This source code is licensed under Apache 2.0 License, * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ #include "planner/Query.h" #include <folly/String.h> #include "common/interface/gen-cpp2/graph_types.h" #include "util/ToJson.h" using folly::stringPrintf; namespace nebula { namespace graph { std::unique_ptr<cpp2::PlanNodeDescription> Explore::explain() const { auto desc = SingleInputNode::explain(); addDescription("space", folly::to<std::string>(space_), desc.get()); addDescription("dedup", util::toJson(dedup_), desc.get()); addDescription("limit", folly::to<std::string>(limit_), desc.get()); auto filter = filter_.empty() ? filter_ : Expression::decode(filter_)->toString(); addDescription("filter", filter, desc.get()); addDescription("orderBy", folly::toJson(util::toJson(orderBy_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> GetNeighbors::explain() const { auto desc = Explore::explain(); addDescription("src", src_ ? src_->toString() : "", desc.get()); addDescription("edgeTypes", folly::toJson(util::toJson(edgeTypes_)), desc.get()); addDescription("edgeDirection", storage::cpp2::_EdgeDirection_VALUES_TO_NAMES.at(edgeDirection_), desc.get()); addDescription( "vertexProps", vertexProps_ ? folly::toJson(util::toJson(*vertexProps_)) : "", desc.get()); addDescription( "edgeProps", edgeProps_ ? folly::toJson(util::toJson(*edgeProps_)) : "", desc.get()); addDescription( "statProps", statProps_ ? folly::toJson(util::toJson(*statProps_)) : "", desc.get()); addDescription("exprs", exprs_ ? folly::toJson(util::toJson(*exprs_)) : "", desc.get()); addDescription("random", util::toJson(random_), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> GetVertices::explain() const { auto desc = Explore::explain(); addDescription("src", src_ ? src_->toString() : "", desc.get()); addDescription("props", folly::toJson(util::toJson(props_)), desc.get()); addDescription("exprs", folly::toJson(util::toJson(exprs_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> GetEdges::explain() const { auto desc = Explore::explain(); addDescription("src", src_ ? src_->toString() : "", desc.get()); addDescription("type", util::toJson(type_), desc.get()); addDescription("ranking", ranking_ ? ranking_->toString() : "", desc.get()); addDescription("dst", dst_ ? dst_->toString() : "", desc.get()); addDescription("props", folly::toJson(util::toJson(props_)), desc.get()); addDescription("exprs", folly::toJson(util::toJson(exprs_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> IndexScan::explain() const { auto desc = Explore::explain(); // TODO return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Filter::explain() const { auto desc = SingleInputNode::explain(); addDescription("condition", condition_ ? condition_->toString() : "", desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Project::explain() const { auto desc = SingleInputNode::explain(); addDescription("columns", cols_ ? cols_->toString() : "", desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Sort::explain() const { auto desc = SingleInputNode::explain(); addDescription("factors", folly::toJson(util::toJson(factors_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Limit::explain() const { auto desc = SingleInputNode::explain(); addDescription("offset", folly::to<std::string>(offset_), desc.get()); addDescription("count", folly::to<std::string>(count_), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Aggregate::explain() const { auto desc = SingleInputNode::explain(); addDescription("groupKeys", folly::toJson(util::toJson(groupKeys_)), desc.get()); folly::dynamic itemArr = folly::dynamic::array(); for (const auto &item : groupItems_) { folly::dynamic itemObj = folly::dynamic::object(); itemObj.insert("distinct", util::toJson(item.distinct)); itemObj.insert("funcType", static_cast<uint8_t>(item.func)); itemObj.insert("expr", item.expr ? item.expr->toString() : ""); itemArr.push_back(itemObj); } addDescription("groupItems", folly::toJson(itemArr), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> SwitchSpace::explain() const { auto desc = SingleInputNode::explain(); addDescription("space", spaceName_, desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> DataCollect::explain() const { auto desc = SingleDependencyNode::explain(); addDescription("inputVars", folly::toJson(util::toJson(inputVars_)), desc.get()); switch (collectKind_) { case CollectKind::kSubgraph: { addDescription("kind", "subgraph", desc.get()); break; } case CollectKind::kRowBasedMove: { addDescription("kind", "row", desc.get()); break; } case CollectKind::kMToN: { addDescription("kind", "m to n", desc.get()); break; } } return desc; } std::unique_ptr<cpp2::PlanNodeDescription> DataJoin::explain() const { auto desc = SingleDependencyNode::explain(); addDescription("leftVar", folly::toJson(util::toJson(leftVar_)), desc.get()); addDescription("rightVar", folly::toJson(util::toJson(rightVar_)), desc.get()); addDescription("hashKeys", folly::toJson(util::toJson(hashKeys_)), desc.get()); addDescription("probeKeys", folly::toJson(util::toJson(probeKeys_)), desc.get()); return desc; } } // namespace graph } // namespace nebula
39.825503
99
0.663128
yixinglu
448f176819f901ec6ed652d795b5faf80dd21c2f
1,312
cpp
C++
MMOCoreORB/src/server/zone/objects/creature/ai/variables/CreatureTemplateReference.cpp
V-Fib/FlurryClone
40e0ca7245ec31b3815eb6459329fd9e70f88936
[ "Zlib", "OpenSSL" ]
18
2017-02-09T15:36:05.000Z
2021-12-21T04:22:15.000Z
MMOCoreORB/src/server/zone/objects/creature/ai/variables/CreatureTemplateReference.cpp
V-Fib/FlurryClone
40e0ca7245ec31b3815eb6459329fd9e70f88936
[ "Zlib", "OpenSSL" ]
61
2016-12-30T21:51:10.000Z
2021-12-10T20:25:56.000Z
MMOCoreORB/src/server/zone/objects/creature/ai/variables/CreatureTemplateReference.cpp
V-Fib/FlurryClone
40e0ca7245ec31b3815eb6459329fd9e70f88936
[ "Zlib", "OpenSSL" ]
71
2017-01-01T05:34:38.000Z
2022-03-29T01:04:00.000Z
/* * CreatureTemplateReference.cpp * * Created on: 29/04/2012 * Author: victor */ #include "CreatureTemplateReference.h" #include "server/zone/managers/creature/CreatureTemplateManager.h" bool CreatureTemplateReference::toBinaryStream(ObjectOutputStream* stream) { #ifdef ODB_SERIALIZATION templateString.toBinaryStream(stream); #else CreatureTemplate* obj = get(); if (obj != nullptr) { obj->getTemplateName().toBinaryStream(stream); } else stream->writeShort(0); #endif return true; } bool CreatureTemplateReference::parseFromBinaryStream(ObjectInputStream* stream) { #ifdef ODB_SERIALIZATION templateString.parseFromBinaryStream(stream); return true; #else String templateName; templateName.parseFromBinaryStream(stream); CreatureTemplate* obj = CreatureTemplateManager::instance()->getTemplate(templateName); if (obj != nullptr) { updateObject(obj); return true; } updateObject(obj); return false; #endif } CreatureTemplate* CreatureTemplateReference::operator=(CreatureTemplate* obj) { updateObject(obj); return obj; } void to_json(nlohmann::json& j, const CreatureTemplateReference& r) { #ifdef ODB_SERIALIZATION j = r.templateString; #else CreatureTemplate* obj = r.get(); if (obj != nullptr) { j = obj->getTemplateName(); } else j = ""; #endif }
19.58209
88
0.749238
V-Fib
4496bfac111c43a836b8eff2037fcb70f625be3a
2,743
cpp
C++
thread/appl_thread_descriptor.cpp
fboucher9/appl
bb90398cf9985d4cc0a2a079c4d49d891108e6d1
[ "MIT" ]
null
null
null
thread/appl_thread_descriptor.cpp
fboucher9/appl
bb90398cf9985d4cc0a2a079c4d49d891108e6d1
[ "MIT" ]
null
null
null
thread/appl_thread_descriptor.cpp
fboucher9/appl
bb90398cf9985d4cc0a2a079c4d49d891108e6d1
[ "MIT" ]
null
null
null
/* See LICENSE for license details */ /* */ #include <appl_status.h> #include <appl_types.h> #include <thread/appl_thread_descriptor.h> #include <object/appl_object.h> #include <buf/appl_buf.h> #include <thread/appl_thread_descriptor_impl.h> #include <heap/appl_heap_handle.h> // // // enum appl_status appl_thread_descriptor_create( struct appl_context * const p_context, struct appl_thread_descriptor * * const r_thread_descriptor) { enum appl_status e_status; e_status = appl_new( p_context, r_thread_descriptor); return e_status; } // _create() // // // enum appl_status appl_thread_descriptor_destroy( struct appl_thread_descriptor * const p_thread_descriptor) { enum appl_status e_status; struct appl_context * const p_context = p_thread_descriptor->get_context(); e_status = appl_delete( p_context, p_thread_descriptor); return e_status; } // _destroy() /* */ void appl_thread_descriptor_set_callback( struct appl_thread_descriptor * const p_thread_descriptor, void (* const p_entry)( void * const p_thread_context), void * const p_context) { struct appl_thread_callback o_callback; o_callback.p_entry = p_entry; o_callback.p_context = p_context; p_thread_descriptor->f_set_callback( &( o_callback)); } /* appl_thread_descriptor_set_callback() */ // // // void appl_thread_descriptor_set_name( struct appl_thread_descriptor * const p_thread_descriptor, unsigned char const * const p_name_min, unsigned char const * const p_name_max) { struct appl_buf o_name; o_name.o_min.pc_uchar = p_name_min; o_name.o_max.pc_uchar = p_name_max; p_thread_descriptor->f_set_name( &( o_name)); } // _set_name() // // // char appl_thread_descriptor_get_callback( struct appl_thread_descriptor const * const p_thread_descriptor, struct appl_thread_callback * const p_thread_callback) { return p_thread_descriptor->f_get_callback( p_thread_callback) ? 1 : 0; } // _get_callback() // // // char appl_thread_descriptor_get_name( struct appl_thread_descriptor const * const p_thread_descriptor, struct appl_buf * const p_name) { return p_thread_descriptor->f_get_name( p_name) ? 1 : 0; } // _get_name() /* end-of-file: appl_thread_descriptor.cpp */
17.471338
51
0.61502
fboucher9
44970b07e76cabf703195cc926a81dceb9e636af
806
hpp
C++
higan/gba/cartridge/cartridge.hpp
13824125580/higan
fbdd3f980b65412c362096579869ae76730e4118
[ "Intel", "ISC" ]
10
2019-12-19T01:19:41.000Z
2021-02-18T16:30:29.000Z
higan/gba/cartridge/cartridge.hpp
13824125580/higan
fbdd3f980b65412c362096579869ae76730e4118
[ "Intel", "ISC" ]
null
null
null
higan/gba/cartridge/cartridge.hpp
13824125580/higan
fbdd3f980b65412c362096579869ae76730e4118
[ "Intel", "ISC" ]
null
null
null
struct Cartridge { #include "memory.hpp" auto pathID() const -> uint { return information.pathID; } auto hash() const -> string { return information.sha256; } auto manifest() const -> string { return information.manifest; } auto title() const -> string { return information.title; } struct Information { uint pathID = 0; string sha256; string manifest; string title; } information; Cartridge(); ~Cartridge(); auto load() -> bool; auto save() -> void; auto unload() -> void; auto power() -> void; auto read(uint mode, uint32 addr) -> uint32; auto write(uint mode, uint32 addr, uint32 word) -> void; auto serialize(serializer&) -> void; private: bool hasSRAM = false; bool hasEEPROM = false; bool hasFLASH = false; }; extern Cartridge cartridge;
22.388889
66
0.66005
13824125580
449a6d2d1ed94330435edd5a25ba9ac3845b028c
2,019
cc
C++
l95/src/lorenz95/ObservationL95.cc
andreapiacentini/oops
48c923c210a75773e2457eea8b1a8eee29837bb5
[ "Apache-2.0" ]
null
null
null
l95/src/lorenz95/ObservationL95.cc
andreapiacentini/oops
48c923c210a75773e2457eea8b1a8eee29837bb5
[ "Apache-2.0" ]
null
null
null
l95/src/lorenz95/ObservationL95.cc
andreapiacentini/oops
48c923c210a75773e2457eea8b1a8eee29837bb5
[ "Apache-2.0" ]
null
null
null
/* * (C) Copyright 2009-2016 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation nor * does it submit to any jurisdiction. */ #include "lorenz95/ObservationL95.h" #include <string> #include <vector> #include "eckit/config/Configuration.h" #include "lorenz95/GomL95.h" #include "lorenz95/LocsL95.h" #include "lorenz95/ObsBias.h" #include "lorenz95/ObsDiags1D.h" #include "lorenz95/ObsVec1D.h" #include "oops/base/Variables.h" #include "oops/util/Logger.h" // ----------------------------------------------------------------------------- namespace lorenz95 { // ----------------------------------------------------------------------------- ObservationL95::ObservationL95(const ObsTable & ot, const eckit::Configuration &) : obsdb_(ot), inputs_(std::vector<std::string>{"x"}) {} // ----------------------------------------------------------------------------- ObservationL95::~ObservationL95() {} // ----------------------------------------------------------------------------- void ObservationL95::simulateObs(const GomL95 & gom, ObsVec1D & ovec, const ObsBias & bias, ObsDiags1D &) const { for (size_t jj = 0; jj < gom.size(); ++jj) { ovec[jj] = gom[jj] + bias.value(); } } // ----------------------------------------------------------------------------- std::unique_ptr<LocsL95> ObservationL95::locations() const { return std::unique_ptr<LocsL95>(new LocsL95(obsdb_.locations(), obsdb_.times())); } // ----------------------------------------------------------------------------- void ObservationL95::print(std::ostream & os) const { os << "Lorenz 95: Identity obs operator"; } // ----------------------------------------------------------------------------- } // namespace lorenz95
33.098361
83
0.505201
andreapiacentini
449b75bc73a0098cc1f0cccc849e41486eabfcba
853
cpp
C++
sdk/test_hls_polling.cpp
zhiyb/SVM_hls
e1223c8528eccd8d48e52c4614c8596db4c253da
[ "MIT" ]
3
2020-11-11T13:04:52.000Z
2021-03-03T06:30:18.000Z
sdk/test_hls_polling.cpp
zhiyb/SVM_hls
e1223c8528eccd8d48e52c4614c8596db4c253da
[ "MIT" ]
null
null
null
sdk/test_hls_polling.cpp
zhiyb/SVM_hls
e1223c8528eccd8d48e52c4614c8596db4c253da
[ "MIT" ]
1
2019-04-11T03:05:59.000Z
2019-04-11T03:05:59.000Z
#include <stdio.h> #include <xtime_l.h> #include "test.h" void test_cls_hls_polling_pre() { // Disable interrupt interrupt_enable(false); } unsigned int test_cls_hls_polling() { XTime tick[4], perf[3] = {0, 0, 0}; unsigned int err = 0; int *label = &testDataLabel[0]; int16_t *x = &testDataI[0][0]; for (size_t ix = ASIZE(testDataLabel); ix != 0; ix--) { XTime_GetTime(&tick[0]); XClassifier_Set_x_V(&cls, *(XClassifier_X_v *)x); XTime_GetTime(&tick[1]); XClassifier_Start(&cls); XTime_GetTime(&tick[2]); while (!XClassifier_IsReady(&cls)); XTime_GetTime(&tick[3]); err += (!XClassifier_Get_output_r(&cls)) != (!*label++); perf[0] += tick[1] - tick[0]; perf[1] += tick[2] - tick[1]; perf[2] += tick[3] - tick[2]; x += N; } printf("Data %llu, starting %llu, result %llu\r\n", perf[0], perf[1], perf[2]); return err; }
25.088235
80
0.635404
zhiyb