text:
//
// $Id$
//
//
// Original author: Darren Kessner <darren@proteowizard.org>
//
// Copyright 2007 Spielberg Family Center for Applied Proteomics
//   Cedars-Sinai Medical Center, Los Angeles, California  90048
//
// 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 "MSDataFile.hpp"
#include "Diff.hpp"
#include "IO.hpp"
#include "SpectrumListBase.hpp"
#include "ChromatogramListBase.hpp"
#include "examples.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Filesystem.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/copy.hpp>

using namespace pwiz::util;
using namespace pwiz::cv;
using namespace pwiz::data;
using namespace pwiz::msdata;

ostream* os_ = 0;

string filenameBase_ = "temp.MSDataFileTest";

void hackInMemoryMSData(MSData& msd)
{
    // remove metadata ptrs appended on read
    vector<SourceFilePtr>& sfs = msd.fileDescription.sourceFilePtrs;
    if (!sfs.empty()) sfs.erase(sfs.end()-1);
    vector<SoftwarePtr>& sws = msd.softwarePtrs;
    if (!sws.empty()) sws.erase(sws.end()-1);

    // remove current DataProcessing created on read
    SpectrumListBase* sl = dynamic_cast<SpectrumListBase*>(msd.run.spectrumListPtr.get());
    ChromatogramListBase* cl = dynamic_cast<ChromatogramListBase*>(msd.run.chromatogramListPtr.get());
    if (sl) sl->setDataProcessingPtr(DataProcessingPtr());
    if (cl) cl->setDataProcessingPtr(DataProcessingPtr());
}

void validateMmgfMzxmlRoundTrip()
{
    string filename1 = filenameBase_ + ".mgf";
    string filename2 = filenameBase_ + ".mzXML";

    ofstream ofs(filename1.c_str());
    string mgf = "CHARGE=2+ and 3+\nBEGIN IONS\nPEPMASS=952.924194 145032.0000\nCHARGE=2+\nRTINSECONDS=301.48\n271.0874 2\n298.1747 4\nEND IONS\nBEGIN IONS\nPEPMASS=503.800000 67522.2000\nCHARGE=2+\nRTINSECONDS=302.51\n147.1840 3\n154.3668 3\n162.2118 2\n162.9007 1\n167.3297 1\n175.2387 2\n184.9460 3\nEND IONS\n";
    ofs.write(mgf.c_str(), mgf.length());
    ofs.close();

    // make sure that round trip doesn't systematically increase converted scan numbers
    for (int loop = 3; loop--; )
    {
        MSDataFile msd1(filename1); // read back the MGF
        const SpectrumList& sl = *msd1.run.spectrumListPtr;
        SpectrumPtr spectrum = sl.spectrum(0);
        unit_assert(spectrum->id == "index=0");
        MSDataFile::WriteConfig writeConfig;
        writeConfig.format = MSDataFile::Format_mzXML;
        MSDataFile::write(msd1, filename2, writeConfig); // write as mzXML
        MSDataFile msd2(filename2); // read back the mzXML
        const SpectrumList& sl2= *msd2.run.spectrumListPtr;
        SpectrumPtr spectrum2 = sl2.spectrum(0);
        unit_assert(spectrum2->id == "index=1"); // mzXML is 1-based
        MSDataFile::WriteConfig writeConfig2;
        writeConfig2.format = MSDataFile::Format_MGF;
        MSDataFile::write(msd2, filename1, writeConfig2); // write as mgf
    }

    // remove temp files
    boost::filesystem::remove(filename1);
    boost::filesystem::remove(filename2);
}

void validateWriteRead(const MSDataFile::WriteConfig& writeConfig,
                       const DiffConfig diffConfig)
{
    if (os_) *os_ << "validateWriteRead()\n  " << writeConfig << endl;

    string filename1 = filenameBase_ + ".1";
    string filename2 = filenameBase_ + ".2";
    string filename3 = filenameBase_ + ".3";
    string filename4 = filenameBase_ + ".\xE4\xB8\x80\xE4\xB8\xAA\xE8\xAF\x95.4";
    // FIXME: 4-byte UTF-8 not working: string filename5 = filenameBase_ + ".\x01\x04\xA4\x01\x04\xA2.5";

    {
        // create MSData object in memory
        MSData tiny;
        examples::initializeTiny(tiny);

        if (writeConfig.format == MSDataFile::Format_mzXML)
        {
            // remove s22 since it is not written to mzXML
            static_cast<SpectrumListSimple&>(*tiny.run.spectrumListPtr).spectra.pop_back();
        }

        // write to file #1 (static)
        MSDataFile::write(tiny, filename1, writeConfig);

        // simulate CLI garbage collect behavior, wherein delayed deletes stress
        // memory and file handle usage
        {
            std::vector< boost::shared_ptr< MSDataFile > > msds;
            for (int i=0;i<100;i++)
            {
                boost::shared_ptr<MSDataFile> msd1(new MSDataFile(filename1));
                msds.push_back(msd1);
                hackInMemoryMSData(*msd1);
                Diff<MSData, DiffConfig> diff(tiny, *msd1, diffConfig);
            }
        }

        // read back into an MSDataFile object
        MSDataFile msd1(filename1);
        hackInMemoryMSData(msd1);

        // compare
        Diff<MSData, DiffConfig> diff(tiny, msd1, diffConfig);
        if (diff && os_) *os_ << diff << endl;
        unit_assert(!diff);

        // write to file #2 (member)
        msd1.write(filename2, writeConfig);

        // read back into another MSDataFile object
        MSDataFile msd2(filename2);
        hackInMemoryMSData(msd2);

        // compare
        diff(tiny, msd2);
        if (diff && os_) *os_ << diff << endl;
        unit_assert(!diff);

        // now give the gzip read a workout
        bio::filtering_istream tinyGZ(bio::gzip_compressor() | bio::file_descriptor_source(filename1));
        bio::copy(tinyGZ, bio::file_descriptor_sink(filename1+".gz", ios::out|ios::binary));

        MSDataFile msd3(filename1+".gz");
        hackInMemoryMSData(msd3);

        // compare
        diff(tiny, msd3);
        if (diff && os_) *os_ << diff << endl;
        unit_assert(!diff);

        // test writing to a stream
        ostringstream oss;
        msd1.write(oss, writeConfig);
        string ossStr = oss.str();
        ofstream ofs(filename3.c_str());
        ofs.write(ossStr.c_str(), ossStr.length());
        ofs.close();

        // read back into another MSDataFile object
        MSDataFile msd4(filename3);
        hackInMemoryMSData(msd4);

        // compare
        diff(tiny, msd4);
        if (diff && os_) *os_ << diff << endl;
        unit_assert(!diff);

        // write to file #4 (testing two byte UTF-8 code points)
        msd1.write(filename4, writeConfig);

        // read back into another MSDataFile object
        MSDataFile msd5(filename4);
        hackInMemoryMSData(msd5);

        // compare
        diff(tiny, msd5);
        if (diff && os_) *os_ << diff << endl;
        unit_assert(!diff);

        // write to file #5 (testing four byte UTF-8 code points)
        /*msd1.write(filename5, writeConfig);

        // read back into another MSDataFile object
        MSDataFile msd6(filename5);
        hackInMemoryMSData(msd6);

        // compare
        diff(tiny, msd6);
        if (diff && os_) *os_ << diff << endl;
        unit_assert(!diff);*/
	}

    // remove temp files
    boost::filesystem::remove(filename1);
    boost::filesystem::remove(filename2);
    boost::filesystem::remove(filename1 + ".gz");
    boost::filesystem::remove(filename3);
    boost::filesystem::remove(filename4);
    //boost::filesystem::remove(filename5);
}

void test()
{
    MSDataFile::WriteConfig writeConfig;
    DiffConfig diffConfig;

    validateMmgfMzxmlRoundTrip();

    // mzML 64-bit, full diff
    validateWriteRead(writeConfig, diffConfig);

    writeConfig.indexed = false;
    validateWriteRead(writeConfig, diffConfig); // no index
    writeConfig.indexed = true;

    // mzML 32-bit, full diff
    writeConfig.binaryDataEncoderConfig.precision = BinaryDataEncoder::Precision_32;
    validateWriteRead(writeConfig, diffConfig);

    // mzXML 32-bit, diff ignoring metadata and chromatograms
    writeConfig.format = MSDataFile::Format_mzXML;
    diffConfig.ignoreMetadata = true;
    diffConfig.ignoreChromatograms = true;
    validateWriteRead(writeConfig, diffConfig);

    // mzXML 64-bit, diff ignoring metadata and chromatograms
    writeConfig.binaryDataEncoderConfig.precision = BinaryDataEncoder::Precision_64;
    validateWriteRead(writeConfig, diffConfig);

    writeConfig.indexed = false;
    validateWriteRead(writeConfig, diffConfig); // no index
    writeConfig.indexed = true;
}

void demo()
{
    MSData tiny;
    examples::initializeTiny(tiny);

    MSDataFile::WriteConfig config;
    MSDataFile::write(tiny, filenameBase_ + ".64.mzML", config);

    config.binaryDataEncoderConfig.precision = BinaryDataEncoder::Precision_32;
    MSDataFile::write(tiny, filenameBase_ + ".32.mzML", config);

    config.format = MSDataFile::Format_Text;
    MSDataFile::write(tiny, filenameBase_ + ".txt", config);

    config.format = MSDataFile::Format_mzXML;
    MSDataFile::write(tiny, filenameBase_ + ".32.mzXML", config);

    config.binaryDataEncoderConfig.precision = BinaryDataEncoder::Precision_64;
    MSDataFile::write(tiny, filenameBase_ + ".64.mzXML", config);
}

const char rawHeader_[] = {'\x01', '\xA1',
    'F', '\0', 'i', '\0', 'n', '\0', 'n', '\0',
    'i', '\0', 'g', '\0', 'a', '\0', 'n', '\0'};

class TestReader : public Reader
{
    public:

    TestReader() : count(0) {}

    virtual std::string identify(const std::string& filename, const std::string& head) const
    {
        if (filename.size()<=4 || filename.substr(filename.size()-4)!=".RAW")
            return std::string("");

        for (size_t i=0; i<sizeof(rawHeader_); i++)
            if (head[i] != rawHeader_[i])
            return std::string("");

        count++;
        return filename;
    }

    virtual void read(const std::string& filename, const std::string& head, MSData& result, int runIndex = 0,
                      const Config& config = Config()) const
    {
        count++;
    }

    virtual void read(const std::string& filename,
                      const std::string& head,
                      std::vector<MSDataPtr>& results,
                      const Config& config = Config()) const
    {
        results.push_back(MSDataPtr(new MSData));
        read(filename, head, *results.back(), 0, config);
    }

    const char *getType() const {return "testReader";} // satisfy inheritance
    CVID getCvType() const { return CVID_Unknown; } // satisfy inheritance
    virtual std::vector<std::string> getFileExtensions() const {return {".test"};}

    mutable int count;
};

void testReader()
{
    // create a file
    string filename = filenameBase_ + ".RAW";
    ofstream os(filename.c_str());
    os.write(rawHeader_, 18);
    os.close();

    // open the file with our Reader
    TestReader reader;
    MSDataFile msd(filename, &reader);

    // verify that our reader got called properly
    unit_assert(reader.count == 2);

    // remove temp file
    boost::filesystem::remove(filename);

    if (os_) *os_ << endl;
}

void testSHA1()
{
    if (os_) *os_ << "testSHA1()\n";

    // write out a test file

    string filename = filenameBase_ + ".SHA1Test";
    MSData tiny;
    examples::initializeTiny(tiny);
    MSDataFile::write(tiny, filename);

    {
        // read in without SHA-1 calculation
        MSDataFile msd(filename);

        if (os_)
        {
            *os_ << "no SHA-1:\n";
            pwiz::minimxml::XMLWriter writer(*os_);
            IO::write(writer, *msd.fileDescription.sourceFilePtrs.back());
        }

        unit_assert(!msd.fileDescription.sourceFilePtrs.empty());
        unit_assert(!msd.fileDescription.sourceFilePtrs.back()->hasCVParam(MS_SHA_1));

        // read in with SHA-1 calculation

        MSDataFile msd_sha1(filename, 0, true);

        if (os_)
        {
            *os_ << "with SHA-1:\n";
            pwiz::minimxml::XMLWriter writer(*os_);
            IO::write(writer, *msd_sha1.fileDescription.sourceFilePtrs.back());
        }

        unit_assert(!msd_sha1.fileDescription.sourceFilePtrs.empty());
        unit_assert(msd_sha1.fileDescription.sourceFilePtrs.back()->hasCVParam(MS_SHA_1));
    }

    // clean up

    boost::filesystem::remove(filename);
    if (os_) *os_ << endl;
}

void testPathLength()
{
    MSData tiny;
    examples::initializeTiny(tiny);

    string goodFilename = string(244 - bfs::current_path().size(), 't') + ".test";
    MSDataFile::write(tiny, goodFilename);

    string absoluteGoodFilename = bfs::absolute(string(244 - bfs::current_path().size(), 't') + ".test").string();
    MSDataFile::write(tiny, absoluteGoodFilename);

    { MSDataFile goodMsd(goodFilename); }

    string badFilename = R"(\\?\)" + bfs::absolute(goodFilename).string(); // bfs::rename fails for paths between 250 and 260 characters long without this prefix
    string badSuffix = ".bad";
    for (int i = 0; i < 10; ++i)
    {
        if (bfs::current_path().size() + badFilename.length() + 4 >= 264)
            break;
        bfs::rename(badFilename, badFilename + badSuffix);
        badFilename += badSuffix;
#ifdef _WIN32
        unit_assert_throws_what(MSDataFile(badFilename), std::invalid_argument, "path is too long (must be 250 characters or less): " + bfs::absolute(badFilename).string());
#else
        { MSDataFile msd(badFilename); }
#endif
        bfs::remove(badFilename);
    }

    badFilename = R"(\\?\)" + bfs::absolute(goodFilename).string();
    badSuffix = ".\xe9\x9d\x9e\xe5\xb8\xb8\xe9\x94\x99"; // . + 3 Chinese characters in UTF-8
    for (int i = 0; i < 10; ++i)
    {
        if (bfs::current_path().size() + badFilename.length() + 4 >= 264)
            break;
        bfs::rename(badFilename, badFilename + badSuffix);
        badFilename += badSuffix;
#ifdef _WIN32
        unit_assert_throws_what(MSDataFile(badFilename), std::invalid_argument, "path is too long (must be 250 characters or less): " + bfs::absolute(badFilename).string());
#else
        { MSDataFile msd(badFilename); }
#endif
        bfs::remove(badFilename);
    }
    bfs::remove(goodFilename);
}

int main(int argc, char* argv[])
{
    TEST_PROLOG(argc, argv)

    try
    {
        if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
        test();
        //demo();
        testReader();
        testSHA1();
        testPathLength();
    }
    catch (exception& e)
    {
        TEST_FAILED(e.what())
    }
    catch (...)
    {
        TEST_FAILED("Caught unknown exception.")
    }

    TEST_EPILOG
}

max_stars_repo_name: vagisha/pwiz

max_issues_repo_name: vagisha/pwiz

max_forks_repo_name: vagisha/pwiz


text: #include <boost/math/special_functions/expint.hpp>

ext: hpp

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
//
//  HostedMonero.hpp
//  MyMonero
//
//  Copyright (c) 2014-2019, MyMonero.com
//
//  All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without modification, are
//  permitted provided that the following conditions are met:
//
//  1. Redistributions of source code must retain the above copyright notice, this list of
//  conditions and the following disclaimer.
//
//  2. Redistributions in binary form must reproduce the above copyright notice, this list
//  of conditions and the following disclaimer in the documentation and/or other
//  materials provided with the distribution.
//
//  3. Neither the name of the copyright holder nor the names of 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.
//
//
//
#ifndef HostedMonero_HPP_
#define HostedMonero_HPP_
//
#include <iostream> // TODO: this is to obtain stdlib.. what should be imported instead of this?
#include <boost/signals2.hpp>
//
#include "../Settings/SettingsController.hpp"
#include "./HTTPRequests_Interface.hpp"
#include "./parsing.hpp"
//
namespace HostedMonero
{
	using namespace std;
	//
	// Principal Types
	class APIClient
	{
	public:
		APIClient() {}
		APIClient(const APIClient&) = delete;
		APIClient& operator=(const APIClient&) = delete;
		~APIClient() {}
		//
		// Dependencies
		std::shared_ptr<HTTPRequests::RequestFactory> requestFactory;
		std::shared_ptr<Settings::Controller> settingsController;
		//
		// Then call:
		void setup();
		//
		// Signals
		boost::signals2::signal<void()> initializedWithNewServerURL_signal;
		//
		// Endpoints
		std::unique_ptr<HTTPRequests::Handle> logIn(
			const string &address,
			const string &view_pub_key,
			bool generated_locally,
			std::function<void(
				optional<string> err_str,
				optional<HostedMonero::ParsedResult_Login> result
			)> fn
		);
	private:
		//
		// Lifecycle
		void startObserving();
		void teardown();
		void stopObserving();
		//
		// Connections
		boost::signals2::connection connection__SettingsController__specificAPIAddressURLAuthority_changed;
		//
		// Delegation
		void SettingsController__specificAPIAddressURLAuthority_changed();
   };
}

#endif /* HostedMonero_HPP_ */

max_stars_repo_name: Toklio-project/mytokl-libapp-cpp

max_issues_repo_name: Toklio-project/mytokl-libapp-cpp

max_forks_repo_name: Toklio-project/mytokl-libapp-cpp


text:
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------

#include "stdafx.h"

#include <windows.h>

#include "Common/WaitHandle.h"
#include "ComUnknownBase.h"
#include "ComPointer.h"

#include <boost/test/unit_test.hpp>
#include "Common/boost-taef.h"

namespace Common
{
    class ComUnknownBaseTest
    {
    };

    GUID IID_IPlant = {0xc4277e5d,0xf904,0x448c,{0x9d,0xb3,0x70,0xe1,0x62,0x00,0xb6,0x42}};
    GUID IID_IFruit = {0x00144491,0x3edb,0x4843,{0x97,0x28,0xf2,0xc0,0x12,0xdc,0x94,0x21}};
    GUID IID_IColor = {0x7edd768d,0xee25,0x4ac2,{0x94,0x10,0x0a,0x01,0x46,0xf0,0xe3,0xd3}};
    GUID IID_ComOrange = {0x1131c218,0x6555,0x453b,{0xa4,0xf7,0xc9,0x77,0x57,0xf8,0x3a,0x7b}};

    namespace Implementor
    {
        enum Enum { ComPlant, ComFruit1, ComFruit2, ComOrange, ComEggplant1, ComEggplant2 };
    }

    //
    // Sample interfaces.
    //
    // ComUnknownBase does arithmetic on the pointer, so we need to verify that the methods we are
    // calling are actually going to the method we expect.  We do this by validating that the
    // method returns the correct implementor and IID value corresponding to the class and
    // interface respectively that we are calling.
    //
    class IPlant : public IUnknown
    {
    public:
        virtual HRESULT GetPlantImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid) = 0;
    };

    class IFruit : public IPlant
    {
    public:
        virtual HRESULT GetFruitImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid) = 0;
    };

    class IColor : public IUnknown
    {
    public:
        virtual HRESULT GetColorImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid) = 0;
    };

    //
    // Implementations of the interfaces
    //

    //
    // Implements a single simple interface.
    // Supports subclassing by other implementations.
    //
    class ComPlant : public IPlant, protected ComUnknownBase
    {
        COM_INTERFACE_LIST1(
            ComPlant,
            IID_IPlant,
            IPlant)
    public:
        virtual HRESULT GetPlantImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComPlant;
            *iid = IID_IPlant;
            return S_OK;
        }
    };

    //
    // Implements two related interfaces explicitly.
    //
    class ComFruit1 : public IFruit, private ComUnknownBase
    {
        COM_INTERFACE_LIST2(
            ComFruit1,
            IID_IPlant,
            IPlant,
            IID_IFruit,
            IFruit)
    public:
        virtual HRESULT GetPlantImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComFruit1;
            *iid = IID_IPlant;
            return S_OK;
        }

        virtual HRESULT GetFruitImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComFruit1;
            *iid = IID_IFruit;
            return S_OK;
        }
    };

    //
    // Implements two related interfaces by delegating one to a base class.
    //
    class ComFruit2 : public IFruit, public ComPlant
    {
        COM_INTERFACE_AND_DELEGATE_LIST(
            ComFruit2,
            IID_IFruit,
            IFruit,
            ComPlant)

    public:
        virtual HRESULT GetPlantImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            return this->ComPlant::GetPlantImplementor(implementor, iid);
        }

        virtual HRESULT GetFruitImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComFruit2;
            *iid = IID_IFruit;
            return S_OK;
        }
    };

    //
    // Implements both related and unrelated interfaces.
    //
    class ComOrange : public IFruit, public IColor, private ComUnknownBase
    {
        BEGIN_COM_INTERFACE_LIST(ComOrange)
        COM_INTERFACE_ITEM(IID_IUnknown, IFruit)
        COM_INTERFACE_ITEM(IID_IPlant, IPlant)
        COM_INTERFACE_ITEM(IID_IFruit, IFruit)
        COM_INTERFACE_ITEM(IID_IColor, IColor)
        COM_INTERFACE_ITEM(IID_ComOrange, ComOrange)
        END_COM_INTERFACE_LIST()

    public:
        virtual HRESULT GetPlantImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComOrange;
            *iid = IID_IPlant;
            return S_OK;
        }

        virtual HRESULT GetFruitImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComOrange;
            *iid = IID_IFruit;
            return S_OK;
        }

        virtual HRESULT GetColorImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComOrange;
            *iid = IID_IColor;
            return S_OK;
        }

        HRESULT GetOrangeImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComOrange;
            *iid = IID_ComOrange;
            return S_OK;
        }
    };

    //
    // Implements two unrelated interfaces explicitly.
    //
    class ComEggplant1 : public IPlant, public IColor, private ComUnknownBase
    {
        BEGIN_COM_INTERFACE_LIST(ComEggplant1)
        COM_INTERFACE_ITEM(IID_IUnknown, IPlant)
        COM_INTERFACE_ITEM(IID_IPlant, IPlant)
        COM_INTERFACE_ITEM(IID_IColor, IColor)
        END_COM_INTERFACE_LIST()

    public:
        virtual HRESULT GetPlantImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComEggplant1;
            *iid = IID_IPlant;
            return S_OK;
        }

        virtual HRESULT GetColorImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComEggplant1;
            *iid = IID_IColor;
            return S_OK;
        }
    };

    //
    // Implements two unrelated interfaces by delegating one to a base class.
    //
    class ComEggplant2 : public ComPlant, public IColor
    {
        COM_INTERFACE_AND_DELEGATE_LIST(
            ComEggplant2,
            IID_IColor,
            IColor,
            ComPlant)

    public:
        virtual HRESULT GetColorImplementor(
            __out Implementor::Enum * implementor,
            __out GUID * iid)
        {
            *implementor = Implementor::ComEggplant2;
            *iid = IID_IColor;
            return S_OK;
        }
    };

    void CheckPlant(
        __in ComPointer<IUnknown> & unknown,
        __in Implementor::Enum expectedImplementor)
    {
        Implementor::Enum actualImplementor;
        GUID actualIID;
        ComPointer<IPlant> plant(unknown, IID_IPlant);

        plant->GetPlantImplementor(&actualImplementor, &actualIID);
        VERIFY_ARE_EQUAL(actualImplementor, expectedImplementor);
        VERIFY_ARE_EQUAL(actualIID, IID_IPlant);
    }

    void CheckFruit(
        __in ComPointer<IUnknown> & unknown,
        __in Implementor::Enum expectedImplementor)
    {
        Implementor::Enum actualImplementor;
        GUID actualIID;
        ComPointer<IFruit> fruit(unknown, IID_IFruit);

        fruit->GetFruitImplementor(&actualImplementor, &actualIID);
        VERIFY_ARE_EQUAL(actualImplementor, expectedImplementor);
        VERIFY_ARE_EQUAL(actualIID, IID_IFruit);
    }

    void CheckColor(
        __in ComPointer<IUnknown> & unknown,
        __in Implementor::Enum expectedImplementor)
    {
        Implementor::Enum actualImplementor;
        GUID actualIID;
        ComPointer<IColor> color(unknown, IID_IColor);

        color->GetColorImplementor(&actualImplementor, &actualIID);
        VERIFY_ARE_EQUAL(actualImplementor, expectedImplementor);
        VERIFY_ARE_EQUAL(actualIID, IID_IColor);
    }

    void CheckOrange(
        __in ComPointer<IUnknown> & unknown,
        __in Implementor::Enum expectedImplementor)
    {
        Implementor::Enum actualImplementor;
        GUID actualIID;
        ComPointer<ComOrange> orange(unknown, IID_ComOrange);

        orange->GetOrangeImplementor(&actualImplementor, &actualIID);
        VERIFY_ARE_EQUAL(actualImplementor, expectedImplementor);
        VERIFY_ARE_EQUAL(actualIID, IID_ComOrange);
    }

    void CheckNotFruit(__in ComPointer<IUnknown> & unknown)
    {
        ComPointer<IFruit> fruit(unknown, IID_IFruit);
        VERIFY_IS_FALSE(fruit);
    }

    void CheckNotColor(__in ComPointer<IUnknown> & unknown)
    {
        ComPointer<IColor> color(unknown, IID_IColor);
        VERIFY_IS_FALSE(color);
    }

    void CheckNotOrange(__in ComPointer<IUnknown> & unknown)
    {
        ComPointer<ComOrange> orange(unknown, IID_ComOrange);
        VERIFY_IS_FALSE(orange);
    }

    BOOST_FIXTURE_TEST_SUITE(ComUnknownBaseTestSuite,ComUnknownBaseTest)

    BOOST_AUTO_TEST_CASE(PlantTest)
    {
        auto unknown = make_com<ComPlant,IUnknown>();

        CheckPlant(unknown, Implementor::ComPlant);
        CheckNotFruit(unknown);
        CheckNotColor(unknown);
        CheckNotOrange(unknown);
    }

    BOOST_AUTO_TEST_CASE(Fruit1Test)
    {
        auto unknown = make_com<ComFruit1,IUnknown>();

        CheckPlant(unknown, Implementor::ComFruit1);
        CheckFruit(unknown, Implementor::ComFruit1);
        CheckNotColor(unknown);
        CheckNotOrange(unknown);
    }

    BOOST_AUTO_TEST_CASE(Fruit2Test)
    {
        auto fruit = make_com<ComFruit2>();
        ComPointer<IUnknown> unknown(fruit, IID_IUnknown);

        CheckPlant(unknown, Implementor::ComPlant);
        CheckFruit(unknown, Implementor::ComFruit2);
        CheckNotColor(unknown);
        CheckNotOrange(unknown);
    }

    BOOST_AUTO_TEST_CASE(OrangeTest)
    {
        auto orange = make_com<ComOrange>();
        ComPointer<IUnknown> unknown(orange, IID_IUnknown);

        CheckPlant(unknown, Implementor::ComOrange);
        CheckFruit(unknown, Implementor::ComOrange);
        CheckColor(unknown, Implementor::ComOrange);
        CheckOrange(unknown, Implementor::ComOrange);
    }

    BOOST_AUTO_TEST_CASE(Eggplant1Test)
    {
        auto eggplant = make_com<ComEggplant1,IColor>();
        ComPointer<IUnknown> unknown(eggplant, IID_IUnknown);

        CheckPlant(unknown, Implementor::ComEggplant1);
        CheckNotFruit(unknown);
        CheckColor(unknown, Implementor::ComEggplant1);
        CheckNotOrange(unknown);
    }

    BOOST_AUTO_TEST_CASE(Eggplant2Test)
    {
        auto eggplant = make_com<ComEggplant2,IColor>();
        ComPointer<IUnknown> unknown(eggplant, IID_IUnknown);

        CheckPlant(unknown, Implementor::ComPlant);
        CheckNotFruit(unknown);
        CheckColor(unknown, Implementor::ComEggplant2);
        CheckNotOrange(unknown);
    }

#ifndef  PLATFORM_UNIX  //LINUXTODO: move COM runtime related code to separate file
    static DWORD __stdcall RunSTAThreadCallback(void *)
    {
        VERIFY_SUCCEEDED(::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
        VERIFY_IS_FALSE(ComUtility::CheckMTA().IsSuccess());
        ::CoUninitialize();
        return 0;
    }

    BOOST_AUTO_TEST_CASE(STATest)
    {
        VERIFY_IS_TRUE(ComUtility::CheckMTA().IsSuccess());
        VERIFY_SUCCEEDED(::CoInitializeEx(NULL, COINIT_MULTITHREADED));
        VERIFY_IS_TRUE(ComUtility::CheckMTA().IsSuccess());

        HANDLE staThread = CreateThread(NULL, 0, RunSTAThreadCallback, NULL, 0, NULL);
        VERIFY_IS_NOT_NULL(staThread);
#if !defined(PLATFORM_UNIX)
        WaitForSingleObject(staThread, INFINITE);
#else
        pthread_join((pthread_t)staThread, NULL);
#endif
        CloseHandle(staThread);
        ::CoUninitialize();
    }
#endif
    BOOST_AUTO_TEST_SUITE_END()
}

ext: cpp


text:
/*
BKSVD implemented by C++ based on https://github.com/cpmusco/bksvd
Author: ItakEjgo@SUSTech
*/

#include <bits/stdc++.h>
#include <Eigen/Dense>
#include <random>
#include <ctime>

#define EIGEN_USE_MKL_ALL

using namespace std;
using namespace Eigen;

typedef Matrix<double, Dynamic, Dynamic, RowMajor> MatrixXd_row;
typedef Matrix<double, Dynamic, Dynamic, ColMajor> MatrixXd_col;

struct bksvd_output {
	MatrixXd U;		// an orthogonal matrix whose columns are approximate top k left singular vectors for A
	MatrixXd S;		// a diagonal matrix whose entries are A's approximate top k singular values
	MatrixXd V;		// an orthogonal matrix whose columns are approximate top k right singular vectors for A
};

static default_random_engine e(233666);
static normal_distribution<double> m_n(0, 1);

//	function bksvd

bksvd_output bksvd(MatrixXd &A, int k = 6, int iter = 3, int bsize = 6, bool center = false) {
	bksvd_output result;

	k = min(k, (int)min(A.rows(), A.cols()));
	bsize = k;

	if (k < 1 || iter < 1 || bsize < k) {
		cerr << "bksvd: BadInput, Oner or more inputs outside required range" << endl;
	}

	//	Calculate row mean if rows should be centered.
	MatrixXd u = MatrixXd::Zero(1, A.cols());
	if (center) {
		for (int i = 0; i < A.cols(); i++) {
			u(0, i) = A.col(i).mean();
		}
	}
	MatrixXd l = MatrixXd::Ones(A.rows(), 1);

	//	We want to iterate on the smaller dimension of A.
	int n, ind;
	if (A.rows() <= A.cols()) {
		n = A.rows();
		ind = 1;
	}
	else {
		n = A.cols();
		ind = 2;
	}
	bool tpose = false;
	if (ind == 1) {
		tpose = true;
		l = u.transpose(); u.setOnes(1, A.rows());
		A.transposeInPlace();
	}

	//	Allocate space for Krylov subspace.
	MatrixXd K = MatrixXd::Zero(A.cols(), bsize * iter);
	//	Random block initialization.
	MatrixXd block = MatrixXd::Zero(A.cols(), bsize).unaryExpr([](double dummy) {return m_n(e); });

	HouseholderQR<MatrixXd> qr;
	qr.compute(block);
	block.noalias() = qr.householderQ() * MatrixXd::Identity(A.cols(), bsize);

	//	Preallocate space for temporary products.
	MatrixXd T = MatrixXd::Zero(A.cols(), bsize);

	//	Construct and orthonormalize Krlov Subspace.
	//	Orthogonalize at each step using economy size QR decomposition
	for (int i = 1; i <= iter; i++) {
		T.noalias() = A * block;
		T.noalias() -= l * (u * block);
		//T = A * block - l * (u * block);
		block.noalias() = A.transpose() * T;
		block.noalias() -= u.transpose() * (l.transpose() * T);
		//block = A.transpose() * T - u.transpose() * (l.transpose() * T);
		HouseholderQR<MatrixXd> tmp_qr;
		tmp_qr.compute(block);
		block.noalias() = tmp_qr.householderQ() * MatrixXd::Identity(block.rows(), block.cols());;
		K.middleCols((i - 1)*bsize, bsize) = block;
	}

	//	Rayleigh-Ritz postprocessing with economy size dense SVD.
	HouseholderQR<MatrixXd> tmp_qr;

	tmp_qr.compute(K);
	MatrixXd Q = tmp_qr.householderQ() * MatrixXd::Identity(K.rows(), K.cols());

	T.noalias() = A * Q;
	T.noalias() -= l * (u * Q);
	//T = A * Q - l * (u * Q);

	BDCSVD<MatrixXd> svd(T, ComputeThinU | ComputeThinV);    //	For large scale Matrix
	//JacobiSVD<MatrixXd>svd(T, ComputeThinU | ComputeThinV); // For small scale Matrix

	MatrixXd Ut = svd.matrixU(), Vt = svd.matrixV();
	MatrixXd St = svd.singularValues().asDiagonal();
	result.S = St.block(0, 0, k, k);
	if (!tpose) {
		result.U = Ut.leftCols(k);
		result.V = Q * Vt.leftCols(k);
	}
	else {
		result.V = Ut.leftCols(k);
		result.U = Q * Vt.leftCols(k);
	}
	return result;
}

//	using reference

void bksvd(bksvd_output &result, MatrixXd &A, int k = 6, int iter = 3, int bsize = 6, bool center = false) {

	k = min(k, (int)min(A.rows(), A.cols()));
	bsize = k;

	if (k < 1 || iter < 1 || bsize < k) {
		cerr << "bksvd: BadInput, Oner or more inputs outside required range" << endl;
	}

	//	Calculate row mean if rows should be centered.
	MatrixXd u = MatrixXd::Zero(1, A.cols());
	if (center) {
		for (int i = 0; i < A.cols(); i++) {
			u(0, i) = A.col(i).mean();
		}
	}
	MatrixXd l = MatrixXd::Ones(A.rows(), 1);

	//	We want to iterate on the smaller dimension of A.
	int n, ind;
	if (A.rows() <= A.cols()) {
		n = A.rows();
		ind = 1;
	}
	else {
		n = A.cols();
		ind = 2;
	}
	bool tpose = false;
	if (ind == 1) {
		tpose = true;
		l = u.transpose(); u.setOnes(1, A.rows());
		A.transposeInPlace();
	}

	//	Allocate space for Krylov subspace.
	MatrixXd K = MatrixXd::Zero(A.cols(), bsize * iter);
	//	Random block initialization.
	MatrixXd block = MatrixXd::Zero(A.cols(), bsize).unaryExpr([](double dummy) {return m_n(e); });

	HouseholderQR<MatrixXd> qr;
	qr.compute(block);
	/*block.noalias() = qr.householderQ() * MatrixXd::Identity(A.cols(), bsize);*/
	block = qr.householderQ() * MatrixXd::Identity(A.cols(), bsize);

	//	Preallocate space for temporary products.
	MatrixXd T = MatrixXd::Zero(A.cols(), bsize);

	//	Construct and orthonormalize Krlov Subspace.
	//	Orthogonalize at each step using economy size QR decomposition
	for (int i = 1; i <= iter; i++) {
		/*T.noalias() = A * block;
		T.noalias() -= l * (u * block);*/
		T = A * block - l * (u * block);
		/*block.noalias() = A.transpose() * T;
		block.noalias() -= u.transpose() * (l.transpose() * T);*/
		block = A.transpose() * T - u.transpose() * (l.transpose() * T);
		HouseholderQR<MatrixXd> tmp_qr;
		tmp_qr.compute(block);
		/*block.noalias() = tmp_qr.householderQ() * MatrixXd::Identity(block.rows(), block.cols());*/
		block = tmp_qr.householderQ() * MatrixXd::Identity(block.rows(), block.cols());
		K.middleCols((i - 1)*bsize, bsize) = block;
	}

	//	Rayleigh-Ritz postprocessing with economy size dense SVD.
	HouseholderQR<MatrixXd> tmp_qr;

	tmp_qr.compute(K);
	MatrixXd Q = tmp_qr.householderQ() * MatrixXd::Identity(K.rows(), K.cols());

	/*T.noalias() = A * Q;
	T.noalias() -= l * (u * Q);*/
	T = A * Q - l * (u * Q);

	BDCSVD<MatrixXd> svd(T, ComputeThinU | ComputeThinV);    //	For large scale Matrix
	//JacobiSVD<MatrixXd>svd(T, ComputeThinU | ComputeThinV); // For small scale Matrix

	MatrixXd Ut = svd.matrixU(), Vt = svd.matrixV();
	MatrixXd St = svd.singularValues().asDiagonal();
	result.S = St.block(0, 0, k, k);
	if (!tpose) {
		result.U = Ut.leftCols(k);
		result.V = Q * Vt.leftCols(k);
	}
	else {
		result.V = Ut.leftCols(k);
		result.U = Q * Vt.leftCols(k);
	}
}

//	function sisvd

bksvd_output sisvd(MatrixXd A, int k = 6, int iter = 3, int bsize = 6, bool center = false) {
	bksvd_output result;

	static default_random_engine e((unsigned int)time(0));
	static normal_distribution<double> m_n(0, 1);

	k = min(k, (int)min(A.rows(), A.cols()));
	bsize = k;
	if (k < 1 || iter < 1 || bsize < k) {
		cerr << "sisvd:BadInput, one or more inputs outside required range" << endl;
	}

	//	Calculate row mean if rows should be centered.
	MatrixXd u = MatrixXd::Zero(1, A.cols());
	if (center) {
		for (int i = 0; i < A.cols(); i++) {
			u(0, i) = A.col(i).mean();
		}
	}
	MatrixXd l = MatrixXd::Ones(A.rows(), 1);

	//	We want to iterate on the smaller dimension of A.
	int n, ind;
	if (A.rows() <= A.cols()) {
		n = A.rows();
		ind = 1;
	}
	else {
		n = A.cols();
		ind = 2;
	}
	bool tpose = false;
	if (ind == 1) {
		tpose = true;
		l = u.transpose(); u.setOnes(1, A.rows());
		A.transposeInPlace();
	}

	//	Random block initialization.
	MatrixXd block = MatrixXd::Zero(A.cols(), bsize).unaryExpr([](double dummy) {return m_n(e); });

	HouseholderQR<MatrixXd> qr;
	qr.compute(block);
	block = qr.householderQ() * MatrixXd::Identity(A.cols(), bsize);

	//	Preallocate space for temporary products.
	MatrixXd T = MatrixXd::Zero(A.cols(), bsize);

	//	Run power iteration, orthogonalizing at each step using economy size QR.
	for (int i = 1; i <= iter; i++) {
		T = A * block - l * (u * block);
		block = A.transpose() * T - u.transpose() * (l.transpose() * T);
		HouseholderQR<MatrixXd> tmp_qr;
		tmp_qr.compute(block);
		block = tmp_qr.householderQ() * MatrixXd::Identity(block.rows(), block.cols());
	}

	//	Rayleigh-Ritz postprocessing with economy size dense SVD.
	T = A * block - l * (u * block);
	//JacobiSVD<MatrixXd>svd(T, ComputeFullU | ComputeFullV);
	BDCSVD<MatrixXd> svd(T, ComputeThinU | ComputeThinV);
	MatrixXd Ut = svd.matrixU(), Vt = svd.matrixV();
	MatrixXd St = svd.singularValues().asDiagonal();
	result.S = St.block(0, 0, k, k);
	if (!tpose) {
		result.U = Ut.leftCols(k);
		result.V = block * Vt.leftCols(k);
	}
	else {
		result.V = Ut.leftCols(k);
		result.U = block * Vt.leftCols(k);
	}
	return result;
}

int main(){
	//ofstream fout;
	//fout.open("Matrix_A.txt");
	//MatrixXd A = MatrixXd::Zero(10000, 161).unaryExpr([](double dummy) {return m_n(e); });
	////MatrixXd_row A = MatrixXd::Zero(1000, 1000).unaryExpr([](double dummy) {return m_n(e); });
	//fout << A << endl;

	MatrixXd A = MatrixXd::Zero(10000, 161);
	ifstream fin; fin.open("MatrixA.txt");
	double val;
	for (int i = 0; i < 10000; i++) {
		for (int j = 0; j < 161; j++) {
			fin >> val;
			A(i, j) = val;
		}
	}

	MatrixXd B = A;
	bksvd_output result1, result2;
	clock_t start, end;
	start = clock();
	//result1 = bksvd(A,10);
	end = clock();
	printf("Time used = :%.5f second(s)\n", (double)(end - start) / CLOCKS_PER_SEC);

	start = clock();
	bksvd(result2, A, 10);
	end = clock();
	printf("Time used = :%.5f second(s)\n", (double)(end - start) / CLOCKS_PER_SEC);

	return 0;
}


text:
#pragma once

#include <boost/asio/ip/udp.hpp>
#include <boost/asio/buffers_iterator.hpp>
#include "detail/handler.hpp"

namespace asio_utp {

class socket_impl;
class udp_multiplexer;

class socket {
public:
    using endpoint_type = boost::asio::ip::udp::endpoint;
    using executor_type = boost::asio::io_context::executor_type;

public:
    socket() = default;

    socket(const socket&) = delete;
    socket& operator=(const socket&) = delete;

    socket(socket&&);
    socket& operator=(socket&&);

    socket(const boost::asio::executor&);
    socket(boost::asio::io_context&);

    void bind(const endpoint_type&, boost::system::error_code&);

    void bind(const udp_multiplexer&, boost::system::error_code&);

    template<typename CompletionToken>
    void async_connect(const endpoint_type&, CompletionToken&&);

    template<typename CompletionToken>
    void async_accept(CompletionToken&&);

    template< typename ConstBufferSequence
            , typename CompletionToken>
    auto async_write_some(const ConstBufferSequence&, CompletionToken&&);

    template< typename MutableBufferSequence
            , typename CompletionToken>
    auto async_read_some(const MutableBufferSequence&, CompletionToken&&);

    endpoint_type local_endpoint() const;

    endpoint_type remote_endpoint() const;

    bool is_open() const;

    void close();

    boost::asio::executor get_executor()
    {
        return _ex;
    }

    // For debugging only
    void* pimpl() const { return _socket_impl.get(); }

    ~socket();

private:
    void do_connect(const endpoint_type&, handler<>&&);
    void do_accept (handler<>&&);
    void do_write  (handler<size_t>&&);
    void do_read   (handler<size_t>&&);

    std::vector<boost::asio::const_buffer>* tx_buffers();
    std::vector<boost::asio::mutable_buffer>* rx_buffers();

private:
    friend class socket_impl;
    boost::asio::executor _ex;
    std::shared_ptr<socket_impl> _socket_impl;
};

template<typename CompletionToken>
inline
void socket::async_connect(const endpoint_type& ep, CompletionToken&& token)
{
    boost::asio::async_completion
        <CompletionToken, void(boost::system::error_code)> c(token);

    do_connect(ep, {get_executor(), std::move(c.completion_handler)});

    return c.result.get();
}

template<typename CompletionToken>
inline
void socket::async_accept(CompletionToken&& token)
{
    boost::asio::async_completion
        <CompletionToken, void(boost::system::error_code)> c(token);

    do_accept({get_executor(), std::move(c.completion_handler)});

    return c.result.get();
}

template< typename ConstBufferSequence
        , typename CompletionToken>
inline
auto socket::async_write_some( const ConstBufferSequence& bufs
                             , CompletionToken&& token)
{
    if (auto txb = tx_buffers()) {
        txb->clear();

        std::copy( boost::asio::buffer_sequence_begin(bufs)
                 , boost::asio::buffer_sequence_end(bufs)
                 , std::back_inserter(*txb));
    }

    boost::asio::async_completion
        < CompletionToken
        , void(boost::system::error_code, size_t)
        > c(token);

    do_write({get_executor(), std::move(c.completion_handler)});

    return c.result.get();
}

template< typename MutableBufferSequence
        , typename CompletionToken>
inline
auto socket::async_read_some( const MutableBufferSequence& bufs
                            , CompletionToken&& token)
{
    if (auto rxb = rx_buffers()) {
        rxb->clear();

        std::copy( boost::asio::buffer_sequence_begin(bufs)
                 , boost::asio::buffer_sequence_end(bufs)
                 , std::back_inserter(*rxb));
    }

    boost::asio::async_completion
        < CompletionToken
        , void(boost::system::error_code, size_t)
        > c(token);

    do_read({get_executor(), std::move(c.completion_handler)});

    return c.result.get();
}

} // namespace

max_stars_repo_name: inetic/asio-utp

max_issues_repo_name: inetic/asio-utp

max_forks_repo_name: equalitie/asio-utp


text:
#ifndef TQ_UTILITIES_HPP_
#define TQ_UTILITIES_HPP_

#include <istream>
#include <string>
#include <boost/iostreams/filtering_stream.hpp>
#include "Decoder.hpp"

namespace Tq
{
  enum class Compression { Gzip, Zlib, None };

  bool endsWith(const std::string &str, const std::string &ending);

  Compression inferCompression(const std::string &filename);

  void decompressFile(boost::iostreams::
                        filtering_stream<boost::iostreams::input>& stream,
                      const std::string& filename,
                      Compression compression);

  Decoder * makeDecoder(std::istream& stream, const char *fmt);
}

#endif // TQ_UTILITIES_HPP_

max_stars_repo_name: vlasenkov/tq

max_issues_repo_name: vlasenkov/tq

max_forks_repo_name: vlasenkov/tq