text:
// Copyright (c) 2018 The Veil developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <boost/test/unit_test.hpp>

#include <chainparams.h>
#include <consensus/merkle.h>
#include <consensus/validation.h>
#include <miner.h>
#include <pow.h>
#include <random.h>
#include <test/test_veil.h>
#include <validation.h>
#include <validationinterface.h>
#include <veil/budget.h>
#include <script/standard.h>
#include <key_io.h>
#include <veil/zerocoin/accumulators.h>

BOOST_FIXTURE_TEST_SUITE(proofofstake_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(proofofstake_block)
{

    CMutableTransaction txCoinBase;
    txCoinBase.vin.resize(1);
    txCoinBase.vin[0].prevout.SetNull();
    txCoinBase.vin[0].scriptSig = CScript() << 1 << OP_0;
    txCoinBase.vpout.resize(1);
    txCoinBase.vpout[0] = MAKE_OUTPUT<CTxOutStandard>();

    CTxOut txOut_coinbase(0, CScript());
    txCoinBase.vpout.clear();
    txCoinBase.vpout.emplace_back(txOut_coinbase.GetSharedPtr());
//    txCoinBase.vpout[0]->SetValue(0);
//    txCoinBase.vpout[0]->SetScriptPubKey(CScript());
    CBlock block;
    block.vtx.emplace_back(MakeTransactionRef(std::move(txCoinBase)));
        block.vtx.resize(2);

    //load our serialized pubcoin
    libzerocoin::PrivateCoin privateCoin_stake(Params().Zerocoin_Params(), libzerocoin::CoinDenomination::ZQ_TEN, true);
    auto pubCoin = privateCoin_stake.getPublicCoin();
    BOOST_CHECK_MESSAGE(pubCoin.validate(), "Failed to validate pubCoin created from hex string");

    //initialize and Accumulator and AccumulatorWitness
    libzerocoin::Accumulator accumulator(Params().Zerocoin_Params(), libzerocoin::CoinDenomination::ZQ_TEN);
    libzerocoin::AccumulatorWitness witness(Params().Zerocoin_Params(), accumulator, pubCoin);

    //Add random zerocoins to the accumulator
    for (unsigned int i = 0; i < 5; i++) {
        libzerocoin::PrivateCoin pc(Params().Zerocoin_Params(), libzerocoin::CoinDenomination::ZQ_TEN, true);
        auto pub = pc.getPublicCoin();
        accumulator.accumulate(pub);
        witness.AddElement(pub);
    }

    //Add our own coin
    accumulator.accumulate(pubCoin);

    //Get the checksum of the accumulator we use for the spend and also add it to our checksum map
    auto hashChecksum = GetChecksum(accumulator.getValue());
    libzerocoin::CoinSpend spend(Params().Zerocoin_Params(), privateCoin_stake, accumulator, hashChecksum, witness, uint256(), libzerocoin::SpendType::STAKE);

    // Deserialize the CoinSpend intro a fresh object
    CDataStream serializedCoinSpend(SER_NETWORK, PROTOCOL_VERSION);
    serializedCoinSpend << spend;
    std::vector<unsigned char> data(serializedCoinSpend.begin(), serializedCoinSpend.end());

    CTxIn txin;
    //Add the coin spend into a transaction
    txin.scriptSig = CScript() << OP_ZEROCOINSPEND << data.size();
    txin.scriptSig.insert(txin.scriptSig.end(), data.begin(), data.end());
    txin.prevout.SetNull();

    //use nSequence as a shorthand lookup of denomination
    //NOTE that this should never be used in place of checking the value in the final blockchain acceptance/verification
    //of the transaction
    txin.nSequence = spend.getDenomination();
    txin.nSequence |= CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG; //Don't use any relative locktime for zerocoin spend

    CMutableTransaction txCoinStake;
    txCoinStake.vin.emplace_back(txin);

    //Coinstake uses empty vout[0]
    txCoinStake.vpout.emplace_back(CTxOut(0, CScript()).GetSharedPtr());

    //Add mints to tx
    for (unsigned int i = 0; i < 5; i++) {
        libzerocoin::PrivateCoin pc(Params().Zerocoin_Params(), libzerocoin::CoinDenomination::ZQ_TEN, true);
        auto pub = pc.getPublicCoin();
        CScript scriptSerializedCoin = CScript() << OP_ZEROCOINMINT << pub.getValue().getvch().size() << pub.getValue().getvch();
        txCoinStake.vpout.emplace_back(CTxOut(libzerocoin::ZerocoinDenominationToAmount(pub.getDenomination()), scriptSerializedCoin).GetSharedPtr());
    }

    block.vtx[1] = MakeTransactionRef(std::move(txCoinStake));

    //This is done in incrementextranonce for PoW blocks
    block.hashMerkleRoot = BlockMerkleRoot(block);

    std::cout << "vpout size: "<<block.vtx[0]->vpout.size()<<"\n Block \n " << block.ToString() << std::endl;
    BOOST_CHECK_MESSAGE(block.IsProofOfStake(), "block is not marked as proof of stake");

    auto hashBlock = block.GetHash();
    CDataStream ss(SER_DISK, 0);
    ss << block;
    std::cout << "vpout size after serialize: "<<block.vtx[0]->vpout.size()<<"\n";
    CBlock block2;
    ss >> block2;

    BOOST_CHECK_MESSAGE(block2.GetHash() == hashBlock, "Block hash does not match after serialization");
    //BOOST_CHECK_MESSAGE(block2 == block, "Block changed after serialization");
    std::cout << "Block 2\n " << block2.ToString() << std::endl;

        BOOST_CHECK_MESSAGE(block.vtx[0]->GetHash() == block2.vtx[0]->GetHash(),
                            "Coinbase tx was malleated during serialization");
    try {
        auto txin1 = block.vtx[0]->vin[0];
        auto txin2 = block2.vtx[0]->vin[0];
        std::cout << "1\n";
        BOOST_CHECK_MESSAGE(txin1 == txin2, "Coinbase input was malleated during serialization");
        BOOST_CHECK_MESSAGE(txin1.scriptSig == txin2.scriptSig, "txin scriptsig mismatch");
        BOOST_CHECK_MESSAGE(txin1.prevout == txin2.prevout, "txin prevout mismatch");
        BOOST_CHECK_MESSAGE(txin1.nSequence == txin2.nSequence, "txin sequence mismatch");
        BOOST_CHECK_MESSAGE(txin1.scriptData.stack == txin2.scriptData.stack, "txin scriptdata mismatch");
        BOOST_CHECK_MESSAGE(txin1.scriptWitness.stack == txin2.scriptWitness.stack, "txin scriptwitness mismatch");

        std::cout << "2\n";

        CTxOut out1;
        block.vtx[0]->vpout[0]->GetTxOut(out1);
        CTxOut out2;
        block2.vtx[0]->vpout[0]->GetTxOut(out2);
        BOOST_CHECK_MESSAGE(out1 == out2, "Coinbase output was malleated during serialization");
    } catch (...) {
        BOOST_CHECK(false);
    }

    auto txCoinBase2 = block2.vtx[0];
    auto txCoinBase_block = block.vtx[0];
    BOOST_CHECK_MESSAGE(txCoinBase2->nLockTime == txCoinBase_block->nLockTime, "locktime incorrect");
    BOOST_CHECK_MESSAGE(txCoinBase2->nVersion == txCoinBase_block->nVersion, "version incorrect");
    BOOST_CHECK_MESSAGE(txCoinBase2->vin == txCoinBase_block->vin, "vin incorrect");
    BOOST_CHECK_MESSAGE(txCoinBase2->vpout.size() == txCoinBase_block->vpout.size(), "vpoutsize incorrect");
    std::cout << "vpoutsize2:"<< txCoinBase_block->vpout.size() << " vpoutsize1:" << txCoinBase_block->vpout.size() << std::endl;
    BOOST_CHECK_MESSAGE(txCoinBase2->HasWitness() == txCoinBase_block->HasWitness(), "witness flag incorrect");

}

BOOST_AUTO_TEST_SUITE_END()


text:
#include <X4ConverterTools/xmf/XmfHeader.h>

#include <boost/format.hpp>
#include <iostream>
#include <X4ConverterTools/xmf/XmfMaterial.h>
#include <X4ConverterTools/xmf/XmfDataBufferDesc.h>
#include <X4ConverterTools/types/DirectX.h>
using namespace Assimp;
using namespace boost;

namespace xmf {
    XmfHeader::XmfHeader(uint8_t numDataBuffers, uint8_t numMaterials) {
// Note that this ignores any header read into this mesh file since we can't guarantee the old header is accurate
        Magic[0] = 'X';
        Magic[1] = 'U';
        Magic[2] = 'M';
        Magic[3] = 'F';
        Version = 3;
        IsBigEndian = (uint8_t) false;
        SizeOfHeader = 0x40;
        reserved0 = 0x00;
        NumDataBuffers = numDataBuffers;
        DataBufferDescSize = sizeof(XmfDataBufferDesc);
        NumMaterials = numMaterials;
        MaterialSize = sizeof(XmfMaterial);
        // TODO

        Culling_CW = static_cast<uint8_t>(false);
        RightHand = static_cast<uint8_t>(false);
        NumVertices = 0;//TODO
        NumIndices = 0;//TODO

        PrimitiveType = D3DPT_TRIANGLELIST;
        for (uint8_t &c : pad) {
            c = 0x00;
        }
        // TODO verify this
        MeshOptimization = 0;

    }

    XmfHeader::XmfHeader(Assimp::StreamReaderLE &reader) {
        for (uint8_t &c : Magic) {
            reader >> c;
        }

        reader >> Version;
        reader >> IsBigEndian;
        reader >> SizeOfHeader;
        reader >> reserved0;
        reader >> NumDataBuffers;
        reader >> DataBufferDescSize;
        reader >> NumMaterials;
        reader >> MaterialSize;

        reader >> Culling_CW;
        reader >> RightHand;
        reader >> NumVertices;
        reader >> NumIndices;
        reader >> PrimitiveType;
        reader >> MeshOptimization;

        for (float &f: BoundingBoxCenter) {
            reader >> f;
        }

        for (float &f: BoundingBoxSize) {
            reader >> f;
        }

        for (uint8_t &c : pad) {
            reader >> c;
        }
    }

    void XmfHeader::Write(Assimp::StreamWriterLE &writer) {
        for (uint8_t &c : Magic) {
            writer << c;
        }
        writer << Version << IsBigEndian;
        writer << SizeOfHeader;
        writer << reserved0;
        writer << NumDataBuffers << DataBufferDescSize;
        writer << NumMaterials << MaterialSize;

        writer << Culling_CW << RightHand;
        writer << NumVertices << NumIndices;

        writer << PrimitiveType << MeshOptimization;

        for (float &f: BoundingBoxCenter) {
            writer << f;
        }

        for (float &f: BoundingBoxSize) {
            writer << f;
        }

        for (uint8_t &c : pad) {
            writer << c;
        }
    }

    std::string XmfHeader::validate() const {
        std::string ret;
        bool valid = true;

        // TODO prettyprinter

        if (memcmp(Magic, "XUMF\x03", 5) != 0) {
            ret.append("\tERROR: Invalid Header Magic or Version\n");
            valid = false;
        }
        if (IsBigEndian) {
            ret.append("\tERROR: Big endian .xmf files are not supported by this importer\n");
            valid = false;
        }
        if (reserved0 != 0) {
            ret.append(str(format("\tERROR: reserved should be 0, was %1%\n") % reserved0));
            valid = false;
        }
        if (SizeOfHeader != XmfHeader::EXPECTED_HEADER_SIZE) {
            ret.append("\tERROR: Header is not 64 bytes long!\n");
            valid = false;
        }
        // TODO fix these
//    if (DataBufferDescSize > sizeof(XmfDataBufferDesc)) {
//        throw std::runtime_error("Data buffer description size is too large");
//    }
//    if (MaterialSize != sizeof(XmfMaterial)) {
//        throw std::runtime_error("Material size is invalid");
//    }

        // TODO does this break teh animations?
        if (Culling_CW != 0) {
            // Would probably still work, but I want to know about it
            ret.append(
                    "\tWARNING: Culling_CW != 0 (0 = CW). Is this file from a mod? if so, why are you converting it?\n");
        }
        if (RightHand != 0) {
            // Would probably still work, but I want to know about it
            ret.append(
                    "\tWARNING: RightHand != 0 (0 = D3D). Is this file from a mod? if so, why are you converting it?\n");
        }
        ret.append(str(format("\tNumVertices: %1%\n") % NumVertices));
        ret.append(str(format("\tNumIndices: %1%\n") % NumIndices));

        ret.append(str(format("\tPrimitiveType: %1% (4 = TRIANGLELIST)\n") % PrimitiveType));
        ret.append(str(format("\tMeshOptimization: %1%\n") % MeshOptimization));
        if (MeshOptimization != 0) {
            ret.append("\tWARNING: Field poorly understood");
        }
        ret.append(str(format("\tBoundingBoxCenter: (%1%,%2%,%3%)\n") % BoundingBoxCenter[0] % BoundingBoxCenter[1] %
                       BoundingBoxCenter[2]));

        ret.append(str(format("\tBoundingBoxSize: (%1%,%2%,%3%)\n") % BoundingBoxSize[0] % BoundingBoxSize[1] %
                       BoundingBoxSize[2]));

        if (PrimitiveType != D3DPT_TRIANGLELIST) {
            ret.append("\tERROR: File is using a DirectX primitive type that's not supported by this importer\n");
            valid = false;
        }
        for (const uint8_t &b : pad) {
            if (b != 0) {
                ret.append("\tERROR: Padding must be 0!\n");
                valid = false;
                break;
            }
        }
        if (!valid) {
            throw std::runtime_error(ret);
        }
        return ret;
    }
}

ext: cpp


text:
// Copyright (C) 2012  JINMEI Tatuya
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

#include <query_repository.h>

#include <dns/name.h>
#include <dns/edns.h>
#include <dns/message.h>
#include <dns/opcode.h>
#include <dns/rcode.h>
#include <dns/rdata.h>
#include <dns/rrclass.h>
#include <dns/rrtype.h>
#include <dns/rrttl.h>
#include <dns/question.h>

#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/scoped_ptr.hpp>

#include <istream>
#include <fstream>
#include <string>
#include <map>
#include <vector>

#include <netinet/in.h>

using namespace std;
using boost::lexical_cast;
using boost::scoped_ptr;
using namespace bundy::dns;

namespace {
// an ad hoc threadshold to prevent a busy loop due to an empty input file.
const size_t MAX_EMPTY_LOOP = 1000;

// Set of parameters of a request (mostly query, but may be of a different
// opcode)
struct RequestParam {
    RequestParam(QuestionPtr question_param, int proto_param) :
        question(question_param), proto(proto_param)
    {}

    // Default constructor.  Using some invalid initial values.
    RequestParam() : proto(IPPROTO_NONE) {}

    void setEDNSPolicy(bool use_dnssec_param, bool use_edns_param) {
        // For special types of queries, we don't use EDNS by default
        if (question->getType() == RRType::AXFR() ||
            question->getType() == RRType::IXFR()) {
            use_dnssec = false;
            use_edns = false;
        } else {
            use_dnssec = use_dnssec_param;
            use_edns = use_edns_param;
        }
    }

    QuestionPtr question;
    int proto;                  // Transport protocol
    vector<RRsetPtr> authorities;
    bool use_dnssec;
    bool use_edns;
};

struct QueryOptions {
    QueryOptions() {
        clear();
    }
    void clear() {
        serial = 0;
    }
    uint32_t serial;         // querier's serial, only useful for IXFR
};
}

namespace Queryperf {

struct QueryRepository::QueryRepositoryImpl {
    QueryRepositoryImpl(istream& input) :
        qclass_(RRClass::IN()), input_(input)
    {
        initialize();
    }

    QueryRepositoryImpl(const string& input_file) :
        qclass_(RRClass::IN()),
        input_ifs_(new ifstream(input_file.c_str())),
        input_(*input_ifs_)
    {
        initialize();
    }

    void initialize() {
        use_dnssec_ = true;
        use_edns_ = true;
        proto_ = IPPROTO_UDP;

        edns_.reset(new EDNS);
        edns_->setUDPSize(4096);
        edns_->setDNSSECAwareness(true);

        // BIND 10 libdns++ doesn't yet recognize all standardized RR type
        // menmonics.  To suppress noisy log and avoid ignoring query data
        // containing such RR types, we use a homebrew mapping table.
        // We keep the same map for each repository object to avoid inter
        // thread contention.
        aux_typemap_["A6"] = "TYPE38";
        aux_typemap_["ANY"] = "TYPE255";
        aux_typemap_["AXFR"] = "TYPE252";
        aux_typemap_["IXFR"] = "TYPE251";
    }

    // Extract the next question from the input stream
    QuestionPtr readNextRequest(vector<RRsetPtr>& authorities,
                                bool rewind);

    // Extract optional attributes of the query.  Used by readNextRequest.
    void parseQueryOptions(stringstream& ss);

    // Get the parameters of the next request, either from the preloaded
    // vector (if done) or from the input stream.
    const RequestParam& getNextParam();

    RRClass qclass_;            // Query class
    scoped_ptr<ifstream> input_ifs_;
    istream& input_;
    map<string, string> aux_typemap_;
    vector<RequestParam> params_;   // used in the "preload" mode
    bool use_edns_;                 // whether to include ENDS by default.
    bool use_dnssec_;               // whether to set EDNS DO bit by default.
                                    // EDNS will be included regardless of
                                    // use_edns_.
    EDNSPtr edns_;                  // template of common EDNS OPT RR
    int proto_;                     // Default transport protocol
    vector<RequestParam>::const_iterator current_param_;
    vector<RequestParam>::const_iterator end_param_;

    QueryOptions options_;

private:
    RequestParam param_placeholder_;
};

void
QueryRepository::QueryRepositoryImpl::parseQueryOptions(stringstream& ss) {
    while (!ss.eof()) {
        string option;
        ss >> option;

        const size_t pos_delim = option.find('=');
        if (pos_delim == string::npos) {
            throw QueryRepositoryError("Invalid query option: no '='");
        }
        const string optname = option.substr(0, pos_delim);
        const string optarg = option.substr(pos_delim + 1);

        // Set option: for now just hardcode known options.
        if (optname == "serial") {
            options_.serial = lexical_cast<uint32_t>(optarg);
        }
    }
}

QuestionPtr
QueryRepository::QueryRepositoryImpl::readNextRequest(
    vector<RRsetPtr>& authorities, bool rewind)
{
    QuestionPtr question;

    if (!rewind && input_.eof()) {
        return (QuestionPtr());
    }

    while (!question) {
        string line;
        size_t loop_count = 0;
        while (line.empty()) {
            if (loop_count++ == MAX_EMPTY_LOOP) {
                throw QueryRepositoryError("failed to get input line too long,"
                                           " possibly an empty input?");
            }
            getline(input_, line);
            if (input_.eof()) {
                if (rewind) {
                    input_.clear();
                    input_.seekg(0);
                } else if (line.empty()) {
                    return (QuestionPtr());
                }
            } else if (input_.bad() || input_.fail()) {
                throw QueryRepositoryError("unexpected failure in reading "
                                           "input data");
            }
            if (line[0] == ';') { // comment check (note it's safe to see [0])
                line.clear();     // force ignoring this line.
            }
        }

        options_.clear();
        authorities.clear();
        stringstream ss(line);
        string qname_text, qtype_text;
        ss >> qname_text >> qtype_text;
        if (ss.bad() || ss.fail()) {
            // Ignore the line is organized in an unexpected way.
            continue;
        }
        if (!ss.eof()) {
            try {
                parseQueryOptions(ss);
            } catch (const std::exception& ex) {
                cerr << "Error parsing query option (" << ex.what() << "): "
                     << line << endl;
                continue;
            }
        }
        // Workaround for some RR types that are not recognized by BIND 10
        map<string, string>::const_iterator it =
            aux_typemap_.find(qtype_text);
        if (it != aux_typemap_.end()) {
            qtype_text = it->second;
        }
        try {
            const RRType qtype(qtype_text);
            const Name qname(qname_text);
            question.reset(new Question(qname, qclass_, qtype));

            // For IXFR, we need to add an SOA to the authority section.
            if (qtype == RRType::IXFR()) {
                RRsetPtr rrset(new RRset(qname, qclass_, qtype, RRTTL(0)));
                rrset->addRdata(rdata::createRdata(
                                    RRType::SOA(), qclass_,
                                    ". . " +
                                    lexical_cast<string>(options_.serial) +
                                    " 0 0 0 0"));
                authorities.push_back(rrset);
            }
        } catch (const bundy::Exception& ex) {
            // The input data may contain bad string, which would trigger an
            // exception.  We ignore them and continue reading until we find
            // a valid one.
            cerr << "Error parsing query (" << ex.what() << "): "
                 << line << endl;
        }
    }

    return (question);
}

const RequestParam&
QueryRepository::QueryRepositoryImpl::getNextParam() {
    if (!params_.empty()) {
        // queries have been preloaded.  get the next one from the vector.
        const RequestParam& param = *current_param_;
        if (++current_param_ == end_param_) {
            current_param_ = params_.begin();
        }
        return (param);
    }

    param_placeholder_.question =
        readNextRequest(param_placeholder_.authorities, true);
    param_placeholder_.proto = proto_;
    param_placeholder_.setEDNSPolicy(use_dnssec_, use_edns_);
    return (param_placeholder_);
}

QueryRepository::QueryRepository(istream& input) :
    impl_(new QueryRepositoryImpl(input))
{
}

QueryRepository::QueryRepository(const string& input_file) :
    impl_(new QueryRepositoryImpl(input_file))
{
    if (impl_->input_.fail()) {
        delete impl_;
        throw QueryRepositoryError("failed to open input data file: " +
                                   input_file);
    }
}

QueryRepository::~QueryRepository() {
    delete impl_;
}

void
QueryRepository::load() {
    // duplicate load check
    if (!impl_->params_.empty()) {
        throw QueryRepositoryError("duplicate preload attempt");
    }

    QuestionPtr question;
    vector<RRsetPtr> authorities;
    while ((question = impl_->readNextRequest(authorities, false))
           != NULL) {
        impl_->params_.push_back(RequestParam(question, impl_->proto_));
        impl_->params_.back().authorities = authorities;
        impl_->params_.back().setEDNSPolicy(impl_->use_dnssec_,
                                            impl_->use_edns_);
    }
    if (impl_->params_.empty()) {
        throw QueryRepositoryError("failed to preload queries: empty input");
    }
    impl_->current_param_ = impl_->params_.begin();
    impl_->end_param_ = impl_->params_.end();
}

size_t
QueryRepository::getQueryCount() const {
    return (impl_->params_.size());
}

void
QueryRepository::getNextQuery(Message& query_msg, int& protocol) {
    const RequestParam& param = impl_->getNextParam();

    query_msg.clear(Message::RENDER);
    query_msg.setOpcode(Opcode::QUERY());
    query_msg.setRcode(Rcode::NOERROR());
    query_msg.setHeaderFlag(Message::HEADERFLAG_RD);
    query_msg.addQuestion(param.question);
    BOOST_FOREACH(const RRsetPtr rrset, param.authorities) {
        query_msg.addRRset(Message::SECTION_AUTHORITY, rrset);
    }
    protocol = param.proto;
    if (param.use_edns || param.use_dnssec) {
        query_msg.setEDNS(impl_->edns_);
    }
}

void
QueryRepository::setQueryClass(RRClass qclass) {
    if (!impl_->params_.empty()) {
        throw QueryRepositoryError("query class is being set after preload");
    }

    impl_->qclass_ = qclass;
}

void
QueryRepository::setDNSSEC(bool on) {
    if (!impl_->params_.empty()) {
        throw QueryRepositoryError(
            "DNSSEC DO bit is being changed after preload");
    }

    impl_->use_dnssec_ = on;
    impl_->edns_->setDNSSECAwareness(on);
}

void
QueryRepository::setEDNS(bool on) {
    if (!impl_->params_.empty()) {
        throw QueryRepositoryError("EDNS flag is being changed after preload");
    }

    impl_->use_edns_ = on;
}

void
QueryRepository::setProtocol(int proto) {
    if (!impl_->params_.empty()) {
        throw QueryRepositoryError("Protocol is being changed after preload");
    }
    if (proto != IPPROTO_UDP && proto != IPPROTO_TCP) {
        throw QueryRepositoryError("Invalid or unsupported transport protocol "
                                   ": " + lexical_cast<string>(proto));
    }

    impl_->proto_ = proto;
}

} // end of QueryPerf

ext: cc

max_stars_repo_name: cstrotm/queryperfpp

max_issues_repo_name: cstrotm/queryperfpp

max_forks_repo_name: cstrotm/queryperfpp


text:
#include <boost/mpl/int.hpp>
#include <boost/simd/sdk/simd/native.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/comparison.hpp>
#include <boost/simd/sdk/memory/align_on.hpp>

using boost::mpl::int_;
using boost::mpl::equal_to;
using boost::simd::meta::align_on_c;

int main()
{
  BOOST_MPL_ASSERT(( equal_to<align_on_c<0,4>::type,int_<0> >::type ));
  BOOST_MPL_ASSERT(( equal_to<align_on_c<1,4>::type,int_<4> >::type ));
  BOOST_MPL_ASSERT(( equal_to<align_on_c<4,4>::type,int_<4> >::type ));
  BOOST_MPL_ASSERT(( equal_to<align_on_c<1055,4>::type,int_<1056> >::type ));
}


text:
/*  _______________________________________________________________________

    DAKOTA: Design Analysis Kit for Optimization and Terascale Applications
    Copyright 2014 Sandia Corporation.
    This software is distributed under the GNU Lesser General Public License.
    For more information, see the README file in the top Dakota directory.
    _______________________________________________________________________ */

//- Non-class:   PRPMultiIndex
//- Description: Global funcs, types, etc. for lookup of PRPairs in eval cache
//- Checked by:
//- Version: $Id$

#ifndef PRP_MULTI_INDEX_H
#define PRP_MULTI_INDEX_H

#include "dakota_system_defs.hpp"
#include "dakota_data_types.hpp"
#include "ParamResponsePair.hpp"

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>

#include <algorithm>

namespace bmi = boost::multi_index;

namespace Dakota {

// --------------------------------------------------------
// Comparison functions shared by PRPCache/PRPQueue
// --------------------------------------------------------

/// search function for a particular ParamResponsePair within a PRPList based
/// on ActiveSet content (request vector and derivative variables vector)

/** a global function to compare the ActiveSet of a particular database_pr
    (presumed to be in the global history list) with a passed in ActiveSet
    (search_set). */
inline bool
set_compare(const ParamResponsePair& database_pr, const ActiveSet& search_set)
{
  // Check each entry of ASV for presence of all requests in the stored data.
  // A match is now detected when the search_asv is a SUBSET of the stored_asv
  // (only exact matches were interpreted as duplicates previously).  This
  // extension is widely applicable, but was first implemented to eliminate
  // duplication in Model::estimate_derivatives() when the gradient evaluation
  // contains inactive fns. whereas a previous line search evaluation at the
  // same X had no inactive fns.
  const ActiveSet&  stored_set = database_pr.active_set();
  const ShortArray& stored_asv = stored_set.request_vector();
  const ShortArray& search_asv = search_set.request_vector();
  size_t i, asv_len = search_asv.size();
  if ( stored_asv.size() != asv_len )
    return false;
  bool deriv_flag = false;
  for (i=0; i<asv_len; ++i) {
    short search_bits = search_asv[i];
    if (search_bits & 6)
      deriv_flag = true;
    // bit-wise AND used to check if each of the search bits is
    // present in the stored_asv value
    if ( (stored_asv[i] & search_bits) != search_bits )
      return false;
  }

  // check if each of the search derivative variables is present in stored_dvv
  if (deriv_flag) {
    const SizetArray& stored_dvv = stored_set.derivative_vector();
    const SizetArray& search_dvv = search_set.derivative_vector();
    size_t dvv_len = search_dvv.size();
    for (i=0; i<dvv_len; ++i)
      if ( std::find(stored_dvv.begin(), stored_dvv.end(), search_dvv[i])
           == stored_dvv.end() )
	return false;
  }

  return true;
}

// ------------------------------------------------------
// Comparison and hashing functions for PRPCache/PRPQueue
// ------------------------------------------------------

/// search function for a particular ParamResponsePair within a PRPMultiIndex

/** a global function to compare the interface id and variables of a
    particular database_pr (presumed to be in the global history list) with
    a passed in key of interface id and variables provided by search_pr. */
inline bool id_vars_exact_compare(const ParamResponsePair& database_pr,
				  const ParamResponsePair& search_pr)
{
  // First check interface id strings.  If a different interface was used, then
  // we must assume that the results are not interchangeable (differing model
  // fidelity).
  if ( search_pr.interface_id()   != database_pr.interface_id() )
    return false;

  // For Boost hashing, need exact binary equality (not tolerance-based)
  if ( search_pr.variables() != database_pr.variables() )
    return false;

  // For Boost hashing, a post-processing step is used to manage the ActiveSet
  // logic as shown in set_compare()

  return true;
}

/// hash_value for ParamResponsePairs stored in a PRPMultiIndex
inline std::size_t hash_value(const ParamResponsePair& prp)
{
  // hash using interface ID string.
  std::size_t seed = 0;
  boost::hash_combine(seed, prp.interface_id());

  // Now, hash values of variables using Variables hash_value friend function
  boost::hash_combine(seed, prp.variables());

  return seed;
}

// --------------------------------------
// structs and typedefs for PRPMultiIndex
// --------------------------------------
// define structs used below in PRPMultiIndex typedef

/// wrapper to delegate to the ParamResponsePair hash_value function
struct partial_prp_hash {
  /// access operator
  std::size_t operator()(const ParamResponsePair& prp) const
  { return hash_value(prp); } // ONLY interfaceId & Vars used for hash_value
};

/// predicate for comparing ONLY the interfaceId and Vars attributes of PRPair
struct partial_prp_equality {
  /// access operator
  bool operator()(const ParamResponsePair& database_pr,
                  const ParamResponsePair& search_pr) const
  { return id_vars_exact_compare(database_pr, search_pr); }
};

// tags
struct ordered {};
struct hashed  {};
//struct random  {};

/// Boost Multi-Index Container for globally caching ParamResponsePairs

/** For a global cache, both evaluation and interface id's are used for
    tagging ParamResponsePair records. */
typedef bmi::multi_index_container<Dakota::ParamResponsePair, bmi::indexed_by<
  // sorted by increasing evalId/interfaceId value; can be non-unique due to
  // restart database and restarted run having different evals with the same
  // evalId/interfaceId (due to modified execution settings)
  bmi::ordered_non_unique<bmi::tag<ordered>,
			  bmi::const_mem_fun<Dakota::ParamResponsePair,
			  const IntStringPair&,
			  &Dakota::ParamResponsePair::eval_interface_ids> >,
  // hashed using partial_prp_hash and compared using partial_prp_equality;
  // can be non-unique due to multiple evals with same interfaceId/variables
  // but distinct active set
  bmi::hashed_non_unique<bmi::tag<hashed>,
			 bmi::identity<Dakota::ParamResponsePair>,
                         partial_prp_hash, partial_prp_equality> > >
PRPMultiIndexCache;

typedef PRPMultiIndexCache PRPCache;
typedef PRPCache::index_iterator<ordered>::type       PRPCacheOIter;
typedef PRPCache::index_const_iterator<ordered>::type PRPCacheOCIter;
typedef PRPCache::index_iterator<hashed>::type        PRPCacheHIter;
typedef PRPCache::index_const_iterator<hashed>::type  PRPCacheHCIter;
typedef PRPCacheOIter  PRPCacheIter;  ///< default cache iterator <0>
typedef PRPCacheOCIter PRPCacheCIter; ///< default cache const iterator <0>
/// default cache const reverse iterator <0>
typedef boost::reverse_iterator<PRPCacheCIter> PRPCacheCRevIter;

// begin()/end() default to index 0.  These macros support other indices.

/// hashed definition of cache begin
inline PRPCacheHIter hashedCacheBegin(PRPCache& prp_cache)
{ return prp_cache.get<hashed>().begin(); }
/// hashed definition of cache end
inline PRPCacheHIter hashedCacheEnd(PRPCache& prp_cache)
{ return prp_cache.get<hashed>().end(); }

/// Boost Multi-Index Container for locally queueing ParamResponsePairs

/** For a local queue, interface id's are expected to be consistent,
    such that evaluation id's are sufficient for tracking particular
    evaluations. */
typedef bmi::multi_index_container<Dakota::ParamResponsePair, bmi::indexed_by<
  /* random access for index-based operator[] access
  bmi::random_access<bmi::tag<random> >, */
  // sorted by unique/increasing evaluation id for fast key-based lookups
  bmi::ordered_unique<bmi::tag<ordered>,
		      bmi::const_mem_fun<Dakota::ParamResponsePair, int,
		      &Dakota::ParamResponsePair::eval_id> >,
  // hashed using partial_prp_hash and compared using partial_prp_equality;
  // can be non-unique due to multiple evals with same interfaceId/variables
  // but distinct active set
  bmi::hashed_non_unique<bmi::tag<hashed>,
			 bmi::identity<Dakota::ParamResponsePair>,
                         partial_prp_hash, partial_prp_equality> > >
PRPMultiIndexQueue;

typedef PRPMultiIndexQueue PRPQueue;
//typedef PRPQueue::index_iterator<random>::type        PRPQueueRIter;
//typedef PRPQueue::index_const_iterator<random>::type  PRPQueueRCIter;
typedef PRPQueue::index_iterator<ordered>::type       PRPQueueOIter;
typedef PRPQueue::index_const_iterator<ordered>::type PRPQueueOCIter;
typedef PRPQueue::index_iterator<hashed>::type        PRPQueueHIter;
typedef PRPQueue::index_const_iterator<hashed>::type  PRPQueueHCIter;
typedef PRPQueueOIter  PRPQueueIter;  // default queue iterator <0>
typedef PRPQueueOCIter PRPQueueCIter; // default queue const iterator <0>

// begin()/end() default to index 0.  These macros support other indices.

/// hashed definition of queue begin
inline PRPQueueHIter hashedQueueBegin(PRPQueue& prp_queue)
{ return prp_queue.get<hashed>().begin(); }
/// hashed definition of queue end
inline PRPQueueHIter hashedQueueEnd(PRPQueue& prp_queue)
{ return prp_queue.get<hashed>().end(); }

// ------------------------------------
// lookup_by_val for PRPMultiIndexCache
// ------------------------------------

/// find a ParamResponsePair based on the interface id, variables, and
/// ActiveSet search data within search_pr.

/** Lookup occurs in two steps: (1) PRPMultiIndexCache lookup based on
    strict equality in interface id and variables, and (2) set_compare()
    post-processing based on ActiveSet subset logic. */
inline PRPCacheHIter
lookup_by_val(PRPMultiIndexCache& prp_cache, const ParamResponsePair& search_pr)
{
  PRPCacheHIter prp_hash_it0, prp_hash_it1;
  boost::tuples::tie(prp_hash_it0, prp_hash_it1)
    = prp_cache.get<hashed>().equal_range(search_pr);

  // equal_range returns a small sequence of possibilities resulting from
  // hashing with ONLY interfaceId and variables.  Post-processing is then
  // applied to this sequence using set_compare().
  while (prp_hash_it0 != prp_hash_it1) {
    if (set_compare(*prp_hash_it0, search_pr.active_set()))
      return prp_hash_it0;
    ++prp_hash_it0;
  }
  return prp_cache.get<hashed>().end();
}

/// find a ParamResponsePair within a PRPMultiIndexCache based on the
/// interface id, variables, and ActiveSet search data
inline PRPCacheHIter
lookup_by_val(PRPMultiIndexCache& prp_cache, const String& search_interface_id,
	      const Variables& search_vars,  const ActiveSet& search_set)
{
  Response search_resp(SIMULATION_RESPONSE, search_set);
  ParamResponsePair search_pr(search_vars, search_interface_id, search_resp);
  return lookup_by_val(prp_cache, search_pr);
}

/* Better to use cache iterators and avoid extra shallow copies if not needed

/// alternate overloaded form returns bool and sets found_pr by wrapping
/// lookup_by_val(PRPMultiIndexCache&, ParamResponsePair&)
inline bool
lookup_by_val(PRPMultiIndexCache& prp_cache, const ParamResponsePair& search_pr,
	      ParamResponsePair& found_pr)
{
  PRPCacheHIter prp_hash_it = lookup_by_val(prp_cache, search_pr);
  if (prp_hash_it != prp_cache.get<hashed>().end()) {
    found_pr = *prp_hash_it;
    return true;
  }
  else
    return false;
}

/// alternate overloaded form returns bool and sets found_pr by wrapping
/// lookup_by_val(PRPMultiIndexCache&, String&, Variables&, ActiveSet&)
inline bool
lookup_by_val(PRPMultiIndexCache& prp_cache, const String& search_interface_id,
	      const Variables& search_vars, const ActiveSet& search_set,
	      ParamResponsePair& found_pr)
{
  PRPCacheHIter prp_hash_it
    = lookup_by_val(prp_cache, search_interface_id, search_vars, search_set);
  if (prp_hash_it != prp_cache.get<hashed>().end()) {
    found_pr = *prp_hash_it;
    return true;
  }
  else
    return false;
}

/// find the response of a ParamResponsePair within a PRPMultiIndexCache
/// based on interface id, variables, and ActiveSet search data
inline bool
lookup_by_val(PRPMultiIndexCache& prp_cache, const String& search_interface_id,
	      const Variables& search_vars, const ActiveSet& search_set,
	      Response& found_resp)
{
  PRPCacheHIter prp_hash_it
    = lookup_by_val(prp_cache, search_interface_id, search_vars, search_set);
  if (prp_hash_it != prp_cache.get<hashed>().end()) {
    found_resp = prp_hash_it->response();
    return true;
  }
  else
    return false;
}
*/

inline PRPCacheOIter
lookup_by_nearby_val(PRPMultiIndexCache& prp_cache,
		     const String& search_interface_id,
		     const Variables& search_vars, const ActiveSet& search_set,
		     Real tol)
{
  PRPCacheOIter cache_it;
  for (cache_it=prp_cache.begin(); cache_it!=prp_cache.end(); ++cache_it)
    if (cache_it->interface_id() == search_interface_id      && // exact
	nearby(cache_it->variables(), search_vars, tol) && // tolerance
	set_compare(*cache_it, search_set))                     // subset
      return cache_it; // Duplication detected.
  return prp_cache.end();
}

// ------------------------------------
// lookup_by_ids for PRPMultiIndexCache
// ------------------------------------
/// find a ParamResponsePair within a PRPMultiIndexCache based on search_ids
/// (i.e. std::pair<eval_id,interface_id>) search data
inline PRPCacheOIter
lookup_by_ids(PRPMultiIndexCache& prp_cache, const IntStringPair& search_ids)
{
  // sign of eval id indicates different dataset sources:
  //   eval id > 0 for unique evals from current execution (in data_pairs)
  //   eval id = 0 for evals from file import (not in data_pairs)
  //   eval id < 0 for non-unique evals from restart (in data_pairs)
  if (search_ids.first > 0) // positive ids (evals from current exec) are unique
    return prp_cache.get<ordered>().find(search_ids);
  else { // negative (restart) and 0 (file import) ids are non-unique in general

    /*
    // could allow lookup if only one item found, but still a misuse of the fn
    PRPCacheOIter prp_it0, prp_it1;
    boost::tuples::tie(prp_it0, prp_it1)
      = prp_cache.get<ordered>().equal_range(search_ids);
    switch (std::distance(prp_it0, prp_it1)) {
    case 0: return prp_cache.get<ordered>().end(); break;
    case 1: return prp_it0;                        break;
    default:
      Cerr << "Error: duplicate entries in PRPCache lookup_by_ids()."
           << std::endl;
      abort_handler(-1); break;
    }
    */

    Cerr << "Error: lookup_by_ids(PRPCache&) used for lookup with non-positive "
	 << "evaluation id, which may be non-unique." << std::endl;
    abort_handler(-1);
  }
}

inline PRPCacheOIter
lookup_by_ids(PRPMultiIndexCache& prp_cache, const IntStringPair& search_ids,
	      const ParamResponsePair& search_pr)
{
  // sign of eval id indicates different dataset sources:
  //   eval id > 0 for unique evals from current execution (in data_pairs)
  //   eval id = 0 for evals from file import (not in data_pairs)
  //   eval id < 0 for non-unique evals from restart (in data_pairs)
  if (search_ids.first > 0) // positive ids (evals from current exec) are unique
    return prp_cache.get<ordered>().find(search_ids);
  else { // negative (restart) and 0 (file import) ids are non-unique in general

    // equal_range returns a small sequence of possibilities resulting from
    // ordered lookup with ONLY search_ids.  Post-processing can then be
    // applied to this sequence if needed using vars_compare().
    PRPCacheOIter prp_it0, prp_it1;
    boost::tuples::tie(prp_it0, prp_it1)
      = prp_cache.get<ordered>().equal_range(search_ids);
    switch (std::distance(prp_it0, prp_it1)) {
    case 0: return prp_cache.get<ordered>().end(); break;
    case 1: return prp_it0;                        break;
    default:
      while (prp_it0 != prp_it1) {
	if (prp_it0->variables() == search_pr.variables() && // exact
	    set_compare(*prp_it0, search_pr.active_set()))            // subset
	  return prp_it0;
	++prp_it0;
      }
      return prp_cache.get<ordered>().end();       break;
    }
  }
}

/* Better to use cache iterators and avoid extra shallow copies if not needed

/// find a ParamResponsePair within a PRPMultiIndexCache based on
/// eval_interface_ids
inline bool
lookup_by_ids(PRPMultiIndexCache& prp_cache,
              const IntStringPair& search_eval_interface_ids,
              ParamResponsePair& found_pr)
{
  PRPCacheOIter prp_iter = lookup_by_ids(prp_cache, search_eval_interface_ids);
  if (prp_iter != prp_cache.get<ordered>().end()) {
    found_pr = *prp_iter;
    return true;
  }
  else
    return false;
}

/// find a ParamResponsePair within a PRPMultiIndexCache based on
/// eval_interface_ids from the ParamResponsePair search data
inline bool
lookup_by_ids(PRPMultiIndexCache& prp_cache, const ParamResponsePair& search_pr,
              ParamResponsePair& found_pr)
{ return lookup_by_ids(prp_cache, search_pr.eval_interface_ids(), found_pr); }
*/

// ------------------------------------
// lookup_by_val for PRPMultiIndexQueue
// ------------------------------------

/// find a ParamResponsePair based on the interface id, variables, and
/// ActiveSet search data within search_pr.

/** Lookup occurs in two steps: (1) PRPMultiIndexQueue lookup based on
    strict equality in interface id and variables, and (2) set_compare()
    post-processing based on ActiveSet subset logic. */
inline PRPQueueHIter
lookup_by_val(PRPMultiIndexQueue& prp_queue, const ParamResponsePair& search_pr)
{
  PRPQueueHIter prp_hash_it0, prp_hash_it1;
  boost::tuples::tie(prp_hash_it0, prp_hash_it1)
    = prp_queue.get<hashed>().equal_range(search_pr);

  // equal_range returns a small sequence of possibilities resulting from
  // hashing with ONLY interfaceId and variables.  Post-processing is then
  // applied to this sequence using set_compare().
  while (prp_hash_it0 != prp_hash_it1) {
    if (set_compare(*prp_hash_it0, search_pr.active_set()))
      return prp_hash_it0;
    ++prp_hash_it0;
  }
  return prp_queue.get<hashed>().end();
}

/// find a ParamResponsePair within a PRPMultiIndexQueue based on
/// interface id, variables, and ActiveSet search data
inline PRPQueueHIter
lookup_by_val(PRPMultiIndexQueue& prp_queue, const String& search_interface_id,
	      const Variables& search_vars,  const ActiveSet& search_set)
{
  Response search_resp(SIMULATION_RESPONSE, search_set);
  ParamResponsePair search_pr(search_vars, search_interface_id, search_resp);
  return lookup_by_val(prp_queue, search_pr);
}

/* Better to use cache iterators and avoid extra shallow copies if not needed

/// alternate overloaded form returns bool and sets found_pr by wrapping
/// lookup_by_val(PRPMultiIndexQueue&, ParamResponsePair&)
inline bool
lookup_by_val(PRPMultiIndexQueue& prp_queue, const ParamResponsePair& search_pr,
	      ParamResponsePair& found_pr)
{
  PRPQueueHIter prp_hash_it = lookup_by_val(prp_queue, search_pr);
  if (prp_hash_it != prp_queue.get<hashed>().end()) {
    found_pr = *prp_hash_it;
    return true;
  }
  else
    return false;
}

/// alternate overloaded form returns bool and sets found_pr by wrapping
/// lookup_by_val(PRPMultiIndexQueue&, String&, Variables&, ActiveSet&)
inline bool
lookup_by_val(PRPMultiIndexQueue& prp_queue, const String& search_interface_id,
	      const Variables& search_vars, const ActiveSet& search_set,
	      ParamResponsePair& found_pr)
{
  PRPQueueHIter prp_hash_it
    = lookup_by_val(prp_queue, search_interface_id, search_vars, search_set);
  if (prp_hash_it != prp_queue.get<hashed>().end()) {
    found_pr = *prp_hash_it;
    return true;
  }
  else
    return false;
}

/// find the response of a ParamResponsePair within a PRPMultiIndexQueue
/// based on interface id, variables, and ActiveSet search data
inline bool
lookup_by_val(PRPMultiIndexQueue& prp_queue, const String& search_interface_id,
	      const Variables& search_vars, const ActiveSet& search_set,
	      Response& found_resp)
{
  PRPQueueHIter prp_hash_it
    = lookup_by_val(prp_queue, search_interface_id, search_vars, search_set);
  if (prp_hash_it != prp_queue.get<hashed>().end()) {
    found_resp = prp_hash_it->response();
    return true;
  }
  else
    return false;
}
*/

// ----------------------------------------
// lookup_by_eval_id for PRPMultiIndexQueue
// ----------------------------------------
/// find a ParamResponsePair within a PRPMultiIndexQueue based on search_id
/// (i.e. integer eval_id) search data
inline PRPQueueOIter
lookup_by_eval_id(PRPMultiIndexQueue& prp_queue, int search_id)
{ return prp_queue.get<ordered>().find(search_id); }

/* Better to use cache iterators and avoid extra shallow copies if not needed

/// find a ParamResponsePair within a PRPMultiIndexQueue based on eval_id
inline bool
lookup_by_eval_id(PRPMultiIndexQueue& prp_queue, int search_id,
		  ParamResponsePair& found_pr)
{
  PRPQueueOIter prp_iter = lookup_by_eval_id(prp_queue, search_id);
  if (prp_iter != prp_queue.get<ordered>().end()) {
    found_pr = *prp_iter;
    return true;
  }
  else
    return false;
}

/// find a ParamResponsePair within a PRPMultiIndexQueue based on
/// eval_id from the ParamResponsePair search data
inline bool
lookup_by_eval_id(PRPMultiIndexQueue& prp_queue,
		  const ParamResponsePair& search_pr,
		  ParamResponsePair& found_pr)
{ return lookup_by_eval_id(prp_queue, search_pr.eval_id(), found_pr); }
*/

} // namespace Dakota

#endif // PRP_MULTI_INDEX_H

ext: hpp

max_stars_repo_name: seakers/ExtUtils

max_issues_repo_name: seakers/ExtUtils

max_forks_repo_name: seakers/ExtUtils


text:
#pragma once

#include <Eigen/Dense>

#include <utils/types.hpp>

template<int Dimension>
struct Pose
{
    Eigen::Matrix<double, Dimension, Dimension> rotation;
    Eigen::Matrix<double, Dimension, 1> translation;

    /*
     * Pose constructor
    **/
    Pose(const Eigen::Matrix<double, Dimension, Dimension>& r = Eigen::Matrix<double, Dimension, Dimension>::Identity(),
         const Eigen::Matrix<double, Dimension, 1>& t = Eigen::Matrix<double, Dimension,1>::Zero())
    : rotation(r), translation(t)
    {}

    /*
     * Pose destructor
    **/
    ~Pose(){};
};

using Pose2D = Pose<2>;
using Pose3D = Pose<3>;

using Poses2D = AlignedVector<Pose2D>;
using Poses3D = AlignedVector<Pose3D>;

/*
 * the custom operator<< for Pose
**/
template<int Dimension>
std::ostream& operator<<(std::ostream& os, const Pose<Dimension>& p)
{
    os << "rotation:\n" << p.rotation.transpose() << "\n";
    os << "translation: " << p.translation.transpose();

    return os;
}

max_stars_repo_name: charlybigoud/kidocam

max_issues_repo_name: charlybigoud/kidocam

max_forks_repo_name: charlybigoud/kidocam


text:
#ifndef HPP_STATE
#define HPP_STATE

#include <boost/serialization/access.hpp>
#include <boost/serialization/set.hpp>
#include <boost/serialization/map.hpp>

#include <set>
#include <map>
#include <vector>
#include <utility>

class state {
private:
    size_t                                          d_depth;
    state*                                          d_root;
    std::map<char, state*>                          d_success;
    state*                                          d_failure;
    std::set<std::pair<unsigned int, unsigned int>> d_pieces;

public:
    state(): state(0) {}

    explicit state(size_t depth)
        : d_depth(depth)
        , d_root(depth == 0 ? this : nullptr)
        , d_success()
        , d_failure(nullptr)
        , d_pieces() {}

    state* next(char character) const {
        return next(character, false);
    }

    state* next_without_root(char character) const {
        return next(character, true);
    }

    state* add(char character) {
        auto next = next_without_root(character);

        if (next == nullptr) {
            next = new state(d_depth + 1);
            d_success[character] = next;
        }

        return next;
    }

    size_t depth() const {
        return d_depth;
    }

    void add_piece(unsigned int size, unsigned int index) {
        d_pieces.insert(std::make_pair(size, index));
    }

    void add_piece(const std::set<std::pair<unsigned int, unsigned int>>& pieces) {
        for (const auto& p : pieces) {
            add_piece(p.first, p.second);
        }
    }

    std::set<std::pair<unsigned int, unsigned int>> pieces() const {
        return d_pieces;
    }

    state* failure() const {
        return d_failure;
    }

    void failure(state* fail_state) {
        d_failure = fail_state;
    }

    std::vector<state*> states() const {
        std::vector<state*> result;

        for (auto it = d_success.cbegin(); it != d_success.cend(); ++it) {
            result.push_back(it->second);
        }

        return std::vector<state*>(result);
    }

    std::vector<char> transitions() const {
        std::vector<char> result;

        for (auto it = d_success.cbegin(); it != d_success.cend(); ++it) {
            result.push_back(it->first);
        }

        return std::vector<char>(result);
    }

private:
    state* next(char character, bool ignore_root_state) const {
        state* result = nullptr;
        auto found = d_success.find(character);

        if (found != d_success.end()) {
            result = found->second;
        }
        else if (!ignore_root_state && d_root != nullptr) {
            result = d_root;
        }

        return result;
    }

private:
    friend class boost::serialization::access;

    template <typename Archive>
    void serialize(Archive &ar, const unsigned int version) {
        ar & d_depth;
        ar & d_root;
        ar & d_success;
        ar & d_failure;
        ar & d_pieces;
    }
};

#endif


text:
// Copyright 2007-2009 Daniel James.
// 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)

// clang-format off
#include "../helpers/prefix.hpp"
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
#include "../helpers/postfix.hpp"
// clang-format on

#include "../helpers/test.hpp"

#include <iostream>

namespace insert_stable {
struct member
{
    int tag1_;
    int tag2_;

    member() : tag1_(0), tag2_(0) {}
    member(int t1, int t2) : tag1_(t1), tag2_(t2) {}

    friend bool operator==(member const& x, member const& y)
    {
        return x.tag1_ == y.tag1_;
    }

    friend bool operator!=(member const& x, member const& y)
    {
        return x.tag1_ != y.tag1_;
    }
};
}

#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
namespace boost
#else
namespace insert_stable
#endif
{
std::size_t hash_value(insert_stable::member const& x)
{
    return static_cast<std::size_t>(x.tag1_);
}
}

// This is now only supported when using grouped nodes. I can't see any
// efficient way to do it otherwise.
#if !BOOST_UNORDERED_INTEROPERABLE_NODES

UNORDERED_AUTO_TEST(stable_insert_test1)
{
    boost::unordered_multiset<insert_stable::member> x;

    x.insert(insert_stable::member(1, 1));
    x.insert(insert_stable::member(1, 2));
    x.insert(insert_stable::member(1, 3));

    BOOST_TEST(x.count(insert_stable::member(1, 4)) == 3);

    boost::unordered_multiset<insert_stable::member>::const_iterator
        it = x.begin(),
        end = x.end();
    BOOST_TEST(it != end);
    if (it != end) {
        BOOST_TEST(it->tag2_ == 1);
        ++it;
    }
    BOOST_TEST(it != end);
    if (it != end) {
        BOOST_TEST(it->tag2_ == 2);
        ++it;
    }
    BOOST_TEST(it != end);
    if (it != end) {
        BOOST_TEST(it->tag2_ == 3);
        ++it;
    }
    BOOST_TEST(it == end);
}

UNORDERED_AUTO_TEST(stable_insert_test2)
{
    boost::unordered_multimap<insert_stable::member, int> x;
    typedef boost::unordered_multimap<insert_stable::member,
        int>::const_iterator iterator;

    iterator it = x.emplace(insert_stable::member(1, 1), 1);
    it = x.emplace(insert_stable::member(1, 2), 2);
    it = x.emplace(insert_stable::member(1, 3), 3);

    BOOST_TEST(x.count(insert_stable::member(1, 4)) == 3);

    it = x.begin();
    iterator end = x.end();
    BOOST_TEST(it != end);
    if (it != end) {
        BOOST_TEST(it->first.tag2_ == 1 && it->second == 1);
        ++it;
    }
    BOOST_TEST(it != end);
    if (it != end) {
        BOOST_TEST(it->first.tag2_ == 2 && it->second == 2);
        ++it;
    }
    BOOST_TEST(it != end);
    if (it != end) {
        BOOST_TEST(it->first.tag2_ == 3 && it->second == 3);
        ++it;
    }
    BOOST_TEST(it == end);
}

#endif

RUN_TESTS()

max_stars_repo_name: ZCube/boost-cmake

max_issues_repo_name: ZCube/boost-cmake

max_forks_repo_name: ZCube/boost-cmake


text:
//  Copyright (c) 2001-2011 Hartmut Kaiser
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#if !defined(BOOST_SPIRIT_KARMA_AS_STRING_DEC_18_0644PM)
#define BOOST_SPIRIT_KARMA_AS_STRING_DEC_18_0644PM

#if defined(_MSC_VER)
#pragma once
#endif

#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/attributes_fwd.hpp>

///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace traits
{
    ///////////////////////////////////////////////////////////////////////////
    //  This file contains the attribute to string conversion utility. The
    //  utility provided also accept spirit's unused_type; all no-ops. Compiler
    //  optimization will easily strip these away.
    ///////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////
    template <typename T, typename Attribute>
    inline typename spirit::result_of::attribute_as<T, Attribute>::type
    as(Attribute const& attr)
    {
        return attribute_as<T, Attribute>::call(attr);
    }

    template <typename T>
    inline unused_type as(unused_type)
    {
        return unused;
    }

    ///////////////////////////////////////////////////////////////////////////
    template <typename T, typename Attribute>
    inline bool valid_as(Attribute const& attr)
    {
        return attribute_as<T, Attribute>::is_valid(attr);
    }

    template <typename T>
    inline bool valid_as(unused_type)
    {
        return true;
    }
}}}

///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace result_of
{
    template <typename T, typename Attribute>
    struct attribute_as
      : traits::attribute_as<T, Attribute>
    {};

    template <typename T>
    struct attribute_as<T, unused_type>
    {
        typedef unused_type type;
    };

    template <typename T>
    struct attribute_as<T, unused_type const>
    {
        typedef unused_type type;
    };
}}}

#endif

max_stars_repo_name: rudylee/expo

max_issues_repo_name: rudylee/expo

max_forks_repo_name: rudylee/expo


text:
//  Copyright (c) 2001-2011 Hartmut Kaiser
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#if !defined(SPIRIT_LEX_SUPPORT_FUNCTIONS_JUN_08_2009_0211PM)
#define SPIRIT_LEX_SUPPORT_FUNCTIONS_JUN_08_2009_0211PM

#if defined(_MSC_VER)
#pragma once
#endif

#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/home/support/detail/scoped_enum_emulation.hpp>
#include <boost/spirit/home/lex/lexer/pass_flags.hpp>

#include <boost/spirit/home/lex/lexer/support_functions_expression.hpp>

///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace lex
{
    ///////////////////////////////////////////////////////////////////////////
    // The function object less_type is used by the implementation of the
    // support function lex::less(). Its functionality is equivalent to flex'
    // function yyless(): it returns an iterator positioned to the nth input
    // character beyond the current start iterator (i.e. by assigning the
    // return value to the placeholder '_end' it is possible to return all but
    // the first n characters of the current token back to the input stream.
    //
    //  This Phoenix actor is invoked whenever the function lex::less(n) is
    //  used inside a lexer semantic action:
    //
    //      lex::token_def<> identifier = "[a-zA-Z_][a-zA-Z0-9_]*";
    //      this->self = identifier [ _end = lex::less(4) ];
    //
    //  The example shows how to limit the length of the matched identifier to
    //  four characters.
    //
    //  Note: the function lex::less() has no effect if used on it's own, you
    //        need to use the returned result in order to make use of its
    //        functionality.
    template <typename Actor>
    struct less_type
    {
        typedef mpl::true_ no_nullary;

        template <typename Env>
        struct result
        {
            typedef typename
                remove_const<
                    typename mpl::at_c<typename Env::args_type, 4>::type
                >::type
            context_type;
            typedef typename context_type::base_iterator_type type;
        };

        template <typename Env>
        typename result<Env>::type
        eval(Env const& env) const
        {
            typename result<Env>::type it;
            return fusion::at_c<4>(env.args()).less(it, actor_());
        }

        less_type(Actor const& actor)
          : actor_(actor) {}

        Actor actor_;
    };

    //  The function lex::less() is used to create a Phoenix actor allowing to
    //  implement functionality similar to flex' function yyless().
    template <typename T>
    inline typename expression::less<
        typename phoenix::as_actor<T>::type
    >::type const
    less(T const& v)
    {
        return expression::less<T>::make(phoenix::as_actor<T>::convert(v));
    }

    ///////////////////////////////////////////////////////////////////////////
    // The function object more_type is used by the implementation of the
    // support function lex::more(). Its functionality is equivalent to flex'
    // function yymore(): it tells the lexer that the next time it matches a
    // rule, the corresponding token should be appended onto the current token
    // value rather than replacing it.
    //
    //  This Phoenix actor is invoked whenever the function lex::more(n) is
    //  used inside a lexer semantic action:
    //
    //      lex::token_def<> identifier = "[a-zA-Z_][a-zA-Z0-9_]*";
    //      this->self = identifier [ lex::more() ];
    //
    //  The example shows how prefix the next matched token with the matched
    //  identifier.
    struct more_type
    {
        typedef mpl::true_ no_nullary;

        template <typename Env>
        struct result
        {
            typedef void type;
        };

        template <typename Env>
        void eval(Env const& env) const
        {
            fusion::at_c<4>(env.args()).more();
        }
    };

    //  The function lex::more() is used to create a Phoenix actor allowing to
    //  implement functionality similar to flex' function yymore().
    //inline expression::more<mpl::void_>::type const
    inline phoenix::actor<more_type> more()
    {
        return phoenix::actor<more_type>();
    }

    ///////////////////////////////////////////////////////////////////////////
    // The function object lookahead_type is used by the implementation of the
    // support function lex::lookahead(). Its functionality is needed to
    // emulate the flex' lookahead operator a/b. Use lex::lookahead() inside
    // of lexer semantic actions to test whether the argument to this function
    // matches the current look ahead input. lex::lookahead() can be used with
    // either a token id or a token_def instance as its argument. It returns
    // a bool indicating whether the look ahead has been matched.
    template <typename IdActor, typename StateActor>
    struct lookahead_type
    {
        typedef mpl::true_ no_nullary;

        template <typename Env>
        struct result
        {
            typedef bool type;
        };

        template <typename Env>
        bool eval(Env const& env) const
        {
            return fusion::at_c<4>(env.args()).
                lookahead(id_actor_(), state_actor_());
        }

        lookahead_type(IdActor const& id_actor, StateActor const& state_actor)
          : id_actor_(id_actor), state_actor_(state_actor) {}

        IdActor id_actor_;
        StateActor state_actor_;
    };

    //  The function lex::lookahead() is used to create a Phoenix actor
    //  allowing to implement functionality similar to flex' lookahead operator
    //  a/b.
    template <typename T>
    inline typename expression::lookahead<
        typename phoenix::as_actor<T>::type
      , typename phoenix::as_actor<std::size_t>::type
    >::type const
    lookahead(T const& id)
    {
        typedef typename phoenix::as_actor<T>::type id_actor_type;
        typedef typename phoenix::as_actor<std::size_t>::type state_actor_type;

        return expression::lookahead<id_actor_type, state_actor_type>::make(
            phoenix::as_actor<T>::convert(id),
            phoenix::as_actor<std::size_t>::convert(std::size_t(~0)));
    }

    template <typename Attribute, typename Char, typename Idtype>
    inline typename expression::lookahead<
        typename phoenix::as_actor<Idtype>::type
      , typename phoenix::as_actor<std::size_t>::type
    >::type const
    lookahead(token_def<Attribute, Char, Idtype> const& tok)
    {
        typedef typename phoenix::as_actor<Idtype>::type id_actor_type;
        typedef typename phoenix::as_actor<std::size_t>::type state_actor_type;

        std::size_t state = tok.state();

        // The following assertion fires if you pass a token_def instance to
        // lex::lookahead without first associating this instance with the
        // lexer.
        BOOST_ASSERT(std::size_t(~0) != state &&
            "token_def instance not associated with lexer yet");

        return expression::lookahead<id_actor_type, state_actor_type>::make(
            phoenix::as_actor<Idtype>::convert(tok.id()),
            phoenix::as_actor<std::size_t>::convert(state));
    }

    ///////////////////////////////////////////////////////////////////////////
    inline BOOST_SCOPED_ENUM(pass_flags) ignore()
    {
        return pass_flags::pass_ignore;
    }

}}}

#endif

max_stars_repo_name: randolphwong/mcsema

max_issues_repo_name: randolphwong/mcsema

max_forks_repo_name: randolphwong/mcsema


text:
#pragma once

#include <sigmaengine/protocol/authority.hpp>
#include <sigmaengine/protocol/sigmaengine_operations.hpp>

#include <sigmaengine/chain/sigmaengine_object_types.hpp>
#include <sigmaengine/chain/account_object.hpp>

#include <boost/multi_index/composite_key.hpp>
#include <boost/multiprecision/cpp_int.hpp>

namespace sigmaengine { namespace chain {

   using sigmaengine::protocol::asset;
   using sigmaengine::protocol::price;
   using sigmaengine::protocol::asset_symbol_type;

   typedef protocol::fixed_string_16 common_fund_name_type;

   class savings_withdraw_object : public object< savings_withdraw_object_type, savings_withdraw_object >
   {
      savings_withdraw_object() = delete;

      public:
         template< typename Constructor, typename Allocator >
         savings_withdraw_object( Constructor&& c, allocator< Allocator > a )
            :memo( a )
         {
            c( *this );
         }

         id_type           id;

         account_name_type from;
         account_name_type to;
         shared_string     memo;
         uint32_t          request_id = 0;
         asset             amount;
         asset             total_amount;
         uint8_t           split_pay_order = 0;
         uint8_t           split_pay_month = 0;
         time_point_sec    complete;
   };

   class fund_withdraw_object : public object< fund_withdraw_object_type, fund_withdraw_object >
   {
      fund_withdraw_object() = delete;

      public:
         template< typename Constructor, typename Allocator >
         fund_withdraw_object( Constructor&& c, allocator< Allocator > a )
            :fund_name( a ), memo( a )
         {
            c( *this );
         }

         id_type           id;

         account_name_type from;
         shared_string     fund_name;
         shared_string     memo;
         uint32_t          request_id = 0;
         asset             amount;
         time_point_sec    complete;
   };

   class decline_voting_rights_request_object : public object< decline_voting_rights_request_object_type, decline_voting_rights_request_object >
   {
      public:
         template< typename Constructor, typename Allocator >
         decline_voting_rights_request_object( Constructor&& c, allocator< Allocator > a )
         {
            c( *this );
         }

         decline_voting_rights_request_object(){}

         id_type           id;

         account_id_type   account;
         time_point_sec    effective_date;
   };

   class account_auth_object : public object< account_auth_object_type, account_auth_object >
   {
      account_auth_object() = delete;

      public:
         template< typename Constructor, typename Allocator >
         account_auth_object( Constructor&& c, allocator< Allocator > a )
         :auth_type( a ), auth_token( a )
         {
            c( *this );
         }

         id_type           id;
         account_name_type account;
         shared_string     auth_type;
         shared_string     auth_token;
         time_point_sec    reg_date;
   };

   class common_fund_object : public object< common_fund_object_type, common_fund_object >
   {
      public:
         template< typename Constructor, typename Allocator >
         common_fund_object( Constructor&& c, allocator< Allocator > a )
         {
            c( *this );
         }

         common_fund_object() {}

         common_fund_id_type                 id;
         common_fund_name_type               name;
         asset                               fund_balance = asset( 0, SGT_SYMBOL );
         asset                               fund_withdraw_ready = asset( 0, SGT_SYMBOL );
         fc::array<fc::array<double,SIGMAENGINE_MAX_STAKING_MONTH>,SIGMAENGINE_MAX_USER_TYPE>   percent_interest;
         time_point_sec                      last_update;
   };

   class dapp_reward_fund_object : public object< dapp_reward_fund_object_type, dapp_reward_fund_object>
   {
      public:
         template< typename Constructor, typename Allocator >
         dapp_reward_fund_object( Constructor&& c, allocator< Allocator > a )
         {
            c( *this );
         }

         dapp_reward_fund_object(){}

         dapp_reward_fund_id_type         id;
         asset                            fund_balance = asset( 0, SGT_SYMBOL );
         time_point_sec                   last_update;
   };

   class transaction_fee_vote_object : public object< transaction_fee_vote_object_type, transaction_fee_vote_object >
   {
      public:
         template< typename Constructor, typename Allocator >
         transaction_fee_vote_object( Constructor&& c, allocator< Allocator > a )
         {
            c( *this );
         }

         id_type                 id;
         account_name_type       voter;
         asset                   trx_fee = asset(0, SGT_SYMBOL);
         uint32_t                vote_block = 0;
   };

   class transaction_fee_reward_object : public object< transaction_fee_reward_object_type, transaction_fee_reward_object>
   {
      public:
         template< typename Constructor, typename Allocator >
         transaction_fee_reward_object( Constructor&& c, allocator< Allocator > a )
         {
            c( *this );
         }

         transaction_fee_reward_object(){}

         id_type                   id;
         asset                     fund_balance = asset( 0, SGT_SYMBOL );
         uint32_t                  reward_block = 0;
   };

   struct by_from_rid;
   struct by_to_complete;
   struct by_complete_from_rid;
   typedef multi_index_container<
      savings_withdraw_object,
      indexed_by<
         ordered_unique< tag< by_id >, member< savings_withdraw_object, savings_withdraw_id_type, &savings_withdraw_object::id > >,
         ordered_unique< tag< by_from_rid >,
            composite_key< savings_withdraw_object,
               member< savings_withdraw_object, account_name_type,  &savings_withdraw_object::from >,
               member< savings_withdraw_object, uint32_t, &savings_withdraw_object::request_id >
            >
         >,
         ordered_unique< tag< by_to_complete >,
            composite_key< savings_withdraw_object,
               member< savings_withdraw_object, account_name_type,  &savings_withdraw_object::to >,
               member< savings_withdraw_object, time_point_sec,  &savings_withdraw_object::complete >,
               member< savings_withdraw_object, savings_withdraw_id_type, &savings_withdraw_object::id >
            >
         >,
         ordered_unique< tag< by_complete_from_rid >,
            composite_key< savings_withdraw_object,
               member< savings_withdraw_object, time_point_sec,  &savings_withdraw_object::complete >,
               member< savings_withdraw_object, account_name_type,  &savings_withdraw_object::from >,
               member< savings_withdraw_object, uint32_t, &savings_withdraw_object::request_id >
            >
         >
      >,
      allocator< savings_withdraw_object >
   > savings_withdraw_index;

   struct by_from_id;
   struct by_complete_from;
   struct by_from_complete;
   struct by_amount_id;
   typedef multi_index_container<
      fund_withdraw_object,
      indexed_by<
         ordered_unique< tag< by_id >, member< fund_withdraw_object, fund_withdraw_id_type, &fund_withdraw_object::id > >,
         ordered_unique< tag< by_from_id >,
            composite_key< fund_withdraw_object,
               member< fund_withdraw_object, account_name_type,  &fund_withdraw_object::from >,
               member< fund_withdraw_object, shared_string,  &fund_withdraw_object::fund_name >,
               member< fund_withdraw_object, uint32_t, &fund_withdraw_object::request_id >
            >,
            composite_key_compare< std::less< account_name_type >, chainbase::strcmp_less, std::less< uint32_t > >
         >,
         ordered_unique< tag< by_complete_from >,
            composite_key< fund_withdraw_object,
               member< fund_withdraw_object, time_point_sec,  &fund_withdraw_object::complete >,
               member< fund_withdraw_object, account_name_type,  &fund_withdraw_object::from >,
               member< fund_withdraw_object, shared_string,  &fund_withdraw_object::fund_name >,
               member< fund_withdraw_object, fund_withdraw_id_type, &fund_withdraw_object::id >
            >
         >,
         ordered_unique< tag< by_from_complete >,
            composite_key< fund_withdraw_object,
               member< fund_withdraw_object, account_name_type,  &fund_withdraw_object::from >,
               member< fund_withdraw_object, shared_string,  &fund_withdraw_object::fund_name >,
               member< fund_withdraw_object, time_point_sec,  &fund_withdraw_object::complete >,
               member< fund_withdraw_object, fund_withdraw_id_type, &fund_withdraw_object::id >
            >,
            composite_key_compare< std::less< account_name_type >, chainbase::strcmp_less, std::less< time_point_sec >, std::less< fund_withdraw_id_type > >
         >,
         ordered_unique< tag< by_amount_id >,
            composite_key< fund_withdraw_object,
               member< fund_withdraw_object, shared_string,  &fund_withdraw_object::fund_name >,
               member< fund_withdraw_object, asset,  &fund_withdraw_object::amount >,
               member< fund_withdraw_object, fund_withdraw_id_type, &fund_withdraw_object::id >
            >,
            composite_key_compare< chainbase::strcmp_less, std::greater< asset >, std::less< fund_withdraw_id_type > >
         >
      >,
      allocator< fund_withdraw_object >
   > fund_withdraw_index;

   struct by_name;
   typedef multi_index_container<
      common_fund_object,
      indexed_by<
         ordered_unique< tag< by_id >, member< common_fund_object, common_fund_id_type, &common_fund_object::id > >,
         ordered_unique< tag< by_name >, member< common_fund_object, common_fund_name_type, &common_fund_object::name > >
      >,
      allocator< common_fund_object >
   > common_fund_index;

   struct by_account;
   struct by_effective_date;
   typedef multi_index_container<
      decline_voting_rights_request_object,
      indexed_by<
         ordered_unique< tag< by_id >, member< decline_voting_rights_request_object, decline_voting_rights_request_id_type, &decline_voting_rights_request_object::id > >,
         ordered_unique< tag< by_account >,
            member< decline_voting_rights_request_object, account_id_type, &decline_voting_rights_request_object::account >
         >,
         ordered_unique< tag< by_effective_date >,
            composite_key< decline_voting_rights_request_object,
               member< decline_voting_rights_request_object, time_point_sec, &decline_voting_rights_request_object::effective_date >,
               member< decline_voting_rights_request_object, account_id_type, &decline_voting_rights_request_object::account >
            >,
            composite_key_compare< std::less< time_point_sec >, std::less< account_id_type > >
         >
      >,
      allocator< decline_voting_rights_request_object >
   > decline_voting_rights_request_index;

   struct by_reg_date;
   struct by_auth_type;
   typedef multi_index_container<
      account_auth_object,
      indexed_by<
         ordered_unique< tag< by_id >, member< account_auth_object, account_auth_id_type, &account_auth_object::id > >,
         ordered_unique< tag< by_auth_type >,
            composite_key< account_auth_object,
               member< account_auth_object, account_name_type, &account_auth_object::account >,
               member< account_auth_object, shared_string, &account_auth_object::auth_type >
            >,
            composite_key_compare< std::less< account_name_type >, chainbase::strcmp_less>
         >
      >,
      allocator< account_auth_object >
   > account_auth_index;

   typedef multi_index_container<
      dapp_reward_fund_object,
      indexed_by<
         ordered_unique< tag< by_id >, member< dapp_reward_fund_object, dapp_reward_fund_id_type, &dapp_reward_fund_object::id > >
      >,
      allocator< dapp_reward_fund_object >
   > dapp_reward_fund_index;

   struct by_voter;
   typedef multi_index_container <
      transaction_fee_vote_object,
      indexed_by <
         ordered_unique < tag < by_id >,
            member < transaction_fee_vote_object, transaction_fee_vote_id_type, &transaction_fee_vote_object::id >
         >,
         ordered_unique < tag < by_voter >,
            composite_key< transaction_fee_vote_object,
               member < transaction_fee_vote_object, account_name_type, &transaction_fee_vote_object::voter >
            >
         >
      >,
      allocator < transaction_fee_vote_object >
   > transaction_fee_vote_index;

   typedef multi_index_container<
      transaction_fee_reward_object,
      indexed_by<
         ordered_unique< tag< by_id >, member< transaction_fee_reward_object, transaction_fee_reward_id_type, &transaction_fee_reward_object::id > >
      >,
      allocator< transaction_fee_reward_object >
   > transaction_fee_reward_index;

} } // sigmaengine::chain

FC_REFLECT( sigmaengine::chain::savings_withdraw_object,
             (id)(from)(to)(memo)(request_id)(amount)(total_amount)(split_pay_order)(split_pay_month)(complete) )
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::savings_withdraw_object, sigmaengine::chain::savings_withdraw_index )

FC_REFLECT( sigmaengine::chain::common_fund_object,
            (id)
            (name)
            (fund_balance)
            (fund_withdraw_ready)
            (percent_interest)
            (last_update)
         )
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::common_fund_object, sigmaengine::chain::common_fund_index )

FC_REFLECT( sigmaengine::chain::fund_withdraw_object,
             (from)(fund_name)(memo)(request_id)(amount)(complete) )
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::fund_withdraw_object, sigmaengine::chain::fund_withdraw_index )

FC_REFLECT( sigmaengine::chain::decline_voting_rights_request_object,
             (id)(account)(effective_date) )
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::decline_voting_rights_request_object, sigmaengine::chain::decline_voting_rights_request_index )

FC_REFLECT( sigmaengine::chain::dapp_reward_fund_object,
            (id)
            (fund_balance)
            (last_update)
         )
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::dapp_reward_fund_object, sigmaengine::chain::dapp_reward_fund_index )

FC_REFLECT( sigmaengine::chain::account_auth_object,
             (account)(auth_type)(auth_token)(reg_date) )
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::account_auth_object, sigmaengine::chain::account_auth_index )

FC_REFLECT( sigmaengine::chain::transaction_fee_vote_object,
   ( id )
   ( voter )
   ( trx_fee )
   ( vote_block )
)
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::transaction_fee_vote_object, sigmaengine::chain::transaction_fee_vote_index )

FC_REFLECT( sigmaengine::chain::transaction_fee_reward_object,
            (id)
            (fund_balance)
            (reward_block)
         )
CHAINBASE_SET_INDEX_TYPE( sigmaengine::chain::transaction_fee_reward_object, sigmaengine::chain::transaction_fee_reward_index )

max_forks_repo_name: busblockos/bus